1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SMESHGUI_ReorientFacesDlg.cxx
24 // Author : Edward AGAPOV, Open CASCADE S.A.S.
27 #include "SMESHGUI_ReorientFacesDlg.h"
30 #include "SMESHGUI_IdValidator.h"
31 #include "SMESHGUI_MeshUtils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_SpinBox.h"
34 #include "SMESHGUI_MeshEditPreview.h"
36 #include <SMDS_Mesh.hxx>
37 #include <SMESH_Actor.h>
38 #include <SMESH_ActorUtils.h>
39 #include <SMESH_NumberFilter.hxx>
40 #include <SMESH_LogicalFilter.hxx>
41 #include <SMESH_TypeFilter.hxx>
43 // SALOME GEOM includes
46 // SALOME GUI includes
47 #include <LightApp_SelectionMgr.h>
48 #include <SALOME_ListIO.hxx>
49 #include <SALOME_ListIteratorOfListIO.hxx>
50 #include <SUIT_Desktop.h>
51 #include <SUIT_MessageBox.h>
52 #include <SUIT_OverrideCursor.h>
53 #include <SUIT_ResourceMgr.h>
54 #include <SVTK_ViewModel.h>
55 #include <SVTK_ViewWindow.h>
56 #include <SalomeApp_Tools.h>
57 #include <SalomeApp_TypeFilter.h>
59 // SALOME KERNEL includes
60 #include <SALOMEDS_SObject.hxx>
63 #include <BRep_Tool.hxx>
64 #include <TColStd_MapOfInteger.hxx>
65 #include <TColgp_SequenceOfXYZ.hxx>
66 #include <TopoDS_Vertex.hxx>
71 #include <QGridLayout>
72 #include <QHBoxLayout>
73 #include <QVBoxLayout>
75 #include <QPushButton>
77 #include <QRadioButton>
79 #include <QButtonGroup>
82 #include <vtkProperty.h>
85 #include <SALOMEconfig.h>
86 #include CORBA_SERVER_HEADER(SMESH_Mesh)
87 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
95 enum { CONSTRUCTOR_POINT=0, CONSTRUCTOR_FACE,
96 EObject, EPoint, EFace, EDirection };
98 //=======================================================================
100 * \brief Dialog to reorient faces acoording to vector
102 //=======================================================================
104 SMESHGUI_ReorientFacesDlg::SMESHGUI_ReorientFacesDlg()
105 : SMESHGUI_Dialog( 0, false, true )
107 setWindowTitle(tr("CAPTION"));
109 QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
110 aDlgLay->setMargin(0);
111 aDlgLay->setSpacing(SPACING);
113 QWidget* aMainFrame = createMainFrame (mainFrame());
115 aDlgLay->addWidget(aMainFrame);
117 aDlgLay->setStretchFactor(aMainFrame, 1);
120 //================================================================================
122 * \brief Create frame containing dialog's input fields
124 //================================================================================
126 QWidget* SMESHGUI_ReorientFacesDlg::createMainFrame (QWidget* theParent)
128 QWidget* aFrame = new QWidget(theParent);
132 QPixmap iconReoriPoint (resMgr()->loadPixmap("SMESH", tr("ICON_DLG_REORIENT2D_POINT")));
133 QPixmap iconReoriFace (resMgr()->loadPixmap("SMESH", tr("ICON_DLG_REORIENT2D_FACE")));
135 QGroupBox* aConstructorBox = new QGroupBox(tr("REORIENT_FACES"), aFrame);
136 myConstructorGrp = new QButtonGroup(aConstructorBox);
137 QHBoxLayout* aConstructorGrpLayout = new QHBoxLayout(aConstructorBox);
138 aConstructorGrpLayout->setMargin(MARGIN);
139 aConstructorGrpLayout->setSpacing(SPACING);
141 QRadioButton* aPntBut = new QRadioButton(aConstructorBox);
142 aPntBut->setIcon(iconReoriPoint);
143 aPntBut->setChecked(true);
144 aConstructorGrpLayout->addWidget(aPntBut);
145 myConstructorGrp->addButton(aPntBut, CONSTRUCTOR_POINT);
147 QRadioButton* aFaceBut= new QRadioButton(aConstructorBox);
148 aFaceBut->setIcon(iconReoriFace);
149 aConstructorGrpLayout->addWidget(aFaceBut);
150 myConstructorGrp->addButton(aFaceBut, CONSTRUCTOR_FACE);
152 // Create other controls
154 setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
156 createObject( tr("OBJECT") , aFrame, EObject );
157 createObject( tr("POINT") , aFrame, EPoint );
158 createObject( tr("FACE") , aFrame, EFace );
159 createObject( tr("DIRECTION"), aFrame, EDirection );
160 setNameIndication( EObject, OneName );
161 setNameIndication( EFace, OneName );
162 setReadOnly( EFace, false );
163 if ( QLineEdit* le = qobject_cast<QLineEdit*>( objectWg( EFace, Control ) ))
164 le->setValidator( new SMESHGUI_IdValidator( this,1 ));
166 const int width = aFaceBut->fontMetrics().width( tr("DIRECTION"));
167 objectWg( EDirection, Label )->setFixedWidth( width );
168 objectWg( EObject , Label )->setFixedWidth( width );
169 objectWg( EPoint , Label )->setFixedWidth( width );
170 objectWg( EFace , Label )->setFixedWidth( width );
172 QLabel* aXLabel = new QLabel(tr("SMESH_X"), aFrame);
173 myX = new SMESHGUI_SpinBox(aFrame);
174 QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aFrame);
175 myY = new SMESHGUI_SpinBox(aFrame);
176 QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aFrame);
177 myZ = new SMESHGUI_SpinBox(aFrame);
179 myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
180 myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
181 myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
186 QLabel* aDXLabel = new QLabel(tr("SMESH_DX"), aFrame);
187 myDX = new SMESHGUI_SpinBox(aFrame);
188 QLabel* aDYLabel = new QLabel(tr("SMESH_DY"), aFrame);
189 myDY = new SMESHGUI_SpinBox(aFrame);
190 QLabel* aDZLabel = new QLabel(tr("SMESH_DZ"), aFrame);
191 myDZ = new SMESHGUI_SpinBox(aFrame);
196 myDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
197 myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
198 myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
202 QGroupBox* anObjectGrp = new QGroupBox(tr("FACES"), aFrame);
203 QHBoxLayout* anObjectGrpLayout = new QHBoxLayout(anObjectGrp);
204 anObjectGrpLayout->setMargin(MARGIN);
205 anObjectGrpLayout->setSpacing(SPACING);
206 anObjectGrpLayout->addWidget( objectWg( EObject, Label ));
207 anObjectGrpLayout->addWidget( objectWg( EObject, Btn ));
208 anObjectGrpLayout->addWidget( objectWg( EObject, Control ));
210 myPointFrm = new QFrame(aFrame);
211 QHBoxLayout* aPointGrpLayout = new QHBoxLayout(myPointFrm);
212 aPointGrpLayout->setMargin(0);
213 objectWg( EPoint, Control )->hide();
214 aPointGrpLayout->addWidget( objectWg( EPoint, Label ) );
215 aPointGrpLayout->addWidget( objectWg( EPoint, Btn ) );
216 aPointGrpLayout->addWidget( aXLabel );
217 aPointGrpLayout->addWidget( myX );
218 aPointGrpLayout->addWidget( aYLabel );
219 aPointGrpLayout->addWidget( myY );
220 aPointGrpLayout->addWidget( aZLabel );
221 aPointGrpLayout->addWidget( myZ );
223 myFaceFrm = new QFrame(aFrame);
224 QHBoxLayout* aFaceGrpLayout = new QHBoxLayout(myFaceFrm);
225 aFaceGrpLayout->setMargin(0);
226 aFaceGrpLayout->addWidget( objectWg( EFace, Label ) );
227 aFaceGrpLayout->addWidget( objectWg( EFace, Btn ) );
228 aFaceGrpLayout->addWidget( objectWg( EFace, Control ) );
230 QFrame* aDirectFrm = new QFrame(aFrame);
231 QHBoxLayout* aDirectGrpLayout = new QHBoxLayout(aDirectFrm);
232 aDirectGrpLayout->setMargin(0);
233 objectWg( EDirection, Control )->hide();
234 aDirectGrpLayout->addWidget( objectWg( EDirection, Label ) );
235 aDirectGrpLayout->addWidget( objectWg( EDirection, Btn ) );
236 aDirectGrpLayout->addWidget(aDXLabel );
237 aDirectGrpLayout->addWidget(myDX );
238 aDirectGrpLayout->addWidget(aDYLabel );
239 aDirectGrpLayout->addWidget(myDY );
240 aDirectGrpLayout->addWidget(aDZLabel );
241 aDirectGrpLayout->addWidget(myDZ );
244 QGroupBox* anOrientGrp = new QGroupBox(tr("ORIENTATION"), aFrame);
245 QVBoxLayout* anOrientGrpLayout = new QVBoxLayout ( anOrientGrp );
246 anOrientGrpLayout->addWidget(myPointFrm);
247 anOrientGrpLayout->addWidget(myFaceFrm);
248 anOrientGrpLayout->addWidget(aDirectFrm);
251 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
252 aLay->addWidget(aConstructorBox);
253 aLay->addWidget(anObjectGrp);
254 aLay->addWidget(anOrientGrp);
256 connect( myConstructorGrp, SIGNAL(buttonClicked (int)), this, SLOT(constructorChange(int)));
261 //================================================================================
263 * \brief Show point or face
265 //================================================================================
267 void SMESHGUI_ReorientFacesDlg::constructorChange(int id)
269 if ( id == CONSTRUCTOR_FACE )
273 activateObject( EFace );
279 activateObject( EPoint );
283 //================================================================================
287 //================================================================================
289 SMESHGUI_ReorientFacesOp::SMESHGUI_ReorientFacesOp()
290 :SMESHGUI_SelectionOp( ActorSelection )
292 //myVectorPreview = 0;
293 myHelpFileName = "reorient_faces_page.html";
295 myDlg = new SMESHGUI_ReorientFacesDlg;
296 myDlg->constructorChange( CONSTRUCTOR_POINT );
298 // connect signals and slots
299 connect( myDlg->objectWg( EFace, LightApp_Dialog::Control ), SIGNAL(textChanged(const QString&)),
300 this, SLOT(onTextChange(const QString&)));
301 // connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
302 // connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
303 // connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
304 // connect(myDlg->myDX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
305 // connect(myDlg->myDY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
306 // connect(myDlg->myDZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
310 //=======================================================================
311 // function : startOperation()
312 // purpose : Init dialog fields, connect signals and slots, show dialog
313 //=======================================================================
315 void SMESHGUI_ReorientFacesOp::startOperation()
319 // init simulation with a current View
320 //if ( myVectorPreview ) delete myVectorPreview;
321 // myVectorPreview = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
322 // vtkProperty* aProp = vtkProperty::New();
323 // aProp->SetRepresentationToWireframe();
324 // aProp->SetColor(250, 0, 250);
325 // aProp->SetPointSize(5);
326 // aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
327 // myVectorPreview->GetActor()->SetProperty(aProp);
330 SMESHGUI_SelectionOp::startOperation();
335 myDlg->activateObject( EObject );
338 //================================================================================
340 * \brief Stops operation
342 //================================================================================
344 void SMESHGUI_ReorientFacesOp::stopOperation()
346 //myVectorPreview->SetVisibility(false);
347 if ( myObjectActor ) {
348 myObjectActor->SetPointRepresentation(false);
349 SMESH::RepaintCurrentView();
352 SMESHGUI_SelectionOp::stopOperation();
353 myDlg->deactivateAll();
356 //================================================================================
358 * \brief Set selection mode corresponding to a pressed selection button
360 //================================================================================
362 void SMESHGUI_ReorientFacesOp::onActivateObject( int what )
364 if ( what == mySelectionMode )
366 mySelectionMode = what;
367 switch ( mySelectionMode )
371 SMESH::SetPointRepresentation(true);
372 setSelectionMode( NodeSelection );
373 SMESH::SetPickable();
376 SMESH::SetPointRepresentation(false);
377 setSelectionMode( ActorSelection );
380 SMESH::SetPointRepresentation(false);
381 setSelectionMode( FaceSelection );
383 SMESH::SetPickable( myObjectActor );
385 SMESH::SetPickable();
388 SMESHGUI_SelectionOp::onActivateObject( what );
391 //================================================================================
393 * \brief Creates a filter corresponding to a pressed selection button
395 //================================================================================
397 SUIT_SelectionFilter* SMESHGUI_ReorientFacesOp::createFilter( const int what ) const
403 QList<SUIT_SelectionFilter*> filters;
404 filters.append( new SMESH_TypeFilter( SMESH::MESH ));
405 filters.append( new SMESH_TypeFilter( SMESH::SUBMESH_FACE ));
406 filters.append( new SMESH_TypeFilter( SMESH::GROUP_FACE ));
407 return new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
411 QList<SUIT_SelectionFilter*> filters;
412 filters.append( new SMESH_TypeFilter( SMESH::IDSOURCE ));
413 filters.append( new SMESH_NumberFilter( "GEOM",TopAbs_VERTEX, 1, TopAbs_VERTEX ));
414 return new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
419 return new SMESH_TypeFilter( SMESH::IDSOURCE );
425 //================================================================================
427 * \brief get data from selection
429 //================================================================================
431 void SMESHGUI_ReorientFacesOp::selectionDone()
433 if ( !myDlg->isVisible() || !myDlg->isEnabled() )
436 myDlg->clearSelection( mySelectionMode );
439 selectionMgr()->selectedObjects(aList);
440 const int nbSelected = aList.Extent();
441 if ( nbSelected == 0 )
444 Handle(SALOME_InteractiveObject) anIO = aList.First();
448 switch ( mySelectionMode )
450 case EObject: { // get an actor of object
452 if ( nbSelected == 1 )
454 myDlg->selectObject( EObject, anIO->getName(), 0, anIO->getEntry(), true );
455 // typeById( aList.First()->getEntry(),
456 // SMESHGUI_SelectionOp::Object ),
457 myObjectActor = SMESH::FindActorByEntry( anIO->getEntry() );
461 case EFace: { // get a face ID
463 if ( nbSelected == 1 )
465 TColStd_IndexedMapOfInteger faceIndices;
466 selector()->GetIndex( anIO, faceIndices );
467 if ( faceIndices.Extent() == 1 )
469 SMESH_Actor* savedActor = myObjectActor;
470 myObjectActor = 0; // to prevent work of onTextChange()
471 myDlg->setObjectText( EFace, QString("%1").arg( faceIndices(1) ));
472 myObjectActor = savedActor;
474 if ( !myObjectActor )
476 myDlg->selectObject( EObject, anIO->getName(), 0, anIO->getEntry(), true );
477 // typeById( aList.First()->getEntry(),
478 // SMESHGUI_SelectionOp::Object ),
479 myObjectActor = SMESH::FindActorByEntry( anIO->getEntry() );
486 case EDirection: { // set XYZ by selected nodes or vertices
488 if ( mySelectionMode == EPoint && aList.Extent() > 1 )
491 TColgp_SequenceOfXYZ points;
492 for( SALOME_ListIteratorOfListIO anIt( aList ); anIt.More(); anIt.Next() )
495 GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
496 if ( !geom->_is_nil() ) {
497 TopoDS_Vertex aShape;
498 if ( GEOMBase::GetShape(geom, aShape) && aShape.ShapeType() == TopAbs_VERTEX ) {
499 gp_Pnt P = BRep_Tool::Pnt(aShape);
500 points.Append( P.XYZ() );
505 TColStd_IndexedMapOfInteger nodeIndices;
506 selector()->GetIndex( anIO, nodeIndices );
507 if ( nodeIndices.Extent() > 0 && nodeIndices.Extent() <=2 )
509 if ( SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry()))
510 if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh())
512 if (const SMDS_MeshNode* aNode = aMesh->FindNode( nodeIndices(1)))
513 points.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z()));
514 if ( nodeIndices.Extent() == 2 )
515 if (const SMDS_MeshNode* aNode = aMesh->FindNode( nodeIndices(2)))
516 points.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z()));
522 if ( points.Length() == 1 )
524 else if ( points.Length() == 2 )
525 xyz = points(2) - points(1);
528 if ( points.Length() == 1 && mySelectionMode == EPoint )
530 myDlg->myX->SetValue( xyz.X() );
531 myDlg->myY->SetValue( xyz.Y() );
532 myDlg->myZ->SetValue( xyz.Z() );
535 if ( mySelectionMode == EDirection )
537 myDlg->myDX->SetValue( xyz.X() );
538 myDlg->myDY->SetValue( xyz.Y() );
539 myDlg->myDZ->SetValue( xyz.Z() );
543 } // case EPoint || EDirection
551 //================================================================================
553 * \brief SLOT called when the face id is changed
555 //================================================================================
557 void SMESHGUI_ReorientFacesOp::onTextChange( const QString& theText )
561 sender()->blockSignals( true );
562 if ( mySelectionMode != EFace )
564 myDlg->activateObject( EFace );
565 myDlg->setObjectText( EFace, theText );
567 TColStd_MapOfInteger ids;
568 if ( !theText.isEmpty() && theText.toInt() > 0 )
569 ids.Add( theText.toInt() );
571 SMESHGUI_SelectionOp::addOrRemoveIndex( myObjectActor->getIO(), ids, false );
572 SMESHGUI_SelectionOp::highlight( myObjectActor->getIO(), true, true );
573 sender()->blockSignals( false );
577 //================================================================================
579 * \brief perform it's intention action: reorient faces of myObject
581 //================================================================================
583 bool SMESHGUI_ReorientFacesOp::onApply()
585 if( isStudyLocked() )
589 if ( !isValid( msg ) ) { // node id is invalid
591 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), msg );
596 QStringList aParameters;
597 aParameters << myDlg->myDX->text();
598 aParameters << myDlg->myDY->text();
599 aParameters << myDlg->myDZ->text();
600 aParameters << myDlg->myX->text();
601 aParameters << myDlg->myY->text();
602 aParameters << myDlg->myZ->text();
605 SUIT_OverrideCursor wc;
606 SMESH::SMESH_Mesh_var aMesh = myObject->GetMesh();
607 if ( aMesh->_is_nil() ) return false;
609 SMESH::DirStruct direction;
610 direction.PS.x = myDlg->myDX->GetValue();
611 direction.PS.y = myDlg->myDY->GetValue();
612 direction.PS.z = myDlg->myDZ->GetValue();
614 long face = myDlg->objectText( EFace ).toInt();
615 if ( myDlg->myConstructorGrp->checkedId() == CONSTRUCTOR_POINT )
618 SMESH::PointStruct point;
619 point.x = myDlg->myX->GetValue();
620 point.y = myDlg->myY->GetValue();
621 point.z = myDlg->myZ->GetValue();
623 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
624 if (aMeshEditor->_is_nil()) return false;
626 aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
628 int aResult = aMeshEditor->Reorient2D( myObject, direction, face, point );
632 selectionMgr()->setSelectedObjects(aList,false);
634 SMESHGUI::Modified();
637 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INFORMATION"),
638 tr("NB_REORIENTED").arg(aResult));
640 catch (const SALOME::SALOME_Exception& S_ex) {
641 SalomeApp_Tools::QtCatchCorbaException(S_ex);
649 //================================================================================
651 * \brief Check data validity
653 //================================================================================
655 bool SMESHGUI_ReorientFacesOp::isValid( QString& msg )
658 QString objectEntry = myDlg->selectedObject( EObject );
659 _PTR(SObject) pSObject = studyDS()->FindObjectID( objectEntry.toLatin1().data() );
660 myObject = SMESH::SMESH_IDSource::_narrow( _CAST( SObject,pSObject )->GetObject() );
661 if ( myObject->_is_nil() )
663 msg = tr("NO_OBJECT_SELECTED");
666 bool hasFaces = false;
667 SMESH::array_of_ElementType_var types = myObject->GetTypes();
668 for ( size_t i = 0; i < types->length() && !hasFaces; ++i )
669 hasFaces = ( types[i] == SMESH::FACE );
672 msg = tr("NO_FACES");
677 gp_Vec vec( myDlg->myDX->GetValue(),
678 myDlg->myDY->GetValue(),
679 myDlg->myDZ->GetValue() );
680 if ( vec.Magnitude() < std::numeric_limits<double>::min() )
682 msg = tr("ZERO_SIZE_VECTOR");
687 if ( myDlg->myConstructorGrp->checkedId() == CONSTRUCTOR_FACE )
689 int faceID = myDlg->objectText( EFace ).toInt();
690 bool faceOK = ( faceID > 0 );
695 faceOK = ( myObjectActor->GetObject()->GetElemDimension( faceID ) == 2 );
699 SMESH::SMESH_Mesh_var aMesh = myObject->GetMesh();
700 if ( !aMesh->_is_nil() )
701 faceOK = ( aMesh->GetElementType( faceID, true ) == SMESH::FACE );
706 msg = tr("INVALID_FACE");
714 //================================================================================
718 //================================================================================
720 SMESHGUI_ReorientFacesOp::~SMESHGUI_ReorientFacesOp()
722 if ( myDlg ) delete myDlg;
723 //if ( myVectorPreview ) delete myVectorPreview;
726 //================================================================================
728 * \brief Gets dialog of this operation
729 * \retval LightApp_Dialog* - pointer to dialog of this operation
731 //================================================================================
733 LightApp_Dialog* SMESHGUI_ReorientFacesOp::dlg() const
738 //================================================================================
740 * \brief update preview
742 //================================================================================
744 void SMESHGUI_ReorientFacesOp::redisplayPreview()
746 // SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
748 // bool moveShown = false;
749 // if ( myObjectActor)
751 // const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
752 // const bool preview = myDlg->myPreviewChkBox->isChecked();
755 // myDlg->myCurrentX->SetValue(0);
756 // myDlg->myCurrentY->SetValue(0);
757 // myDlg->myCurrentZ->SetValue(0);
758 // myDlg->myDX->SetValue(0);
759 // myDlg->myDY->SetValue(0);
760 // myDlg->myDZ->SetValue(0);
761 // myDlg->myId->setText("");
764 // if ( autoSearch || isValid( msg ) )
767 // SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myObjectActor->getIO());
768 // if (!aMesh->_is_nil()) {
769 // SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
770 // if (!aPreviewer->_is_nil())
772 // SUIT_OverrideCursor aWaitCursor;
776 // anId = aPreviewer->FindNodeClosestTo(myDlg->myX->GetValue(),
777 // myDlg->myY->GetValue(),
778 // myDlg->myZ->GetValue());
780 // anId = myDlg->myId->text().toInt();
782 // // find id and/or just compute preview
783 // aPreviewer->MoveNode(anId,
784 // myDlg->myX->GetValue(),
785 // myDlg->myY->GetValue(),
786 // myDlg->myZ->GetValue());
787 // if ( autoSearch ) { // set found id
788 // QString idTxt("%1");
790 // idTxt = idTxt.arg( anId );
793 // myDlg->myId->setText( idTxt );
796 // SMESH::double_array* aXYZ = aMesh->GetNodeXYZ( anId );
797 // if( aXYZ && aXYZ->length() >= 3 )
799 // double x = aXYZ->operator[](0);
800 // double y = aXYZ->operator[](1);
801 // double z = aXYZ->operator[](2);
802 // double dx = myDlg->myX->GetValue() - x;
803 // double dy = myDlg->myY->GetValue() - y;
804 // double dz = myDlg->myZ->GetValue() - z;
805 // myDlg->myCurrentX->SetValue(x);
806 // myDlg->myCurrentY->SetValue(y);
807 // myDlg->myCurrentZ->SetValue(z);
808 // myDlg->myDX->SetValue(dx);
809 // myDlg->myDY->SetValue(dy);
810 // myDlg->myDZ->SetValue(dz);
813 // if ( preview ) { // fill preview data
814 // aMeshPreviewStruct = aPreviewer->GetPreviewData();
815 // moveShown = ( anId > 0 );
826 // aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
828 // aMeshPreviewStruct->nodesXYZ.length(1);
829 // aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
830 // aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
831 // aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
833 // aMeshPreviewStruct->elementTypes.length(1);
834 // aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
835 // aMeshPreviewStruct->elementTypes[0].isPoly = false;
836 // aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
838 // aMeshPreviewStruct->elementConnectivities.length(1);
839 // aMeshPreviewStruct->elementConnectivities[0] = 0;
843 // if ( aMeshPreviewStruct.operator->() )
845 // myVectorPreview->SetData(aMeshPreviewStruct._retn());
849 // myVectorPreview->SetVisibility(false);