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})
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(
${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)
--- /dev/null
+
+#include <HYDROGUI_ColorWidget.h>
+#include <QColorDialog>
+
+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() );
+}*/
--- /dev/null
+
+#ifndef HYDROGUI_COLOR_WIDGET_HEADER
+#define HYDROGUI_COLOR_WIDGET_HEADER
+
+#include <QFrame>
+
+/** \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
--- /dev/null
+
+#include <HYDROGUI_ImportImageOp.h>
+
+HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule )
+ : HYDROGUI_Operation( theModule )
+{
+}
+
+HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp()
+{
+}
+
+HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
+{
+ return 0;
+}
--- /dev/null
+
+#ifndef HYDROGUI_IMPORT_IMAGE_OP_HEADER
+#define HYDROGUI_IMPORT_IMAGE_OP_HEADER
+
+#include <HYDROGUI_Operation.h>
+
+class HYDROGUI_ImportImageOp : public HYDROGUI_Operation
+{
+public:
+ HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_ImportImageOp();
+
+protected:
+ virtual HYDROGUI_InputPanel* createInputPanel() const;
+};
+
+#endif
{
}
+HYDROGUI_Module* HYDROGUI_InputPanel::module() const
+{
+ return myModule;
+}
+
void HYDROGUI_InputPanel::OnApply()
{
+ emit panelApply();
}
void HYDROGUI_InputPanel::OnCancel()
{
+ emit panelCancel();
}
void HYDROGUI_InputPanel::OnHelp()
aMainLayout->addWidget( new QLabel( theLabel, this ), aRow, 0 );
aMainLayout->addWidget( theWidget, aRow, 1 );
}
+
+void HYDROGUI_InputPanel::addSeparator()
+{
+ QGridLayout* aMainLayout = dynamic_cast<QGridLayout*>( 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<QGridLayout*>( myMainFrame->layout() );
+ int aRow = aMainLayout->rowCount();
+ aMainLayout->setRowStretch( aRow, 1 );
+}
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();
#include <QApplication>
#include <HYDROGUI_InputPanel.h>
#include <HYDROGUI_ObjSelector.h>
+#include <HYDROGUI_Operations.h>
extern "C" HYDRO_EXPORT CAM_Module* createModule()
{
void HYDROGUI_Module::initialize( CAM_Application* theApp )
{
+ printf( "Initialization of the HYDROGUI module\n" );
LightApp_Module::initialize( theApp );
CreateActions();
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 )
}
myObjName->setText( anObjName );
}
+
+QString HYDROGUI_ObjSelector::GetName() const
+{
+ return myObjName->text();
+}
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;
#include <HYDROGUI_Operation.h>
#include <HYDROGUI_Module.h>
#include <HYDROGUI_InputPanel.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_Iterator.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_Desktop.h>
+#include <SUIT_Study.h>
HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule )
-: SUIT_Operation( theModule->getApp() ), myModule( theModule ), myPanel( 0 )
+: LightApp_Operation(), myModule( theModule ), myPanel( 0 )
{
}
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();
+}
#define HYDROGUI_OPERATION_HEADER
#include <HYDROGUI.h>
-#include <SUIT_Operation.h>
+#include <LightApp_Operation.h>
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
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;
#include <HYDROGUI_Module.h>
#include <HYDROGUI_Operations.h>
+#include <HYDROGUI_ImportImageOp.h>
+#include <HYDROGUI_TwoImagesOp.h>
+
#include <CAM_Application.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Desktop.h>
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;
}
{
FirstId,
- ImportImageId
+ ImportImageId,
+ FuseId,
+ CutId,
};
#endif
--- /dev/null
+
+#include <HYDROGUI_TwoImagesDlg.h>
+#include <HYDROGUI_ObjSelector.h>
+#include <HYDROGUI_ColorWidget.h>
+#include <QLineEdit>
+#include <QRadioButton>
+#include <QLayout>
+
+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();
+}
--- /dev/null
+
+#ifndef HYDROGUI_TWO_IMAGE_DLG_HEADER
+#define HYDROGUI_TWO_IMAGE_DLG_HEADER
+
+#include <HYDROGUI_InputPanel.h>
+
+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
--- /dev/null
+
+#include <HYDROGUI_TwoImagesOp.h>
+#include <HYDROGUI_TwoImagesDlg.h>
+#include <HYDROData_Image.h>
+#include <HYDROData_Document.h>
+#include <HYDROOperations_Factory.h>
+
+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<HYDROGUI_TwoImagesDlg*>( 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 );
+}
--- /dev/null
+
+#ifndef HYDROGUI_TWO_IMAGE_OP_HEADER
+#define HYDROGUI_TWO_IMAGE_OP_HEADER
+
+#include <HYDROGUI_Operation.h>
+
+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