+
+/*!
+ \brief Return \c true if object can be renamed
+*/
+bool VisuGUI::renameAllowed( const QString& entry) const {
+
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
+ SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
+
+ if(!app || !appStudy || !obj)
+ return false;
+
+ if(appStudy->isComponent(entry) || obj->isReference())
+ return false;
+
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( GetAppStudy(this), qPrintable(entry) );
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ if(aBase){
+ VISU::VISUType aType = aBase->GetType();
+ if( aType == VISU::TCOLOREDPRS3DHOLDER ) {
+ CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+ aType = aHolder->GetPrsType();
+ }
+ if (aType == VISU::TSCALARMAP || aType == VISU::TISOSURFACES ||
+ aType == VISU::TDEFORMEDSHAPE || aType == VISU::TCUTPLANES ||
+ aType == VISU::TCUTLINES || aType == VISU::TCUTSEGMENT || aType == VISU::TVECTORS ||
+ aType == VISU::TSTREAMLINES || aType == VISU::TPLOT3D ||
+ aType == VISU::TSCALARMAPONDEFORMEDSHAPE || aType == VISU::TCOLOREDPRS3DHOLDER ||
+ aType == VISU::TTABLE || aType == VISU::TCURVE || aType == VISU::TCONTAINER ||
+ aType == VISU::TPOINTMAP3D || aType == VISU::TVIEW3D ||
+ aType == VISU::TPOINTMAP3D || aType == VISU::TGAUSSPOINTS)
+ return true;
+ } else {
+ VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
+ bool anIsExist;
+ QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist);
+ return anIsExist && "VIEW3D" == aVal;
+ }
+ return false;
+}
+
+void VisuGUI::OnShowDeviation() {
+
+ if(IsStudyLocked(GetCStudy(GetAppStudy(this))))
+ return;
+
+ QAction* anAction = action(VISU_SHOW_DEVIATION);
+ if(!anAction)
+ return;
+
+ bool anIsShow = anAction->isChecked();
+
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ TSelectionInfo::iterator anIter = aSelectionInfo.begin();
+ for( ; anIter != aSelectionInfo.end(); anIter++ )
+ {
+ VISU::TSelectionItem aSelectionItem = *anIter;
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(aBase && aBase->GetType() == VISU::TCURVE) {
+ // Curve object
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase)) {
+ aCurve->ShowDeviation(anIsShow);
+ if( displayer()->IsDisplayed( anIO->getEntry() ) )
+ PlotCurve(this, aCurve, VISU::eDisplay);
+ }
+ }
+ }
+}
+
+/*!
+ Rename object by entry.
+ \param entry entry of the object
+ \param name new name of the object
+ \brief Return \c true if rename operation finished successfully, \c false otherwise.
+*/
+bool VisuGUI::renameObject( const QString& entry, const QString& name) {
+
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
+ SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
+
+ if(!appStudy)
+ return false;
+
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ if(!aStudy)
+ return false;
+
+ bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
+ if ( aLocked ) {
+ SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
+ return false;
+ }
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this) , qPrintable(entry) );
+
+ _PTR(SObject) aSObject = anObjectInfo.mySObject;
+ if (aSObject) {
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
+ if(aBase){
+ VISU::VISUType aType = aBase->GetType();
+ if( aType == VISU::TCOLOREDPRS3DHOLDER ) {
+ CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+ aType = aHolder->GetPrsType();
+ }
+ if (aType == VISU::TSCALARMAP || aType == VISU::TISOSURFACES ||
+ aType == VISU::TDEFORMEDSHAPE || aType == VISU::TCUTPLANES ||
+ aType == VISU::TCUTLINES || aType == VISU::TCUTSEGMENT || aType == VISU::TVECTORS ||
+ aType == VISU::TSTREAMLINES || aType == VISU::TPLOT3D ||
+ aType == VISU::TSCALARMAPONDEFORMEDSHAPE || aType == VISU::TCOLOREDPRS3DHOLDER ||
+ aType == VISU::TTABLE || aType == VISU::TCURVE || aType == VISU::TCONTAINER ||
+ aType == VISU::TPOINTMAP3D || aType == VISU::TVIEW3D ||
+ aType == VISU::TPOINTMAP3D || aType == VISU::TGAUSSPOINTS) {
+ _PTR(GenericAttribute) anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributeName")) {
+ _PTR(AttributeName) aName (anAttr);
+ if (!name.isEmpty()) {
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ // rename specific objects
+ if (VISU::Base_i* aBase = anObjectInfo.myBase) {
+ switch (aBase->GetType()) {
+ case VISU::TCURVE: { // Curve object
+ if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
+ aCurve->SetName(qPrintable(name), true);
+ break;
+ }
+ case VISU::TTABLE: { // Table object
+ if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+ aTable->SetName(qPrintable(name), true);
+ break;
+ }
+ case VISU::TPOINTMAP3D: { // Table object
+ if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
+ aTable3d->SetTitle(qPrintable(name));
+ aTable3d->UpdateActors();
+ }
+ break;
+ }
+ case VISU::TCONTAINER: { // Container object
+ if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
+ aContainer->SetName(qPrintable(name), true);
+ break;
+ }
+ default: {
+ }}
+ }
+
+ // rename the study object
+ aName->SetValue( qPrintable(name) ); // rename the SObject
+
+ ViewManagerList aViewManagerList;
+ getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
+ SUIT_ViewManager* aViewManager;
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject ( qPrintable(entry), "VISU", qPrintable(name) );
+ foreach( aViewManager, aViewManagerList ) {
+ if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
+ if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
+ aViewer->renameAll( anIO, qPrintable(name) );
+ }
+ }
+ QApplication::restoreOverrideCursor();
+ return true;
+ }
+ }
+ //Rename visual params
+ }
+ } else {
+ bool anIsExist;
+ QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist);
+ if(anIsExist && "VIEW3D" == aVal) {
+ _PTR(GenericAttribute) anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributeName")) {
+ _PTR(AttributeName) aName (anAttr);
+ if (!name.isEmpty()) {
+ aName->SetValue(qPrintable(name));
+ }
+ }
+ }
+ }
+ }
+ return false;
+}