Salome HOME
IPAL9285,9292,9314
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
index 39ae63851a971090ed6eb29e361a0957261c6a96..ced02edf286d7ad476290cd8de1e3e8be76be6a1 100644 (file)
@@ -425,7 +425,7 @@ CreatePrs3d(SalomeApp_Module* theModule,
     SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
     int aValue = aResourceMgr->integerValue("Visu:BuildDefaultPrs3d",0);
     if(!aValue){
-      if(TDlg* aDlg = new TDlg(GetDesktop(theModule))){ // dialog box in creation mode
+      if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
        aDlg->initFromPrsObject(aPrs3d);
        if(IsDlgModal)
          if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
@@ -678,7 +678,7 @@ EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
   TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
   if (aPrsObject) {
     //TDlg* aDlg = new TDlg (GetDesktop(theModule), false, true);
-    TDlg* aDlg = new TDlg (GetDesktop(theModule));
+    TDlg* aDlg = new TDlg (theModule);
     aDlg->initFromPrsObject(aPrsObject);
     if (aDlg->exec()) {
       if (!(aDlg->storeToPrsObject(aPrsObject))) {
@@ -775,40 +775,6 @@ OnEditPrs()
     vw->highlight(anIO, 1);
 }
 
-void
-VisuGUI::
-OnDeletePrs()
-{
-  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-  if (CheckLock(aCStudy))
-    return;
-  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
-
-  Handle(SALOME_InteractiveObject) anIO;
-  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
-  if (anIO.IsNull())
-    return;
-
-  // There is a transaction
-  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-  aStudyBuilder->NewCommand();
-
-  // is it Prs3d object ?
-  VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
-  if (aPrsObject) {
-    DeletePrs3d(this, aPrsObject, anIO);
-  }
-
-  // is it Curve object ?
-  VISU::Curve_i* aCurveObject = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
-  if (aCurveObject) {
-    //jfa tmp:DeleteCurve(this, aCurveObject, anIO);
-  }
-
-  aStudyBuilder->CommitCommand();
-}
-
-
 void
 VisuGUI::
 OnEraseAll()
@@ -1111,75 +1077,6 @@ OnCreateTable()
   }
 }
 
-void
-VisuGUI::
-OnDeleteObject()
-{
-  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-  if (CheckLock(aCStudy))
-    return;
-  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
-
-  Handle(SALOME_InteractiveObject) anIO;
-  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
-  if (anIO.IsNull() || !anIO->hasEntry())
-    return;
-
-  SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
-  if (!aSObject->_is_nil()) {
-    SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
-    for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
-      SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
-      CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
-      ErasePrs(this, aChildObj);
-    }
-    SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-    // There is a transaction
-    aStudyBuilder->NewCommand();
-    CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
-    if (!CORBA::is_nil(anObj)) {
-      VISU::Base_var aBase = VISU::Base::_narrow(anObj);
-      if (!CORBA::is_nil(aBase)) {
-        VISU::VISUType aType = aBase->GetType();
-        switch (aType) {
-        case VISU::TRESULT:
-          {
-            SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
-           for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
-              SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
-              CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
-              if (CORBA::is_nil(aChildObj)) continue;
-              VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
-              if (CORBA::is_nil(aPrs3d)) continue;
-              VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
-              DeletePrs3d(this, pPrs3d, NULL);
-           }
-           break;
-         }
-        case VISU::TTABLE:
-          {
-            SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
-           for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
-              SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
-              CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
-              if (CORBA::is_nil(aChildObj)) continue;
-              CORBA::Object_ptr aCurve = VISU::Curve::_narrow(aChildObj);
-              if (CORBA::is_nil(aCurve)) continue;
-              //VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
-              //jfa tmp:DeleteCurve(this, pCurve, NULL);
-            }
-            break;
-          }
-        }
-      }
-    }
-    aStudyBuilder->RemoveObjectWithChildren(aSObject);
-    aStudyBuilder->CommitCommand();
-    //jfa tmp:GetActiveStudy()->unHighlightAll();
-    updateObjBrowser(true);
-  }
-}
-
 void
 VisuGUI::
 OnDeleteObjects()
@@ -1519,38 +1416,6 @@ OnRestoreViewParams()
   VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
 }
 
-void
-VisuGUI::
-OnDeleteViewParams()
-{
-  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-  if (CheckLock(aCStudy))
-    return;
-  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
-
-  Handle(SALOME_InteractiveObject) anIO;
-  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
-  _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
-  if (!aSObject) return;
-
-  VISU::VISUType aType = (VISU::VISUType)getValue(aSObject, "myType").toInt();
-  if (aType == VISU::TVIEW3D) {
-    SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
-    SALOME_ListIO aListIO, aNewListIO;
-    aSelectionMgr->selectedObjects(aListIO);
-    for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
-      if (it.Value()->getEntry() != anIO->getEntry()) {
-        aNewListIO.Append(it.Value());
-      }
-    }
-    aSelectionMgr->setSelectedObjects(aNewListIO);
-
-    aCStudy->NewBuilder()->RemoveObject(aSObject);
-
-    updateObjBrowser();
-  }
-}
-
 void
 VisuGUI::
 OnRename()
@@ -1860,7 +1725,13 @@ void
 VisuGUI::
 OnSelectionInfo()
 {
-  (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
+  if (GetViewWindow())
+    (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
+  else
+    SUIT_MessageBox::warn1(GetDesktop(this),
+                           tr("WRN_VISU"),
+                           tr("ERR_ACTIVATE_VIEW3D"),
+                           tr("BUT_OK") );
 }
 
 void
@@ -2188,20 +2059,22 @@ createActions()
   createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(), tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
                this, SLOT(OnClearContainer()));
 
-  //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
   createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
                this, SLOT(OnSaveViewParams()));
+  createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
+                tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
+               this, SLOT(OnSaveViewParams()));
 
   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
   createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
                 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
                this, SLOT(OnRestoreViewParams()));
 
-  //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
   createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
                 tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
-               this, SLOT(OnDeleteViewParams()));
+               //this, SLOT(OnDeleteViewParams()));
+               this, SLOT(OnDeleteObjects()));
 
   createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
                 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
@@ -2462,6 +2335,7 @@ createPopupMenus()
 
   // view parameters commands
   mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
+  mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
   mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
   mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
 
@@ -2522,9 +2396,9 @@ createPopupMenus()
   mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
 
   // View parameters
-  //jfa tmp:aRule = "(client='VTKViewer' and selcount=0) or (selcount=1 and type='VISU::TVIEW3D')";
-  //jfa tmp:mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), aRule, true );
-  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true ); //jfa tmp
+  aRule = "selcount=1 and type='VISU::TVIEW3D'";
+  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
+  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
   mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
   mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
 
@@ -2594,7 +2468,7 @@ createPopupMenus()
   mgr->setRule( action( VISU_SWEEP ), aRule, true );
 
   // Selection info popup item
-  aRule = "client='ObjectBrowser' and selcount=1" + aInsideType;
+  aRule = "client='VTKViewer' and selcount=1" + aInsideType;
   mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
 
   aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";