#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_SpinBox.h"
+#include "SMESHGUI_MeshEditPreview.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
::SMESHGUI_MultiEditDlg(SMESHGUI* theModule,
const int theMode,
const bool the3d2d):
- QDialog(SMESH::GetDesktop(theModule)),
+ SMESHGUI_PreviewDlg(theModule),
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
mySMESHGUI(theModule)
{
setWindowTitle(tr("CAPTION"));
+ //Preview check box
+ myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), mySelGrp);
+ QGridLayout* aLay = (QGridLayout*)(mySelGrp->layout());
+ aLay->addWidget(myPreviewCheckBox, aLay->rowCount(), 0, 1, aLay->columnCount());
+
myComboBoxFunctor->setEnabled(true);
myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only
((QVBoxLayout*)(myCriterionGrp->layout()))->addWidget(aMaxAngleGrp);
myCriterionGrp->show();
+ connect(myComboBoxFunctor, SIGNAL(activated(int)), this, SLOT(toDisplaySimulation()));
+ connect(myMaxAngleSpin, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
+ connect(this, SIGNAL(ListContensChanged()), this, SLOT(toDisplaySimulation()));
+ connectPreviewControl(); //To Connect preview check box
+
+ myPreviewCheckBox->setChecked(false);
+ onDisplaySimulation(false);
+
myHelpFileName = "uniting_set_of_triangles_page.html";
}
ok = theEditor->TriToQuadObject(obj, aCriterion, aMaxAngle);
return ok;
}
-
+
+void SMESHGUI_UnionOfTrianglesDlg::onDisplaySimulation( bool toDisplayPreview )
+{
+ if ( myPreviewCheckBox->isChecked() && toDisplayPreview ) {
+ if ( isValid( true ) ) {
+ try{
+ SUIT_OverrideCursor aWaitCursor;
+ // get Ids of elements
+ SMESH::SMESH_IDSource_var obj;
+ SMESH::long_array_var anElemIds = getIds( obj );
+
+ SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
+ SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
+
+ double aMaxAngle = myMaxAngleSpin->GetValue() * M_PI / 180.0;
+
+ if ( CORBA::is_nil( obj ) )
+ aMeshEditor->TriToQuad( anElemIds.inout(), aCriterion, aMaxAngle );
+ else
+ aMeshEditor->TriToQuadObject( obj, aCriterion, aMaxAngle );
+
+ SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
+
+ vtkProperty* aProp = vtkProperty::New();
+ aProp->SetRepresentationToWireframe();
+ aProp->SetColor( 250, 0, 250 );
+ aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 3 );
+ mySimulation->GetActor()->SetProperty( aProp );
+ aProp->Delete();
+
+ mySimulation->SetData( aMeshPreviewStruct._retn() );
+ } catch ( ... ) {
+ hidePreview();
+ }
+ } else {
+ hidePreview();
+ }
+ } else {
+ hidePreview();
+ }
+}
/*!
* Class : SMESHGUI_CuttingOfQuadsDlg
if (myPreviewActor != 0)
erasePreview();
+ SUIT_OverrideCursor aWaitCursor;
// get Ids of elements
SMESH::SMESH_IDSource_var obj;
SMESH::long_array_var anElemIds = getIds(obj);
return;
}
+ if ( anElemIds->length() == 0 ) {
+ anElemIds = obj->GetIDs();
+ }
+
//Create grid
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
// SMESH includes
#include "SMESH_SMESHGUI.hxx"
+#include "SMESHGUI_PreviewDlg.h"
// Qt includes
#include <QDialog>
* union of two neighboring triangles
*/
-class SMESHGUI_EXPORT SMESHGUI_MultiEditDlg : public QDialog
+class SMESHGUI_EXPORT SMESHGUI_MultiEditDlg : public SMESHGUI_PreviewDlg
{
Q_OBJECT
const SMESH::long_array&,
SMESH::SMESH_IDSource_ptr obj );
+protected slots:
+ virtual void onDisplaySimulation( bool );
+
private:
SMESHGUI_SpinBox* myMaxAngleSpin;
};
void arrayToSet(const SMESH::long_array & IDs,
const SMESHDS_Mesh* aMesh,
TIDSortedElemSet& aMap,
- const SMDSAbs_ElementType aType = SMDSAbs_All )
+ const SMDSAbs_ElementType aType = SMDSAbs_All,
+ SMDS_MeshElement::Filter* aFilter = NULL)
{
SMDS_MeshElement::NonNullFilter filter1;
SMDS_MeshElement::TypeFilter filter2( aType );
- SMDS_MeshElement::Filter & filter =
- ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter&) filter1 : filter2;
+
+ if ( aFilter == NULL )
+ aFilter = ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter*) &filter1 : (SMDS_MeshElement::Filter*) &filter2;
+
+ SMDS_MeshElement::Filter & filter = *aFilter;
if ( aType == SMDSAbs_Node )
for (int i=0; i<IDs.length(); i++) {
initData();
SMESHDS_Mesh* aMesh = getMeshDS();
- TIDSortedElemSet faces;
- arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
+ TIDSortedElemSet faces,copyFaces;
+ SMDS_MeshElement::GeomFilter triaFilter(SMDSGeom_TRIANGLE);
+ arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face, & triaFilter);
+ TIDSortedElemSet* workElements = & faces;
+
+ if ( myIsPreviewMode ) {
+ SMDSAbs_ElementType select = SMDSAbs_Face;
+ getPreviewMesh( SMDSAbs_Face )->Copy( faces, copyFaces, select );
+ workElements = & copyFaces;
+ }
SMESH::NumericalFunctor_i* aNumericalFunctor =
dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
else
aCrit = aNumericalFunctor->GetNumericalFunctor();
- // Update Python script
- TPythonDump() << "isDone = " << this << ".TriToQuad( "
- << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
-
+ if ( !myIsPreviewMode ) {
+ // Update Python script
+ TPythonDump() << "isDone = " << this << ".TriToQuad( "
+ << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ }
- bool stat = getEditor().TriToQuad( faces, aCrit, MaxAngle );
+ bool stat = getEditor().TriToQuad( *workElements, aCrit, MaxAngle );
declareMeshModified( /*isReComputeSafe=*/!stat );
return stat;
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
- SMESH::NumericalFunctor_i* aNumericalFunctor =
- SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
+ if ( !myIsPreviewMode ) {
+ SMESH::NumericalFunctor_i* aNumericalFunctor =
+ SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
- // Update Python script
- aTPythonDump << "isDone = " << this << ".TriToQuadObject("
- << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ // Update Python script
+ aTPythonDump << "isDone = " << this << ".TriToQuadObject("
+ << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ }
return isDone;
int id = getEditor().BestSplit(quad, aCrit);
declareMeshModified( /*isReComputeSafe=*/ id < 1 );
+ return id;
}
SMESH_CATCH( SMESH::throwCorbaException );