//---------------------------------------------------------------------------------------- // HandleTreeSelectionChange //---------------------------------------------------------------------------------------- void CZPAssetsPanelObserver::HandleTreeSelectionChange( const ClassID& theChange, ISubject* theSubject, const PMIID & protocol, void* changedBy) { do { IControlView * nodeControlView = reinterpret_cast<IControlView*>(changedBy); if( !nodeControlView ) break; ClassID theWidgetClass = ::GetClass( nodeControlView ); if( theWidgetClass != kZPAssetsTVAssetNodeWidgetBoss ) break; InterfacePtr<const IZPUITVNodeData> nodeData( nodeControlView, UseDefaultIID()); ASSERT(nodeData); const IStringData * assetID = static_cast<const IStringData *>(nodeData->GetDataObj()); this->UpdatePreview( assetID ); return; }while(kFalse); //Clear the preview this->ClearPreview(); }
//---------------------------------------------------------------------------------------- // Refresh //---------------------------------------------------------------------------------------- void CZPTasksTVNodeWidgetMgr::Refresh()const { InterfacePtr<const IZPUITVNodeData> nodeData(this, UseDefaultIID()); ASSERT(nodeData); const IPMUnknown * taskID = nodeData->GetDataObj(); if( !taskID ) return; InterfacePtr<const IZPTaskInfo> taskInfo( taskID, UseDefaultIID() ); ASSERT( taskInfo ); InterfacePtr<const IPanelControlData> selfPanelCtrlData( this, UseDefaultIID() ); ASSERT( selfPanelCtrlData ); const WidgetID & widgetStartID = kZPUITasksTVNodeSubjectWidgetID; //First column widget ID //Update each column text int currControlCount = selfPanelCtrlData->Length(); int i = 0; enTVColTasks currColID = eTVColTasks_Subject; WidgetID currWidgetID; IControlView * columnWidgetView = nil; PMString currColText; for( ; i < currControlCount ; ++i ) { columnWidgetView = selfPanelCtrlData->GetWidget( i ); currWidgetID = columnWidgetView->GetWidgetID(); currColID = (enTVColTasks)(currWidgetID - widgetStartID); ASSERT( currColID >= eTVColTasks_Subject && currColID < eTVColTasksCount ); currColText = this->GetColumnText( taskID, taskInfo, currColID ); this->SetColumnText( currWidgetID, currColText ); } }
//---------------------------------------------------------------------------------------- // RenameAsset //---------------------------------------------------------------------------------------- void CZPAssetsTVActionComponent::RenameAsset( IPMUnknown* assetNodeWidget) { do { IDialog* theDialog = Utils<IZPUIDialogFacade>()->CreateDialogRenameAsset(false); ASSERT(theDialog); IControlView* dialogPanel = theDialog->GetDialogPanel(); ASSERT(dialogPanel); InterfacePtr<const IZPUITVNodeData> nodeData(assetNodeWidget, UseDefaultIID()); ASSERT(nodeData); const IStringData * dbAssetID = (IStringData *)nodeData->GetDataObj(); InterfacePtr<IStringData> dbAssetName( dbAssetID, IID_IZPDATANAME ); ASSERT( dbAssetName ); const PMString & oldAssetName = dbAssetName->Get(); InterfacePtr<IStringData> dlgAssetID( dialogPanel, IID_IZPDATAID ); ASSERT( dlgAssetID ); dlgAssetID->Set(dbAssetID->Get()); InterfacePtr<IStringData> dlgAssetName( dialogPanel, IID_IZPDATANAME ); ASSERT( dlgAssetName ); dlgAssetName->Set(oldAssetName); InterfacePtr<IBoolData> dlgResultBoolData( dialogPanel, UseDefaultIID() ); ASSERT( dlgResultBoolData ); dlgResultBoolData->Set( kFalse ); // Open the dialog. theDialog->Open(); theDialog->WaitForDialog(); //Get the dialog result InterfacePtr<IBoolData> dialogResult( dialogPanel, UseDefaultIID() ); ASSERT( dialogResult ); if (!dialogResult->Get()) break; const PMString & newAssetName = dlgAssetName->Get(); if (oldAssetName.Compare(kTrue, newAssetName) == 0) //If both are equal then don't do anything break; Utils<IZPAMWSUtils>()->UpdateAssetName_sync( dbAssetID->Get(), newAssetName ); //TODO: if renamed failed, then should we show the dialog again? }while(kFalse); }
//---------------------------------------------------------------------------------------- // CanRenameAsset //---------------------------------------------------------------------------------------- bool CZPAssetsTVActionComponent::CanRenameAsset( IPMUnknown* assetNodeWidget) { bool toReturn = false; do { InterfacePtr<const IZPUITVNodeData> nodeData(assetNodeWidget, UseDefaultIID()); ASSERT(nodeData); const IStringData * dbAssetID = (IStringData *)nodeData->GetDataObj(); InterfacePtr<const IZPAssetLockInfo> assetLockInfo( dbAssetID, UseDefaultIID()); if (assetLockInfo && (assetLockInfo->GetLockState() == IAMLockable::enAvailable || assetLockInfo->GetLockState() == IAMLockable::enCheckedOut)) toReturn = true; }while(kFalse); return toReturn; }
int LoadPattern::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { // get my current database tag // NOTE - dbTag equals 0 if not sending to a database OR has not yet been sent int myDbTag = this->getDbTag(); // into an ID we place all info needed to determine state of LoadPattern int numNod, numEle, numSPs; ID lpData(11); if (theChannel.recvID(myDbTag, cTag, lpData) < 0) { opserr << "LoadPattern::recvSelf - channel failed to recv the initial ID\n"; return -1; } isConstant = lpData(7); this->setTag(lpData(10)); if (isConstant == 0) { // we must recv the load factor in a Vector Vector data(2); if (theChannel.recvVector(myDbTag, cTag, data) < 0) { opserr << "LoadPattern::recvSelf - channel failed to recv the Vector\n"; return -2; } loadFactor = data(0); scaleFactor = data(1); } // read data about the time series if (lpData(8) != -1) { if (theSeries == 0) { theSeries = theBroker.getNewTimeSeries(lpData(8)); } else if (theSeries->getClassTag() != lpData(8)) { delete theSeries; theSeries = theBroker.getNewTimeSeries(lpData(8)); } if (theSeries == 0) { opserr << "LoadPattern::recvSelf - failed to create TimeSeries\n"; return -3; } theSeries->setDbTag(lpData(9)); if (theSeries->recvSelf(cTag, theChannel, theBroker) < 0) { opserr << "LoadPattern::recvSelf - the TimeSeries failed to recv\n"; return -3; } } /* if (theChannel.isDatastore() == 1) { static ID theLastSendTag(1); if (theChannel.recvID(myDbTag,0,theLastSendTag) == 0) lastGeoSendTag = theLastSendTag(0); } */ if (lastChannel != theChannel.getTag() || currentGeoTag != lpData(0) || theChannel.isDatastore() == 0) { // clear out the all the components in the current load pattern this->clearAll(); lastChannel = theChannel.getTag(); currentGeoTag = lpData(0); numNod = lpData(1); numEle = lpData(2); numSPs = lpData(3); dbNod = lpData(4); dbEle = lpData(5); dbSPs = lpData(6); // // now we rebuild the nodal loads // // first get the information from the domainData about the nodes if (numNod != 0) { ID nodeData(2*numNod); // now receive the ID about the nodes, class tag and dbTags if (theChannel.recvID(dbNod, currentGeoTag, nodeData) < 0) { opserr << "LoadPAttern::recvSelf - channel failed to recv the NodalLoad ID\n"; return -2; } // now for each NodalLoad we 1) get a new node of the correct type from the ObjectBroker // 2) ensure the node exists and set it's dbTag, 3) we invoke recvSelf on this new // blank node and 4) add this node to the domain int loc = 0; for (int i=0; i<numNod; i++) { int classTag = nodeData(loc); int dbTag = nodeData(loc+1); NodalLoad *theNode = theBroker.getNewNodalLoad(classTag); if (theNode == 0) { opserr << "LoadPattern::recv - cannot create NodalLoad with classTag " << classTag << endln; return -2; } theNode->setDbTag(dbTag); if (theNode->recvSelf(cTag, theChannel, theBroker) < 0) { opserr << "LoadPattern::recvSelf - NodalLoad with dbTag " << dbTag << " failed in recvSelf\n"; return -2; } if (this->addNodalLoad(theNode) == false) { opserr << "LoadPattern::recvSelf - failed adding NodalLoad tagged " << theNode->getTag() << " into LP!\n"; return -3; } loc+=2; } } // // now we rebuild the ElementalLoads .. same as NodalLoads above .. see comments above // if (numEle != 0) { ID eleData(2*numEle); if (theChannel.recvID(dbEle, currentGeoTag, eleData) < 0) { opserr << "LoadPattern::recvSelf - channel failed to recv the EleLoad ID\n"; return -2; } int loc = 0; for (int i=0; i<numEle; i++) { int classTag = eleData(loc); int dbTag = eleData(loc+1); ElementalLoad *theEle = theBroker.getNewElementalLoad(classTag); if (theEle == 0) { opserr << "LoadPattern::recv - cannot create ElementalLoad with classTag " << classTag << endln; return -2; } theEle->setDbTag(dbTag); if (theEle->recvSelf(cTag, theChannel, theBroker) < 0) { opserr << "LoadPattern::recvSelf - Ele with dbTag " << dbTag << " failed in recvSelf\n"; return -2; } if (this->addElementalLoad(theEle) == false) { opserr << "LoadPattern::recvSelf - could not add Ele with tag " << theEle->getTag() << " into LP!\n"; return -3; } loc+=2; } } // // now we rebuild the SP_Constraints .. same as nodes above .. see above if can't understand!! // if (numSPs != 0) { ID spData(2*numSPs); if (theChannel.recvID(dbSPs, currentGeoTag, spData) < 0) { opserr << "LoadPattern::recvSelf - channel failed to recv the SP_Constraints ID\n"; return -2; } int loc = 0; for (int i=0; i<numSPs; i++) { int classTag = spData(loc); int dbTag = spData(loc+1); SP_Constraint *theSP = theBroker.getNewSP(classTag); if (theSP == 0) { opserr << "LoadPattern::recv - cannot create SP_Constraint with classTag " << classTag << endln; return -2; } theSP->setDbTag(dbTag); if (theSP->recvSelf(cTag, theChannel, theBroker) < 0) { opserr << "LoadPattern::recvSelf - SP_Constraint with dbTag " << dbTag << " failed in recvSelf\n"; return -2; } if (this->addSP_Constraint(theSP) == false) { opserr << "LoadPattern::recvSelf - could not add SP_Constraint with tag " << theSP->getTag() << " into LP!\n"; return -3; } loc+=2; } } // now set the load pattern db count currentGeoTag = lpData(0); lastGeoSendTag = currentGeoTag; } else { if (theSeries != 0) if (theSeries->recvSelf(cTag, theChannel, theBroker) < 0) { opserr << "LoadPattern::recvSelf - the TimeSeries failed to recv\n"; return -3; } NodalLoad *theNode; NodalLoadIter &theNodes = this->getNodalLoads(); while ((theNode = theNodes()) != 0) { if (theNode->recvSelf(cTag, theChannel, theBroker) < 0) { opserr << "LoadPattern::recvSelf - node with tag " << theNode->getTag() << " failed in recvSelf\n"; return -7; } } ElementalLoad *theEle; ElementalLoadIter &theElements = this->getElementalLoads(); while ((theEle = theElements()) != 0) { if (theEle->recvSelf(cTag, theChannel, theBroker) < 0) { opserr << "LoadPattern::recvSelf - element with tag " << theEle->getTag() << " failed in recvSelf\n"; return -8; } } SP_Constraint *theSP; SP_ConstraintIter &theSPs = this->getSPs(); while ((theSP = theSPs()) != 0) { if (theSP->recvSelf(cTag, theChannel, theBroker) < 0) { opserr << "LoadPattern::recvSelf - SP_Constraint tagged " << theSP->getTag() << " failed recvSelf\n"; return -9; } } } // if we get here we are successfull return 0; }
int LoadPattern::sendSelf(int cTag, Channel &theChannel) { // get my current database tag // NOTE - dbTag equals 0 if not sending to a database OR has not yet been sent int myDbTag = this->getDbTag(); // into an ID we place all info needed to determine state of LoadPattern int numNodLd, numEleLd, numSPs; ID lpData(11); numNodLd = theNodalLoads->getNumComponents(); numEleLd = theElementalLoads->getNumComponents(); numSPs = theSPs->getNumComponents(); lpData(10) = this->getTag(); lpData(0) = currentGeoTag; lpData(1) = numNodLd; lpData(2) = numEleLd; lpData(3) = numSPs; if (dbNod == 0) { dbNod = theChannel.getDbTag(); dbEle = theChannel.getDbTag(); dbSPs = theChannel.getDbTag(); } lpData(4) = dbNod; lpData(5) = dbEle; lpData(6) = dbSPs; lpData(7) = isConstant; if (theSeries != 0) { int dbtag = theSeries->getDbTag(); int classtag = theSeries->getClassTag(); if (dbtag == 0) { dbtag = theChannel.getDbTag(); theSeries->setDbTag(dbtag); } lpData(8) = classtag; lpData(9) = dbtag; } else lpData(8) = -1; // see if we can save sending the vector containing just the load factor // will happen in parallel if sending the loadPattern .. not in database if (theChannel.sendID(myDbTag, cTag, lpData) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the initial ID\n"; return -1; } if (isConstant == 0) { Vector data(2); data(0) = loadFactor; data(1) = scaleFactor; if (theChannel.sendVector(myDbTag, cTag, data) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the Vector\n"; return -2; } } if (theSeries != 0) if (theSeries->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - the TimeSeries failed to send\n"; return -3; } // now check if data defining the objects in the LoadPAttern needs to be sent // NOTE THIS APPROACH MAY NEED TO CHANGE FOR VERY LARGE PROBLEMS IF CHANNEL CANNOT // HANDLE VERY LARGE ID OBJECTS. /* if (theChannel.isDatastore() == 1) { static ID theLastSendTag(1); if (theChannel.recvID(myDbTag,0,theLastSendTag) == 0) lastGeoSendTag = theLastSendTag(0); else lastGeoSendTag = -1; } */ if (lastChannel != theChannel.getTag() || lastGeoSendTag != currentGeoTag || theChannel.isDatastore() == 0) { lastChannel = theChannel.getTag(); // // into an ID we are gonna place the class and db tags for each node so can rebuild // this ID we then send to the channel // // create the ID and get the node iter if (numNodLd != 0) { ID nodeData(numNodLd*2); NodalLoad *theNode; NodalLoadIter &theNodes = this->getNodalLoads(); int loc =0; // loop over nodes in domain adding their classTag and dbTag to the ID while ((theNode = theNodes()) != 0) { nodeData(loc) = theNode->getClassTag(); int dbTag = theNode->getDbTag(); // if dbTag still 0 get one from Channel; // if this tag != 0 set the dbTag in node if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theNode->setDbTag(dbTag); } nodeData(loc+1) = dbTag; loc+=2; } // now send the ID if (theChannel.sendID(dbNod, currentGeoTag, nodeData) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the NodalLoads ID\n"; return -4; } } // we do the same for elemental loads as we did for nodal loads above .. see comments above! if (numEleLd != 0) { ID elementData(numEleLd*2); ElementalLoad *theEle; ElementalLoadIter &theElements = this->getElementalLoads(); int loc = 0; while ((theEle = theElements()) != 0) { elementData(loc) = theEle->getClassTag(); int dbTag = theEle->getDbTag(); if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theEle->setDbTag(dbTag); } elementData(loc+1) = dbTag; loc+=2; } // now send the ID if (theChannel.sendID(dbEle, currentGeoTag, elementData) < 0) { opserr << "Domain::send - channel failed to send the element ID\n"; return -5; } } // we do the same for SP_Constraints as for NodalLoads above .. see comments above! if (numSPs != 0) { ID spData(numSPs*2); SP_Constraint *theSP; SP_ConstraintIter &theSPs = this->getSPs(); int loc = 0; while ((theSP = theSPs()) != 0) { spData(loc) = theSP->getClassTag(); int dbTag = theSP->getDbTag(); if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theSP->setDbTag(dbTag); } spData(loc+1) = dbTag; loc+=2; } if (theChannel.sendID(dbSPs, currentGeoTag, spData) < 0) { opserr << "LoadPAttern::sendSelf - channel failed sending SP_Constraint ID\n"; return -6; } } // set the lst send db tag so we don't have to do all that again lastGeoSendTag = currentGeoTag; if (theChannel.isDatastore() == 1) { static ID theLastSendTag(1); theLastSendTag(0) = lastGeoSendTag; theChannel.sendID(myDbTag,0, theLastSendTag); } } // now we invoke sendSelf on all the NodalLoads, ElementalLoads and SP_Constraints // which have been added to the LoadCase NodalLoad *theNode; NodalLoadIter &theNodes = this->getNodalLoads(); while ((theNode = theNodes()) != 0) { if (theNode->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - node with tag " << theNode->getTag() << " failed in sendSelf\n"; return -7; } } ElementalLoad *theEle; ElementalLoadIter &theElements = this->getElementalLoads(); while ((theEle = theElements()) != 0) { if (theEle->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - element with tag " << theEle->getTag() << " failed in sendSelf\n"; return -8; } } SP_Constraint *theSP; SP_ConstraintIter &theSPs = this->getSPs(); while ((theSP = theSPs()) != 0) { if (theSP->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - SP_Constraint: " << *theSP << " failed sendSelf\n"; return -9; } } // if we get here we are successfull return 0; }
void CVtkTableAlgorithm::setVtkObject(vtkObject* ptr) { d->tableAlgorithm = dynamic_cast<vtkTableAlgorithm*>(ptr); nodeData()["vtkObject"] = qVariantFromValue<vtkObject*>(d->tableAlgorithm); }