From c66fbd26a75a044039dc2b2f8dea2249582deabc Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 26 Jul 2013 09:35:01 +0000 Subject: [PATCH] basic implementation of images operations support --- src/HYDROGUI/CMakeLists.txt | 13 +++++- src/HYDROGUI/HYDROGUI_ColorWidget.cxx | 56 ++++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_ColorWidget.h | 42 ++++++++++++++++++ src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx | 0 src/HYDROGUI/HYDROGUI_ImportImageDlg.h | 0 src/HYDROGUI/HYDROGUI_ImportImageOp.cxx | 16 +++++++ src/HYDROGUI/HYDROGUI_ImportImageOp.h | 17 +++++++ src/HYDROGUI/HYDROGUI_InputPanel.cxx | 26 +++++++++++ src/HYDROGUI/HYDROGUI_InputPanel.h | 8 ++++ src/HYDROGUI/HYDROGUI_Module.cxx | 12 ++--- src/HYDROGUI/HYDROGUI_ObjSelector.cxx | 5 +++ src/HYDROGUI/HYDROGUI_ObjSelector.h | 2 + src/HYDROGUI/HYDROGUI_Operation.cxx | 53 +++++++++++++++++----- src/HYDROGUI/HYDROGUI_Operation.h | 13 ++++-- src/HYDROGUI/HYDROGUI_Operations.cxx | 11 ++++- src/HYDROGUI/HYDROGUI_Operations.h | 4 +- src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx | 45 +++++++++++++++++++ src/HYDROGUI/HYDROGUI_TwoImagesDlg.h | 27 ++++++++++++ src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx | 40 +++++++++++++++++ src/HYDROGUI/HYDROGUI_TwoImagesOp.h | 25 +++++++++++ 20 files changed, 389 insertions(+), 26 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_ColorWidget.cxx create mode 100644 src/HYDROGUI/HYDROGUI_ColorWidget.h create mode 100644 src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx create mode 100644 src/HYDROGUI/HYDROGUI_ImportImageDlg.h create mode 100644 src/HYDROGUI/HYDROGUI_ImportImageOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_ImportImageOp.h create mode 100644 src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx create mode 100644 src/HYDROGUI/HYDROGUI_TwoImagesDlg.h create mode 100644 src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_TwoImagesOp.h diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 9f2554a3..b6c0cc71 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -8,6 +8,11 @@ set(PROJECT_HEADERS HYDROGUI_ObjSelector.h HYDROGUI_Operation.h HYDROGUI_Operations.h + HYDROGUI_ImportImageOp.h + HYDROGUI_ImportImageDlg.h + HYDROGUI_TwoImagesOp.h + HYDROGUI_TwoImagesDlg.h + HYDROGUI_ColorWidget.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -18,6 +23,11 @@ set(PROJECT_SOURCES HYDROGUI_ObjSelector.cxx HYDROGUI_Operation.cxx HYDROGUI_Operations.cxx + HYDROGUI_ImportImageOp.cxx + HYDROGUI_ImportImageDlg.cxx + HYDROGUI_TwoImagesOp.cxx + HYDROGUI_TwoImagesDlg.cxx + HYDROGUI_ColorWidget.cxx ) add_definitions( @@ -33,10 +43,11 @@ include_directories( ${GUI_ROOT_DIR}/include/salome ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROData + ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROOperations ) add_library(HYDROGUI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${PROJECT_HEADERS_MOC}) -target_link_libraries(HYDROGUI ${CAS_OCAF}) +target_link_libraries(HYDROGUI ${CAS_OCAF} HYDROData HYDROOperations) set(PROJECT_LIBRARIES HYDROGUI) diff --git a/src/HYDROGUI/HYDROGUI_ColorWidget.cxx b/src/HYDROGUI/HYDROGUI_ColorWidget.cxx new file mode 100644 index 00000000..312b9283 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ColorWidget.cxx @@ -0,0 +1,56 @@ + +#include +#include + +HYDROGUI_ColorWidget::HYDROGUI_ColorWidget( QWidget* parent ) +: QFrame( parent ) +{ + setFrameShape( QFrame::Box ); + //setFixedSize( 40, 20 ); + //commented for correct layout management + //(otherwise the column with color widget can not be resized + //and all free space is arranged on sides +} + +HYDROGUI_ColorWidget::~HYDROGUI_ColorWidget() +{ +} + +QColor HYDROGUI_ColorWidget::color() const +{ + QPalette aPalette = palette(); + return aPalette.color( QPalette::Window ); +} + +void HYDROGUI_ColorWidget::setColor( const QColor& c ) +{ + QPalette aPalette = palette(); + aPalette.setColor( QPalette::Window, c ); + setAutoFillBackground( true ); + setPalette( aPalette ); +} + +void HYDROGUI_ColorWidget::mouseDoubleClickEvent( QMouseEvent* ) +{ + QColor c = QColorDialog::getColor( color(), this ); + if( c.isValid() ) + { + setColor( c ); + emit colorChanged( c ); + } +} +/* +int HYDROGUI_ColorWidget::intColor() const +{ + return HYDROGUI_Tools::color2int( color() ); +} + +void HYDROGUI_ColorWidget::setColor( const int col ) +{ + setColor( HYDROGUI_Tools::int2color( col ) ); +} +*/ +/*void HYDROGUI_ColorWidget::setRandColor() +{ + setColor( HYDROGUI_Tools::randColor() ); +}*/ diff --git a/src/HYDROGUI/HYDROGUI_ColorWidget.h b/src/HYDROGUI/HYDROGUI_ColorWidget.h new file mode 100644 index 00000000..6cb802e5 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ColorWidget.h @@ -0,0 +1,42 @@ + +#ifndef HYDROGUI_COLOR_WIDGET_HEADER +#define HYDROGUI_COLOR_WIDGET_HEADER + +#include + +/** \class HYDROGUI_ColorWidget + * \brief The class representing widget for color selection + */ +class HYDROGUI_ColorWidget : public QFrame +{ + Q_OBJECT + +public: + /** Constructor + * \param parent - parent widget + */ + HYDROGUI_ColorWidget( QWidget* parent ); + /** Destructor */ + virtual ~HYDROGUI_ColorWidget(); + + /** \return color value */ + QColor color() const; + /** Sets color value */ + void setColor( const QColor& ); + /** \return color value in the integer form */ + //int intColor() const; + /** Sets color value in the integer form */ + //void setColor( const int ); + /** Sets a randomized color as current value */ + //void setRandColor(); + +signals: + /** is emitted when signal is changed */ + void colorChanged( const QColor& ); + +protected: + /** mouse double click event handler, activates the standard color dialog for color choice */ + virtual void mouseDoubleClickEvent( QMouseEvent* ); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx new file mode 100644 index 00000000..e69de29b diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h new file mode 100644 index 00000000..e69de29b diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx new file mode 100644 index 00000000..9b0093c2 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -0,0 +1,16 @@ + +#include + +HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule ) + : HYDROGUI_Operation( theModule ) +{ +} + +HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp() +{ +} + +HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const +{ + return 0; +} diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h new file mode 100644 index 00000000..d9011c56 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -0,0 +1,17 @@ + +#ifndef HYDROGUI_IMPORT_IMAGE_OP_HEADER +#define HYDROGUI_IMPORT_IMAGE_OP_HEADER + +#include + +class HYDROGUI_ImportImageOp : public HYDROGUI_Operation +{ +public: + HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_ImportImageOp(); + +protected: + virtual HYDROGUI_InputPanel* createInputPanel() const; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index a48f65ad..6e3181f9 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -46,12 +46,19 @@ HYDROGUI_InputPanel::~HYDROGUI_InputPanel() { } +HYDROGUI_Module* HYDROGUI_InputPanel::module() const +{ + return myModule; +} + void HYDROGUI_InputPanel::OnApply() { + emit panelApply(); } void HYDROGUI_InputPanel::OnCancel() { + emit panelCancel(); } void HYDROGUI_InputPanel::OnHelp() @@ -65,3 +72,22 @@ void HYDROGUI_InputPanel::addWidget( const QString& theLabel, QWidget* theWidget aMainLayout->addWidget( new QLabel( theLabel, this ), aRow, 0 ); aMainLayout->addWidget( theWidget, aRow, 1 ); } + +void HYDROGUI_InputPanel::addSeparator() +{ + QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + int aRow = aMainLayout->rowCount(); + + QFrame* aLine = new QFrame(); + aLine->setFrameShape( QFrame::HLine ); + aLine->setFrameShadow( QFrame::Sunken ); + + aMainLayout->addWidget( aLine, aRow, 0, 1, 2 ); +} + +void HYDROGUI_InputPanel::setRowStretch() +{ + QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + int aRow = aMainLayout->rowCount(); + aMainLayout->setRowStretch( aRow, 1 ); +} diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index e1801c10..33d36217 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -21,6 +21,14 @@ public: virtual ~HYDROGUI_InputPanel(); void addWidget( const QString& theLabel, QWidget* theWidget ); + void addSeparator(); + void setRowStretch(); + + HYDROGUI_Module* module() const; + +signals: + void panelApply(); + void panelCancel(); protected slots: void OnApply(); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 1ddd42d3..bad6da24 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -12,6 +12,7 @@ #include #include #include +#include extern "C" HYDRO_EXPORT CAM_Module* createModule() { @@ -29,6 +30,7 @@ HYDROGUI_Module::~HYDROGUI_Module() void HYDROGUI_Module::initialize( CAM_Application* theApp ) { + printf( "Initialization of the HYDROGUI module\n" ); LightApp_Module::initialize( theApp ); CreateActions(); @@ -38,14 +40,8 @@ void HYDROGUI_Module::initialize( CAM_Application* theApp ) 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(); + //startOperation( ImportImageId ); + startOperation( FuseId ); } bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx index 9a6016ee..02c737bb 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx @@ -75,3 +75,8 @@ void HYDROGUI_ObjSelector::OnSelectionChanged() } myObjName->setText( anObjName ); } + +QString HYDROGUI_ObjSelector::GetName() const +{ + return myObjName->text(); +} diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.h b/src/HYDROGUI/HYDROGUI_ObjSelector.h index 55c463b4..427ddd93 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.h +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.h @@ -16,6 +16,8 @@ public: HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent ); virtual ~HYDROGUI_ObjSelector(); + QString GetName() const; + protected: virtual void paintEvent( QPaintEvent* ); virtual bool hitButton( const QPoint& thePnt ) const; diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 6bd7e444..3b74134f 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -2,12 +2,15 @@ #include #include #include +#include +#include #include #include #include +#include HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule ) -: SUIT_Operation( theModule->getApp() ), myModule( theModule ), myPanel( 0 ) +: LightApp_Operation(), myModule( theModule ), myPanel( 0 ) { } @@ -20,31 +23,57 @@ SUIT_SelectionMgr* HYDROGUI_Operation::selectionMgr() const return myModule->getApp()->selectionMgr(); } -void HYDROGUI_Operation::startOperation() +HYDROGUI_Module* HYDROGUI_Operation::module() const { - /*TODO: if( myIsTransactional && doc() ) - doc()->OpenTransaction();*/ + return myModule; +} - if( selectionMgr() ) - connect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( OnSelectionDone() ) ); +void HYDROGUI_Operation::startOperation() +{ + doc()->StartOperation(); if( inputPanel() ) { - //TODO: connect( inputPanel(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); - //TODO: connect( inputPanel(), SIGNAL( dlgCancel() ), this, SLOT( abort() ) ); + connect( inputPanel(), SIGNAL( panelApply() ), this, SLOT( OnApply() ) ); + connect( inputPanel(), SIGNAL( panelCancel() ), this, SLOT( OnCancel() ) ); 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; } + +Handle_HYDROData_Document HYDROGUI_Operation::doc() const +{ + int aStudyId = myModule->application()->activeStudy()->id(); + return HYDROData_Document::Document( aStudyId ); +} + +void HYDROGUI_Operation::OnApply() +{ + doc()->CommitOperation(); + inputPanel()->hide(); +} + +void HYDROGUI_Operation::OnCancel() +{ + doc()->AbortOperation(); + inputPanel()->hide(); +} + +Handle_HYDROData_Object HYDROGUI_Operation::FindObjectByName( const QString& theName, int theKind ) const +{ + HYDROData_Iterator anIt( doc(), theKind ); + for( ; anIt.More(); anIt.Next() ) + { + if( anIt.Current()->GetName() == theName ) + return anIt.Current(); + } + return Handle_HYDROData_Object(); +} diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 04db8ead..67938e59 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -3,13 +3,15 @@ #define HYDROGUI_OPERATION_HEADER #include -#include +#include class HYDROGUI_Module; class HYDROGUI_InputPanel; class SUIT_SelectionMgr; +class Handle_HYDROData_Document; +class Handle_HYDROData_Object; -class HYDROGUI_Operation : public SUIT_Operation +class HYDROGUI_Operation : public LightApp_Operation { Q_OBJECT @@ -19,13 +21,18 @@ public: HYDROGUI_InputPanel* inputPanel() const; SUIT_SelectionMgr* selectionMgr() const; + HYDROGUI_Module* module() const; protected: virtual void startOperation(); virtual HYDROGUI_InputPanel* createInputPanel() const = 0; + Handle_HYDROData_Document doc() const; + Handle_HYDROData_Object FindObjectByName( const QString& theName, int theKind ) const; + protected slots: - virtual void OnSelectionDone(); + virtual void OnApply(); + virtual void OnCancel(); private: HYDROGUI_Module* myModule; diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 9b7b0c1d..0a23fe33 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -1,6 +1,9 @@ #include #include +#include +#include + #include #include #include @@ -60,7 +63,13 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const switch( theId ) { case ImportImageId: - anOp = 0; + anOp = new HYDROGUI_ImportImageOp( aModule ); + break; + case FuseId: + anOp = new HYDROGUI_TwoImagesOp( aModule, tr( "FUSE_OP" ) ); + break; + case CutId: + anOp = new HYDROGUI_TwoImagesOp( aModule, tr( "CUT_OP" ) ); break; } diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 75fa4146..ad5aab33 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -6,7 +6,9 @@ enum OperationId { FirstId, - ImportImageId + ImportImageId, + FuseId, + CutId, }; #endif diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx new file mode 100644 index 00000000..98ab08cc --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx @@ -0,0 +1,45 @@ + +#include +#include +#include +#include +#include +#include + +HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ) +{ + printf( "two images operation\n" ); + myName = new QLineEdit(); + myImage1 = new HYDROGUI_ObjSelector( module(), 0 ); + myImage2 = new HYDROGUI_ObjSelector( module(), 0 ); + myTransparent = new QRadioButton( tr( "TRANSPARENT" ) ); + myTransparent->setChecked( true ); + myColor = new QRadioButton( tr( "COLOR" ) ); + myColorBox = new HYDROGUI_ColorWidget( 0 ); + + addWidget( tr( "NAME" ), myName ); + addSeparator(); + addWidget( tr( "IMAGE_1" ), myImage1 ); + addWidget( tr( "IMAGE_2" ), myImage2 ); + + QFrame* aBackground = new QFrame(); + QGridLayout* aLayout = new QGridLayout( aBackground ); + aLayout->addWidget( myTransparent, 0, 0 ); + aLayout->addWidget( myColor, 1, 0 ); + aLayout->addWidget( myColorBox, 1, 1 ); + + addWidget( tr( "BACKGROUND" ), aBackground ); + addSeparator(); + setRowStretch(); +} + +HYDROGUI_TwoImagesDlg::~HYDROGUI_TwoImagesDlg() +{ +} + +void HYDROGUI_TwoImagesDlg::GetSelectedImages( QString& theName1, QString& theName2 ) const +{ + theName1 = myImage1->GetName(); + theName2 = myImage2->GetName(); +} diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h new file mode 100644 index 00000000..0bd57bc5 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h @@ -0,0 +1,27 @@ + +#ifndef HYDROGUI_TWO_IMAGE_DLG_HEADER +#define HYDROGUI_TWO_IMAGE_DLG_HEADER + +#include + +class QLineEdit; +class HYDROGUI_ObjSelector; +class QRadioButton; +class HYDROGUI_ColorWidget; + +class HYDROGUI_TwoImagesDlg : public HYDROGUI_InputPanel +{ +public: + HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_TwoImagesDlg(); + + void GetSelectedImages( QString& theEntry1, QString& theEntry2 ) const; + +private: + QLineEdit* myName; + HYDROGUI_ObjSelector *myImage1, *myImage2; + QRadioButton *myTransparent, *myColor; + HYDROGUI_ColorWidget* myColorBox; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx new file mode 100644 index 00000000..5a9a1711 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx @@ -0,0 +1,40 @@ + +#include +#include +#include +#include +#include + +HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const QString& theTitle ) + : HYDROGUI_Operation( theModule ), myTitle( theTitle ) +{ +} + +HYDROGUI_TwoImagesOp::~HYDROGUI_TwoImagesOp() +{ +} + +HYDROGUI_InputPanel* HYDROGUI_TwoImagesOp::createInputPanel() const +{ + return new HYDROGUI_TwoImagesDlg( module(), myTitle ); +} + +void HYDROGUI_TwoImagesOp::OnApply() +{ + HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast( inputPanel() ); + QString aName1, aName2; + aPanel->GetSelectedImages( aName1, aName2 ); + + Handle_HYDROData_Image anImage1 = Handle_HYDROData_Image::DownCast( + FindObjectByName( aName1, KIND_IMAGE ) ); + Handle_HYDROData_Image anImage2 = Handle_HYDROData_Image::DownCast( + FindObjectByName( aName2, KIND_IMAGE ) ); + + HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory(); + ImageComposer_Operator* anOperator = 0; //TODO + + Handle(HYDROData_Image) aResult = aFactory->CreateImage( doc(), anOperator ); + aResult->AppendReference( anImage1 ); + aResult->AppendReference( anImage2 ); + aFactory->UpdateImage( doc(), aResult ); +} diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.h b/src/HYDROGUI/HYDROGUI_TwoImagesOp.h new file mode 100644 index 00000000..59404f65 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.h @@ -0,0 +1,25 @@ + +#ifndef HYDROGUI_TWO_IMAGE_OP_HEADER +#define HYDROGUI_TWO_IMAGE_OP_HEADER + +#include + +class HYDROGUI_TwoImagesOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_TwoImagesOp(); + +protected: + virtual HYDROGUI_InputPanel* createInputPanel() const; + +protected slots: + virtual void OnApply(); + +private: + QString myTitle; +}; + +#endif -- 2.39.2