#include <qgroupbox.h>
#include <qlayout.h>
#include <qcheckbox.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
SMESHGUI_ConvToQuadDlg::SMESHGUI_ConvToQuadDlg()
: SMESHGUI_Dialog( 0, false, true )
createObject( tr( "MESH" ), aGrp, 0 );
//Create check box
- myMedNdsOnGeom = new QCheckBox( tr( "MEDIUMNDS" ), mainFrame() );
+ myMedNdsOnGeom = new QCheckBox( tr( "MEDIUMNDS" ), mainFrame() );
+
+ //Create RadioButtons
+ myBG = new QButtonGroup( 2, Qt::Vertical, "", mainFrame() );
+ myBG->setExclusive( true );
+ myRB1 = new QRadioButton( myBG );
+ myRB1->setText( tr( "RADIOBTN_1" ) );
+ myRB1->setChecked( true );
+
+ myRB2 = new QRadioButton( myBG );
+ myRB2->setText( tr( "RADIOBTN_2" ) );
+
// Fill layout
QVBoxLayout* aLay = new QVBoxLayout( mainFrame(), 5, 5 );
aLay->addWidget( aGrp );
aLay->addWidget( myMedNdsOnGeom );
+ aLay->addWidget( myBG );
+
+ connect(myBG, SIGNAL( clicked( int ) ), this, SIGNAL( onClicked( int ) ) );
}
SMESHGUI_ConvToQuadDlg::~SMESHGUI_ConvToQuadDlg()
return myMedNdsOnGeom->isEnabled();
}
-void SMESHGUI_ConvToQuadDlg::SetEnabledCheck(const bool theCheck)
+void SMESHGUI_ConvToQuadDlg::SetEnabledCheck( const bool theCheck )
{
- myMedNdsOnGeom->setEnabled(theCheck);
+ myMedNdsOnGeom->setEnabled( theCheck );
}
+
+int SMESHGUI_ConvToQuadDlg::CurrentRB( )
+{
+ return myBG->selectedId();
+}
+
+void SMESHGUI_ConvToQuadDlg::SetEnabledControls( const bool theCheck )
+{
+ myBG->setEnabled( theCheck );
+ myMedNdsOnGeom->setEnabled( theCheck );
+ setButtonEnabled( theCheck, QtxDialog::OK | QtxDialog::Apply );
+}
+
+void SMESHGUI_ConvToQuadDlg::SetEnabledRB( const int idx, const bool theCheck )
+{
+ if(idx)
+ {
+ myRB2->setEnabled( theCheck );
+ myRB1->setEnabled( !theCheck );
+ myRB1->setChecked( true );
+ }
+ else
+ {
+ myRB1->setEnabled( theCheck );
+ myRB2->setEnabled( !theCheck );
+ myRB2->setChecked( true );
+ }
+ emit onClicked( myBG->selectedId() );
+}
+
+
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QCheckBox;
+class QRadioButton;
+class QButtonGroup;
class SMESHGUI_ConvToQuadDlg : public SMESHGUI_Dialog
{
bool IsMediumNdsOnGeom() const;
void SetMediumNdsOnGeom(const bool theCheck);
bool IsEnabledCheck() const;
- void SetEnabledCheck(const bool theCheck);
-
+ void SetEnabledCheck( const bool theCheck );
+ void SetEnabledGroup( const bool theCheck );
+ void SetEnabledControls( const bool theCheck );
+ void SetEnabledRB( const int idx, const bool theCheck );
+ int CurrentRB();//returns the ID of the selected toggle button
+
+signals:
+ void onClicked( int );
+
private:
QCheckBox* myMedNdsOnGeom;
+ QButtonGroup* myBG;
+ QRadioButton* myRB1;
+ QRadioButton* myRB2;
+
};
#endif
{
myDlg = new SMESHGUI_ConvToQuadDlg( );
}
+ connect( myDlg, SIGNAL( onClicked( int ) ), SLOT( ConnectRadioButtons( int ) ) );
+
SMESHGUI_SelectionOp::startOperation();
myDlg->SetMediumNdsOnGeom( false );
SMESH::SMESH_Mesh_var mesh =
SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
- GEOM::GEOM_Object_var mainGeom;
- mainGeom = mesh->GetShapeToMesh();
-
- if( mesh->_is_nil() ||
- ( !mesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR) &&
- !mesh->NbFacesOfOrder(SMESH::ORDER_LINEAR) &&
- !mesh->NbVolumesOfOrder(SMESH::ORDER_LINEAR) ) )
+ if( mesh->_is_nil() )
{
- myDlg->setButtonEnabled( false, QtxDialog::OK | QtxDialog::Apply );
- myDlg->SetEnabledCheck( false );
+ myDlg->SetEnabledControls( false );
+ }
+ else if( ConsistMesh( mesh ) == SMESHGUI_ConvToQuadOp::Quadratic )
+ {
+ myDlg->SetEnabledRB( 0, false );
+ }
+ else if( ConsistMesh( mesh ) == SMESHGUI_ConvToQuadOp::Linear )
+ {
+ myDlg->SetEnabledRB( 1, false );
}
- else if( mainGeom->_is_nil() && myDlg->IsEnabledCheck() )
- myDlg->SetEnabledCheck( false );
else
{
- myDlg->setButtonEnabled( true, QtxDialog::OK | QtxDialog::Apply );
- myDlg->SetEnabledCheck( true );
+ myDlg->SetEnabledControls( true );
}
}
catch ( const SALOME::SALOME_Exception& S_ex )
try
{
- bool aParam = true;
- if( myDlg->IsEnabledCheck() )
- aParam = myDlg->IsMediumNdsOnGeom();
-
SMESH::SMESH_MeshEditor_var aEditor = mesh->GetMeshEditor();
- aEditor->ConvertToQuadratic( aParam );
- aResult = true;
+ if( !myDlg->CurrentRB() )
+ {
+ bool aParam = true;
+ if( myDlg->IsEnabledCheck() )
+ aParam = myDlg->IsMediumNdsOnGeom();
+
+ aEditor->ConvertToQuadratic( aParam );
+ aResult = true;
+ }
+ else
+ {
+ aResult = aEditor->ConvertFromQuadratic();
+ }
}
catch ( const SALOME::SALOME_Exception& S_ex )
{
{
aResult = false;
}
- if(aResult)
+ if( aResult )
{
- update( UF_ObjBrowser | UF_Model );
- myDlg->setButtonEnabled( false, QtxDialog::Apply );
+ update( UF_ObjBrowser | UF_Model | UF_Viewer );
+ selectionDone();
}
return aResult;
}
+//================================================================================
+/*! ConsistMesh
+ * Determines, what elements this mesh contains.
+ */
+//================================================================================
+SMESHGUI_ConvToQuadOp::MeshType SMESHGUI_ConvToQuadOp::ConsistMesh( const SMESH::SMESH_Mesh_var& mesh) const
+{
+ int nbAllElem = 0, nbQEdges =0, nbQFaces =0, nbQVolum = 0;
+ int nbEdges = 0, nbFaces = 0, nbVolum = 0;
+
+ nbAllElem = (int)mesh->NbElements();
+ nbQEdges = (int)mesh->NbEdgesOfOrder(SMESH::ORDER_QUADRATIC);
+ nbQFaces = (int)mesh->NbFacesOfOrder(SMESH::ORDER_QUADRATIC);
+ nbQVolum = (int)mesh->NbVolumesOfOrder(SMESH::ORDER_QUADRATIC);
+
+ nbEdges = (int)mesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR);
+ nbFaces = (int)mesh->NbFacesOfOrder(SMESH::ORDER_LINEAR);
+ nbVolum = (int)mesh->NbVolumesOfOrder(SMESH::ORDER_LINEAR);
+
+ if( nbAllElem == (nbQEdges+nbQFaces+nbQVolum) )
+ return SMESHGUI_ConvToQuadOp::Quadratic;
+ else if ( nbAllElem == (nbEdges+nbFaces+nbVolum) )
+ return SMESHGUI_ConvToQuadOp::Linear;
+ else
+ return SMESHGUI_ConvToQuadOp::Comp;
+}
+
+
+void SMESHGUI_ConvToQuadOp::ConnectRadioButtons( int id )
+{
+ QString anMeshEntry = myDlg->selectedObject( 0 );
+ _PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.latin1() );
+ if ( !pMesh ) return;
+
+ SMESH::SMESH_Mesh_var mesh =
+ SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+
+ GEOM::GEOM_Object_var mainGeom;
+ mainGeom = mesh->GetShapeToMesh();
+
+ if( id || mainGeom->_is_nil() )
+ myDlg->SetEnabledCheck( false );
+ else
+ myDlg->SetEnabledCheck( true );
+}
+
+
class SMESHGUI_ConvToQuadOp : public SMESHGUI_SelectionOp
{
Q_OBJECT
-
- // enum HypType{ Algo = 0, MainHyp, AddHyp };
+
+public:
+enum MeshType{ Comp = 0, Linear, Quadratic };
public:
SMESHGUI_ConvToQuadOp();
virtual void startOperation();
virtual void selectionDone();
virtual SUIT_SelectionFilter* createFilter( const int ) const;
+ MeshType ConsistMesh( const SMESH::SMESH_Mesh_var& ) const;
protected slots:
virtual bool onApply();
+ void ConnectRadioButtons( int);
private:
- SMESHGUI_ConvToQuadDlg* myDlg;
+ SMESHGUI_ConvToQuadDlg* myDlg;
};
#endif
msgstr "Pattern mapping"
msgid "MEN_CONV_TO_QUAD"
-msgstr "Convert to quadratic"
+msgstr "Convert to/from quadratic"
msgid "MEN_EXTRUSION_ALONG"
msgstr "Extrusion along a path"
msgstr "Pattern mapping"
msgid "TOP_CONV_TO_QUAD"
-msgstr "Convert to quadratic"
+msgstr "Convert to/from quadratic"
msgid "TOP_EXTRUSION_ALONG"
msgstr "Extrusion along a path"
msgstr "Pattern mapping"
msgid "STB_CONV_TO_QUAD"
-msgstr "Convert to quadratic"
+msgstr "Convert to/from quadratic"
msgid "STB_EXTRUSION_ALONG"
msgstr "Extrusion along a path"
#-----------------------------------------------------------
msgid "SMESHGUI_ConvToQuadDlg::CAPTION"
-msgstr "Convert to quadratic"
+msgstr "Convert to/from quadratic"
msgid "SMESHGUI_ConvToQuadDlg::MESH"
msgstr "Mesh"
msgid "SMESHGUI_ConvToQuadDlg::MEDIUMNDS"
msgstr "Medium nodes on geometry"
+msgid "SMESHGUI_ConvToQuadDlg::RADIOBTN_1"
+msgstr "Convert to quadratic"
+
+msgid "SMESHGUI_ConvToQuadDlg::RADIOBTN_2"
+msgstr "Convert from quadratic"
+
msgid "SMESHGUI_ConvToQuadOp::MESH_IS_NOT_SELECTED"
msgstr "Mesh is not selected\nPlease specify it and try again"