static CString ExcludePath( const CString& supportPath, const CString& arxPath ) { AcStringArray cc; SplitCString( supportPath, _T( ";" ), cc ); AcStringArray paths; int n = cc.length(); for( int i = 0; i < n; i++ ) { if( cc[i].compareNoCase( arxPath ) == 0 ) continue; paths.append( cc[i] ); } CString path; n = paths.length(); for( int i = 0; i < n; i++ ) { if( i == n - 1 ) { path.AppendFormat( _T( "%s" ), paths[i].kACharPtr() ); } else { path.AppendFormat( _T( "%s;" ), paths[i].kACharPtr() ); } } return path; }
bool IntStrListHelper::GetIntStrList( const CString& name, AcDbIntArray& intList, AcStringArray& strList ) { AcStringArray entries; if( !ArxDictHelper::GetAllEntries( INT_LIST_DICT, name, entries ) ) return false; int len = entries.length(); bool ret = ( len > 0 && len % 2 == 0 ); if( ret ) // 长度必须为偶数 { intList.removeAll(); strList.removeAll(); for( int i = 0; i < len; i++ ) { if( i % 2 == 0 ) // 偶数位置的元素为整数 { intList.append( _ttoi( entries[i].kACharPtr() ) ); } else // 奇数位置的元素为字符串 { strList.append( entries[i] ); } } } return ret; }
bool ReportDataHelper::SetObjectDatas( const AcDbObjectId& objId,const AcStringArray& values ) { if( objId.isNull() ) return false; AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return false; AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objId, AcDb::kForWrite ) ) { actrTransactionManager->abortTransaction(); return false; } DataObject* pDO = DataObject::cast( pObj ); if( pDO == 0 ) { actrTransactionManager->abortTransaction(); return false; } pDO->clearAll(); for(int i = 0; i < values.length(); i++) { CString value = values[i].kACharPtr(); pDO->addData(); pDO->setData(i,value); } actrTransactionManager->endTransaction(); return true; }
void FieldInfoDlg::fillVarList() { m_varList.ResetContent(); // 清空列表 AcStringArray names; switch( m_lt ) { case LT_STRING: StringListHelper::GetAllNames( names ); break; case LT_INT: IntStrListHelper::GetAllNames( names ); break; case LT_OBJECT: DataObjectListHelper::GetAllNames( names ); break; } if( names.isEmpty() ) return; int index = names.find( m_varName ); if( index < 0 ) m_varName = _T( "" ); // 清空 int len = names.length(); for( int i = 0; i < len; i++ ) { m_varList.AddString( names[i].kACharPtr() ); } m_varList.SetCurSel( index ); }
void BlockDraw::explodeBlock( AcGeVoidPointerArray& ents ) { // 填充属性数据 AcStringArray names; regPropertyDataNames( names ); if( names.isEmpty() ) { acutPrintf( _T( "\n没有注册要提取的字段..." ) ); return; } if( names.length() != m_attValues.length() ) { acutPrintf( _T( "\n注册的属性数据与读取的数据个数不相等!" ) ); return; } AcDbObjectId blkId = GetBlockDefinitionByName( m_blockName ); if( blkId.isNull() ) { acutPrintf( _T( "\n未知的块定义:%s" ), m_blockName ); return; } // 计算变换矩阵 AcGeMatrix3d blkXform = GetBlockTransformMatrix( blkId, m_insertPt, m_angle, m_scale ); // 分解块定义 BlockToEntity( blkId, blkXform, names, m_attValues, ents ); }
void ReportDataHelper::ReadDatas( const CString& name, ArrayVector& datasVector,int unitCount ) { AcStringArray getDatas; AcDbObjectId objId; GDESDataObjectHelper::GetObjectId(name,objId); GetObjectDatas(objId,getDatas); //AcStringArray strName,strIsRunning,strReason; ArrayVector datas; int nCount = getDatas.length(); if(nCount <= 0) return; datas.resize( unitCount ); for(int i = 0; i < nCount; i = i+2 ) { int j = (i/2)% unitCount; datas[j].append(getDatas[i]); } datasVector.clear(); for(int i = 0; i < nCount / (2 * unitCount); i++) { CString temp; AcStringArray temps; for(int j = 0; j < unitCount; j++) { temp.Format(_T("%s"),datas[j][i].kACharPtr()); if(temp == ISNULL) temp = _T(""); temps.append(temp); } datasVector.push_back(temps); } }
bool PropertyDataUpdater::BuildPropGridCtrl( CMFCPropertyGridCtrl* pPropDataList, const CString& type, const AcStringArray& fields ) { if( pPropDataList == NULL ) return false; if( type.GetLength() == 0 ) return false; if( fields.isEmpty() ) return false; // 清空已添加的属性 pPropDataList->RemoveAll(); //acutPrintf(_T("\n清空所有属性...")); // 创建MFCPropertyGridCtrlHelper对象 // 同时初始化m_propertyDataList的属性 // 参见MFCPropertyGridCtrlHelper的构造函数 MFCPropertyGridCtrlHelper pgch( pPropDataList ); int len = fields.length(); for( int i = 0; i < len; i++ ) { CString name = fields[i].kACharPtr(); FieldInfo info; // 默认设置(DT_STRING, m_enable=true, m_descr =_T("")) FieldInfoHelper::ReadFieldInfo( type, name, info ); // 构建PropertyList BuildPropList( pgch, name, _T( "" ), info ); // 赋予空字符串 } //PrintPropList(pPropDataList); return true; }
static void StringsToNum( const AcStringArray& strDatas, doubleVector& doubleDatas) { for(int i = 0; i < strDatas.length(); i++) { double temp = _tstof(strDatas[i].kACharPtr()); doubleDatas.push_back(temp); } }
void PDFConverter(BOOL bDwg) { // test(); resbuf* rb = getFileNameInput(); resbuf* pRb = rb; AcStringArray arrFileName; while (pRb) { arrFileName.append(pRb->resval.rstring); pRb = pRb->rbnext; } acutRelRb(rb); rb = NULL; int page = 0; if (arrFileName.length() == 1) { acedInitGet(4, NULL); // use resource for multi langeage. // modify by yhl, 2016/6/29. CString strPrompt; CAcModuleResourceOverride rs; strPrompt.LoadString(IDS_ASKFORPAGENUMBER); int rc = acedGetInt(strPrompt, &page); // int rc = acedGetInt(_T("\nPlease input the page number, 0 for all <1>: "), &page); if (RTNONE == rc) { page = 1; } else if (RTNORM != rc) { return; } } for (int i=0; i<arrFileName.length(); i++) { convertFile(arrFileName[i], page, bDwg); } }
static void CreatDrillTables(const CString& type, const AcStringArray& funcs,const AcDbObjectId& objId) { for (int j =0 ; j < funcs.length(); j++) { MyWord->WriteText(funcs[j].kACharPtr(),wdAlignParagraphJustify); MyWord->TypeParagraph(); CreatDrillTable(type,funcs[j].kACharPtr(),objId); MyWord->MoveToEnd(); MyWord->TypeParagraph(); } }
void FieldHelper::RemoveAllFields( const CString& type ) { AcStringArray fields; GetAllFields( type, fields ); int len = fields.length(); for( int i = 0; i < len; i++ ) { RemoveField( type, fields[i].kACharPtr() ); } RemoveKey_Helper( PROPERTY_DATA_FIELD_DICT, type ); }
void ContourLayerDlg::FillLayerList() { // 读取所有图层列表 AcStringArray layers; GetEntityLayers( _T( "ContourGE" ), layers ); m_layerList.ResetContent(); // 填充列表 int n = layers.length(); for( int i = 0; i < n; i++ ) { m_layerList.AddString( layers[i].kACharPtr() ); } }
bool DataObjectListHelper::RemoveAllObject( const CString& name ) { if( name.GetLength() == 0 ) return false; AcStringArray values; GetObjectNameList( name, values ); bool ret = true; int len = values.length(); for( int i = 0; i < len; i++ ) { ret = ( ret && RemoveObject( name, values[i].kACharPtr() ) ); } ArxDictHelper::RemoveAllEntries( OBJECT_LIST_DICT, name ); return ret; }
static bool GetFieldsDatas(const CString& type, const CString& func, const AcDbObjectId& objId,AcStringArray& fields,AcStringArray& datas) { fields.removeAll(); datas.removeAll(); if(!FuncFieldHelper::GetFields(func,type,fields)) return false; fields.remove(_T("钻孔名称")); for(int i = 0; i < fields.length(); i++) { CString strData; if(!DataHelper::GetPropertyData(objId,fields[i].kACharPtr(),strData)) return false; DealIntListDatas(fields[i].kACharPtr(),strData); datas.append(strData); } return true; }
bool StringListHelper::AddStringList( const CString& name, const AcStringArray& strList ) { if( ( name.GetLength() == 0 ) || strList.isEmpty() ) return false; ArxDictTool* pDictTool = ArxDictTool::GetDictTool( STRING_LIST_DICT ); bool ret = pDictTool->findKey( name ); if( !ret ) // 如果变量name已存在,则不进行修改 { int len = strList.length(); for( int i = 0; i < len; i++ ) { pDictTool->addEntry( name, strList[i].kACharPtr() ); } } delete pDictTool; return !ret; }
static bool IsPathExit( const CString& supportPath, const CString& arxPath ) { AcStringArray cc; SplitCString( supportPath, _T( ";" ), cc ); bool bFind = false; int n = cc.length(); for( int i = 0; i < n; i++ ) { if( cc[i].compareNoCase( arxPath ) == 0 ) { bFind = true; break; } } return bFind; }
bool ArxClassHelper::GetAllTopParentClass( const CString& root, AcStringArray& types ) { AcStringArray allGETypes; ArxClassHelper::GetArxClassTypes( root, allGETypes, false ); if( allGETypes.isEmpty() ) return false; int len = allGETypes.length(); for( int i = 0; i < len; i++ ) { CString parentType; if( !ArxClassHelper::GetTopParentClass( allGETypes[i].kACharPtr(), parentType ) ) continue; if( allGETypes[i].compareNoCase( parentType ) != 0 ) continue; if( !types.contains( parentType ) ) { types.append( parentType ); } } return true; }
void PropertyDataDlgHelper::DisplayPartialPropertyDataDlg( const AcDbObjectId& objId, const AcStringArray& fields ) { if( objId.isNull() ) return; if( fields.isEmpty() ) return; // 切换资源 CAcModuleResourceOverride myResources; PropertyDataDlg pdd; pdd.showAllData( true ); pdd.setMineGE( objId ); int len = fields.length(); for( int i = 0; i < len; i++ ) { pdd.addField( fields[i].kACharPtr() ); //acutPrintf(_T("\n字段:%s"),fields[i].kACharPtr()); } pdd.DoModal(); }
bool IntStrListHelper::AddIntStrList( const CString& name, const AcDbIntArray& intList, const AcStringArray& strList ) { if( ( name.GetLength() == 0 ) || strList.isEmpty() || intList.isEmpty() ) return false; if( intList.length() != strList.length() ) return false; ArxDictTool* pDictTool = ArxDictTool::GetDictTool( INT_LIST_DICT ); bool ret = pDictTool->findKey( name ); if( !ret ) { int len = intList.length(); for( int i = 0; i < len; i++ ) { CString intValue; intValue.Format( _T( "%d" ), intList[i] ); pDictTool->addEntry( name, intValue ); // 偶数位置的元素为整数 pDictTool->addEntry( name, strList[i].kACharPtr() ); // 奇数位置的元素为字符串 } } delete pDictTool; return !ret; }
BOOL GasSysDlg::RecordRunningSysName(const AcStringArray& gasSysNams,const AcStringArray& gasSysRunning) { //CString dataDirName = _T( "Datas\\BaseTemp\\" ); //CString fileName =BuildPath ( BuildPath( GetAppPathDir(), dataDirName ),_T("bgaspumpvars0.txt") ); //AcOfstream outFile(fileName); //if (!outFile) return FALSE; ArrayVector namesVector; AcStringArray names; for(int i = 0; i < gasSysNams.length(); i++) { CString isRunning = gasSysRunning[i].kACharPtr(); if(isRunning != _T("是")) continue; names.append(gasSysNams[i]); //outFile << gasSysNams[i].kACharPtr() << _T("\n"); } namesVector.push_back(names); ReportDataHelper::WriteDatas(RUNNING_SYS_OBJCT_NAME,namesVector); if(namesVector.empty()) return FALSE; return TRUE; }
void FieldManagerDlg::fillFieldListBox( const CString& type ) { setLastSelIndex( LB_ERR ); // 记录listbox切换之前的索引位置 AcStringArray fields; FieldHelper::GetAllFields( type, fields ); if( fields.isEmpty() ) return; int len = fields.length(); for( int i = 0; i < len; i++ ) { CString field = fields[i].kACharPtr(); m_fieldListBox.AddString( field ); // 初始为默认设置 FieldInfo* pInfo = new FieldInfo(); // 读取字段信息 FieldInfoHelper::ReadFieldInfo( type, field, *pInfo ); m_infoes.append( pInfo ); } m_fieldListBox.SetCurSel( 0 ); }
static void FormatStringListMsg( const AcStringArray& strList, const CString& name, CString& msg ) { msg.Format( _T( "【%s】数据列表:\n" ), name ); int len = strList.length(); if( len <= LIST_ITEM_MAX_COUNT ) { for( int i = 0; i < len; i++ ) { msg.AppendFormat( _T( "%s\n" ), strList[i].kACharPtr() ); } } else { for( int i = 0; i < len; i++ ) { msg.AppendFormat( _T( "%s\t" ), strList[i].kACharPtr() ); if( ( i + 1 ) % DEF_COL_COUNT == 0 ) { msg.Append( _T( "\n" ) ); } } } }
static BOOL SetBaseReportVal(CString& mineName) { SetGroundSys(); SetUndergroundSys(); //瓦斯抽采达标规划和年度实施计划表格 SetTableVal(GAS_PLAN_BOOKMKS_OBJCT_NAME); //抽采达标工艺方案设计和采掘工作面施工设计表格 SetTableVal(EPCMFD_BOOKMKS_OBJCT_NAME); //矿井瓦斯抽采达标自评价体系和瓦斯抽采管理制度表格 SetTableVal(SM_BOOKMKS_OBJCT_NAME); //瓦斯抽采工程验收资料表格 SetTableVal(INSPECT_BOOKMKS_OBJCT_NAME); //瓦斯泵站能力 SetPumpTable(); AcStringArray names; names.append(RET_GASSYS_OBJCT_NAME); names.append(RET_EPCMFD_OBJCT_NAME); names.append(RET_GASPLAN_OBJCT_NAME); names.append(RET_INSPECT_OBJCT_NAME); names.append(RET_SM_OBJCT_NAME); names.append(RET_GASPUMP_OBJCT_NAME); names.append(RET_MERSURE_OBJCT_NAME); names.append(RET_REALATE_OBJCT_NAME); //结论表格的书写 for(int i = 0; i < names.length(); i++) { CString name = names[i].kACharPtr(); if(!SetConclusionTable(name)) return FALSE; } WriteMineName(mineName); //MyWord->SetSeekView(mineName,wdAlignParagraphJustify,wdSeekCurrentPageHeader,_T("{{MineName_Header}}")); //DeleteExcludeLine(); return TRUE; }
void PropertyDataDlgHelper::InputPropertyDataDlg( const AcDbObjectId& objId, const AcStringArray& fields, const CString& func ) { if( objId.isNull() ) return; if( fields.isEmpty() ) return; // 切换资源 CAcModuleResourceOverride myResources; if (_T("参与评价的煤量") == func) { GasWidthCaculDlg gaswidthdlg; gaswidthdlg.setMineGE(objId); int ret = gaswidthdlg.DoModal(); if (IDCANCEL == ret) return; } if (_T("邻近层瓦斯涌出量") == func) { if(!AddNearByFields(objId,func)) return; } if(_T("工作面瓦斯抽采率") == func) { CString strGD,strVD,strGDold,strVDold; DataHelper::GetPropertyData(objId,_T("瓦斯绝对涌出量"),strGD); DataHelper::GetPropertyData(objId,_T("风排瓦斯量"),strVD); DataHelper::GetPropertyData(objId,_T("当月工作面月平均瓦斯抽采量"),strGDold); DataHelper::GetPropertyData(objId,_T("当月工作面风排瓦斯量"),strVDold); double ret = _tstof(strGD) - _tstof(strVD); CString strRet; strRet.Format(_T("%.2lf"),ret); if(_tstof(strGDold) <= 0 && ret >= 0) DataHelper::SetPropertyData(objId,_T("当月工作面月平均瓦斯抽采量"),strRet); if(_tstof(strVDold) <= 0) DataHelper::SetPropertyData(objId,_T("当月工作面风排瓦斯量"),strVD); } //if (_T("管路阻力") == func) //{ // ValueHelper::setGasAirValue(objId); //} //if(_T("通过瓦斯抽采量计算") == func || _T("通过残余瓦斯压力反算") == func) //{ // WcyPropertyDlg pdd(NULL,func); // pdd.showAllData( true ); // pdd.setMineGE( objId ); // int len = fields.length(); // for( int i = 0; i < len; i++ ) // { // pdd.addField( fields[i].kACharPtr() ); // //acutPrintf(_T("\n字段:%s"),fields[i].kACharPtr()); // } // pdd.DoModal(); //} //else //{ PropertyDataDlg pdd(NULL,func); pdd.showAllData( true ); pdd.setMineGE( objId ); int len = fields.length(); for( int i = 0; i < len; i++ ) { pdd.addField( fields[i].kACharPtr() ); //acutPrintf(_T("\n字段:%s"),fields[i].kACharPtr()); } pdd.DoModal(); //} }
/* * 方法: * 1) 得到原始的字段链表L1和字段列表框中的字段链表L2 * 2) 遍历链表L2,判断字段是否存在于L1中 * a) 如果存在,则该字段保持不变,并从L1中移除该字段; * b) 如果不存在,则转第(3)步 * 3) 该字段是新添加的字段,则执行"增加字段"操作Add * 4) 完成遍历L2,最后剩下的L1的元素就是需要删除的字段 * 5) 执行"删除字段"操作Remove */ void FieldManagerDlg::OnBnClickedApplyBtn() { if( m_fieldListBox.GetCount() > 0 ) { // 切换之前更新上次选择的字段信息 // 并检查字段信息的有效性 if( !updateFieldInfo() ) return; } // 选择的图元类型 CString selType = getSelType(); if( selType.GetLength() == 0 ) return; AcStringArray fields; FieldHelper::GetAllFields( selType, fields ); if( fields.isEmpty() && m_fieldListBox.GetCount() == 0 ) { MessageBox( _T( "没有字段可更新" ) ); return; } // "剩余"字段 // 与m_infoes应该是一一对应的 AcStringArray leftFields; for( int i = 0; i < m_fieldListBox.GetCount(); i++ ) { CString text; m_fieldListBox.GetText( i, text ); leftFields.append( text ); } int len = leftFields.length(); for( int i = 0; i < len; i++ ) { CString field = leftFields[i].kACharPtr(); int index = fields.find( field ); if( index >= 0 ) // 已存在,不变 { fields.removeAt( index ); } else { // 增加字段 FieldHelper::AddField( selType, field ); } // 默认属性设置不需要添加到词典中 if( m_infoes[i]->isDefault() ) { FieldInfoHelper::RemoveFieldInfo( selType, field ); } else { // 新增的字段 if( index < 0 || !FieldInfoHelper::FindFieldInfo( selType, field ) ) { FieldInfoHelper::AddFieldInfo( selType, field, *m_infoes[i] ); } else { // 更新已有的字段信息 FieldInfoHelper::WriteFieldInfo( selType, field, *m_infoes[i] ); } } } // 删除字段 len = fields.length(); for( int i = 0; i < len; i++ ) { FieldHelper::RemoveField( selType, fields[i].kACharPtr() ); } MessageBox( _T( "字段信息更新成功!" ) ); }