Salome HOME
Fix for bug 0019870(Import/Export should show current directory).
[modules/geom.git] / src / BlocksGUI / BlocksGUI_ExplodeDlg.cxx
index be34aa1165c65ef5ab02e43a522e73f26f1c6933..802980698279688477ced74814802447948ac8df 100644 (file)
@@ -16,7 +16,7 @@
 //  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.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 
 #include "GEOM_Displayer.h"
 
-#include "QAD_Desktop.h"
+#include "SUIT_Session.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "OCCViewer_ViewModel.h"
 #include "SALOME_ListIteratorOfListIO.hxx"
 
 #include "utilities.h"
 #include <qmessagebox.h>
 #include <qtextedit.h>
 #include <qcheckbox.h>
+#include <qlabel.h>
 
 //=================================================================================
 // class    : BlocksGUI_ExplodeDlg()
 // purpose  : Constructs a BlocksGUI_ExplodeDlg which is a child of 'parent'.
 //=================================================================================
-BlocksGUI_ExplodeDlg::BlocksGUI_ExplodeDlg (QWidget* parent,
-                                            SALOME_Selection* Sel,
-                                            bool modal)
-     : GEOMBase_Skeleton(parent, "ExplodeDlg", Sel, modal,
+BlocksGUI_ExplodeDlg::BlocksGUI_ExplodeDlg (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal)
+     : GEOMBase_Skeleton(theGeometryGUI, parent, "ExplodeDlg", modal,
                          WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-  QPixmap image1 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BLOCK_EXPLODE")));
-  QPixmap imageS (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_BLOCK_EXPLODE")));
+  QPixmap imageS (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
 
   setCaption(tr("GEOM_BLOCK_EXPLODE_TITLE"));
 
@@ -105,6 +107,8 @@ BlocksGUI_ExplodeDlg::BlocksGUI_ExplodeDlg (QWidget* parent,
   Layout1->addWidget(myGrp1, 1, 0);
   /***************************************************************/
 
+  setHelpFileName("explode_on_blocks_operation_page.html");
+
   Init();
 }
 
@@ -129,7 +133,8 @@ void BlocksGUI_ExplodeDlg::Init()
   mySpinBoxMin->RangeStepAndValidator(0.0, 999.0, SpecificStep, 3);
   mySpinBoxMax->RangeStepAndValidator(0.0, 999.0, SpecificStep, 3);
 
-  if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC)
+  if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() 
+      != OCCViewer_Viewer::Type())
     myCheckBtn->setEnabled(false);
 
   // signals and slots connections
@@ -143,7 +148,8 @@ void BlocksGUI_ExplodeDlg::Init()
 
   connect(myCheckBtn, SIGNAL(stateChanged(int)), this, SLOT(SubShapeToggled()));
 
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
 
   myConstructorId = -1;
   ConstructorsClicked(0);
@@ -194,7 +200,7 @@ void BlocksGUI_ExplodeDlg::ClickOnOk()
 //=================================================================================
 bool BlocksGUI_ExplodeDlg::ClickOnApply()
 {
-  QAD_Application::getDesktop()->putInfo(tr(""));
+  SUIT_Session::session()->activeApplication()->putInfo(tr(""));
 
   // Explode all sub shapes
   if (isAllSubShapes()) {
@@ -230,10 +236,10 @@ void BlocksGUI_ExplodeDlg::SelectionIntoArgument()
   myObject = GEOM::GEOM_Object::_nil();
   mySelName->setText("");
 
-  if (mySelection->IObjectCount() == 1) {
+  if (IObjectCount() == 1) {
     Standard_Boolean aResult = Standard_False;
     GEOM::GEOM_Object_var anObj =
-      GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), aResult);
+      GEOMBase::ConvertIOinGEOMObject(firstIObject(), aResult);
 
     if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) {
       myObject = anObj;
@@ -268,7 +274,8 @@ void BlocksGUI_ExplodeDlg::SetEditCurrentArgument()
 void BlocksGUI_ExplodeDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
 
   activateSelection();
 }
@@ -315,9 +322,14 @@ void BlocksGUI_ExplodeDlg::activateSelection()
   erasePreview(true);
 
   if (isAllSubShapes()) { // Sub-shapes selection disabled
+    disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+              SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
     globalSelection( GEOM_ALLSHAPES );
-    SelectionIntoArgument();
-
+    if (myObject->_is_nil()) {
+      SelectionIntoArgument();
+    }
+    connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+           SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
   } else {
     displayPreview(true, true, false);
     globalSelection(GEOM_PREVIEW);
@@ -330,8 +342,8 @@ void BlocksGUI_ExplodeDlg::activateSelection()
 //=================================================================================
 void BlocksGUI_ExplodeDlg::updateButtonState()
 {
-  if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC ||
-      myObject->_is_nil()) {
+  if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() 
+      != OCCViewer_Viewer::Type() || myObject->_is_nil()) {
     myCheckBtn->setChecked(FALSE);
     myCheckBtn->setEnabled(FALSE);
   } else {
@@ -384,7 +396,7 @@ bool BlocksGUI_ExplodeDlg::isValid (QString&)
     if (IsPreview())
       return !myObject->_is_nil();
     else
-      return !myObject->_is_nil() && (isAllSubShapes() || mySelection->IObjectCount());
+      return !myObject->_is_nil() && (isAllSubShapes() || IObjectCount());
   default:
     return false;
   }
@@ -431,7 +443,7 @@ bool BlocksGUI_ExplodeDlg::execute (ObjectList& objects)
     QMap<QString, char> selected;
 
     // Get names of selected objects
-    SALOME_ListIteratorOfListIO it (mySelection->StoredIObjects());
+    SALOME_ListIteratorOfListIO it (selectedIO());
     for (; it.More(); it.Next()) {
       selected.insert(it.Value()->getName(), 0);
     }
@@ -440,7 +452,8 @@ bool BlocksGUI_ExplodeDlg::execute (ObjectList& objects)
     ObjectList toRemoveFromEnggine;
     ObjectList::iterator anIter;
     for (anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter) {
-      if (selected.contains(GeometryGUI::GetORB()->object_to_string(*anIter)))
+      CORBA::String_var objStr = myGeomGUI->getApp()->orb()->object_to_string(*anIter);
+      if (selected.contains(QString(objStr.in())))
         objects.push_back(*anIter);
       else
         toRemoveFromEnggine.push_back(*anIter);
@@ -483,3 +496,12 @@ GEOM::GEOM_Object_ptr BlocksGUI_ExplodeDlg::getFather (GEOM::GEOM_Object_ptr)
 {
   return myObject;
 }
+
+//================================================================
+// Function : getNewObjectName
+// Purpose  : Redefine this method to return proper name for a new object
+//================================================================
+const char* BlocksGUI_ExplodeDlg::getNewObjectName() const
+{
+  return "";
+}