首页 / C++ / 最新《C++高级编程教程项目实战》
最新《C++高级编程教程项目实战》
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了最新《C++高级编程教程项目实战》,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含11756字,纯文字阅读大概需要17分钟。
内容图文
from openpyxl import load_workbook
class doExcel:
def __init__(self,excelFile,excelSheet,confFile):
self.excelFile = excelFile
self.excelSheet = excelSheet
self.confFile = confFile
def do_excel(self,button,case_id_list):
wb = load_workbook(self.excelFile)
sheet = wb[self.excelSheet]
title_data = []
for i in range(1,sheet.max_column+1):
title_data.append(sheet.cell(1,i).value)
test_data = []
for i in range(2,sheet.max_row+1):
dict_data = {}
for j in range(1,sheet.max_column+1):
dict_data[title_data[j-1]] = sheet.cell(i,j).value
test_data.append(dict_data)
# 可以根据case.conf去决定跑用例
if button == 'off': # 约定button==off的时候,就执行所有用例
finally_data = test_data
else: # 默认执行case_id_list里面的用例
finally_data = []
for item in test_data:
# 判断item['id']是否在case_id_list里面
if item['id'] in eval(case_id_list):
finally_data.append(item)
return finally_data
# 清除指定行列数据
def write_clear(self):
wb = load_workbook(self.excelFile)
sheet = wb[self.excelSheet]
for i in range(2, sheet.max_column + 1):
# 每次执行前清空该列数据
sheet.cell(i, 6).value = ''
# 每次执行前清空该列数据
sheet.cell(i, 7).value = ''
# 保存
wb.save(self.excelFile)
# 写回结果
def write_back(self, row, actual, testResult):
wb = load_workbook(self.excelFile)
sheet = wb[self.excelSheet]
# 写入实际结果值
sheet.cell(row, 7).value = actual # 运算结果的实际值
# 写入测试结果是通过还是不通过
sheet.cell(row, 8).value = testResult
# 保存
wb.save(self.excelFile)
//定义工具栏管理类
//cwgisToolBarClass.js
//vp:hsg
//定义全局变量
//插件调用方法cmToolbar.addItem(pluginCmdTool);
//定义工具栏管理类
class cwgisToolBarClass
{
//初始化函数
constructor(){
//类名称
this.CLASS_NAME="cwgisToolBarClass";
this.m_ToolBarItems=[];
this.isScan= false;
}
getMap(){
return map;
}
//添加插件项
addItem(item) {
if (item != null) {
this.m_ToolBarItems.push(item);
}
}
//反激活插件集合
deactivateItems() {
//清除全局地图事件鼠标监听者
//this.getMap().map.events.clearMouseListener();
//反激活所有全局工具
if (this.m_ToolBarItems == null) return;
for (var i=0;i<this.m_ToolBarItems.length;i++) {
var item=this.m_ToolBarItems[i];
if (item != null) {
try {
item.dispose();
}
catch (e) { }
try {
item.deactivate();
}
catch (e) { }
}
}
}
//启动扫描
startScan() {
this.isScan = true;
window.setInterval('loopScanItemEvent()', 1000); //1000为1秒钟,时间可以自己设
}
//循环扫描项事件
loopScanItemEvent() {
if (this.isScan == true) {
for (var item in this.m_ToolBarItems) {
if (this.isScan == false) break;
if (item != null) {
item.enabled;
}
}
}
}
//释放类
dispose() {
this.isScan = false;
this.deactivateItems();
this.m_ToolBarItems = null;
}
}
//export {cwgisToolBarClass};
//es6 需要采用支持es6的游览器
//定义插件Command基类 继承于OpenLayers.Class(OpenLayers.Control)
//基类抽象类名称:cwgisCommand
class cwgisCommand
{
constructor(mapWrap){
//定义属性
this.map_=null;
this.mapWrap=null;
//
this.values_ = {};
//类名称
this.CLASS_NAME="cwgisCommand";
this.init(mapWrap);
this.setActive(false);
}
//定义类 初始化函数
init(p_mapCwgisClass) {
this.mapWrap = p_mapCwgisClass;
if(p_mapCwgisClass && p_mapCwgisClass.map) {
this.setMap(p_mapCwgisClass.map);
}
}
get(key) {
let value;
if (this.values_.hasOwnProperty(key)) {
value = this.values_[key];
}
return value;
}
getKeys() {
return Object.keys(this.values_);
}
getProperties() {
return assign({}, this.values_);
}
set(key, value,opt_silent) {
if (opt_silent) {
this.values_[key] = value;
} else {
const oldValue = this.values_[key];
this.values_[key] = value;
}
}
//----
getActive() {
return this.get("ACTIVE");
}
getMap() {
return this.map_;
}
setActive(active) {
this.set("ACTIVE", active);
}
setMap(map) {
this.map_ = map;
}
//释放类
dispose() {
this.deactivate();
}
deactivate(){
}
activate(){
}
//定义单击事件
onClick () {
if (cmToolBar != null) {
cmToolBar.deactivateItems();
}
this.activate(); //激活控件
}
}
//export {cwgisCommand};
//定义插件Tool基类 继承于OpenLayers.Class(mapCwgisPluginCommand)
//基类抽象类名称:cwgisTool
class cwgisTool extends cwgisCommand
{
constructor(mapWrap) {
super(mapWrap); //继承父类Control
this.init(mapWrap);
//类名称
this.CLASS_NAME = "cwgisTool";
//定义属性
this.layer = null;
this.callbacks = null;
this.multi = false;
this.handlerOptions = null;
this.handlerClass = null;
}
//定义类 初始化函数
initialize (p_mapCwgisClass,handler,options) {
this.init(p_mapCwgisClass);
//定义 处理鼠标事件基础对象 (点) /线/面etc...
this.handlerClass = handler;
//
var handlerAbsClass = this.handlerClass;
this.handlerOptions = handlerAbsClass;
//初始化基类OpenLayers.Control的初始化方法
ol.control.Control.prototype.initialize.apply(this, [this.handlerOptions]);
//定义一个回调函数
this.callbacks = OpenLayers.Util.extend(
{
done: function (geometry) { },
modify: function (vertex, feature) {
},
create: function (vertex, feature) {
}
},
this.callbacks
);
if (this.mapWrap.vlayer_drawFeature == null) {
this.mapWrap.vlayer_drawFeature = new ol.Layer.Vector();
this.mapWrap.map.addLayer(this.mapWrap.vlayer_drawFeature);
}
//定义一个临时绘制的图层
this.layer = this.mapWrap.vlayer_drawFeature;
//this.handlerOptions =OpenLayers.Handler.Point;// this.handlerOptions || {};
if (!("multi" in this.handlerOptions)) {
this.handlerOptions.multi = this.multi;
}
var sketchStyle = this.layer.styleMap && this.layer.styleMap.styles.select; //.temporary;
if (sketchStyle) {
this.handlerOptions.layerOptions = ol.Util.applyDefaults(
this.handlerOptions.layerOptions,
{ styleMap: new ol.StyleMap({ "default": sketchStyle }) }
);
}
//定义处理鼠标事件基础对象
this.handler = new handlerAbsClass(this, this.callbacks, this.handlerOptions);
}
//定义 鼠标处理事件集合
//定义鼠标按上事件
onm ouseUp(e){
}
//定义鼠标按下事件
onm ouseDown(e){
}
//定义鼠标移动事件
onm ouseMove(e) {
}
//定义鼠标双击事件
onDoubleClick(e) {
}
//定义鼠标右键单击事件
onRightClick(e) {
}
onSingleClick(e){
}
//释放类鼠标移动事件
dispose() {
//
if(this.layer) {
this.layer.destroyFeatures();
this.layer.redraw();
}
//选中地块清除操作
//this.mapWrap.layer_Highlight.destroyFeatures();
//this.mapWrap.layer_Highlight.redraw();
//
//反注册鼠标按上事件 mouseup
this.mapWrap.map.un("mouseup", this.onMouseUp);
//反注册鼠标按下事件 mousedown
this.mapWrap.map.un("mousedown", this.onMouseDown);
//反注册鼠标移动事件 mousemove
this.mapWrap.map.un("mousemove", this.onMouseMove);
//反注册鼠标双击事件 dblclick
this.mapWrap.map.un("dblclick", this.onDoubleClick);
//反注册鼠标右键单击事件 rightclick
this.mapWrap.map.un("rightclick", this.onRightClick);
//
//this.mapWrap.map.un("singleclick", this.onSingleClick);
//
this.deactivate();
}
//定义单击事件
onClick() {
if (cmToolBar != null) {
cmToolBar.deactivateItems();
}
//初始化事件处理对象
//注册鼠标按上事件 mouseup
this.mapWrap.map.un("mouseup", this.onMouseUp);
this.mapWrap.map.on("mouseup", this.onMouseUp);
//注册鼠标按下事件 mousedown
this.mapWrap.map.un("mousedown", this.onMouseDown);
this.mapWrap.map.on("mousedown", this.onMouseDown);
//注册鼠标移动事件 mousemove
this.mapWrap.map.un("mousemove", this.onMouseMove);
this.mapWrap.map.on("mousemove", this.onMouseMove);
//注册鼠标双击事件 dblclick
this.mapWrap.map.un("dblclick", this.onDoubleClick);
this.mapWrap.map.on("dblclick", this.onDoubleClick);
//注册鼠标右键单击事件 rightclick
this.mapWrap.map.un("rightclick", this.onRightClick);
this.mapWrap.map.on("rightclick", this.onRightClick);
//singleclick
//this.mapWrap.map.un("singleclick", this.onSingleClick);
//this.mapWrap.map.on("singleclick", this.onSingleClick);
//
this.activate(); //激活控件
}
}
//export {cwgisTool};
//==========================================================
//定义 地图平移插件命令功能
class cwgisMapPanCmd extends cwgisTool
{
constructor(mapWrap) {
super(mapWrap);
this.CLASS_NAME="cwgisMapPanCmd";
this.init(mapWrap);
this.dPan=null;
}
deactivate(){
//this.mapWrap.map.removeInteraction(this.dPan);
}
activate(){
//this.dPan=new ol.interaction.DragPan();
//this.mapWrap.map.addInteraction(this.dPan);
}
};
//export {cwgisMapPanCmd};
//================
//定义 地图全屏显示插件命令功能
class cwgisMapFullExtentCmd extends cwgisCommand
{
constructor(mapWrap)
{
super(mapWrap);
this.CLASS_NAME="cwgisMapFullExtentCmd";
this.init(mapWrap);
}
//定义单击事件
onClick () {
if (cmToolBar != null) {
cmToolBar.deactivateItems();
}
if (this.mapWrap) {
this.mapWrap.fullScreenMap(); //this.mapWrap.map.zoomToMaxExtent();
}
//激活控件
this.activate();
}
};
//export {cwgisMapFullExtentCmd};
class cwgisMapBoxZoomCmd extends cwgisTool
{
constructor(mapWrap)
{
super(mapWrap);
this.CLASS_NAME="cwgisMapBoxZoomCmd";
this.init(mapWrap);
this.dBox=null;
}
deactivate(){
this.mapWrap.map.removeInteraction(this.dBox);
}
//OK
activate(){
this.dBox=new ol.interaction.DragBox();
var Tthis=this;
this.dBox.onBoxEnd_=function(mapBrowserEvent){
var t_geo=Tthis.dBox.getGeometry();
var t_mapbounds=t_geo;
Tthis.mapWrap.map.getView().fit(t_mapbounds, Tthis.mapWrap.map.getSize());
Tthis.mapWrap.map.updateSize();
};
this.mapWrap.map.addInteraction(this.dBox);
}
}
//=========================================================
内容总结
以上是互联网集市为您收集整理的最新《C++高级编程教程项目实战》全部内容,希望文章能够帮你解决最新《C++高级编程教程项目实战》所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。