Salome HOME
26637768a25c9db598bded09536903ebbd5d9c12
[modules/geom.git] / src / XAOPlugin / XAOPlugin_GUI.cxx
1 // Copyright (C) 2014-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // internal includes
21 #include "XAOPlugin_GUI.h"
22 #include "XAOPlugin_ExportDlg.h"
23 #include "XAOPlugin_ImportDlg.h"
24
25 // GUI includes
26 #include <SUIT_Desktop.h>
27 #include <SalomeApp_Application.h>
28
29 // GEOM includes
30 #include "GeometryGUI.h"
31
32 //=======================================================================
33 // function : XAOPlugin_GUI()
34 // purpose  : Constructor
35 //=======================================================================
36 XAOPlugin_GUI::XAOPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent )
37 {
38 }
39
40 //=======================================================================
41 // function : ~XAOPlugin_GUI
42 // purpose  : Destructor
43 //=======================================================================
44 XAOPlugin_GUI::~XAOPlugin_GUI()
45 {
46 }
47
48 //=======================================================================
49 // function : OnGUIEvent()
50 // purpose  : 
51 //=======================================================================
52 bool XAOPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
53 {
54   switch ( theCommandID ) {
55   case 1:
56     return OnGUIEvent("Export_XAO", parent);
57   case 2:
58     return OnGUIEvent("Import_XAO", parent);
59   default:
60     return OnGUIEvent("", parent);
61   }
62   return false;
63 }
64
65 //=======================================================================
66 // function : OnGUIEvent()
67 // purpose  :
68 //=======================================================================
69 bool XAOPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent )
70 {
71   SalomeApp_Application* app = getGeometryGUI()->getApp();
72   if (!app) return false;
73
74   getGeometryGUI()->EmitSignalDeactivateDialog();
75
76   QDialog* dialog = NULL;
77   if( theCommandID == "Export_XAO" )
78     dialog = new XAOPlugin_ExportDlg(getGeometryGUI(), parent);
79   else if( theCommandID == "Import_XAO" )
80     dialog = new XAOPlugin_ImportDlg(getGeometryGUI(), parent);
81   else
82     app->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) );
83
84   if (dialog != NULL)
85     dialog->show();
86
87   return true;
88 }
89
90 //=====================================================================================
91 // EXPORTED METHODS
92 //=====================================================================================
93 extern "C"
94 {
95 #ifdef WIN32
96     __declspec( dllexport )
97 #endif
98   GEOMGUI* GetLibGUI(GeometryGUI* parent)
99   {
100     return new XAOPlugin_GUI(parent);
101   }
102 }