#include <QLayout>
#include <QPushButton>
-#include <QStackedLayout>
HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle )
: QDockWidget( theModule->application()->desktop() ),
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 );
{
}
-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 )
{
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 );
- }
-}
class QFrame;
class QPushButton;
class QLayout;
-class QStackedLayout;
class HYDROGUI_Module;
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:
QPushButton* myApply;
QPushButton* myCancel;
QPushButton* myHelp;
- QStackedLayout* myStackedLayout;
};
#endif
#include <CurveCreator_Widget.h>
#include <CurveCreator_Curve.hxx>
+#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
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()
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()
#include "HYDROGUI_InputPanel.h"
-
+class QGroupBox;
class QLineEdit;
class CurveCreator_Widget;
class CurveCreator_Curve;
private:
QLineEdit* myName;
CurveCreator_Widget* myEditorWidget;
+ QGroupBox* myAddElementBox;
};
#endif
HYDROGUI_PolylineOp::~HYDROGUI_PolylineOp()
{
+ closePreview();
}
HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const
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();
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();
}
}
}
+
+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;
+ }
+}
#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
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;
<context>
<name>HYDROGUI_PolylineDlg</name>
+ <message>
+ <source>ADD_ELEMENT</source>
+ <translation>Add element</translation>
+ </message>
<message>
<source>CURVE_NAME_TLT</source>
<translation>Name</translation>