1 // Copyright (C) 2009-2023 EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "cppcomposGUI.h"
21 #include <SUIT_MessageBox.h>
22 #include <SUIT_ResourceMgr.h>
23 #include <SUIT_Desktop.h>
24 #include <SUIT_Study.h>
25 #include <SUIT_ViewWindow.h>
26 #include <SUIT_ViewManager.h>
27 #include <SalomeApp_Application.h>
29 #include <SALOMEconfig.h>
32 #include <QInputDialog>
38 CAM_Module* createModule()
40 return new cppcomposGUI();
45 cppcomposGUI::cppcomposGUI() :
46 LightApp_Module( "cppcompos" ) // default name
50 //static cppcompos_ORB::cppcompos_var engine;
52 // Module's initialization
53 void cppcomposGUI::initialize( CAM_Application* app )
56 LightApp_Module::initialize( app );
58 QWidget* aParent = application()->desktop();
59 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
62 QPixmap aPixmap = aResourceMgr->loadPixmap( "cppcompos","exec.png" );
63 createAction( 901, "Banner", QIcon( aPixmap ), "Banner", "Banner", 0, aParent, false, this, SLOT( OnGetBanner() ) );
64 createAction( 902, "Designer", QIcon( aPixmap ), "Designer", "Designer", 0, aParent, false, this, SLOT( OnDesigner() ) );
68 aMenuId = createMenu( "cppcompos", -1, -1, 30 );
69 createMenu( 901, aMenuId, 10 );
72 int aToolId = createTool ( "cppcompos" );
73 createTool( 901, aToolId );
74 createTool( 902, aToolId );
76 _myWidget = new QLabel("My module!", aParent);
77 _myViewManager = getApp()->createViewManager("cppcompos", _myWidget);
78 _myViewManager->getActiveView()->setClosable( false );
80 connect( app->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
81 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
85 // Get compatible dockable windows.
86 void cppcomposGUI::windows( QMap<int, int>& theMap ) const
89 // theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
90 // theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
93 // Module's activation
94 bool cppcomposGUI::activateModule( SUIT_Study* theStudy )
96 bool bOk = LightApp_Module::activateModule( theStudy );
100 setMenuShown( true );
101 setToolShown( true );
102 _myViewManager->setShown(true);
103 _myWidget->setVisible(true);
104 _myViewManager->getActiveView()->setFocus();
109 // Module's deactivation
110 bool cppcomposGUI::deactivateModule( SUIT_Study* theStudy )
112 setMenuShown( false );
113 setToolShown( false );
114 _myWidget->setVisible(false);
115 _myViewManager->setShown(false);
117 return LightApp_Module::deactivateModule( theStudy );
120 void cppcomposGUI::onWindowActivated( SUIT_ViewWindow* svw)
122 if(_myViewManager->getActiveView()->getId() == svw->getId())
123 if (!getApp()->activeModule() ||
124 getApp()->activeModule()->moduleName() != "cppcompos")
125 getApp()->activateModule("cppcompos");
129 void cppcomposGUI::OnGetBanner()
131 // Dialog to get the Name
133 QString myName = QInputDialog::getText( getApp()->desktop(), "label", "name", QLineEdit::Normal, QString::null, &ok );
135 if ( ok && !myName.isEmpty())
137 QString banner = "Hello " + myName;
138 SUIT_MessageBox::information( getApp()->desktop(), "info", banner, "OK" );
143 void cppcomposGUI::OnDesigner()
145 QWidget* wid= new MyDemo(getApp()->desktop());
149 MyDemo::MyDemo(QWidget *parent)