]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Edit polyline operation was added
authormtn <mtn@opencascade.com>
Fri, 9 Aug 2013 13:46:06 +0000 (13:46 +0000)
committermtn <mtn@opencascade.com>
Fri, 9 Aug 2013 13:46:06 +0000 (13:46 +0000)
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_PolylineDlg.cxx
src/HYDROGUI/HYDROGUI_PolylineDlg.h
src/HYDROGUI/HYDROGUI_PolylineOp.cxx
src/HYDROGUI/HYDROGUI_PolylineOp.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 461b493c9d73594aa759786346d4cab17dbb021d..71fe1237cedfffeeba1819c3cd764f1daa0fd0f8 100644 (file)
@@ -202,7 +202,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
   for( ; aPolyIterator.More(); aPolyIterator.Next() )
   {
     Handle(HYDROData_Polyline) aPolylineObj =
-      Handle(HYDROData_Polyline)::DownCast( anIterator.Current() );
+      Handle(HYDROData_Polyline)::DownCast( aPolyIterator.Current() );
     if( !aPolylineObj.IsNull() )
       createObject( aPolylineRootObj, aPolylineObj );
   }
index 9a377428af3184319e240f8e26785109c68b6c77..3a87b3745d61362cfd844290038401ebd291a238 100644 (file)
@@ -142,6 +142,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsHiddenInSelection = false;
 
   bool anIsImage = false;
+  bool anIsPolyline = false;
 
   foreach( SUIT_DataOwner* aSUITOwner, anOwners )
   {
@@ -158,6 +159,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
 
         if( anObject->GetKind() == KIND_IMAGE )
           anIsImage = true;
+
+        if( anObject->GetKind() == KIND_POLYLINE )
+          anIsPolyline = true;
       }
     }
   }
@@ -168,6 +172,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addSeparator();
   }
 
+  if( anOwners.count() == 1 && anIsPolyline )
+  {
+    theMenu->addAction( action( EditPolylineId ) );
+    theMenu->addSeparator();
+  }
+
   if( anIsSelection )
   {
     theMenu->addAction( action( DeleteId ) );
index ba62ab2203758320d9445972ba4b803dc16cbd91..e921a53242f4bd5c38886740d9a288fe72f81e55 100644 (file)
@@ -64,7 +64,8 @@ void HYDROGUI_Module::createActions()
 {
   createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
   createAction( EditImageId, "EDIT_IMAGE" );
-  createAction( PolylineId, "POLYLINE" );
+  createAction( CreatePolylineId, "CREATE_POLYLINE" );
+  createAction( EditPolylineId, "EDIT_POLYLINE" ); 
 
   createAction( FuseId, "FUSE_IMAGES" );
   createAction( CutId, "CUT_IMAGES" );
@@ -87,7 +88,7 @@ void HYDROGUI_Module::createMenus()
   int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
   int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
   createMenu( ImportImageId, aHydroId, -1, -1 );
-  createMenu( PolylineId, aHydroId, -1, -1 );
+  createMenu( CreatePolylineId, aHydroId, -1, -1 );
   createMenu( FuseId, aHydroId, -1, -1 );
   createMenu( CutId, aHydroId, -1, -1 );
 }
@@ -206,8 +207,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditImageId:
     anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImageId );
     break;
-  case PolylineId:
-    anOp = new HYDROGUI_PolylineOp( aModule );
+  case CreatePolylineId:
+  case EditPolylineId:
+    anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
     break;
   case FuseId:
     anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse );
index 22eca2ed4fe4ed45bf7d242a2bb8877f6e7db312..116d7a300f96f6867333f94f7e256c650fd156ba 100644 (file)
@@ -30,7 +30,8 @@ enum OperationId
   RedoId,
   ImportImageId,
   EditImageId,
-  PolylineId,
+  CreatePolylineId,
+  EditPolylineId,
   FuseId,
   CutId,
   DeleteId,
index 894bc23a12b9e53099671ab5a55264e20042393e..ef39f2af19e89049bc54a3d7e8ab925f2a82ef4a 100755 (executable)
@@ -42,3 +42,7 @@ HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QS
 HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
 {
 }
+
+void HYDROGUI_PolylineDlg::reset()
+{
+}
\ No newline at end of file
index 54c4ae258226eba19bb929d3e1f5626f3b280134..2204c68448a081d955bd976621381e2c66799ed5 100755 (executable)
@@ -34,6 +34,7 @@ public:
   HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_PolylineDlg();
 
+  void  reset();
 protected slots:
 
 signals:
index cfe2c92257ec5f314a975a827e2a30b20367e34a..774f3c3646b0bb14566fdee388b2d2cf38da3914 100755 (executable)
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-
+#include "HYDROGUI_Module.h"
 #include "HYDROGUI_PolylineOp.h"
 #include "HYDROGUI_PolylineDlg.h"
+#include "HYDROGUI_Tool.h"
 
-#include "HYDROGUI_Module.h"
+#include <HYDROData_Document.h>
+#include <HYDROData_Polyline.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
 
 
-HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule )
-: HYDROGUI_Operation( theModule )
+HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit )
+: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit)
 {
-  setName( tr("POLYLINE") );
+  setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) );
 }
 
 HYDROGUI_PolylineOp::~HYDROGUI_PolylineOp()
@@ -43,5 +48,45 @@ HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const
 
 bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags )
 {
+  HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
+
+  int aStudyId = module()->getStudyId();
+  bool aHasDoc = HYDROData_Document::HasDocument(aStudyId);
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
+  if( aDocument.IsNull() )
+    return false;
+
+  Handle(HYDROData_Polyline) aPolylineObj;
+  if( myIsEdit ){
+    aPolylineObj = myEditedObject;
+  }
+  else{
+    aPolylineObj = Handle(HYDROData_Polyline)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) );
+  }
+
+  if( aPolylineObj.IsNull() )
+    return false;
+
+  if( !myIsEdit ){
+    static int PolylineId = 0;
+    aPolylineObj->SetName( QString( "Polyline_%1" ).arg( QString::number( ++PolylineId ) ) );
+  }
+
+  aPolylineObj->SetVisibility( true );
+
+  theUpdateFlags = UF_Model | UF_Viewer;
   return true;
 }
+
+void HYDROGUI_PolylineOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
+  aPanel->reset();
+
+  myEditedObject = Handle(HYDROData_Polyline)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+  if( !myEditedObject.IsNull() )
+  {
+  }
+}
\ No newline at end of file
index be473d9774e553d6b6a3f71e6a5b7a517cf603de..d337760364507648d58021db0ba39a454e69aeb9 100755 (executable)
 
 #include "HYDROGUI_Operation.h"
 
+#include <HYDROData_Polyline.h>
+
 class HYDROGUI_PolylineOp : public HYDROGUI_Operation
 {
   Q_OBJECT
 
 public:
-  HYDROGUI_PolylineOp( HYDROGUI_Module* theModule );
+  HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool isEdit );
   virtual ~HYDROGUI_PolylineOp();
 
 protected:
@@ -38,6 +40,11 @@ protected:
 
   virtual bool processApply( int& theUpdateFlags );
 
+  virtual void startOperation();
+
+private:
+  bool                       myIsEdit;
+  Handle(HYDROData_Polyline) myEditedObject;
 };
 
 #endif
index 3fe2979d63814a3b055c63067d4e1ed63282fea3..30f70b53d7de08ca3e43223b10d1bac5c114cf83 100644 (file)
   </context>
   <context>
     <name>HYDROGUI_Module</name>
+    <message>
+      <source>DSK_CREATE_POLYLINE</source>
+      <translation>Create polyline</translation>
+    </message>
     <message>
       <source>DSK_CUT_IMAGES</source>
       <translation>Cut images</translation>
       <source>DSK_EDIT_IMAGE</source>
       <translation>Edit image</translation>
     </message>
+    <message>
+      <source>DSK_EDIT_POLYLINE</source>
+      <translation>Edit polyline</translation>
+    </message>
     <message>
       <source>DSK_FUSE_IMAGES</source>
       <translation>Fuse images</translation>
       <source>DSK_IMPORT_IMAGE</source>
       <translation>Import image</translation>
     </message>
-    <message>
-      <source>DSK_POLYLINE</source>
-      <translation>Create polyline</translation>
-    </message>
     <message>
       <source>DSK_REDO</source>
       <translation>Redo</translation>
       <source>HYDRO_TOOLBAR</source>
       <translation>HYDRO toolbar</translation>
     </message>
+    <message>
+      <source>MEN_CREATE_POLYLINE</source>
+      <translation>Create polyline</translation>
+    </message>
     <message>
       <source>MEN_CUT_IMAGES</source>
       <translation>Cut images</translation>
       <source>MEN_EDIT_IMAGE</source>
       <translation>Edit image</translation>
     </message>
+    <message>
+      <source>MEN_EDIT_POLYLINE</source>
+      <translation>Create polyline</translation>
+    </message>
     <message>
       <source>MEN_FUSE_IMAGES</source>
       <translation>Fuse images</translation>
       <source>MEN_IMPORT_IMAGE</source>
       <translation>Import image</translation>
     </message>
-    <message>
-      <source>MEN_POLYLINE</source>
-      <translation>Create polyline</translation>
-    </message>
     <message>
       <source>MEN_REDO</source>
       <translation>Redo</translation>
       <source>MEN_UNDO</source>
       <translation>Undo</translation>
     </message>
+    <message>
+      <source>STB_CREATE_POLYLINE</source>
+      <translation>Create polyline</translation>
+    </message>
     <message>
       <source>STB_CUT_IMAGES</source>
       <translation>Cut images</translation>
       <source>STB_EDIT_IMAGE</source>
       <translation>Edit image</translation>
     </message>
+    <message>
+      <source>STB_EDIT_POLYLINE</source>
+      <translation>Edit polyline</translation>
+    </message>
     <message>
       <source>STB_FUSE_IMAGES</source>
       <translation>Fuse images</translation>
       <source>STB_IMPORT_IMAGE</source>
       <translation>Import image</translation>
     </message>
-    <message>
-      <source>STB_POLYLINE</source>
-      <translation>Create polyline</translation>
-    </message>
     <message>
       <source>STB_REDO</source>
       <translation>Redo</translation>
       <translation>Undo</translation>
     </message>
   </context>
+  <context>
+    <name>HYDROGUI_PolylineOp</name>
+    <message>
+      <source>CREATE_POLYLINE</source>
+      <translation>Create polyline</translation>
+    </message>
+    <message>
+      <source>EDIT_POLYLINE</source>
+      <translation>Edit polyline</translation>
+    </message>
+  </context>
   <context>
     <name>HYDROGUI_ShowHideOp</name>
     <message>