// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// GEOM GEOMGUI : GUI for Geometry component
// File : GEOMBase_Helper.h
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
-//
+
#ifndef GEOMBASE_HELPER_H
#define GEOMBASE_HELPER_H
//================================================================
// Class : GEOMBase_Helper
-// Description : Helper class for dialog box development, can be used as
+// Description : Helper class for dialog box development, can be used as
// the second base class for dialog boxes. Contains convenient methods
// performing common operations (display/erase, selection activation,
// publication in a study, transaction management)
void redisplay ( GEOM::GEOM_Object_ptr, const bool = true, const bool = true );
virtual void displayPreview ( const bool display,
- const bool activate = false,
+ const bool activate = false,
const bool update = true,
const bool toRemoveFromEngine = true,
- const double lineWidth = -1,
+ const double lineWidth = -1,
const int displayMode = -1,
const int color = -1 );
// This is the easiest way to show preview. It is based on execute() method.
// It removes temporary GEOM::GEOM_Objects automatically.
- virtual void displayPreview ( GEOM::GEOM_Object_ptr obj,
- const bool append = false,
- const bool activate = false,
+ virtual void displayPreview ( GEOM::GEOM_Object_ptr obj,
+ const bool append = false,
+ const bool activate = false,
const bool update = true,
- const double lineWidth = -1,
+ const double lineWidth = -1,
const int displayMode = -1,
const int color = -1 );
- void displayPreview ( const SALOME_Prs* prs,
- const bool append = false,
+ void displayPreview ( const SALOME_Prs* prs,
+ const bool append = false,
const bool = true );
void erasePreview ( const bool = true );
void prepareSelection( const ObjectList&, const int );
void prepareSelection( GEOM::GEOM_Object_ptr, const int );
- QString addInStudy ( GEOM::GEOM_Object_ptr, const char* theName );
+ QString addInStudy ( GEOM::GEOM_Object_ptr, const char* theName );
bool openCommand ();
bool abortCommand ();
bool onAccept( const bool publish = true, const bool useTransaction = true, bool erasePreviewFlag = true);
// This method should be called from "OK" button handler.
- // <publish> == true means that objects returned by execute()
+ // <publish> == true means that objects returned by execute()
// should be published in a study.
void showError();
inline void setPrefix( const QString& prefix ) { myPrefix = prefix; }
QString getPrefix( GEOM::GEOM_Object_ptr = GEOM::GEOM_Object::_nil() ) const;
-
+
bool selectObjects( ObjectList& objects );
- // Selects list of objects
+ // Selects list of objects
////////////////////////////////////////////////////////////////////////////
// Virtual methods, to be redefined in dialog classes
////////////////////////////////////////////////////////////////////////////
virtual GEOM::GEOM_IOperations_ptr createOperation();
- // This method should be redefined in dialog boxes so as to return
+ // This method should be redefined in dialog boxes so as to return
// proper GEOM_IOperation interface.
// Returns nil reference by default
// Called by onAccept(). Redefine this method to check validity of user input in dialog boxes.
virtual bool execute( ObjectList& objects );
- // This method is called by onAccept().
- // It should perform the required operation and put all new or modified objects into
- // <objects> argument.Should return <false> if some error occurs during its execution.
+ // This method is called by onAccept().
+ // It should perform the required operation and put all new or modified objects into
+ // <objects> argument.Should return <false> if some error occurs during its execution.
virtual void restoreSubShapes( SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject );
// This method is called by addInStudy().
// for <theObj> or a nil reference if <theObj> should be published
// as a top-level object.
- virtual QString getNewObjectName() const;
+ virtual QString getNewObjectName (int CurrObj = -1) const;
virtual bool extractPrefix() const;
virtual void addSubshapesToStudy();
virtual void setIsOptimizedBrowsing( const bool theFlag );
virtual bool isOptimizedBrowsing() const;
-
+
virtual void setIsWaitCursorEnabled( const bool theFlag ) {myIsWaitCursorEnabled = theFlag;}
virtual bool isWaitCursorEnabled() const {return myIsWaitCursorEnabled ;}
virtual void setIsDisableBrowsing( const bool theFlag ) { myIsDisableBrowsing = theFlag; }
virtual bool isDisableBrowsing() const { return myIsDisableBrowsing; }
-
private:
QString getEntry( GEOM::GEOM_Object_ptr ) const;
bool myIsApplyAndClose;
bool myIsOptimizedBrowsing;
bool myIsWaitCursorEnabled;
- bool myIsDisableBrowsing; //This flag enable/disable selection
+ bool myIsDisableBrowsing; //This flag enable/disable selection
//in the Object Browser newly created objects.
-
};
#endif // GEOMBASE_HELPER_H
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// GEOM GEOMGUI : GUI for Geometry component
// File : RepairGUI_FreeBoundDlg.cxx
// Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com)
-//
+
#include "RepairGUI_FreeBoundDlg.h"
#include <GEOMBase.h>
+#include <DlgRef.h>
+
#include <GeometryGUI.h>
#include <GEOM_Displayer.h>
#include <GEOMImpl_Types.hxx>
#include <QKeyEvent>
#define SPACING 6
-#define MARGIN 9
+#define MARGIN 0
/*!
Class : RepairGUI_FreeBoundDlg
// function : RepairGUI_FreeBoundDlg
// purpose : Constructor
//=================================================================================
-RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg( GeometryGUI* theGUI, QWidget* theParent )
- : QDialog( theParent, 0 ),
- GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( theParent ) ),
- myGeomGUI( theGUI )
+RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg (GeometryGUI* theGUI, QWidget* theParent)
+ : GEOMBase_Skeleton(theGUI, theParent)
{
- setAttribute( Qt::WA_DeleteOnClose );
-
- setWindowTitle( tr( "CAPTION" ) );
-
- QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
-
- QGroupBox* aMainGrp = new QGroupBox( tr( "FREE_BOUND" ), this );
-
- QLabel* lab = new QLabel( tr( "GEOM_OBJECT" ), aMainGrp );
- QPushButton* btn = new QPushButton( aMainGrp );
- btn->setIcon( iconSelect );
- myEdit = new QLineEdit( aMainGrp );
- myEdit->setReadOnly( true );
- myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- myClosedLbl = new QLabel( tr( "NUMBER_CLOSED" ), aMainGrp );
- myOpenLbl = new QLabel( tr( "NUMBER_OPEN" ), aMainGrp );
- myClosedLbl->setMinimumWidth( 150 );
- myOpenLbl->setMinimumWidth( 150 );
-
- QGridLayout* aMainGrpLayout = new QGridLayout( aMainGrp );
- aMainGrpLayout->setMargin( MARGIN ); aMainGrpLayout->setSpacing( SPACING );
- aMainGrpLayout->addWidget( lab, 0, 0 );
- aMainGrpLayout->addWidget( btn, 0, 1 );
- aMainGrpLayout->addWidget( myEdit, 0, 2 );
- aMainGrpLayout->addWidget( myClosedLbl, 1, 0, 1, 3 );
- aMainGrpLayout->addWidget( myOpenLbl, 2, 0, 1, 3 );
-
- QFrame* aFrame = new QFrame( this );
- aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
- QPushButton* aCloseBtn = new QPushButton( tr( "GEOM_BUT_CLOSE" ), aFrame );
- QPushButton* aHelpBtn = new QPushButton( tr( "GEOM_BUT_HELP" ), aFrame );
- QHBoxLayout* aBtnLay = new QHBoxLayout( aFrame );
- aBtnLay->setMargin( MARGIN ); aBtnLay->setSpacing( SPACING );
- aBtnLay->addWidget( aCloseBtn );
- aBtnLay->addSpacing( SPACING ); aBtnLay->addStretch();
- aBtnLay->addWidget( aHelpBtn );
-
- QVBoxLayout* aLay = new QVBoxLayout( this );
- aLay->setSpacing( SPACING );
- aLay->setMargin( MARGIN );
- aLay->addWidget( aMainGrp );
- aLay->addWidget( aFrame );
-
- myHelpFileName = "using_measurement_tools_page.html#boundaries_anchor";
-
- connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) );
- connect( aHelpBtn, SIGNAL( clicked() ), SLOT( onHelp() ) );
+ QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FREE_BOUNDS")));
+ QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+ setWindowTitle(tr("CAPTION"));
+
+ /***************************************************************/
+
+ mainFrame()->GroupConstructors->setTitle(tr("FREE_BOUND"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton2->close();
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton3->close();
+
+ mainFrame()->GroupBoxName->hide();
+
+ QGroupBox* aMainGrp = new QGroupBox (tr("FREE_BOUND"), this);
+
+ QLabel* lab = new QLabel (tr("GEOM_OBJECT"), aMainGrp);
+ QPushButton* btn = new QPushButton (aMainGrp);
+ btn->setIcon(image1);
+ myEdit = new QLineEdit (aMainGrp);
+ myEdit->setReadOnly(true);
+ myEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+
+ myClosedLbl = new QLabel (tr("NUMBER_CLOSED"), aMainGrp);
+ myOpenLbl = new QLabel (tr("NUMBER_OPEN"), aMainGrp);
+ myClosedLbl->setMinimumWidth(150);
+ myOpenLbl->setMinimumWidth(150);
+
+ QGridLayout* aMainGrpLayout = new QGridLayout (aMainGrp);
+ aMainGrpLayout->addWidget(lab, 0, 0);
+ aMainGrpLayout->addWidget(btn, 0, 1);
+ aMainGrpLayout->addWidget(myEdit, 0, 2);
+ aMainGrpLayout->addWidget(myClosedLbl, 1, 0, 1, 3);
+ aMainGrpLayout->addWidget(myOpenLbl, 2, 0, 1, 3);
+
+ QVBoxLayout* aLay = new QVBoxLayout (centralWidget());
+ aLay->setSpacing(SPACING);
+ aLay->setMargin(MARGIN);
+ aLay->addWidget(aMainGrp);
+
+ resize(minimumSizeHint());
+ /***************************************************************/
+
+ myHelpFileName = "boundaries_page.html";
Init();
}
}
//=================================================================================
-// function : onClose
-// purpose : SLOT. Called when "close" button pressed. Close dialog
+// function : Init
+// purpose : Initialize dialog fields
//=================================================================================
-void RepairGUI_FreeBoundDlg::onClose()
+void RepairGUI_FreeBoundDlg::Init()
{
- globalSelection();
- disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 );
- myGeomGUI->SetActiveDialogBox( 0 );
- reject();
- erasePreview();
+ myNbClosed = myNbOpen = 0;
+ myObj = GEOM::GEOM_Object::_nil();
+
+ myEditCurrentArgument = myEdit;
+
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
+ activateSelection();
+ SelectionIntoArgument();
}
//=================================================================================
-// function : onHelp()
+// function : ClickOnOk()
// purpose :
//=================================================================================
-void RepairGUI_FreeBoundDlg::onHelp()
+void RepairGUI_FreeBoundDlg::ClickOnOk()
{
- LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
- if ( app )
- app->onHelpContextModule( myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString(""), myHelpFileName );
- else {
- QString platform;
-#ifdef WIN32
- platform = "winapplication";
-#else
- platform = "application";
-#endif
- SUIT_MessageBox::warning( this,
- tr( "WRN_WARNING" ),
- tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg( app->resourceMgr()->stringValue( "ExternalBrowser",
- platform ) ).arg( myHelpFileName ) );
- }
+ if (ClickOnApply())
+ ClickOnCancel();
}
//=================================================================================
-// function : onDeactivate
-// purpose : Deactivate this dialog
+// function : ClickOnApply()
+// purpose :
//=================================================================================
-void RepairGUI_FreeBoundDlg::onDeactivate()
+bool RepairGUI_FreeBoundDlg::ClickOnApply()
{
- setEnabled( false );
- globalSelection();
- disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
- myGeomGUI->SetActiveDialogBox( 0 );
+ if (!onAccept())
+ return false;
+ return true;
}
//=================================================================================
-// function : onActivate
-// purpose : Activate this dialog
+// function : ActivateThisDialog()
+// purpose :
//=================================================================================
-void RepairGUI_FreeBoundDlg::onActivate()
+void RepairGUI_FreeBoundDlg::ActivateThisDialog()
{
- myGeomGUI->EmitSignalDeactivateDialog();
- setEnabled( true );
- myGeomGUI->SetActiveDialogBox( this );
- connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
+ GEOMBase_Skeleton::ActivateThisDialog();
+
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
activateSelection();
- onSelectionDone();
+ displayPreview(true);
}
//=================================================================================
-// function : onSelectionDone
-// purpose : SLOT. Called when selection changed.
+// function : enterEvent()
+// purpose :
//=================================================================================
-void RepairGUI_FreeBoundDlg::onSelectionDone()
+void RepairGUI_FreeBoundDlg::enterEvent(QEvent*)
{
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
- if ( aSelList.Extent() != 1 )
- return;
-
- GEOM::GEOM_Object_var anObj =
- GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-
- if ( !GEOMBase::IsShape( anObj ) )
- return;
- else {
- myObj = anObj;
- displayPreview( true, false, true, true, 3 );
- }
+ if (!mainFrame()->GroupConstructors->isEnabled())
+ ActivateThisDialog();
}
//=================================================================================
-// function : Init
-// purpose : Initialize dialog fields
+// function : SelectionIntoArgument
+// purpose : SLOT. Called when selection changed.
//=================================================================================
-void RepairGUI_FreeBoundDlg::Init()
+void RepairGUI_FreeBoundDlg::SelectionIntoArgument()
{
- myNbClosed = myNbOpen = 0;
+ myEditCurrentArgument->setText("");
+ myClosedLbl->setText(tr("NUMBER_CLOSED"));
+ myOpenLbl->setText(tr("NUMBER_OPEN"));
myObj = GEOM::GEOM_Object::_nil();
+ erasePreview();
- connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT ( onDeactivate() ) );
- connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
- activateSelection();
- onSelectionDone();
-}
+ if (aSelList.Extent() != 1)
+ return;
-//=================================================================================
-// function : enterEvent
-// purpose : Activate dialog
-//=================================================================================
-void RepairGUI_FreeBoundDlg::enterEvent( QEvent* )
-{
- onActivate();
-}
+ GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First());
-//=================================================================================
-// function : closeEvent
-// purpose : Close dialog
-//=================================================================================
-void RepairGUI_FreeBoundDlg::closeEvent( QCloseEvent* )
-{
- onClose();
+ if (!GEOMBase::IsShape(anObj))
+ return;
+
+ myObj = anObj;
+ myEditCurrentArgument->setText(GEOMBase::GetName(myObj));
+ displayPreview(true, false, true, true, 3);
}
//=================================================================================
void RepairGUI_FreeBoundDlg::activateSelection()
{
TColStd_MapOfInteger aMap;
- aMap.Add( GEOM_FACE );
- aMap.Add( GEOM_SHELL );
- aMap.Add( GEOM_SOLID );
- aMap.Add( GEOM_COMPOUND );
- globalSelection( aMap );
+ aMap.Add(GEOM_FACE);
+ aMap.Add(GEOM_SHELL);
+ aMap.Add(GEOM_SOLID);
+ aMap.Add(GEOM_COMPOUND);
+ globalSelection(aMap);
}
//=================================================================================
//=================================================================================
GEOM::GEOM_IOperations_ptr RepairGUI_FreeBoundDlg::createOperation()
{
- return getGeomEngine()->GetIHealingOperations( getStudyId() );
+ return getGeomEngine()->GetIHealingOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
-bool RepairGUI_FreeBoundDlg::isValid( QString& )
+bool RepairGUI_FreeBoundDlg::isValid (QString&)
{
return !myObj->_is_nil();
}
// function : execute
// purpose : Get free boundaries
//=================================================================================
-bool RepairGUI_FreeBoundDlg::execute( ObjectList& objects )
+bool RepairGUI_FreeBoundDlg::execute (ObjectList& objects)
{
- if ( !IsPreview() || myObj->_is_nil() )
- return false;
-
GEOM::ListOfGO_var aClosed, anOpen;
- GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() );
- bool result = anOper->GetFreeBoundary( myObj, aClosed, anOpen );
+ GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
+ bool result = anOper->GetFreeBoundary(myObj, aClosed, anOpen);
- if ( result ) {
+ if (result) {
myNbClosed = aClosed->length();
myNbOpen = anOpen->length();
int i;
- for ( i = 0; i < myNbClosed; i++ )
- objects.push_back( aClosed[i]._retn() );
- for ( i = 0; i < myNbOpen; i++ )
- objects.push_back( anOpen[i]._retn() );
-
- myEdit->setText( GEOMBase::GetName( myObj ) );
- QString aLabelText = tr( "NUMBER_CLOSED" ) + QString( "%1" ).arg( myNbClosed );
- myClosedLbl->setText( aLabelText );
- aLabelText = tr( "NUMBER_OPEN" ) + QString( "%1" ).arg( myNbOpen );
- myOpenLbl->setText( aLabelText );
- }
- else {
- myEdit->setText( GEOMBase::GetName( myObj ) );
- myClosedLbl->setText( tr( "NUMBER_CLOSED" ) );
- myOpenLbl->setText( tr( "NUMBER_OPEN" ) );
+ for (i = 0; i < myNbClosed; i++)
+ objects.push_back(aClosed[i]._retn());
+ for (i = 0; i < myNbOpen; i++)
+ objects.push_back(anOpen[i]._retn());
+
+ QString aLabelText = tr("NUMBER_CLOSED") + QString("%1").arg(myNbClosed);
+ myClosedLbl->setText(aLabelText);
+ aLabelText = tr("NUMBER_OPEN") + QString("%1").arg(myNbOpen);
+ myOpenLbl->setText(aLabelText);
}
+ myCurrObj = 1;
return result;
}
-//=================================================================================
-// function : keyPressEvent()
-// purpose :
-//=================================================================================
-void RepairGUI_FreeBoundDlg::keyPressEvent( QKeyEvent* e )
+//================================================================
+// Function : getNewObjectName
+// Purpose : Redefine this method to return proper name for a new object
+//================================================================
+QString RepairGUI_FreeBoundDlg::getNewObjectName (int currObj) const
{
- QDialog::keyPressEvent( e );
- if ( e->isAccepted() )
- return;
+ QString aName = tr("NAME_CLOSED").arg(currObj);
+ if (currObj > myNbClosed)
+ aName = tr("NAME_OPEN").arg(currObj);
+ return aName;
+}
- if ( e->key() == Qt::Key_F1 ) {
- e->accept();
- onHelp();
- }
+//================================================================
+// Function : getFather
+// Purpose : Get father object for object to be added in study
+// (called with addInStudy method)
+//================================================================
+GEOM::GEOM_Object_ptr RepairGUI_FreeBoundDlg::getFather (GEOM::GEOM_Object_ptr)
+{
+ return myObj;
}