add a dialogue for linear<->quadratic mesh conversion

This commit is contained in:
eap 2006-04-26 12:05:53 +00:00
parent e016671451
commit f48b64f7ad
8 changed files with 507 additions and 2 deletions

View File

@ -107,7 +107,9 @@ LIB_SRC = SMESHGUI.cxx \
SMESHGUI_Displayer.cxx \
SMESHGUI_Hypotheses.cxx \
SMESHGUI_ShapeByMeshDlg.cxx \
SMESHGUI_AddQuadraticElementDlg.cxx
SMESHGUI_AddQuadraticElementDlg.cxx \
SMESHGUI_ConvToQuadDlg.cxx \
SMESHGUI_ConvToQuadOp.cxx
LIB_MOC = \
SMESHGUI.h \
@ -153,7 +155,9 @@ LIB_MOC = \
SMESHGUI_MeshOp.h \
SMESHGUI_Hypotheses.h \
SMESHGUI_ShapeByMeshDlg.h \
SMESHGUI_AddQuadraticElementDlg.h
SMESHGUI_AddQuadraticElementDlg.h \
SMESHGUI_ConvToQuadDlg.h \
SMESHGUI_ConvToQuadOp.h
LIB_CLIENT_IDL = SALOME_Exception.idl \

View File

@ -62,6 +62,7 @@
#include "SMESHGUI_MeshPatternDlg.h"
#include "SMESHGUI_Selection.h"
#include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
#include "SMESHGUI_ConvToQuadOp.h"
#include "SMESHGUI_MeshOp.h"
#include "SMESHGUI_Displayer.h"
@ -1497,6 +1498,20 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
}
break;
}
case 417: // Convert mesh to quadratic
{
startOperation( 417 );
/* if (checkLock(aStudy)) break;
if (vtkwnd) {
EmitSignalDeactivateDialog();
new SMESHGUI_ConvToQuadDlg();
} else {
SUIT_MessageBox::warn1(desktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
}*/
break;
}
case 801: // CREATE GROUP
{
if ( !vtkwnd )
@ -2355,6 +2370,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
createSMESHAction( 415, "MAP", "ICON_MAP" );
createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
createSMESHAction( 200, "RESET" );
createSMESHAction( 201, "SCALAR_BAR_PROP" );
createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
@ -2501,6 +2517,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createMenu( 416, modifyId, -1 );
createMenu( 414, modifyId, -1 );
createMenu( 415, modifyId, -1 );
createMenu( 417, modifyId, -1 );
createMenu( 214, viewId, -1 );
@ -2585,6 +2602,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createTool( 416, modifyTb );
createTool( 414, modifyTb );
createTool( 415, modifyTb );
createTool( 417, modifyTb );
createTool( 214, dispModeTb );
@ -3231,6 +3249,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
case 704: // Edit mesh/sub-mesh
op = new SMESHGUI_MeshOp( false );
break;
case 417: //convert to quadratic
op = new SMESHGUI_ConvToQuadOp();
break;
default:
break;
}

View File

@ -0,0 +1,83 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/
//
/**
* SMESH SMESHGUI
*
* Copyright (C) 2005 CEA/DEN, EDF R&D
*
*
*
* File : SMESHGUI_ConvToQuadDlg.cxx
* Module : SMESH
*/
#include <SMESHGUI_ConvToQuadDlg.h>
#include <SUIT_Session.h>
#include <qgroupbox.h>
#include <qlayout.h>
#include <qcheckbox.h>
SMESHGUI_ConvToQuadDlg::SMESHGUI_ConvToQuadDlg()
: SMESHGUI_Dialog( 0, false, true )
{
setCaption( tr( "CAPTION" ) );
// Create top controls
QGroupBox* aGrp = new QGroupBox( 3, Qt::Horizontal, mainFrame() );
aGrp->setFrameStyle( QFrame::NoFrame );
aGrp->setInsideMargin( 0 );
// mesh
createObject( tr( "MESH" ), aGrp, 0 );
//Create check box
myMedNdsOnGeom = new QCheckBox( tr( "MEDIUMNDS" ), mainFrame() );
// Fill layout
QVBoxLayout* aLay = new QVBoxLayout( mainFrame(), 5, 5 );
aLay->addWidget( aGrp );
aLay->addWidget( myMedNdsOnGeom );
}
SMESHGUI_ConvToQuadDlg::~SMESHGUI_ConvToQuadDlg()
{
}
bool SMESHGUI_ConvToQuadDlg::IsMediumNdsOnGeom() const
{
return !myMedNdsOnGeom->isChecked();
}
void SMESHGUI_ConvToQuadDlg::SetMediumNdsOnGeom(const bool theCheck)
{
myMedNdsOnGeom->setChecked(theCheck);
}
bool SMESHGUI_ConvToQuadDlg::IsEnabledCheck() const
{
return myMedNdsOnGeom->isEnabled();
}
void SMESHGUI_ConvToQuadDlg::SetEnabledCheck(const bool theCheck)
{
myMedNdsOnGeom->setEnabled(theCheck);
}

View File

@ -0,0 +1,68 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/
//
/**
* SMESH SMESHGUI
*
* Copyright (C) 2005 CEA/DEN, EDF R&D
*
*
*
* File : SMESHGUI_ConvToQuadDlg.h
* Module : SMESH
*/
#ifndef SMESHGUI_ConvToQuadDlg_H
#define SMESHGUI_ConvToQuadDlg_H
#include "SMESHGUI_Dialog.h"
/*#include <qframe.h>
#include <qstringlist.h>
#include <qmap.h>*/
//idl headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QCheckBox;
class SMESHGUI_ConvToQuadDlg : public SMESHGUI_Dialog
{
Q_OBJECT
public:
SMESHGUI_ConvToQuadDlg();
virtual ~SMESHGUI_ConvToQuadDlg();
bool IsMediumNdsOnGeom() const;
void SetMediumNdsOnGeom(const bool theCheck);
bool IsEnabledCheck() const;
void SetEnabledCheck(const bool theCheck);
private:
QCheckBox* myMedNdsOnGeom;
};
#endif

View File

@ -0,0 +1,232 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/
//
/**
* SMESH SMESHGUI
*
* Copyright (C) 2005 CEA/DEN, EDF R&D
*
*
*
* File : SMESHGUI_ConvToQuadOp.h
* Module : SMESHGUI
*/
#include "SMESHGUI_ConvToQuadOp.h"
#include "SMESHGUI_ConvToQuadDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h"
#include "SMESH_TypeFilter.hxx"
#include "SalomeApp_Tools.h"
#include "SUIT_MessageBox.h"
#include "LightApp_UpdateFlags.h"
//================================================================================
/*!
* \brief Constructor
*
* Initialize operation
*/
//================================================================================
SMESHGUI_ConvToQuadOp::SMESHGUI_ConvToQuadOp()
: SMESHGUI_SelectionOp(),
myDlg( 0 )
{
}
//================================================================================
/*!
* \brief Destructor
*/
//================================================================================
SMESHGUI_ConvToQuadOp::~SMESHGUI_ConvToQuadOp()
{
if ( myDlg )
delete myDlg;
}
//================================================================================
/*!
* \brief Gets dialog of this operation
* \retval LightApp_Dialog* - pointer to dialog of this operation
*/
//================================================================================
LightApp_Dialog* SMESHGUI_ConvToQuadOp::dlg() const
{
return myDlg;
}
//================================================================================
/*!
* \brief Creates dialog if necessary and shows it
*
* Virtual method redefined from base class called when operation is started creates
* dialog if necessary and shows it, activates selection
*/
//================================================================================
void SMESHGUI_ConvToQuadOp::startOperation()
{
if( !myDlg )
{
myDlg = new SMESHGUI_ConvToQuadDlg( );
}
SMESHGUI_SelectionOp::startOperation();
myDlg->SetMediumNdsOnGeom( false );
myDlg->activateObject( 0 );
myDlg->show();
selectionDone();
}
//================================================================================
/*!
* \brief Updates dialog's look and feel
*
* Virtual method redefined from the base class updates dialog's look and feel
*/
//================================================================================
void SMESHGUI_ConvToQuadOp::selectionDone()
{
if ( !dlg()->isShown() )
return;
SMESHGUI_SelectionOp::selectionDone();
try
{
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( mesh->_is_nil() ||
( !mesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR) &&
!mesh->NbFacesOfOrder(SMESH::ORDER_LINEAR) &&
!mesh->NbVolumesOfOrder(SMESH::ORDER_LINEAR) ) )
{
myDlg->setButtonEnabled( false, QtxDialog::OK | QtxDialog::Apply );
myDlg->SetEnabledCheck( false );
}
else if( mainGeom->_is_nil() && myDlg->IsEnabledCheck() )
myDlg->SetEnabledCheck( false );
else
{
myDlg->setButtonEnabled( true, QtxDialog::OK | QtxDialog::Apply );
myDlg->SetEnabledCheck( true );
}
}
catch ( const SALOME::SALOME_Exception& S_ex )
{
SalomeApp_Tools::QtCatchCorbaException( S_ex );
}
catch ( ... )
{
}
}
//================================================================================
/*!
* \brief Creates selection filter
* \param theId - identifier of current selection widget
* \retval SUIT_SelectionFilter* - pointer to the created filter or null
*
* Creates selection filter in accordance with identifier of current selection widget
*/
//================================================================================
SUIT_SelectionFilter* SMESHGUI_ConvToQuadOp::createFilter( const int theId ) const
{
if ( theId == 0 )
return new SMESH_TypeFilter( MESH );
else
return 0;
}
//================================================================================
/*!
* \brief Edits mesh
*
* Virtual slot redefined from the base class called when "Apply" button is clicked
*/
//================================================================================
bool SMESHGUI_ConvToQuadOp::onApply()
{
QString aMess;
QString anMeshEntry = myDlg->selectedObject( 0 );
_PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.latin1() );
if ( !pMesh )
{
dlg()->show();
SUIT_MessageBox::warn1( myDlg,
tr( "SMESH_WRN_WARNING" ), tr("MESH_IS_NOT_SELECTED"), tr( "SMESH_BUT_OK" ) );
return false;
}
SMESH::SMESH_Mesh_var mesh =
SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
if( CORBA::is_nil(mesh) )
{
SUIT_MessageBox::warn1( myDlg,
tr( "SMESH_WRN_WARNING" ), tr("REF_IS_NULL"), tr( "SMESH_BUT_OK" ) );
return false;
}
bool aResult = false;
try
{
bool aParam = true;
if( myDlg->IsEnabledCheck() )
aParam = myDlg->IsMediumNdsOnGeom();
SMESH::SMESH_MeshEditor_var aEditor = mesh->GetMeshEditor();
aEditor->ConvertToQuadratic( aParam );
aResult = true;
}
catch ( const SALOME::SALOME_Exception& S_ex )
{
SalomeApp_Tools::QtCatchCorbaException( S_ex );
aResult = false;
}
catch ( ... )
{
aResult = false;
}
if(aResult)
{
update( UF_ObjBrowser | UF_Model );
myDlg->setButtonEnabled( false, QtxDialog::Apply );
}
return aResult;
}

View File

@ -0,0 +1,67 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/
//
/**
* SMESH SMESHGUI
*
* Copyright (C) 2005 CEA/DEN, EDF R&D
*
*
*
* File : SMESHGUI_ConvToQuadOp.h
* Module : SMESHGUI
*/
#ifndef SMESHGUI_ConvToQuadOp_H
#define SMESHGUI_ConvToQuadOp_H
#include <SMESHGUI_SelectionOp.h>
//#include <qstringlist.h>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class SMESHGUI_ConvToQuadDlg;
class SMESHGUI_ConvToQuadOp : public SMESHGUI_SelectionOp
{
Q_OBJECT
// enum HypType{ Algo = 0, MainHyp, AddHyp };
public:
SMESHGUI_ConvToQuadOp();
virtual ~SMESHGUI_ConvToQuadOp();
virtual LightApp_Dialog* dlg() const;
protected:
virtual void startOperation();
virtual void selectionDone();
virtual SUIT_SelectionFilter* createFilter( const int ) const;
protected slots:
virtual bool onApply();
private:
SMESHGUI_ConvToQuadDlg* myDlg;
};
#endif

View File

@ -368,3 +368,6 @@ msgstr "mesh_pattern.png"
msgid "ICON_FILE_OPEN"
msgstr "open.png"
msgid "ICON_CONV_TO_QUAD"
msgstr "mesh_conv_to_quad.png"

View File

@ -2215,6 +2215,9 @@ msgstr "Revolution"
msgid "MEN_MAP"
msgstr "Pattern mapping"
msgid "MEN_CONV_TO_QUAD"
msgstr "Convert to quadratic"
msgid "MEN_EXTRUSION_ALONG"
msgstr "Extrusion along a path"
@ -2565,6 +2568,9 @@ msgstr "Revolution"
msgid "TOP_MAP"
msgstr "Pattern mapping"
msgid "TOP_CONV_TO_QUAD"
msgstr "Convert to quadratic"
msgid "TOP_EXTRUSION_ALONG"
msgstr "Extrusion along a path"
@ -2866,6 +2872,9 @@ msgstr "Revolution"
msgid "STB_MAP"
msgstr "Pattern mapping"
msgid "STB_CONV_TO_QUAD"
msgstr "Convert to quadratic"
msgid "STB_EXTRUSION_ALONG"
msgstr "Extrusion along a path"
@ -3163,3 +3172,21 @@ msgstr "Geometry object is not a subshape of the shape to mesh"
msgid "SMESHGUI_MeshOp::MESH_IS_NOT_DEFINED"
msgstr "Mesh is not defined\nPlease specify it and try again"
#-----------------------------------------------------------
msgid "SMESHGUI_ConvToQuadDlg::CAPTION"
msgstr "Convert to quadratic"
msgid "SMESHGUI_ConvToQuadDlg::MESH"
msgstr "Mesh"
msgid "SMESHGUI_ConvToQuadDlg::MEDIUMNDS"
msgstr "Medium nodes on geometry"
msgid "SMESHGUI_ConvToQuadOp::MESH_IS_NOT_SELECTED"
msgstr "Mesh is not selected\nPlease specify it and try again"
msgid "SMESHGUI_ConvToQuadOp::REF_IS_NULL"
msgstr "No valid mesh object selected"