1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "HEXABLOCKGUI.h"
24 #include <SUIT_MessageBox.h>
25 #include <SUIT_ResourceMgr.h>
26 #include <SUIT_Desktop.h>
27 #include <SalomeApp_Application.h>
29 #include <SALOME_LifeCycleCORBA.hxx>
32 #include <QInputDialog>
38 HEXABLOCKGUI::HEXABLOCKGUI() :
39 SalomeApp_Module( "HEXABLOCK" ), // default name
40 LightApp_Module( "HEXABLOCK" )
44 // Gets an reference to the module's engine
45 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
47 Engines::Component_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","HEXABLOCK" );
48 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
49 ASSERT(!CORBA::is_nil(clr));
53 // Module's initialization
54 void HEXABLOCKGUI::initialize( CAM_Application* app )
57 SalomeApp_Module::initialize( app );
59 InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
61 QWidget* aParent = application()->desktop();
62 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
65 createAction( 190, tr( "TLT_MY_NEW_ITEM" ), QIcon(), tr( "MEN_MY_NEW_ITEM" ), tr( "STS_MY_NEW_ITEM" ), 0, aParent, false,
66 this, SLOT( OnMyNewItem() ) );
67 QPixmap aPixmap = aResourceMgr->loadPixmap( "HEXABLOCK",tr( "ICON_GET_BANNER" ) );
68 createAction( 901, tr( "TLT_GET_BANNER" ), QIcon( aPixmap ), tr( "MEN_GET_BANNER" ), tr( "STS_GET_BANNER" ), 0, aParent, false,
69 this, SLOT( OnGetBanner() ) );
73 aMenuId = createMenu( tr( "MEN_FILE" ), -1, -1 );
74 createMenu( separator(), aMenuId, -1, 10 );
75 aMenuId = createMenu( tr( "MEN_FILE_HEXABLOCK" ), aMenuId, -1, 10 );
76 createMenu( 190, aMenuId );
78 aMenuId = createMenu( tr( "MEN_HEXABLOCK" ), -1, -1, 30 );
79 createMenu( 901, aMenuId, 10 );
82 int aToolId = createTool ( tr( "TOOL_HEXABLOCK" ) );
83 createTool( 901, aToolId );
86 // Module's engine IOR
87 QString HEXABLOCKGUI::engineIOR() const
89 CORBA::String_var anIOR = getApp()->orb()->object_to_string( InitHEXABLOCKGen( getApp() ) );
90 return QString( anIOR.in() );
93 // Module's activation
94 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
96 bool bOk = SalomeApp_Module::activateModule( theStudy );
104 // Module's deactivation
105 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
107 setMenuShown( false );
108 setToolShown( false );
110 return SalomeApp_Module::deactivateModule( theStudy );
114 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
117 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
118 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
122 void HEXABLOCKGUI::OnMyNewItem()
124 SUIT_MessageBox::warning( getApp()->desktop(),tr( "INF_HEXABLOCK_BANNER" ), tr( "INF_HEXABLOCK_MENU" ) );
128 void HEXABLOCKGUI::OnGetBanner()
130 // Dialog to get the Name
132 QString myName = QInputDialog::getText( getApp()->desktop(), tr( "QUE_HEXABLOCK_LABEL" ), tr( "QUE_HEXABLOCK_NAME" ),
133 QLineEdit::Normal, QString::null, &ok );
135 if ( ok && !myName.isEmpty()) // if we got a name, get a HEXABLOCK component and ask for makeBanner
137 // HEXABLOCK_ORB::HEXABLOCK_Gen_ptr hexablockgen = HEXABLOCKGUI::InitHEXABLOCKGen( getApp() );
138 // QString banner = hexablockgen->makeBanner( (const char*)myName.toLatin1() );
139 // SUIT_MessageBox::information( getApp()->desktop(), tr( "INF_HEXABLOCK_BANNER" ), banner, tr( "BUT_OK" ) );
145 CAM_Module* createModule()
147 return new HEXABLOCKGUI();