]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Few GUI modifications related to the Create Polyline functionality.
authorouv <ouv@opencascade.com>
Fri, 20 Sep 2013 15:27:31 +0000 (15:27 +0000)
committerouv <ouv@opencascade.com>
Fri, 20 Sep 2013 15:27:31 +0000 (15:27 +0000)
src/HYDROGUI/HYDROGUI_InputPanel.cxx
src/HYDROGUI/HYDROGUI_InputPanel.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 a20c755bcfb3d782e399589d54e65d6deae0892f..5b9fa21d02f1ce9bb94b2cc4c5213dd1b6b99fed 100644 (file)
@@ -28,7 +28,6 @@
 
 #include <QLayout>
 #include <QPushButton>
-#include <QStackedLayout>
 
 HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle )
 : QDockWidget( theModule->application()->desktop() ),
@@ -43,17 +42,14 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr
   QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
   
   myMainFrame = new QFrame( aFrame );
-  QVBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
+  QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
   aMainLayout->setMargin( 0 );
   aMainLayout->setSpacing( 5 );
 
-  myStackedLayout = new QStackedLayout();
-
   myBtnFrame = new QFrame( aFrame );
-  activateWidget( myBtnFrame );
   
-  aLayout->addWidget( myMainFrame, 3 );
-  aLayout->addLayout( myStackedLayout, 1 );
+  aLayout->addWidget( myMainFrame, 1 );
+  aLayout->addWidget( myBtnFrame, 0 );
 
   QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
   aBtnsLayout->setMargin( 5 );
@@ -96,10 +92,10 @@ void HYDROGUI_InputPanel::onHelp()
 {
 }
 
-void HYDROGUI_InputPanel::addWidget( QWidget* theWidget )
+void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch )
 {
   QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
-  aMainLayout->addWidget( theWidget );
+  aMainLayout->addWidget( theWidget, theStretch );
 }
 
 void HYDROGUI_InputPanel::addLayout( QLayout* theLayout )
@@ -118,15 +114,3 @@ QFrame* HYDROGUI_InputPanel::mainFrame() const
 {
   return myMainFrame;
 }
-
-void HYDROGUI_InputPanel::activateWidget( QWidget* theWidget )
-{
-  if (theWidget == 0) {
-    myStackedLayout->setCurrentIndex( 0 );
-  }
-  else { 
-    if ( myStackedLayout->indexOf( theWidget ) == -1 )
-      myStackedLayout->addWidget( theWidget );
-    myStackedLayout->setCurrentWidget( theWidget );
-  }
-}
index 7c3c829b404e9c5e45d9c110b74bb235700cf8a0..9d16ad0f225682be2e4ae113ef9a843ec161133a 100644 (file)
@@ -28,7 +28,6 @@
 class QFrame;
 class QPushButton;
 class QLayout;
-class QStackedLayout;
 
 class HYDROGUI_Module;
 
@@ -43,12 +42,10 @@ public:
   HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_InputPanel();
 
-  void addWidget( QWidget* theWidget );
+  void addWidget( QWidget* theWidget, int theStretch = 0 );
   void addLayout( QLayout* theLayout );
   void addStretch();
 
-  void addToStackedLayout( QWidget* );
-  void activateWidget( QWidget* );
   HYDROGUI_Module* module() const;
 
 signals:
@@ -70,7 +67,6 @@ private:
   QPushButton* myApply;
   QPushButton* myCancel;
   QPushButton* myHelp;
-  QStackedLayout* myStackedLayout;
 };
 
 #endif
index 40a831d80db3cab3a7a59f1fe96dfed29b8fc29d..e68a8f6743e1549eb2173c98e26e89ff9b114e61 100755 (executable)
@@ -26,6 +26,7 @@
 #include <CurveCreator_Widget.h>
 #include <CurveCreator_Curve.hxx>
 
+#include <QGroupBox>
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QLineEdit>
@@ -41,14 +42,21 @@ HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QS
 
   addLayout(aNameLayout);
 
-  myEditorWidget =
-    new CurveCreator_Widget( this, NULL );
+  myEditorWidget = new CurveCreator_Widget( this, NULL );
+  addWidget( myEditorWidget, 3 );
 
-  addWidget( myEditorWidget );
+  myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this );
+  addWidget( myAddElementBox, 2 );
+
+  QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
+  anAddElementLayout->setMargin( 0 );
+  anAddElementLayout->setSpacing( 5 );
 
   connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
   connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*) ), this, SLOT( processStartedSubOperation(QWidget*) ) );
   connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
+
+  myAddElementBox->hide();
 }
 
 HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
@@ -58,13 +66,23 @@ HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
 void HYDROGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget )
 {
   myEditorWidget->setEnabled( false );
-  activateWidget( theWidget );
+
+  QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
+  anAddElementLayout->addWidget( theWidget );
+
+  theWidget->show();
+  myAddElementBox->show();
 }
 
 void HYDROGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
 {
   myEditorWidget->setEnabled( true );
-  activateWidget( 0 );
+
+  QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
+  anAddElementLayout->removeWidget( theWidget );
+
+  theWidget->hide();
+  myAddElementBox->hide();
 }
 
 void HYDROGUI_PolylineDlg::reset()
index 4ca803fa320a141c19c16f56bf70602d86cd647b..01d5a13cbe206cd06d63602f1c05c54cb305ac59 100755 (executable)
@@ -25,7 +25,7 @@
 
 #include "HYDROGUI_InputPanel.h"
 
-
+class QGroupBox;
 class QLineEdit;
 class CurveCreator_Widget;
 class CurveCreator_Curve;
@@ -60,6 +60,7 @@ signals:
 private:
   QLineEdit*            myName;
   CurveCreator_Widget*  myEditorWidget;
+  QGroupBox*            myAddElementBox;
 };
 
 #endif
index 2e3ad922dd59aa4fa5499485f1ca2010a5dfe494..b8b19f763778e2b1a2cbb63b3c2aef813004fc0a 100755 (executable)
@@ -52,6 +52,7 @@ HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIs
 
 HYDROGUI_PolylineOp::~HYDROGUI_PolylineOp()
 {
+  closePreview();
 }
 
 HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const
@@ -121,6 +122,9 @@ void HYDROGUI_PolylineOp::onCreatePreview()
     dynamic_cast<OCCViewer_ViewManager*>( anApp->createViewManager( OCCViewer_Viewer::Type() ) );
   if( myPreviewViewManager )
   {
+    connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+             this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
     //anApp->selectionMgr()->setEnabled(false); // what the hell?!
     myPreviewViewManager->setTitle( tr( "CREATE_POLYLINE" ) );
     OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
@@ -188,6 +192,20 @@ void HYDROGUI_PolylineOp::startOperation()
   onCreatePreview();
 }
 
+void HYDROGUI_PolylineOp::abortOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_PolylineOp::commitOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::commitOperation();
+}
+
 void HYDROGUI_PolylineOp::onEditorSelectionChanged()
 {
   HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
@@ -205,3 +223,26 @@ void HYDROGUI_PolylineOp::onEditorSelectionChanged()
     }
   }
 }
+
+void HYDROGUI_PolylineOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
+{
+  closePreview();
+}
+
+void HYDROGUI_PolylineOp::closePreview()
+{
+  if( myPreviewViewManager )
+  {
+    disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+                this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+    module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
+    myPreviewViewManager = 0;
+  }
+
+  if( myActiveViewManager )
+  {
+    HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
+    myActiveViewManager = 0;
+  }
+}
index 2502c970b541aad060833c3341893697e0da45a7..28667125ae145d5422d481d5cb0bcd7d0474130d 100755 (executable)
@@ -27,9 +27,9 @@
 
 #include <HYDROData_Polyline.h>
 
-class CurveCreator_Curve;
-class SUIT_ViewManager;
 class OCCViewer_ViewManager;
+class SUIT_ViewManager;
+class CurveCreator_Curve;
 class HYDROGUI_AISCurve;
 
 class HYDROGUI_PolylineOp : public HYDROGUI_Operation
@@ -41,21 +41,28 @@ public:
   virtual ~HYDROGUI_PolylineOp();
 
 protected:
+  virtual void               startOperation();
+  virtual void               abortOperation();
+  virtual void               commitOperation();
+
   virtual HYDROGUI_InputPanel* createInputPanel() const;
 
-  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+  virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg );
 
-  virtual void startOperation();
-  
-  void onCreatePreview();
+  void                       onCreatePreview();
 
 protected slots:
-  void onEditorSelectionChanged();
+  void                       onEditorSelectionChanged();
+
+  void                       onLastViewClosed( SUIT_ViewManager* );
+
+private:
+  void                       closePreview();
 
 private:
-  SUIT_ViewManager*           myActiveViewManager;
+  SUIT_ViewManager*          myActiveViewManager;
 
-  OCCViewer_ViewManager*      myPreviewViewManager;
+  OCCViewer_ViewManager*     myPreviewViewManager;
 
   bool                       myIsEdit;
   Handle(HYDROData_Polyline) myEditedObject;
index 13f36555762a16ec254f1c4379a2a04174aaccde..9aee684a7d0a827f352a0f9aee1940c996769f9e 100644 (file)
@@ -711,6 +711,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
   
   <context>
     <name>HYDROGUI_PolylineDlg</name>
+    <message>
+      <source>ADD_ELEMENT</source>
+      <translation>Add element</translation>
+    </message>
     <message>
       <source>CURVE_NAME_TLT</source>
       <translation>Name</translation>