struct resbuf* AecUiPrEntitySet::keywordCallback(const TCHAR* str) { if (AecUiPrEntitySet::m_currentPromptObj == NULL) { AEC_ASSERT(0); return NULL; } AecRmCString tmpStr; AecRmCString tmpStr2(GetAecUiBaseAppName(), AECU_STR_KEYWORDCALLBACK_AECUIPRENTITYSET_FILTERS, TRUE); AecRmCString tmpStr3(GetAecUiBaseAppName(), AECU_STR_KEYWORDCALLBACK_AECUIPRENTITYSET_ALLOWED_OBJECT, TRUE); ads_printf(tmpStr2); //~ "\nFILTERS:" Aec::ads_printf(GetAecUiBaseAppName(), AECU_STR_KEYWORDCALLBACK_AECUIPRENTITYSET_LOCKED_LAYERS, //~ "\n Locked Layers: %s" Aec::booleanToStr(AecUiPrEntitySet::m_currentPromptObj->m_filterLockedLayers, tmpStr)); ads_printf(tmpStr3); //~ "\n Allowed Object Types:" int len = AecUiPrEntitySet::m_currentPromptObj->m_classTypeCache.length(); if (len == 0) { AecRmCString tmpStr4(GetAecUiBaseAppName(), AECU_STR_KEYWORDCALLBACK_AECUIPRENTITYSET_ALL_ENTITIES, TRUE); ads_printf(tmpStr4); //~ "\n All entities allowed." } else { AcRxClass* classType; for (int i=0; i<len; i++) { classType = static_cast<AcRxClass*>(AecUiPrEntitySet::m_currentPromptObj->m_classTypeCache[i]); ads_printf(_DNT(_T("\n %s")), classType->name()); } } ads_printf(_DNT(_T("\n"))); return NULL; }
//----------------------------------------------------------------------------- void C[!output SAFE_PROJECT_NAME]App::getRequiredModules (AecRmCStringArray &reqApps) { reqApps.Add (_DNT("AecBase60")) ; [!if APP_ARX_TYPE] reqApps.Add (_DNT("AecUiBase60")) ; [!else] reqApps.Add (_DNT("AecArchBase60")) ; [!endif] }
//----------------------------------------------------------------------------- void C[!output SAFE_PROJECT_NAME]App::initRegistryInfo () { //----- Add the resource only Dll info AecRegistryInfo *reginfo =appRegistryInfo () ; if ( reginfo != NULL ) { reginfo->getRegistryString (_DNT("Language"), _DNT("CurrentLanguage"), _DNT("English"), TRUE) ; CString locale ("Language\\English") ; CString dllName =appName () + _DNT("Enu.dll") ; reginfo->writeRegistryString (locale, (LPCTSTR)(C[!output SAFE_PROJECT_NAME]App::getApp ()->appName ()), dllName) ; } }
AecUiPrBase::Status AecUiPrEntitySet::go() { m_selSet.setLogicalLength(0); // reset to null set getLockedLayers(); getAllowableClassTypes(); if (verifyPickfirstSet(Adesk::kFalse)) return AecUiPrBase::kOk; resbuf* filter = buildSelSetFilter(); m_ss.setKeywordCallback(_DNT(_T("FIlter _ FIlter")), AecUiPrEntitySet::keywordCallback); m_currentPromptObj = this; // hack way to get back from keyword callback AecAcadSelSet::SelSetStatus stat; // if supplied prompt, pass it on to selection set AecRmCString promptStr(message()); if (promptStr.IsEmpty() == FALSE) { AecRmCString tmpPrompt; tmpPrompt.Format(_DNT(_T("\n%s: ")), static_cast<LPCTSTR>(promptStr)); stat = m_ss.userSelect(tmpPrompt, NULL, filter); } // no prompt supplied, use regular ssget prompts else { stat = m_ss.userSelect(filter); } m_currentPromptObj = NULL; if (filter) ads_relrb(filter); if (stat != AecAcadSelSet::kSelected) { if (stat == AecAcadSelSet::kNone) return AecUiPrBase::kNone; else return AecUiPrBase::kCancel; } m_ss.asArray(m_selSet); if (m_selSet.isEmpty()) { AEC_ASSERT(0); // should have return kNone already return AecUiPrBase::kNone; } else return AecUiPrBase::kOk; }
//----------------------------------------------------------------------------- void C[!output SAFE_PROJECT_NAME]App::getRegistryInfo (AecRmCString ®CompanyName, AcadApp::LoadReasons &reasons) { regCompanyName =_DNT("Your Company Name") ; [!if APP_ARX_TYPE] reasons =static_cast<AcadApp::LoadReasons> (AcadApp::kOnLoadRequest | AcadApp::kOnCommandInvocation) ; [!else] reasons =static_cast<AcadApp::LoadReasons> (AcadApp::kOnLoadRequest) ; [!endif] }
void AecUiPrEntitySet::getLockedLayers() { m_lockedLayerCache.setLogicalLength(0); m_lockedLayerNames.RemoveAll(); if (m_filterLockedLayers == Adesk::kFalse) return; AcDbLayerTableRecord* layer; const TCHAR* tmpName; AcDbLayerTable* layTbl; Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase()->getSymbolTable(layTbl, AcDb::kForRead); if (es == Acad::eOk) { AcDbLayerTableIterator* tblIter; if (layTbl->newIterator(tblIter) == Acad::eOk) { for (; !tblIter->done(); tblIter->step()) { es = tblIter->getRecord(layer, AcDb::kForRead); if (es == Acad::eOk) { if (layer->isLocked()) { m_lockedLayerCache.append(layer->objectId()); es = layer->getName(tmpName); if (es == Acad::eOk) { m_lockedLayerNames.Add(tmpName); } else { AEC_ASSERT(0); m_lockedLayerNames.Add(_DNT(_T(""))); // have to keep balanced } } layer->close(); } } delete tblIter; } else { AEC_ASSERT(0); } layTbl->close(); } }
Adesk::Boolean AecUiPrSubentity::retrievePickDataAt(long index) { AecRmCString hardErrMsg(GetAecUiBaseAppName(), AECU_STR_RETRIEVEPICKDATAAT_AECUIPRSUBENTITY_ERROR_COULD_NOT, TRUE); //~ "\nERROR: could not retreive pick data!" resbuf* rb; ads_name selSet; m_ss.asAdsName(selSet); if (ads_ssnamex(&rb, selSet, index) != RTNORM) return Adesk::kFalse; // find out the objectId of the item picked AcDbObjectId mainId; ads_name ent; ads_ssname(selSet, index, ent); if (Aec::enameToObjId(ent, mainId) != Acad::eOk) { ads_printf(hardErrMsg); return Adesk::kFalse; } resbuf* tmp = rb; if ((tmp == NULL) || (tmp->restype != RTLB)) { // should start with this AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // second element is selection method, which should always be pickPt=1 tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTSHORT) || (tmp->resval.rint != 1)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // third element is entity name of object selected tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTENAME)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // fourth element is the gsMarker tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTSHORT)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } int gsMarker = tmp->resval.rint; // fifth element is start of list for pickPt tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTLB)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // sixth element is point descriptor tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RTSHORT)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } // seventh element is pick point tmp = tmp->rbnext; if ((tmp == NULL) || (tmp->restype != RT3DPOINT)) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } AcGePoint3d pickPt(tmp->resval.rpoint[0], tmp->resval.rpoint[1], tmp->resval.rpoint[2]); // eigth element is either end of list or the direction vector tmp = tmp->rbnext; if (tmp == NULL) { AEC_ASSERT(0); ads_relrb(rb); ads_printf(hardErrMsg); return Adesk::kFalse; } AcGeVector3d pickVector; if (tmp->restype == RT3DPOINT) pickVector.set(tmp->resval.rpoint[0], tmp->resval.rpoint[1], tmp->resval.rpoint[2]); else pickVector.set(0.0, 0.0, 1.0); // WCS Z-axis ads_relrb(rb); // if this is the first time its picked, set mainId to this objectId. // All subsequent picks must match this id if (m_mainEnt == AcDbObjectId::kNull) { m_mainEnt = mainId; // add this to the "set" of objects selected (which in our case is 1 item) m_selSet.setLogicalLength(0); // reset array m_selSet.append(mainId); } else { // must be from same entity! if (m_mainEnt != mainId) { AecRmCString msg; msg.LoadString(GetAecUiBaseAppName(), AECU_STR_SUBENT_MUST_BE_FROM_MAINENT); ads_printf(msg); return Adesk::kFalse; } } // unhighlight any existing edges doUnHighlight(m_mainEnt); // if the same edge is picked twice, remove it out of the set int atIndex; if (m_gsMarkers.find(gsMarker, atIndex)) { m_gsMarkers.removeAt(atIndex); m_pickPts.removeAt(atIndex); m_pickVecs.removeAt(atIndex); DEBUG_ONLY(ads_printf(_DNT(_T("\nAecUiPrSubentity:: removed gsmarker: %d")), gsMarker)); } else { m_isValidssnamexData = Adesk::kTrue; // this isn't really accurate Nth time thru loop m_gsMarkers.append(gsMarker); m_pickPts.append(pickPt); m_pickVecs.append(pickVector); DEBUG_ONLY(ads_printf(_DNT(_T("\nAecUiPrSubentity:: added gsmarker: %d")), gsMarker)); } // re-highlight with new data doHighlight(m_mainEnt); return Adesk::kTrue; }
AecUiPrBase::Status AecUiPrSubentity::go() { m_selSet.setLogicalLength(0); // reset to null set m_isValidssnamexData = Adesk::kFalse; getLockedLayers(); getAllowableClassTypes(); m_disallowPickfirstSet = Adesk::kTrue; // don't allow pickfirst set because we need the gsmarkers cleanPickfirstSet(); resbuf* filter = buildSelSetFilter(); m_ss.setKeywordCallback(_DNT(_T("FIlter _ FIlter")), AecUiPrEntitySetSingle::keywordCallback); m_currentPromptObj = this; // hack way to get back from keyword callback m_ss.setAllowSingleOnly(Adesk::kTrue, Adesk::kFalse); m_ss.setAllAtPickBox(Adesk::kTrue); // enable selection of more than 1. Filter will do the rest. If not, it will work // like normal anyway by taking the first one and they can turn on object cycling // if they want to be exact. AecRmCString promptStr(message()); AecAcadSelSet::SelSetStatus stat = AecAcadSelSet::kNone; int errNum = 0; while (1) { Aecu::setSysVar(AcadVar::adserr, 0); // reset fresh // if supplied prompt, pass it on to selection set if (promptStr.IsEmpty() == FALSE) { AecRmCString tmpPrompt; tmpPrompt.Format(_DNT(_T("\n%s: ")), static_cast<LPCTSTR>(promptStr)); stat = m_ss.userSelect(tmpPrompt, NULL, filter); } // no prompt supplied, use regular ssget prompts else { stat = m_ss.userSelect(filter); } // got some kind of response, if its a NULL response, only // allow it if allowNone flag is set or if they have already // picked some sub-entities if (stat == AecAcadSelSet::kNone) { if (Aecu::getSysVar(AcadVar::adserr, errNum) == Acad::eOk) { if (errNum != OL_ENTSELNULL) { // this means they missed hitting an entity Aec::ads_printf(GetAecUiBaseApp(), AECU_STR_NO_SELECTION); continue; } } if ((m_allowNone) || (m_mainEnt != AcDbObjectId::kNull)) { // if they have already picked one, final return value should // be selected, not NONE if (m_mainEnt != AcDbObjectId::kNull) stat = AecAcadSelSet::kSelected; break; } else continue; } else if (stat == AecAcadSelSet::kSelected) { if (retrievePickDataAt(0L)) { // bail early if we only allow a single edgeId if (m_allowMultipleSelect == Adesk::kFalse) break; } } else break; } doUnHighlight(m_mainEnt); // leave object unhighlighted when we leave the prompt m_currentPromptObj = NULL; if (filter) ads_relrb(filter); if (stat != AecAcadSelSet::kSelected) { if (stat == AecAcadSelSet::kNone) return AecUiPrBase::kNone; else return AecUiPrBase::kCancel; } if (m_selSet.isEmpty()) { AEC_ASSERT(0); // should have return kNone already return AecUiPrBase::kCancel; } else return AecUiPrBase::kOk; }
AecRmCString AecUiPrEntitySet::keyWords() const { return _DNT(_T("")); }
resbuf* AecUiPrEntitySet::buildSelSetFilter() { if ((m_lockedLayerNames.GetSize() == 0) && m_classTypeCache.isEmpty()) return NULL; AecResbufList rbList; resbuf* tmpRb; if (m_classTypeCache.isEmpty() == Adesk::kFalse) { tmpRb = acutNewRb(-4); newString(_DNT(_T("<or")), tmpRb->resval.rstring); rbList.addTail(tmpRb); const TCHAR* dxfStr; int len = m_classTypeCache.length(); for (int i=0; i<len; i++) { dxfStr = static_cast<AcRxClass*>(m_classTypeCache[i])->dxfName(); if (dxfStr) { tmpRb = acutNewRb(0); newString(dxfStr, tmpRb->resval.rstring); rbList.addTail(tmpRb); } //else { //AEC_ASSERT(0); // can't assert because AcDbCurve has no DXF name //} } tmpRb = acutNewRb(-4); newString(_DNT(_T("or>")), tmpRb->resval.rstring); rbList.addTail(tmpRb); } int len = m_lockedLayerNames.GetSize(); if (len > 0) { tmpRb = acutNewRb(-4); newString(_DNT(_T("<not")), tmpRb->resval.rstring); rbList.addTail(tmpRb); tmpRb = acutNewRb(-4); newString(_DNT(_T("<or")), tmpRb->resval.rstring); rbList.addTail(tmpRb); for (int i=0; i<len; i++) { if (m_lockedLayerNames[i].IsEmpty() == FALSE) { tmpRb = acutNewRb(8); newString(m_lockedLayerNames[i], tmpRb->resval.rstring); rbList.addTail(tmpRb); } else { AEC_ASSERT(0); } } tmpRb = acutNewRb(-4); newString(_DNT(_T("or>")), tmpRb->resval.rstring); rbList.addTail(tmpRb); tmpRb = acutNewRb(-4); newString(_DNT(_T("not>")), tmpRb->resval.rstring); rbList.addTail(tmpRb); } return rbList.orphanData(); }
AecUiPrEntitySet::AecUiPrEntitySet() : AecUiPrBase(_DNT(_T("")), NULL), m_filterLockedLayers(Adesk::kFalse), m_disallowPickfirstSet(Adesk::kFalse) { }
Adesk::Boolean AecUiPrEntitySet::verifyPickfirstSet(Adesk::Boolean singleSelect) { if (m_disallowPickfirstSet) { cleanPickfirstSet(); return Adesk::kFalse; } // if the set is already selected, verify that it has // the right stuff in it. AecBaseEditorReactor* edReact = AecUiBaseServices::getEditorReactor(); if (edReact == NULL) { AEC_ASSERT(0); cleanPickfirstSet(); return Adesk::kFalse; } m_selSet.setLogicalLength(0); // reset to null set AcDbEntity* ent; Acad::ErrorStatus es; int filteredBecauseOfClass = 0; int filteredBecauseOfLockedLayer = 0; const AcDbObjectIdArray& pickSet = edReact->pickfirstSet(); int len = pickSet.length(); // if only allowing single select, bail if more than 1 item // in the pickfirst set. if (singleSelect && (len > 1)) { ads_printf(_DNT(_T("\n"))); // make sure we get to a new line AecRmCString tmpStr(GetAecUiBaseAppName(), AECU_STR_VERIFYPICKFIRSTSET_AECUIPRENTITYSET_TOO_MANY_OBJECTS, TRUE); ads_printf(tmpStr); //~ "Too many objects in the pickfirst set, please select again.\n" cleanPickfirstSet(); return Adesk::kFalse; } for (int i=0; i<len; i++) { es = acdbOpenAcDbEntity(ent, pickSet[i], AcDb::kForRead); if (es == Acad::eOk) { if (isCorrectClassType(ent->isA()) == Adesk::kFalse) { filteredBecauseOfClass++; ent->close(); continue; } if (m_filterLockedLayers && m_lockedLayerCache.contains(ent->layerId())) { filteredBecauseOfLockedLayer++; ent->close(); continue; } ent->close(); m_selSet.append(pickSet[i]); } else { Aec::ads_printf(GetAecUiBaseAppName(), AECU_STR_VERIFYPICKFIRSTSET_AECUIPRENTITYSET_COULD_NOT_OPEN_ENTITY_FOR_READ, Aec::rxErrorStr(es)); //~ "\nCould not open entity for read: %s" } } ads_printf(_DNT(_T("\n"))); // make sure we get to a new line if (filteredBecauseOfClass == 1) { AecRmCString tmpStr(GetAecUiBaseAppName(), AECU_STR_VERIFYPICKFIRSTSET_AECUIPRENTITYSET_OBJECT_WAS, TRUE); ads_printf(tmpStr); // NOTE: leave \n's at end so you can see message before dialog comes up (jma) //~ "1 object was of the wrong type.\n" } else if (filteredBecauseOfClass > 1) { Aec::ads_printf(GetAecUiBaseAppName(), AECU_STR_VERIFYPICKFIRSTSET_AECUIPRENTITYSET_OBJECTS_WERE_OF_THE_WRONG_TYPE, filteredBecauseOfClass); //~ "%ld objects were of the wrong type.\n" } if (filteredBecauseOfLockedLayer == 1) { AecRmCString tmpStr(GetAecUiBaseAppName(), AECU_STR_VERIFYPICKFIRSTSET_AECUIPRENTITYSET_OBJECT_WAS_0, TRUE); ads_printf(tmpStr); //~ "1 object was on a locked layer.\n" } else if (filteredBecauseOfLockedLayer > 1) { Aec::ads_printf(GetAecUiBaseAppName(), AECU_STR_VERIFYPICKFIRSTSET_AECUIPRENTITYSET_OBJECTS_WERE_ON_LOCKED_LAYER, filteredBecauseOfLockedLayer); //~"%ld objects were on a locked layer.\n" } if ((len > 0) && m_selSet.isEmpty()) { AecRmCString tmpStr(GetAecUiBaseAppName(), AECU_STR_VERIFYPICKFIRSTSET_AECUIPRENTITYSET_ALL_OBJECTS_IN, TRUE); ads_printf(tmpStr); //~ "All objects in the pickfirst set were filtered out, please select again.\n" } cleanPickfirstSet(); return !m_selSet.isEmpty(); }
AecUiPrBase::Status AecUiPrEntitySetSingle::go() { m_selSet.setLogicalLength(0); // reset to null set getLockedLayers(); getAllowableClassTypes(); if (verifyPickfirstSet(Adesk::kTrue)) return AecUiPrBase::kOk; resbuf* filter = buildSelSetFilter(); m_ss.setKeywordCallback(_DNT(_T("FIlter _ FIlter")), AecUiPrEntitySetSingle::keywordCallback); m_currentPromptObj = this; // hack way to get back from keyword callback m_ss.setAllowSingleOnly(Adesk::kTrue, Adesk::kTrue); m_ss.setAllAtPickBox(Adesk::kTrue); // enable selection of more than 1. Filter will do the rest. If not, it will work // like normal anyway by taking the first one and they can turn on object cycling // if they want to be exact. AecRmCString promptStr(message()); AecAcadSelSet::SelSetStatus stat = AecAcadSelSet::kNone; while (1) { // if supplied prompt, pass it on to selection set if (promptStr.IsEmpty() == FALSE) { AecRmCString tmpPrompt; tmpPrompt.Format(_DNT(_T("\n%s: ")), static_cast<LPCTSTR>(promptStr)); stat = m_ss.userSelect(tmpPrompt, NULL, filter); } // no prompt supplied, use regular ssget prompts else { stat = m_ss.userSelect(filter); } if (stat == AecAcadSelSet::kNone) { if (m_allowNone) break; else continue; } else break; } m_currentPromptObj = NULL; if (filter) ads_relrb(filter); if (stat != AecAcadSelSet::kSelected) { if (stat == AecAcadSelSet::kNone) return AecUiPrBase::kNone; else return AecUiPrBase::kCancel; } m_ss.asArray(m_selSet); if (m_selSet.isEmpty()) { AEC_ASSERT(0); // should have return kNone already return AecUiPrBase::kCancel; } else return AecUiPrBase::kOk; }
extern AFX_EXTENSION_MODULE [!output RDS_SYMB][!output SAFE_PROJECT_NAME]DLL ; HINSTANCE _hdllInstance =NULL ; //----------------------------------------------------------------------------- [!if APP_ARX_TYPE] ACRX_NO_CONS_DEFINE_MEMBERS(C[!output SAFE_PROJECT_NAME]App, AecAppArx) AEC_CLASS_DECORATOR(C[!output SAFE_PROJECT_NAME]App, AecAppArx, [!output RDS_SYMB][!output SAFE_PROJECT_NAME], -1, -1) [!else] ACRX_NO_CONS_DEFINE_MEMBERS(C[!output SAFE_PROJECT_NAME]App, AecAppDbx) AEC_CLASS_DECORATOR(C[!output SAFE_PROJECT_NAME]App, AecAppDbx, [!output RDS_SYMB][!output SAFE_PROJECT_NAME], -1, -1) [!endif] //----------------------------------------------------------------------------- C[!output SAFE_PROJECT_NAME]App::C[!output SAFE_PROJECT_NAME]App () [!if APP_ARX_TYPE] : AecAppArx (_DNT("[!output RDS_SYMB][!output SAFE_PROJECT_NAME]"), _hdllInstance, [!output RDS_SYMB][!output SAFE_PROJECT_NAME]DLL) { [!else] : AecAppDbx (_DNT("[!output RDS_SYMB][!output SAFE_PROJECT_NAME]"), _hdllInstance, [!output RDS_SYMB][!output SAFE_PROJECT_NAME]DLL) { [!endif] } //----------------------------------------------------------------------------- AcRx::AppRetCode C[!output SAFE_PROJECT_NAME]App::initApp () { [!if !NO_COM_SERVER] if ( FAILED(DllRegisterServer()) ) acutPrintf (_DNT("\nFailed to register.")) ; [!endif] acrxRegisterAppMDIAware (acadAppPtr ()) ; // TODO: add your initialization functions