From: ouv Date: Tue, 23 Jul 2013 15:03:20 +0000 (+0000) Subject: Compilation by CMake. X-Git-Tag: BR_hydro_v_0_1~141 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=16b8dd948d4cadb6b06a34786eca8bee8eb4ea08;p=modules%2Fhydro.git Compilation by CMake. --- diff --git a/CMake/Common.cmake b/CMake/Common.cmake index 29f6e224..ceefd5be 100644 --- a/CMake/Common.cmake +++ b/CMake/Common.cmake @@ -1,8 +1,8 @@ cmake_minimum_required (VERSION 2.6) cmake_policy(SET CMP0011 NEW) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/salome) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/salome) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/salome) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/CMake/CommonInstall.cmake b/CMake/CommonInstall.cmake index 7394c236..5e6a62c0 100644 --- a/CMake/CommonInstall.cmake +++ b/CMake/CommonInstall.cmake @@ -1,2 +1,2 @@ -install(TARGETS ${PROJECT_LIBRARIES} RUNTIME DESTINATION bin LIBRARY DESTINATION lib) +install(TARGETS ${PROJECT_LIBRARIES} RUNTIME DESTINATION bin/salome LIBRARY DESTINATION lib/salome) install(FILES ${PROJECT_HEADERS} DESTINATION include) diff --git a/CMake/UseQT4EXT.cmake b/CMake/UseQT4EXT.cmake new file mode 100644 index 00000000..79835778 --- /dev/null +++ b/CMake/UseQT4EXT.cmake @@ -0,0 +1,40 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INSTALL(CODE "MACRO(QT4_COMPILE_TS_ON_INSTALL MYLRELEASE MYTSFILE MYFULLDIR MYOUTQMFILE) + FILE(MAKE_DIRECTORY \${MYFULLDIR}) + MESSAGE(STATUS \"Compiling \${MYTSFILE}\") + EXECUTE_PROCESS(COMMAND \${MYLRELEASE} \${MYTSFILE} -qm \${MYFULLDIR}/\${MYOUTQMFILE}) +ENDMACRO(QT4_COMPILE_TS_ON_INSTALL)") + +# This MACRO uses the following vars +# - QT_LRELEASE_EXECUTABLE : (given by default by FindQT.cmake) +# +# MYTSFILES containing all ts files to be compiled. +# WHERETOINSTALL contains directory (relative to install_prefix) where to install files after compilation of ts files too qm. +MACRO(QT4_INSTALL_TS_RESOURCES MYTSFILES WHERETOINSTALL) + INSTALL(CODE "SET(INSTALL_TS_DIR ${WHERETOINSTALL})") + SET(MYSOURCES) + FOREACH(input ${MYTSFILES}) + GET_FILENAME_COMPONENT(input2 ${input} NAME) + STRING(REGEX REPLACE ".ts" "" base ${input2}) + SET(output "${base}.qm") + INSTALL(CODE "QT4_COMPILE_TS_ON_INSTALL( \"${QT_LRELEASE_EXECUTABLE}\" \"${CMAKE_CURRENT_SOURCE_DIR}/${input}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_TS_DIR}\" ${output})") + ENDFOREACH(input ${MYIDLFILES}) +ENDMACRO(QT4_INSTALL_TS_RESOURCES) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcda5f39..e0a54982 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,10 @@ find_package(SalomeQT4) find_package(SalomeCAS) find_package(SalomeCPPUNIT) +set(HYDRO_salomeres_DATA share/salome/resources/hydro) + add_subdirectory (src/HYDROData) add_subdirectory (src/HYDROOperations) +add_subdirectory (src/HYDROGUI) enable_testing() diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt new file mode 100644 index 00000000..9f2554a3 --- /dev/null +++ b/src/HYDROGUI/CMakeLists.txt @@ -0,0 +1,57 @@ +include(../../CMake/Common.cmake) +include(../../CMake/UseQT4EXT.cmake) + +set(PROJECT_HEADERS + HYDROGUI.h + HYDROGUI_InputPanel.h + HYDROGUI_Module.h + HYDROGUI_ObjSelector.h + HYDROGUI_Operation.h + HYDROGUI_Operations.h +) + +QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) + +set(PROJECT_SOURCES + HYDROGUI_InputPanel.cxx + HYDROGUI_Module.cxx + HYDROGUI_ObjSelector.cxx + HYDROGUI_Operation.cxx + HYDROGUI_Operations.cxx +) + +add_definitions( + -DHYDROGUI_EXPORTS + ${CAS_DEFINITIONS} + ${QT_DEFINITIONS} + $(GUI_CXXFLAGS) +) + +include_directories( + ${CAS_INCLUDE_DIRS} + ${QT_INCLUDES} + ${GUI_ROOT_DIR}/include/salome + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROData +) + +add_library(HYDROGUI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${PROJECT_HEADERS_MOC}) +target_link_libraries(HYDROGUI ${CAS_OCAF}) + +set(PROJECT_LIBRARIES HYDROGUI) + +set(GUITS_SOURCES + resources/HYDROGUI_images.ts + resources/HYDROGUI_msg_en.ts + resources/HYDROGUI_msg_fr.ts +) + +include(../../CMake/CommonInstall.cmake) + +# resources +QT4_INSTALL_TS_RESOURCES("${GUITS_SOURCES}" "${HYDRO_salomeres_DATA}") + +FILE(GLOB GUIPNG_DATA "${CMAKE_CURRENT_SOURCE_DIR}/resources/*.png") +FILE(GLOB GUIXML_DATA "${CMAKE_CURRENT_SOURCE_DIR}/resources/*.xml") +SET(GUI_DATA ${GUIPNG_DATA} ${GUIXML_DATA}) +INSTALL(FILES ${GUI_DATA} DESTINATION ${HYDRO_salomeres_DATA}) diff --git a/src/HYDROGUI/HYDROGUI.h b/src/HYDROGUI/HYDROGUI.h new file mode 100644 index 00000000..c2d7cec2 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI.h @@ -0,0 +1,36 @@ + +#ifndef HYDROGUI_H +#define HYDROGUI_H + +#if defined HYDROGUI_EXPORTS +#if defined WNT +#define HYDRO_EXPORT __declspec( dllexport ) +#else +#define HYDRO_EXPORT +#endif +#else +#if defined WNT +#define HYDRO_EXPORT __declspec( dllimport ) +#else +#define HYDRO_EXPORT +#endif +#endif + +#ifdef WNT +#pragma warning ( disable: 4251 ) +#pragma warning ( disable: 4267 ) +#pragma warning ( disable: 4311 ) +#pragma warning ( disable: 4312 ) +#endif + +#if defined ( _DEBUG ) || defined ( DEBUG ) +#include +#define HYDRO_VERIFY(x) (assert(x)) +#define HYDRO_ASSERT(x) (assert(x)) +#else +#define HYDRO_VERIFY(x) (x) +#define HYDRO_ASSERT(x) +#endif + +#endif + diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx new file mode 100644 index 00000000..a48f65ad --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -0,0 +1,67 @@ + +#include +#include +#include +#include +#include +#include + +HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle ) +: QDockWidget( theModule->application()->desktop() ), + myModule( theModule ) +{ + setFloating( false ); + setWindowTitle( theTitle ); + setAllowedAreas( Qt::RightDockWidgetArea ); + + QFrame* aFrame = new QFrame( this ); + setWidget( aFrame ); + QVBoxLayout* aLayout = new QVBoxLayout( aFrame ); + + myMainFrame = new QFrame( this ); + QGridLayout* aMainLayout = new QGridLayout( myMainFrame ); + myBtnFrame = new QFrame( this ); + aLayout->addWidget( myMainFrame, 1 ); + aLayout->addWidget( myBtnFrame, 0 ); + + QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame ); + aBtnsLayout->setMargin( 5 ); + aBtnsLayout->setSpacing( 5 ); + + myApply = new QPushButton( tr( "APPLY" ), myBtnFrame ), + myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame ); + myHelp = new QPushButton( tr( "HELP" ), myBtnFrame ); + + aBtnsLayout->addWidget( myApply, 0 ); + aBtnsLayout->addWidget( myCancel, 0 ); + aBtnsLayout->addStretch( 1 ); + aBtnsLayout->addWidget( myHelp, 0 ); + + connect( myApply, SIGNAL( clicked() ), this, SLOT( OnApply() ) ); + connect( myCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) ); + connect( myHelp, SIGNAL( clicked() ), this, SLOT( OnHelp() ) ); +} + +HYDROGUI_InputPanel::~HYDROGUI_InputPanel() +{ +} + +void HYDROGUI_InputPanel::OnApply() +{ +} + +void HYDROGUI_InputPanel::OnCancel() +{ +} + +void HYDROGUI_InputPanel::OnHelp() +{ +} + +void HYDROGUI_InputPanel::addWidget( const QString& theLabel, QWidget* theWidget ) +{ + QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + int aRow = aMainLayout->rowCount(); + aMainLayout->addWidget( new QLabel( theLabel, this ), aRow, 0 ); + aMainLayout->addWidget( theWidget, aRow, 1 ); +} diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h new file mode 100644 index 00000000..e1801c10 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -0,0 +1,39 @@ + +#ifndef HYDROGUI_DIALOG_HEADER +#define HYDROGUI_DIALOG_HEADER + +#include +#include + +class HYDROGUI_Module; +class QFrame; +class QPushButton; + +/**\class HYDROGUI_Dialog + *\brief The base class representing base input panel for all HYDROGUI panels + */ +class HYDROGUI_InputPanel : public QDockWidget +{ + Q_OBJECT + +public: + HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_InputPanel(); + + void addWidget( const QString& theLabel, QWidget* theWidget ); + +protected slots: + void OnApply(); + void OnCancel(); + void OnHelp(); + +private: + HYDROGUI_Module* myModule; + QFrame* myMainFrame; + QFrame* myBtnFrame; + QPushButton* myApply; + QPushButton* myCancel; + QPushButton* myHelp; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx new file mode 100644 index 00000000..1ddd42d3 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -0,0 +1,103 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" HYDRO_EXPORT CAM_Module* createModule() +{ + return new HYDROGUI_Module(); +} + +HYDROGUI_Module::HYDROGUI_Module() +: LightApp_Module( "HYDRO GUI" ) +{ +} + +HYDROGUI_Module::~HYDROGUI_Module() +{ +} + +void HYDROGUI_Module::initialize( CAM_Application* theApp ) +{ + LightApp_Module::initialize( theApp ); + + CreateActions(); + CreateMenus(); + CreatePopups(); + CreateToolbars(); + + setMenuShown( false ); + + HYDROGUI_InputPanel* aDlg = new HYDROGUI_InputPanel( this, "Fuse Images" ); + HYDROGUI_ObjSelector* aSel1 = new HYDROGUI_ObjSelector( this, aDlg ); + HYDROGUI_ObjSelector* aSel2 = new HYDROGUI_ObjSelector( this, aDlg ); + aDlg->addWidget( "Image 1", aSel1 ); + aDlg->addWidget( "Image 2", aSel2 ); + application()->desktop()->addDockWidget( Qt::RightDockWidgetArea, aDlg ); + + qApp->processEvents(); +} + +bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) +{ + setMenuShown( true ); + return LightApp_Module::activateModule( theStudy ); +} + +void HYDROGUI_Module::windows( QMap& theMap ) const +{ + theMap.clear(); + theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea ); + theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); +} + +void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const +{ + theTypesList << GraphicsView_Viewer::Type(); +} + +void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theMgr ) +{ + LightApp_Module::onViewManagerAdded( theMgr ); + connect( theMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), + this, SLOT( onViewWindowAdded( SUIT_ViewWindow* ) ) ); +} + +void HYDROGUI_Module::onViewWindowAdded( SUIT_ViewWindow* theWnd ) +{ + GraphicsView_ViewFrame* aViewFrame = dynamic_cast( theWnd ); + + LightApp_SelectionMgr* aSelMgr = getApp()->selectionMgr(); + LightApp_GVSelector* aSelector = new LightApp_GVSelector( aViewFrame->getViewer(), aSelMgr ); + + GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort(); + + GraphicsView_PrsImage* aPrs1 = new GraphicsView_PrsImage(); + QImage anImage1( "W:/Work/HYDRO/data/samples/1.bmp" ); + aPrs1->setImage( anImage1 ); + aPrs1->setName( "example_1" ); + aPrs1->compute(); + aViewPort->addItem( aPrs1 ); + + GraphicsView_PrsImage* aPrs2 = new GraphicsView_PrsImage(); + QImage anImage2( "W:/Work/HYDRO/data/samples/2.bmp" ); + aPrs2->setImage( anImage2 ); + aPrs2->setName( "example_2" ); + aPrs2->setRotationAngle( 30 ); + aPrs2->setPosition( 200, 50 ); + aPrs2->compute(); + aViewPort->addItem( aPrs2 ); + + //qApp->processEvents(); + aViewPort->fitAll(); +} diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h new file mode 100644 index 00000000..7ed7f660 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -0,0 +1,49 @@ + +#ifndef HYDROGUI_MODULE_HEADER +#define HYDROGUI_MODULE_HEADER + +#include +#include + +class SUIT_ViewWindow; + +/**\class HYDROGUI_Module + *\brief The class representing the HYDROGUI module + */ +class HYDROGUI_Module : public LightApp_Module +{ + Q_OBJECT + +public: + HYDROGUI_Module(); + virtual ~HYDROGUI_Module(); + + virtual void initialize( CAM_Application* ); + virtual void windows( QMap& ) const; + virtual void viewManagers( QStringList& ) const; + +public slots: + virtual bool activateModule( SUIT_Study* ); + +protected: + virtual LightApp_Operation* createOperation( const int ) const; + +protected slots: + void onOperation(); + virtual void onViewManagerAdded( SUIT_ViewManager* ); + virtual void onViewWindowAdded( SUIT_ViewWindow* ); + +private: + void CreateActions(); + void CreateMenus(); + void CreatePopups(); + void CreateToolbars(); + +private: + QAction* CreateAction( const int theId, const QString& theSuffix, + const QString& theImg = QString::null, + const int theKey = 0, const bool isToggle = false, + const QString& theSlot = QString::null ); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx new file mode 100644 index 00000000..9a6016ee --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx @@ -0,0 +1,77 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent ) +: QAbstractButton( theParent ), myModule( theModule ) +{ + QHBoxLayout* aLayout = new QHBoxLayout( this ); + myBtn = new QToolButton( this ); + myBtn->setCheckable( true ); + myBtn->setChecked( false ); + myObjName = new QLineEdit( this ); + myObjName->setReadOnly( true ); + aLayout->addWidget( myBtn, 0 ); + aLayout->addWidget( myObjName, 1 ); + + SUIT_SelectionMgr* aSelMgr = theModule->getApp()->selectionMgr(); + + connect( myBtn, SIGNAL( toggled( bool ) ), this, SLOT( OnToggled( bool ) ) ); + connect( aSelMgr, SIGNAL( selectionChanged() ), this, SLOT( OnSelectionChanged() ) ); +} + +HYDROGUI_ObjSelector::~HYDROGUI_ObjSelector() +{ +} + +void HYDROGUI_ObjSelector::paintEvent( QPaintEvent* ) +{ +} + +bool HYDROGUI_ObjSelector::hitButton( const QPoint& thePnt ) const +{ + return false; +} + +void HYDROGUI_ObjSelector::OnToggled( bool isChecked ) +{ + if( !isChecked ) + return; + + QList aSelectors = parentWidget()->findChildren(); + foreach( HYDROGUI_ObjSelector* aSelector, aSelectors ) + if( aSelector != this ) + aSelector->myBtn->setChecked( false ); + + if( isChecked ) + OnSelectionChanged(); +} + +void HYDROGUI_ObjSelector::OnSelectionChanged() +{ + if( !myBtn->isChecked() ) + return; + + SUIT_SelectionMgr* aSelMgr = myModule->getApp()->selectionMgr(); + SUIT_DataOwnerPtrList anOwners; + aSelMgr->selected( anOwners ); + + QString anObjName; + foreach( SUIT_DataOwner* anOwner, anOwners ) + { + LightApp_GVDataOwner* aGrDOwner = dynamic_cast( anOwner ); + if( aGrDOwner ) + { + anObjName = aGrDOwner->object()->getName(); + break; + } + } + myObjName->setText( anObjName ); +} diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.h b/src/HYDROGUI/HYDROGUI_ObjSelector.h new file mode 100644 index 00000000..55c463b4 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.h @@ -0,0 +1,33 @@ + +#ifndef HYDROGUI_OBJ_SELECTOR_HEADER +#define HYDROGUI_OBJ_SELECTOR_HEADER + +#include + +class QToolButton; +class QLineEdit; +class HYDROGUI_Module; + +class HYDROGUI_ObjSelector : public QAbstractButton +{ + Q_OBJECT + +public: + HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent ); + virtual ~HYDROGUI_ObjSelector(); + +protected: + virtual void paintEvent( QPaintEvent* ); + virtual bool hitButton( const QPoint& thePnt ) const; + +protected slots: + void OnToggled( bool ); + void OnSelectionChanged(); + +private: + HYDROGUI_Module* myModule; + QToolButton* myBtn; + QLineEdit* myObjName; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx new file mode 100644 index 00000000..6bd7e444 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -0,0 +1,50 @@ + +#include +#include +#include +#include +#include +#include + +HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule ) +: SUIT_Operation( theModule->getApp() ), myModule( theModule ), myPanel( 0 ) +{ +} + +HYDROGUI_Operation::~HYDROGUI_Operation() +{ +} + +SUIT_SelectionMgr* HYDROGUI_Operation::selectionMgr() const +{ + return myModule->getApp()->selectionMgr(); +} + +void HYDROGUI_Operation::startOperation() +{ + /*TODO: if( myIsTransactional && doc() ) + doc()->OpenTransaction();*/ + + if( selectionMgr() ) + connect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( OnSelectionDone() ) ); + + if( inputPanel() ) + { + //TODO: connect( inputPanel(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); + //TODO: connect( inputPanel(), SIGNAL( dlgCancel() ), this, SLOT( abort() ) ); + + inputPanel()->show(); + myModule->getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, inputPanel() ); + } +} + +void HYDROGUI_Operation::OnSelectionDone() +{ +} + +HYDROGUI_InputPanel* HYDROGUI_Operation::inputPanel() const +{ + if( !myPanel ) + ( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel(); + return myPanel; +} diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h new file mode 100644 index 00000000..04db8ead --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -0,0 +1,35 @@ + +#ifndef HYDROGUI_OPERATION_HEADER +#define HYDROGUI_OPERATION_HEADER + +#include +#include + +class HYDROGUI_Module; +class HYDROGUI_InputPanel; +class SUIT_SelectionMgr; + +class HYDROGUI_Operation : public SUIT_Operation +{ + Q_OBJECT + +public: + HYDROGUI_Operation( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_Operation(); + + HYDROGUI_InputPanel* inputPanel() const; + SUIT_SelectionMgr* selectionMgr() const; + +protected: + virtual void startOperation(); + virtual HYDROGUI_InputPanel* createInputPanel() const = 0; + +protected slots: + virtual void OnSelectionDone(); + +private: + HYDROGUI_Module* myModule; + HYDROGUI_InputPanel* myPanel; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx new file mode 100644 index 00000000..9b7b0c1d --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -0,0 +1,71 @@ + +#include +#include +#include +#include +#include +#include + +QAction* HYDROGUI_Module::CreateAction( const int theId, const QString& theSuffix, const QString& theImg, + const int theKey, const bool isToggle, const QString& theSlot ) +{ + QString aSlot = theSlot; + if( aSlot.isEmpty() ) + aSlot = SLOT( onOperation() ); + SUIT_ResourceMgr* aMgr = application()->resourceMgr(); + std::string anImg = theImg.toStdString(); + QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aMgr->loadPixmap( "HYDROGUI", tr( anImg.c_str() ) ); + std::string aMenu = ( "MEN_" + theSuffix ).toStdString(); + std::string aDesktop = ( "DSK_" + theSuffix ).toStdString(); + std::string aToolbar = ( "STB_" + theSuffix ).toStdString(); + std::string aSlotStr = aSlot.toStdString(); + return LightApp_Module::createAction( theId, tr( aMenu.c_str() ), aPixmap, + tr( aDesktop.c_str() ), tr( aToolbar.c_str() ), + theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() ); +} + +void HYDROGUI_Module::CreateActions() +{ + CreateAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I ); +} + +void HYDROGUI_Module::CreateMenus() +{ + int aFileId = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 ); + + createMenu( separator(), aFileId, -1, 1, -1 ); + createMenu( ImportImageId, aFileId, -1, -1 ); +} + +void HYDROGUI_Module::CreatePopups() +{ +} + +void HYDROGUI_Module::CreateToolbars() +{ +} + +void HYDROGUI_Module::onOperation() +{ + const QAction* anAction = dynamic_cast( sender() ); + int anId = actionId( anAction ); + if( anId >= 0 ) + startOperation( anId ); +} + +LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const +{ + LightApp_Operation* anOp = 0; + HYDROGUI_Module* aModule = const_cast( this ); + switch( theId ) + { + case ImportImageId: + anOp = 0; + break; + } + + if( !anOp ) + anOp = LightApp_Module::createOperation( theId ); + + return anOp; +} diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h new file mode 100644 index 00000000..75fa4146 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -0,0 +1,12 @@ + +#ifndef HYDROGUI_OPERATIONS_HEADER +#define HYDROGUI_OPERATIONS_HEADER + +enum OperationId +{ + FirstId, + + ImportImageId +}; + +#endif diff --git a/src/HYDROGUI/resources/HYDRO.png b/src/HYDROGUI/resources/HYDRO.png new file mode 100755 index 00000000..7eba0d76 Binary files /dev/null and b/src/HYDROGUI/resources/HYDRO.png differ diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts new file mode 100644 index 00000000..aec9f527 --- /dev/null +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -0,0 +1,10 @@ + + + + @default + + TEST_ICO + icon_test.png + + + diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts new file mode 100644 index 00000000..dd0c8589 --- /dev/null +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -0,0 +1,10 @@ + + + + @default + + TEST + Test + + + diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_fr.ts b/src/HYDROGUI/resources/HYDROGUI_msg_fr.ts new file mode 100644 index 00000000..dd0c8589 --- /dev/null +++ b/src/HYDROGUI/resources/HYDROGUI_msg_fr.ts @@ -0,0 +1,10 @@ + + + + @default + + TEST + Test + + + diff --git a/src/HYDROGUI/resources/LightApp.xml b/src/HYDROGUI/resources/LightApp.xml new file mode 100644 index 00000000..d7895ac4 --- /dev/null +++ b/src/HYDROGUI/resources/LightApp.xml @@ -0,0 +1,19 @@ + + +
+ + + + +
+
+ +
+
+ + +
+
+ +
+
diff --git a/src/HYDROGUI/resources/SalomeApp.xml b/src/HYDROGUI/resources/SalomeApp.xml new file mode 100644 index 00000000..d7895ac4 --- /dev/null +++ b/src/HYDROGUI/resources/SalomeApp.xml @@ -0,0 +1,19 @@ + + +
+ + + + +
+
+ +
+
+ + +
+
+ +
+
diff --git a/src/HYDROOperations/HYDROOperations_Factory.cxx b/src/HYDROOperations/HYDROOperations_Factory.cxx index 974155b0..d327fc98 100644 --- a/src/HYDROOperations/HYDROOperations_Factory.cxx +++ b/src/HYDROOperations/HYDROOperations_Factory.cxx @@ -9,6 +9,8 @@ #include #include +#include + // global instance HYDROOperations_Factory* FACTORY = 0;