Salome HOME
NPAL16559: EDF507: Implementation of a more advanced system of measurement.
[modules/geom.git] / src / PrimitiveGUI / PrimitiveGUI.cxx
index 0304e194f9944096710fbb908ea178b41bf6b9ad..45ca54db0855f9a1b8d2b8c51a07db43890bde0e 100644 (file)
@@ -17,7 +17,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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 //  Module : GEOM
 //  $Header$
 
-using namespace std;
+
 #include "PrimitiveGUI.h"
 #include "GeometryGUI.h"
 
-#include "QAD_Application.h"
-#include "QAD_Desktop.h"
+#include "SUIT_Session.h"
+#include "SUIT_Desktop.h"
 
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
+#include "SalomeApp_Application.h"
 
 #include "PrimitiveGUI_BoxDlg.h"      // Method BOX
 #include "PrimitiveGUI_CylinderDlg.h" // Method CYLINDER
@@ -41,30 +41,16 @@ using namespace std;
 #include "PrimitiveGUI_TorusDlg.h"    // Method TORUS
 #include "PrimitiveGUI_ConeDlg.h"     // Method CONE
 
-PrimitiveGUI* PrimitiveGUI::myGUIObject = 0;
-
-//=======================================================================
-// function : GetPrimitiveGUI()
-// purpose  : Get the only PrimitiveGUI object [ static ]
-//=======================================================================
-PrimitiveGUI* PrimitiveGUI::GetPrimitiveGUI()
-{
-  if ( myGUIObject == 0 ) {
-    // init PrimitiveGUI only once
-    myGUIObject = new PrimitiveGUI();
-  }
-  return myGUIObject;
-}
+using namespace std;
 
 //=======================================================================
 // function : PrimitiveGUI()
 // purpose  : Constructor
 //=======================================================================
-PrimitiveGUI::PrimitiveGUI() : GEOMGUI()
+PrimitiveGUI::PrimitiveGUI(GeometryGUI* parent) : GEOMGUI(parent)
 {
 }
 
-
 //=======================================================================
 // function : ~PrimitiveGUI
 // purpose  : Destructor
@@ -78,51 +64,40 @@ PrimitiveGUI::~PrimitiveGUI()
 // function : OnGUIEvent()
 // purpose  : 
 //=======================================================================
-bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
+bool PrimitiveGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
 {
-  PrimitiveGUI* aPrimitiveGUI = GetPrimitiveGUI();
-  GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog();
-  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-  
+  SalomeApp_Application* app = getGeometryGUI()->getApp();
+  if (!app) return false;
+
+  getGeometryGUI()->EmitSignalDeactivateDialog();
+
   QDialog* aDlg = NULL;
 
   switch (theCommandID)
-    {
+  {
     case 4021: // BOX
-      {
-       aDlg = new PrimitiveGUI_BoxDlg(parent, "", Sel);
+       aDlg = new PrimitiveGUI_BoxDlg(getGeometryGUI(), parent, "");
        break;
-      }
     case 4022: // CYLINDER
-      {
-       aDlg = new PrimitiveGUI_CylinderDlg(parent, "", Sel);
+       aDlg = new PrimitiveGUI_CylinderDlg(getGeometryGUI(), parent, "");
        break;
-      }
     case 4023: // SPHERE
-      {
-       aDlg = new PrimitiveGUI_SphereDlg(parent, "", Sel);
+       aDlg = new PrimitiveGUI_SphereDlg(getGeometryGUI(), parent, "");
        break;
-      }
     case 4024: // TORUS
-      {
-       aDlg = new PrimitiveGUI_TorusDlg(parent, "", Sel);
+       aDlg = new PrimitiveGUI_TorusDlg(getGeometryGUI(), parent, "");
        break;
-      }
     case 4025: // CONE
-      {
-       aDlg = new PrimitiveGUI_ConeDlg(parent, "", Sel);
+       aDlg = new PrimitiveGUI_ConeDlg(getGeometryGUI(), parent, "");
        break;
-      }
     default:
-      {
-       parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
+       app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
        break;
-      }
     }
 
-  if ( aDlg != NULL )
+  if (aDlg != NULL)
     aDlg->show();
-  
+
   return true;
 }
 
@@ -132,8 +107,11 @@ bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
 //=====================================================================================
 extern "C"
 {
-  GEOMGUI* GetLibGUI()
+#ifdef WNT
+       __declspec( dllexport )
+#endif
+  GEOMGUI* GetLibGUI( GeometryGUI* parent )
   {
-    return PrimitiveGUI::GetPrimitiveGUI();
+    return new PrimitiveGUI( parent );
   }
 }