From: ouv Date: Wed, 21 Aug 2013 09:21:25 +0000 (+0000) Subject: Observe Image operation. X-Git-Tag: BR_hydro_v_0_1~105 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=df03ea9aaf89174b8faa08eee7a371286c751a3e;p=modules%2Fhydro.git Observe Image operation. --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 79f867e8..5231ebb9 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -15,6 +15,7 @@ set(PROJECT_HEADERS HYDROGUI_InputPanel.h HYDROGUI_Module.h HYDROGUI_ObjSelector.h + HYDROGUI_ObserveImageOp.h HYDROGUI_Operation.h HYDROGUI_Operations.h HYDROGUI_PolylineDlg.h @@ -48,6 +49,7 @@ set(PROJECT_SOURCES HYDROGUI_InputPanel.cxx HYDROGUI_Module.cxx HYDROGUI_ObjSelector.cxx + HYDROGUI_ObserveImageOp.cxx HYDROGUI_Operation.cxx HYDROGUI_Operations.cxx HYDROGUI_PolylineDlg.cxx diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 14c08125..0baa3d6f 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -228,8 +228,8 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage ) dynamic_cast( anApp->createViewManager( GraphicsView_Viewer::Type() ) ); if( myPreviewViewManager ) { - module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_Mapping ); - myPreviewViewManager->setTitle( tr( "MAPPING" ) ); + module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_TransformImage ); + myPreviewViewManager->setTitle( tr( "TRANSFORM_IMAGE" ) ); if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() ) { if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() ) diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 567dab1f..9b13d845 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -171,6 +171,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, if( anIsImage ) { theMenu->addAction( action( EditImageId ) ); + theMenu->addAction( action( ObserveImageId ) ); theMenu->addAction( action( ExportImageId ) ); theMenu->addSeparator(); } @@ -434,7 +435,7 @@ void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent ) aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) ); } - else if( aRole == VMR_Mapping ) + else if( aRole == VMR_TransformImage ) aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) ); } } diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index 0b3bb0f2..8db2c13b 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -46,7 +46,7 @@ class HYDROGUI_Module : public LightApp_Module enum CustomEvent { NewViewEvent = QEvent::User + 100 }; public: - enum ViewManagerRole { VMR_Unknown = 0, VMR_General, VMR_Observe, VMR_Mapping }; + enum ViewManagerRole { VMR_Unknown = 0, VMR_General, VMR_TransformImage, VMR_ObserveImage }; typedef QPair< SUIT_ViewManager*, ViewManagerRole > ViewManagerInfo; typedef QMap < int, ViewManagerInfo > ViewManagerMap; diff --git a/src/HYDROGUI/HYDROGUI_ObserveImageOp.cxx b/src/HYDROGUI/HYDROGUI_ObserveImageOp.cxx new file mode 100644 index 00000000..b559dbc1 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ObserveImageOp.cxx @@ -0,0 +1,81 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#include "HYDROGUI_ObserveImageOp.h" + +#include "HYDROGUI_Module.h" +#include "HYDROGUI_PrsImage.h" +#include "HYDROGUI_Tool.h" + +#include + +#include + +#include +#include + +HYDROGUI_ObserveImageOp::HYDROGUI_ObserveImageOp( HYDROGUI_Module* theModule ) +: HYDROGUI_Operation( theModule ) +{ + setName( tr( "OBSERVE_IMAGE" ) ); +} + +HYDROGUI_ObserveImageOp::~HYDROGUI_ObserveImageOp() +{ +} + +void HYDROGUI_ObserveImageOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + Handle(HYDROData_Image) anImageObj = + Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( !anImageObj.IsNull() ) + { + QImage anImage = anImageObj->Image(); + QTransform aTransform = anImageObj->Trsf(); + + HYDROGUI_PrsImage* aPrs = new HYDROGUI_PrsImage( anImageObj ); + aPrs->setImage( anImage ); + aPrs->setTransform( aTransform ); + aPrs->compute(); + + LightApp_Application* anApp = module()->getApp(); + GraphicsView_ViewManager* aViewManager = + dynamic_cast( anApp->createViewManager( GraphicsView_Viewer::Type() ) ); + if( aViewManager ) + { + module()->setViewManagerRole( aViewManager, HYDROGUI_Module::VMR_ObserveImage ); + aViewManager->setTitle( anImageObj->GetName() ); + if( GraphicsView_Viewer* aViewer = aViewManager->getViewer() ) + { + if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() ) + { + aViewPort->addItem( aPrs ); + aViewPort->fitAll(); + } + } + } + } + + abort(); // do not commit the document command +} diff --git a/src/HYDROGUI/HYDROGUI_ObserveImageOp.h b/src/HYDROGUI/HYDROGUI_ObserveImageOp.h new file mode 100644 index 00000000..6cd5b417 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ObserveImageOp.h @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#ifndef HYDROGUI_OBSERVEIMAGEOP_H +#define HYDROGUI_OBSERVEIMAGEOP_H + +#include "HYDROGUI_Operation.h" + +class HYDROGUI_ObserveImageOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_ObserveImageOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_ObserveImageOp(); + +protected: + virtual void startOperation(); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 634c20b7..e173c54b 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -27,6 +27,7 @@ #include "HYDROGUI_ExportImageOp.h" #include "HYDROGUI_ImportImageOp.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_ObserveImageOp.h" #include "HYDROGUI_PolylineOp.h" #include "HYDROGUI_ShowHideOp.h" #include "HYDROGUI_TwoImagesOp.h" @@ -65,6 +66,7 @@ void HYDROGUI_Module::createActions() { createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I ); createAction( EditImageId, "EDIT_IMAGE" ); + createAction( ObserveImageId, "OBSERVE_IMAGE" ); createAction( ExportImageId, "EXPORT_IMAGE" ); createAction( CreatePolylineId, "CREATE_POLYLINE" ); createAction( EditPolylineId, "EDIT_POLYLINE" ); @@ -209,6 +211,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditImageId: anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImageId ); break; + case ObserveImageId: + anOp = new HYDROGUI_ObserveImageOp( aModule ); + break; case ExportImageId: anOp = new HYDROGUI_ExportImageOp( aModule ); break; diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index c44fd694..d8a2b9e8 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -30,6 +30,7 @@ enum OperationId RedoId, ImportImageId, EditImageId, + ObserveImageId, ExportImageId, CreatePolylineId, EditPolylineId, diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 4b39d55b..5c935637 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -117,8 +117,8 @@ Import image - MAPPING - Mapping + TRANSFORM_IMAGE + Transform image POINTS_A_B_C_BELONG_TO_SINGLE_LINE @@ -171,6 +171,10 @@ DSK_IMPORT_IMAGE Import image + + DSK_OBSERVE_IMAGE + Observe image + DSK_REDO Redo @@ -239,6 +243,10 @@ MEN_IMPORT_IMAGE Import image + + MEN_OBSERVE_IMAGE + Observe image + MEN_REDO Redo @@ -299,6 +307,10 @@ STB_IMPORT_IMAGE Import image + + STB_OBSERVE_IMAGE + Observe image + STB_REDO Redo @@ -354,6 +366,13 @@ Hide all + + HYDROGUI_ObserveImageOp + + OBSERVE_IMAGE + Observe image + + HYDROGUI_TwoImagesDlg