]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Observe Image operation.
authorouv <ouv@opencascade.com>
Wed, 21 Aug 2013 09:21:25 +0000 (09:21 +0000)
committerouv <ouv@opencascade.com>
Wed, 21 Aug 2013 09:21:25 +0000 (09:21 +0000)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_ObserveImageOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ObserveImageOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 79f867e86b32ce9e7c7775005f9c56aac28ab818..5231ebb93b06e6c1857444a13c279b9b75648cc3 100644 (file)
@@ -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
index 14c081255003be9a86e6ba8439faed75c4d14714..0baa3d6fd95c36a582be980464013bde95271afb 100644 (file)
@@ -228,8 +228,8 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
     dynamic_cast<GraphicsView_ViewManager*>( 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() )
index 567dab1ff2faa7035bdf8c1d5b144dfe538bb209..9b13d845d165a2d23caab1db3e8ae04ad8be5e86 100644 (file)
@@ -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 ) );
   }
 }
index 0b3bb0f2e1cfd481571e4f1ae65d54030e89a02c..8db2c13b32e0570c784d720779b32c79a1578f9b 100644 (file)
@@ -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 (file)
index 0000000..b559dbc
--- /dev/null
@@ -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 <HYDROData_Image.h>
+
+#include <LightApp_Application.h>
+
+#include <GraphicsView_ViewManager.h>
+#include <GraphicsView_Viewer.h>
+
+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<GraphicsView_ViewManager*>( 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 (file)
index 0000000..6cd5b41
--- /dev/null
@@ -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
index 634c20b75ec94464192ffaa360130c58eebc22be..e173c54b1538d7bd9b5070ab6c79191ba21c6b24 100644 (file)
@@ -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;
index c44fd694169dd9341163c2a97599a34bba0c2683..d8a2b9e8f0e311fd660f217b4992c73420e946d1 100644 (file)
@@ -30,6 +30,7 @@ enum OperationId
   RedoId,
   ImportImageId,
   EditImageId,
+  ObserveImageId,
   ExportImageId,
   CreatePolylineId,
   EditPolylineId,
index 4b39d55bf5d5cb00ebbc99f5a5e6da1f6a5f6614..5c935637c493616184f170ca52d32d37d36817ec 100644 (file)
       <translation>Import image</translation>
     </message>
     <message>
-      <source>MAPPING</source>
-      <translation>Mapping</translation>
+      <source>TRANSFORM_IMAGE</source>
+      <translation>Transform image</translation>
     </message>
     <message>
       <source>POINTS_A_B_C_BELONG_TO_SINGLE_LINE</source>
       <source>DSK_IMPORT_IMAGE</source>
       <translation>Import image</translation>
     </message>
+    <message>
+      <source>DSK_OBSERVE_IMAGE</source>
+      <translation>Observe image</translation>
+    </message>
     <message>
       <source>DSK_REDO</source>
       <translation>Redo</translation>
       <source>MEN_IMPORT_IMAGE</source>
       <translation>Import image</translation>
     </message>
+    <message>
+      <source>MEN_OBSERVE_IMAGE</source>
+      <translation>Observe image</translation>
+    </message>
     <message>
       <source>MEN_REDO</source>
       <translation>Redo</translation>
       <source>STB_IMPORT_IMAGE</source>
       <translation>Import image</translation>
     </message>
+    <message>
+      <source>STB_OBSERVE_IMAGE</source>
+      <translation>Observe image</translation>
+    </message>
     <message>
       <source>STB_REDO</source>
       <translation>Redo</translation>
       <translation>Hide all</translation>
     </message>
   </context>
+  <context>
+    <name>HYDROGUI_ObserveImageOp</name>
+    <message>
+      <source>OBSERVE_IMAGE</source>
+      <translation>Observe image</translation>
+    </message>
+  </context>
   <context>
     <name>HYDROGUI_TwoImagesDlg</name>
     <message>