// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
int i = 0, nbSelected = aList.Extent();
if (nbSelected < 1) return;
- std::vector<std::string> anEntries(nbSelected);
+ std::vector<std::string> anEntries (nbSelected);
Handle(SALOME_InteractiveObject) anIO;
for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
anIO = it.Value();
- if (anIO->hasEntry())
- anEntries[i++] = anIO->getEntry();
+ if (anIO->hasEntry()) {
+ if (IsRemovable(anIO->getEntry(), this))
+ anEntries[i++] = anIO->getEntry();
+ }
}
nbSelected = i;
- if (nbSelected < 1) return;
+ if (nbSelected < 1) {
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ QObject::tr("WRN_VISU"),
+ QObject::tr("WRN_NO_APPROPRIATE_SELECTION"),
+ QObject::tr("BUT_OK"));
+ }
// There is a transaction
_PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
}
}
}
- }else{
+ }
+ else{
DeleteSObject(this, aCStudy, aSObject);
UpdateObjBrowser(this, true, aSObject);
}
return;
VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
- if(aSelectionInfo.empty())
- return;
-
- VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
- _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
- if(!aSObject)
+ if (aSelectionInfo.empty())
return;
- //TEST DU PARENT == VISU
- _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
- _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObject, "AttributeName");
- if (anAttr) {
- _PTR(AttributeName) aName (anAttr);
- QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
- if (!Name.isEmpty()) {
- QApplication::setOverrideCursor(Qt::waitCursor);
+ VisuGUI_Selection aSel (this);
+ aSel.init("", getApp()->selectionMgr());
+ if (aSel.count() < 1) return;
- // rename specific objects
- if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
- switch(aBase->GetType()){
- case VISU::TCURVE: { // Curve object
- if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
- aCurve->SetName(Name.latin1(), true);
- break;
- }
- case VISU::TTABLE: { // Table object
- if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
- aTable->SetName(Name.latin1(), true);
- break;
- }
- case VISU::TPOINTMAP3D: { // Table object
- if(VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
- aTable3d->SetTitle(Name);
- aTable3d->UpdateActors();
- }
- break;
- }
- case VISU::TCONTAINER: { // Container object
- if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
- aContainer->SetName(Name.latin1(), true);
- break;
- }
- default: {
- }}
- }
- }
+ bool isAny = false; // is there any appropriate object selected
+ for (int i = 0; i < aSelectionInfo.size(); i++) {
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
+ VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
- if (!Name.isEmpty()) {
- // rename the study object
- Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
- aName->SetValue(Name.latin1()); // rename the SObject
- anIO->setName(Name.latin1()); // rename the InteractiveObject
-
- ViewManagerList aViewManagerList;
- getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
- SUIT_ViewManager* aViewManager = aViewManagerList.first();
- for(; aViewManager; aViewManager = aViewManagerList.next()){
- if(Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)){
- if(SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
- aViewer->renameAll( anIO, Name.latin1() );
- }
- }
+ _PTR(SObject) aSObject = anObjectInfo.mySObject;
+ if (!aSObject)
+ continue;
- UpdateObjBrowser(this, false);
+ // Check, if the selected object can be renamed
+ QString aStr = aSel.param(i, "type" ).toString();
+ if (aStr == "VISU::TSCALARMAP" || aStr == "VISU::TISOSURFACES" ||
+ aStr == "VISU::TDEFORMEDSHAPE" || aStr == "VISU::TCUTPLANES" ||
+ aStr == "VISU::TCUTLINES" || aStr == "VISU::TVECTORS" ||
+ aStr == "VISU::TSTREAMLINES" || aStr == "VISU::TPLOT3D" ||
+ aStr == "VISU::TSCALARMAPONDEFORMEDSHAPE" || aStr == "VISU::TCOLOREDPRS3DHOLDER" ||
+ aStr == "VISU::TTABLE" || aStr == "VISU::TCURVE" || aStr == "VISU::TCONTAINER" ||
+ aStr == "VISU::POINTMAP3D" || aStr == "VISU::TVIEW3D" ||
+ aStr == "VISU::TMESH" || aStr == "VISU::TPOINTMAP3D")
+ {
+ _PTR(GenericAttribute) anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributeName")) {
+ isAny = true;
+ _PTR(AttributeName) aName (anAttr);
+ QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
+ 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(Name.latin1(), true);
+ break;
+ }
+ case VISU::TTABLE: { // Table object
+ if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+ aTable->SetName(Name.latin1(), true);
+ break;
+ }
+ case VISU::TPOINTMAP3D: { // Table object
+ if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
+ aTable3d->SetTitle(Name);
+ aTable3d->UpdateActors();
+ }
+ break;
+ }
+ case VISU::TCONTAINER: { // Container object
+ if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
+ aContainer->SetName(Name.latin1(), true);
+ break;
+ }
+ default: {
+ }}
+ }
+
+ // rename the study object
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ aName->SetValue(Name.latin1()); // rename the SObject
+ anIO->setName(Name.latin1()); // rename the InteractiveObject
+
+ ViewManagerList aViewManagerList;
+ getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
+ SUIT_ViewManager* aViewManager = aViewManagerList.first();
+ for (; aViewManager; aViewManager = aViewManagerList.next()) {
+ if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
+ if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
+ aViewer->renameAll( anIO, Name.latin1() );
+ }
+ }
+
+ UpdateObjBrowser(this, false);
+
+ QApplication::restoreOverrideCursor();
+ }
+ }
}
+ } // for
- QApplication::restoreOverrideCursor();
+ if (!isAny) {
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ QObject::tr("WRN_VISU"),
+ QObject::tr("WRN_NO_APPROPRIATE_SELECTION"),
+ QObject::tr("BUT_OK"));
}
}
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
// Create actions
- //createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
- // tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
- // this, SLOT(OnImportFromFile()));
aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_IMPORT_MED"));
createAction( VISU_IMPORT_FROM_FILE, tr("IMPORT_FROM_FILE"), QIconSet(aPixmap),
// Reset actions accelerator keys
action(VISU_IMPORT_FROM_FILE)->setAccel(QKeySequence(CTRL + Key_I));
+ action(VISU_DELETE_OBJS)->setEnabled(true); // Delete: Key_Delete
+ action(VISU_RENAME )->setEnabled(true); // Rename: Key_F2
+
return true;
}
setToolShown( false );
// Unset actions accelerator keys
- action(VISU_IMPORT_FROM_FILE)->setAccel(QKeySequence());
+ action(VISU_IMPORT_FROM_FILE)->setAccel(QKeySequence()); // Import: CTRL + Key_I
+
+ action(VISU_DELETE_OBJS)->setEnabled(false); // Delete: Key_Delete
+ action(VISU_RENAME )->setEnabled(false); // Rename: Key_F2
SalomeApp_Module::deactivateModule( theStudy );
return true;
theSelectionMgr->setSelectedObjects(aNewListIO);
}
+ /*!
+ * \brief Check, if the object can be deleted
+ *
+ * \param theEntry - entry of the object to check
+ * \param theModule - is used to access Study and VISU_Gen
+ * \retval bool - returns TRUE if the object is removable
+ */
+ bool
+ IsRemovable (const std::string theEntry,
+ const SalomeApp_Module* theModule)
+ {
+ // asv : if selected object is a Save Point object selected in object browser - return false
+ if ( QString( theEntry.c_str() ).startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) )
+ return false;
+
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
+
+ _PTR(SObject) aSObject = aStudy->FindObjectID(theEntry);
+ VISU::Storable::TRestoringMap pMap;
+ if (aSObject) {
+ CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
+ if (!CORBA::is_nil(aCORBAObject)) {
+ VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject);
+ if (CORBA::is_nil(aRemovableObj)) {
+ // Not removable CORBA object
+ return false;
+ }
+ } else {
+ // Can be removed, if lays directly under VISU
+ // (first sub-level) or is a child of such an object
+ string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType();
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeString) aComment;
+
+ bool isUnderVISU = false;
+ _PTR(SObject) aFatherSObject = aSObject->GetFather();
+ if (aFatherSObject->FindAttribute(anAttr, "AttributeName")) {
+ // mkr : 24.11.2006 : use AttributeName and module title for correct "Delete"
+ // popup item displaying in object browser popup
+ _PTR(AttributeName) aComment (anAttr);
+ aNAME = aComment->Value();
+ QString aVisuTITLE = theModule->getApp()->moduleTitle(QString(aVisuNAME));
+ if (!aVisuTITLE.compare(QString(aNAME))) {
+ isUnderVISU = true;
+ }
+ }
+ if (!isUnderVISU) {
+ // Not directly under VISU component, check father
+ aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject);
+ if (!CORBA::is_nil(aCORBAObject)) {
+ // Father has IOR
+ return false;
+ }
+
+ isUnderVISU = false;
+ aFatherSObject = aFatherSObject->GetFather();
+ if (aFatherSObject->FindAttribute(anAttr, "AttributeString")) {
+ _PTR(AttributeString) aComment (anAttr);
+ aNAME = aComment->Value();
+ if (aNAME == aVisuNAME) {
+ isUnderVISU = true;
+ }
+ }
+ if (!isUnderVISU) {
+ // Father is not directly under VISU component
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
/*!
* \brief Check, if "Delete" popup-menu can be put on current selection
*
for (; anIter.More(); anIter.Next()) {
Handle(SALOME_InteractiveObject) anIO = anIter.Value();
if (anIO->hasEntry()) {
-
- // asv : if selected object is a Save Point object selected in object browser - return false
- if ( QString( anIO->getEntry() ).startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) )
- return false;
-
- _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
- VISU::Storable::TRestoringMap pMap;
- if (aSObject) {
- CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
- if (!CORBA::is_nil(aCORBAObject)) {
- VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject);
- if (CORBA::is_nil(aRemovableObj)) {
- // Not removable CORBA object
- return false;
- }
- } else {
- // Can be removed, if lays directly under VISU
- // (first sub-level) or is a child of such an object
- string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType();
- _PTR(GenericAttribute) anAttr;
- _PTR(AttributeString) aComment;
-
- bool isUnderVISU = false;
- _PTR(SObject) aFatherSObject = aSObject->GetFather();
- if (aFatherSObject->FindAttribute(anAttr, "AttributeName")) {
- // mkr : 24.11.2006 : use AttributeName and module title for correct "Delete"
- // popup item displaying in object browser popup
- _PTR(AttributeName) aComment (anAttr);
- aNAME = aComment->Value();
- QString aVisuTITLE = theModule->getApp()->moduleTitle(QString(aVisuNAME));
- if (!aVisuTITLE.compare(QString(aNAME))) {
- isUnderVISU = true;
- }
- }
- if (!isUnderVISU) {
- // Not directly under VISU component, check father
- aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject);
- if (!CORBA::is_nil(aCORBAObject)) {
- // Father has IOR
- return false;
- }
-
- isUnderVISU = false;
- aFatherSObject = aFatherSObject->GetFather();
- if (aFatherSObject->FindAttribute(anAttr, "AttributeString")) {
- _PTR(AttributeString) aComment (anAttr);
- aNAME = aComment->Value();
- if (aNAME == aVisuNAME) {
- isUnderVISU = true;
- }
- }
- if (!isUnderVISU) {
- // Father is not directly under VISU component
- return false;
- }
- }
- }
- }
+ if (!IsRemovable(anIO->getEntry(), theModule))
+ return false;
}
}
return true;