1 // Copyright (C) 2007-2013 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
23 #include "HYDROGUI_Operations.h"
25 #include "HYDROGUI_DataModel.h"
26 #include "HYDROGUI_ImportImageOp.h"
27 #include "HYDROGUI_Module.h"
28 #include "HYDROGUI_TwoImagesOp.h"
30 #include <CAM_Application.h>
32 #include <SUIT_Desktop.h>
33 #include <SUIT_ResourceMgr.h>
37 QAction* HYDROGUI_Module::CreateAction( const int theId, const QString& theSuffix, const QString& theImg,
38 const int theKey, const bool isToggle, const QString& theSlot )
40 QString aSlot = theSlot;
42 aSlot = SLOT( onOperation() );
43 SUIT_ResourceMgr* aMgr = application()->resourceMgr();
44 std::string anImg = theImg.toStdString();
45 QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aMgr->loadPixmap( "HYDROGUI", tr( anImg.c_str() ) );
46 std::string aMenu = ( "MEN_" + theSuffix ).toStdString();
47 std::string aDesktop = ( "DSK_" + theSuffix ).toStdString();
48 std::string aToolbar = ( "STB_" + theSuffix ).toStdString();
49 std::string aSlotStr = aSlot.toStdString();
50 return LightApp_Module::createAction( theId, tr( aMenu.c_str() ), aPixmap,
51 tr( aDesktop.c_str() ), tr( aToolbar.c_str() ),
52 theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() );
55 void HYDROGUI_Module::CreateActions()
57 CreateAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
58 CreateAction( FuseId, "FUSE_IMAGES" );
59 CreateAction( CutId, "CUT_IMAGES" );
62 void HYDROGUI_Module::CreateMenus()
64 int aHydroMenuIndex = 6; // Edit menu id == 5, View menu id == 10
65 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenuIndex );
66 createMenu( ImportImageId, aHydroId, -1, -1 );
67 createMenu( FuseId, aHydroId, -1, -1 );
68 createMenu( CutId, aHydroId, -1, -1 );
71 void HYDROGUI_Module::CreatePopups()
75 void HYDROGUI_Module::CreateToolbars()
79 void HYDROGUI_Module::onOperation()
81 const QAction* anAction = dynamic_cast<const QAction*>( sender() );
82 int anId = actionId( anAction );
84 startOperation( anId );
87 LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
89 LightApp_Operation* anOp = 0;
90 HYDROGUI_Module* aModule = const_cast<HYDROGUI_Module*>( this );
94 anOp = new HYDROGUI_ImportImageOp( aModule );
97 anOp = new HYDROGUI_TwoImagesOp( aModule, tr( "FUSE_OP" ) );
100 anOp = new HYDROGUI_TwoImagesOp( aModule, tr( "CUT_OP" ) );
105 anOp = LightApp_Module::createOperation( theId );