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 );
}
bool anIsHiddenInSelection = false;
bool anIsImage = false;
+ bool anIsPolyline = false;
foreach( SUIT_DataOwner* aSUITOwner, anOwners )
{
if( anObject->GetKind() == KIND_IMAGE )
anIsImage = true;
+
+ if( anObject->GetKind() == KIND_POLYLINE )
+ anIsPolyline = true;
}
}
}
theMenu->addSeparator();
}
+ if( anOwners.count() == 1 && anIsPolyline )
+ {
+ theMenu->addAction( action( EditPolylineId ) );
+ theMenu->addSeparator();
+ }
+
if( anIsSelection )
{
theMenu->addAction( action( DeleteId ) );
{
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" );
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 );
}
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 );
RedoId,
ImportImageId,
EditImageId,
- PolylineId,
+ CreatePolylineId,
+ EditPolylineId,
FuseId,
CutId,
DeleteId,
HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
{
}
+
+void HYDROGUI_PolylineDlg::reset()
+{
+}
\ No newline at end of file
HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle );
virtual ~HYDROGUI_PolylineDlg();
+ void reset();
protected slots:
signals:
//
// 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()
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
#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:
virtual bool processApply( int& theUpdateFlags );
+ virtual void startOperation();
+
+private:
+ bool myIsEdit;
+ Handle(HYDROData_Polyline) myEditedObject;
};
#endif
</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>