X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_AddQuadraticElementDlg.cxx;h=49d24f18c1d39c0b59829496ce48b8ecedc68e44;hp=3a72de15241aab33b4caa01ea809753d0067e84d;hb=1c3a10f8107fc78132341eb9543a42b4ea0e4fa0;hpb=88b3dbe23b236bd1746405155ae33a76aaf59ecd diff --git a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx index 3a72de152..49d24f18c 100644 --- a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -52,9 +53,13 @@ #include #include +#include +#include #include +#include + // IDL includes #include #include CORBA_SERVER_HEADER(SMESH_MeshEditor) @@ -63,12 +68,14 @@ #include // VTK includes +#include #include #include #include #include #include #include +#include // Qt includes #include @@ -111,7 +118,7 @@ namespace } namespace SMESH { - class TElementSimulation { + class TElementSimulationQuad { SalomeApp_Application* myApplication; SUIT_ViewWindow* myViewWindow; SVTK_ViewWindow* myVTKViewWindow; @@ -119,16 +126,23 @@ namespace SMESH SALOME_Actor* myPreviewActor; vtkDataSetMapper* myMapper; vtkUnstructuredGrid* myGrid; - //vtkProperty* myBackProp, *myProp; - //vtkFloatingPointType myRGB[3], myBackRGB[3]; + SALOME_Actor* myCornerActor; + VTKViewer_PolyDataMapper* myCornerMapper; + vtkPolyData* myCornerPolyData; + + SALOME_Actor* mySelectCornerActor; + VTKViewer_PolyDataMapper* mySelectCornerMapper; + vtkPolyData* mySelectCornerPolyData; + + //double myRGB[3], myBackRGB[3]; SALOME_Actor* myFaceOrientation; vtkPolyDataMapper* myFaceOrientationDataMapper; SMESH_FaceOrientationFilter* myFaceOrientationFilter; public: - TElementSimulation (SalomeApp_Application* theApplication) + TElementSimulationQuad (SalomeApp_Application* theApplication) { myApplication = theApplication; SUIT_ViewManager* mgr = theApplication->activeViewManager(); @@ -140,23 +154,25 @@ namespace SMESH // Create and display actor myMapper = vtkDataSetMapper::New(); - myMapper->SetInput(myGrid); + myMapper->SetInputData(myGrid); myPreviewActor = SALOME_Actor::New(); myPreviewActor->PickableOff(); myPreviewActor->VisibilityOff(); myPreviewActor->SetMapper(myMapper); - + + QColor ffc, bfc; + int delta; vtkProperty* myProp = vtkProperty::New(); - vtkFloatingPointType aRGB[3], aBackRGB[3]; - GetColor( "SMESH", "fill_color", aRGB[0], aRGB[1], aRGB[2], QColor( 0, 170, 255 ) ); - myProp->SetColor( aRGB[0], aRGB[1], aRGB[2] ); + SMESH::GetColor( "SMESH", "preview_color", ffc, delta, "0, 255, 0|-100" ) ; + + myProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. ); myPreviewActor->SetProperty( myProp ); myProp->Delete(); vtkProperty* myBackProp = vtkProperty::New(); - GetColor( "SMESH", "backface_color", aBackRGB[0], aBackRGB[1], aBackRGB[2], QColor( 0, 0, 255 ) ); - myBackProp->SetColor( aBackRGB[0], aBackRGB[1], aBackRGB[2] ); + bfc = Qtx::mainColorToSecondary(ffc, delta); + myBackProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. ); myPreviewActor->SetBackfaceProperty( myBackProp ); myBackProp->Delete(); @@ -164,10 +180,10 @@ namespace SMESH // Orientation of faces myFaceOrientationFilter = SMESH_FaceOrientationFilter::New(); - myFaceOrientationFilter->SetInput(myGrid); + myFaceOrientationFilter->SetInputData(myGrid); myFaceOrientationDataMapper = vtkPolyDataMapper::New(); - myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput()); + myFaceOrientationDataMapper->SetInputConnection(myFaceOrientationFilter->GetOutputPort()); myFaceOrientation = SALOME_Actor::New(); myFaceOrientation->PickableOff(); @@ -175,12 +191,52 @@ namespace SMESH myFaceOrientation->SetMapper(myFaceOrientationDataMapper); vtkProperty* anOrientationProp = vtkProperty::New(); + double aRGB[3]; GetColor( "SMESH", "orientation_color", aRGB[0], aRGB[1], aRGB[2], QColor( 255, 255, 255 ) ); anOrientationProp->SetColor( aRGB[0], aRGB[1], aRGB[2] ); myFaceOrientation->SetProperty( anOrientationProp ); anOrientationProp->Delete(); myVTKViewWindow->AddActor(myFaceOrientation); + + // Create and display actor with corner nodes + myCornerPolyData = vtkPolyData::New(); + myCornerPolyData->Allocate(); + myCornerMapper = VTKViewer_PolyDataMapper::New(); + myCornerMapper->SetInputData(myCornerPolyData); + myCornerMapper->SetMarkerEnabled(true); + + myCornerActor = SALOME_Actor::New(); + myCornerActor->PickableOff(); + myCornerActor->VisibilityOff(); + myCornerActor->SetMapper(myCornerMapper); + + vtkProperty* myCornerProp = vtkProperty::New(); + myCornerProp->SetColor( 50 / 255. , 100 / 255. , 0 / 255. ); + myCornerActor->SetProperty( myCornerProp ); + myCornerProp->Delete(); + + myVTKViewWindow->AddActor(myCornerActor); + + // Create and display actor with selected corner nodes + mySelectCornerPolyData = vtkPolyData::New(); + mySelectCornerPolyData->Allocate(); + mySelectCornerMapper = VTKViewer_PolyDataMapper::New(); + mySelectCornerMapper->SetInputData(mySelectCornerPolyData); + mySelectCornerMapper->SetMarkerEnabled(true); + + mySelectCornerActor = SALOME_Actor::New(); + mySelectCornerActor->PickableOff(); + mySelectCornerActor->VisibilityOff(); + mySelectCornerActor->SetMapper(mySelectCornerMapper); + + vtkProperty* mySelectCornerProp = vtkProperty::New(); + mySelectCornerProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. ); + mySelectCornerActor->SetProperty( mySelectCornerProp ); + mySelectCornerProp->Delete(); + + myVTKViewWindow->AddActor(mySelectCornerActor); + } typedef std::vector TVTKIds; @@ -213,26 +269,76 @@ namespace SMESH myPreviewActor->GetMapper()->Update(); myPreviewActor->SetRepresentation( theMode ); - SetVisibility(true, theActor->GetFacesOriented()); } + void SetCornerNodes (SMESH_Actor* theActor, + TVTKIds& theIds) + { + vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); + + myCornerMapper->SetMarkerStd(theActor->GetMarkerType(), theActor->GetMarkerScale()); + myCornerPolyData->Reset(); + myCornerPolyData->DeleteCells(); + myCornerPolyData->SetPoints(aGrid->GetPoints()); - void SetVisibility (bool theVisibility, bool theShowOrientation = false) + vtkIdList *anIds = vtkIdList::New(); + for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) { + anIds->InsertId(i,theIds[i]); + myCornerPolyData->InsertNextCell(VTK_VERTEX, anIds); + anIds->Reset(); + } + anIds->Delete(); + myCornerPolyData->Modified(); + myCornerActor->GetMapper()->Update(); + myCornerActor->SetRepresentation(SMESH_Actor::ePoint); + } + void SetSelectedNodes (SMESH_Actor* theActor, + TVTKIds& theIds) + { + vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); + + mySelectCornerMapper->SetMarkerStd(theActor->GetMarkerType(), theActor->GetMarkerScale()); + + mySelectCornerPolyData->Reset(); + mySelectCornerPolyData->DeleteCells(); + mySelectCornerPolyData->SetPoints(aGrid->GetPoints()); + + vtkIdList *anIds = vtkIdList::New(); + for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) { + anIds->InsertId(i,theIds[i]); + mySelectCornerPolyData->InsertNextCell(VTK_VERTEX, anIds); + anIds->Reset(); + } + anIds->Delete(); + mySelectCornerPolyData->Modified(); + mySelectCornerActor->GetMapper()->Update(); + mySelectCornerActor->SetRepresentation(SMESH_Actor::ePoint); + } + + void SetVisibility ( bool theVisibility, + bool theCornerVisibility = false, + bool theSelectCornerVisibility = false, + bool theShowOrientation = false ) { myPreviewActor->SetVisibility(theVisibility); myFaceOrientation->SetVisibility(theShowOrientation); + myCornerActor->SetVisibility(theCornerVisibility); + mySelectCornerActor->SetVisibility(theSelectCornerVisibility); RepaintCurrentView(); } - - ~TElementSimulation() + ~TElementSimulationQuad() { if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) { myVTKViewWindow->RemoveActor(myPreviewActor); myVTKViewWindow->RemoveActor(myFaceOrientation); + myVTKViewWindow->RemoveActor(myCornerActor); + myVTKViewWindow->RemoveActor(mySelectCornerActor); } myPreviewActor->Delete(); myFaceOrientation->Delete(); + myCornerActor->Delete(); + mySelectCornerActor->Delete(); myMapper->RemoveAllInputs(); myMapper->Delete(); @@ -244,6 +350,14 @@ namespace SMESH myGrid->Delete(); + myCornerMapper->RemoveAllInputs(); + myCornerMapper->Delete(); + myCornerPolyData->Delete(); + + mySelectCornerMapper->RemoveAllInputs(); + mySelectCornerMapper->Delete(); + mySelectCornerPolyData->Delete(); + // myProp->Delete(); // myBackProp->Delete(); } @@ -278,7 +392,6 @@ static int LastHexahedronIds[] = {1,2,3,0,5,6,7,4,4,5,6,7}; \brief Simple 'busy state' flag locker. \internal */ - class BusyLocker { public: @@ -295,7 +408,6 @@ private: \brief Simple editable table item. \internal */ - class IdEditItem: public QTableWidgetItem { public: @@ -325,6 +437,7 @@ QWidget* IdEditItem::createEditor() const // function : SMESHGUI_AddQuadraticElementDlg() // purpose : constructor //================================================================================= + SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theModule, const SMDSAbs_EntityType theType ) : QDialog( SMESH::GetDesktop( theModule ) ), @@ -340,7 +453,7 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM SalomeApp_Application* anApp = dynamic_cast (SUIT_Session::session()->activeApplication()); - mySimulation = new SMESH::TElementSimulation (anApp); + mySimulation = new SMESH::TElementSimulationQuad (anApp); mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); QString anElementName; @@ -358,6 +471,9 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM case SMDSEntity_BiQuad_Quadrangle: anElementName = QString("BIQUADRATIC_QUADRANGLE"); break; + case SMDSEntity_BiQuad_Triangle: + anElementName = QString("BIQUADRATIC_TRIANGLE"); + break; case SMDSEntity_Quad_Tetra: anElementName = QString("QUADRATIC_TETRAHEDRON"); break; @@ -436,19 +552,30 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM myCenterNode->setValidator(new SMESHGUI_IdValidator(this, 1)); myReverseCB = new QCheckBox(tr("SMESH_REVERSE"), GroupArguments); + myAutomaticPresentation = (myGeomType == SMDSEntity_Quad_Quadrangle || myGeomType == SMDSEntity_BiQuad_Quadrangle || + myGeomType == SMDSEntity_Quad_Pyramid || myGeomType == SMDSEntity_Quad_Penta || + myGeomType == SMDSEntity_Quad_Hexa || myGeomType == SMDSEntity_TriQuad_Hexa ) ? new QCheckBox(tr("SMESH_AUTOMATIC_PRESENTATION"), GroupArguments) : 0; + if ( myAutomaticPresentation ) { + myNextPresentationButton = new QPushButton(tr("SMESH_BUT_GET_NEXT_SHAPE"), GroupArguments); + myNextPresentationButton->setAutoDefault(false); + } aGroupArgumentsLayout->addWidget(aCornerNodesLabel, 0, 0); aGroupArgumentsLayout->addWidget(myCornerSelectButton, 0, 1); aGroupArgumentsLayout->addWidget(myCornerNodes, 0, 2); - aGroupArgumentsLayout->addWidget(myTable, 1, 0, 1, 3); - aGroupArgumentsLayout->addWidget(myMidFaceLabel, 2, 0); - aGroupArgumentsLayout->addWidget(myMidFaceSelectButton, 2, 1); - aGroupArgumentsLayout->addWidget(myMidFaceNodes, 2, 2); - aGroupArgumentsLayout->addWidget(myCenterLabel, 3, 0); - aGroupArgumentsLayout->addWidget(myCenterSelectButton, 3, 1); - aGroupArgumentsLayout->addWidget(myCenterNode, 3, 2); - aGroupArgumentsLayout->addWidget(myReverseCB, 4, 0, 1, 3); - + if ( myAutomaticPresentation ) { + myAutomaticPresentation->setChecked(true); + aGroupArgumentsLayout->addWidget(myAutomaticPresentation, 1, 0, 1, 2); + aGroupArgumentsLayout->addWidget(myNextPresentationButton, 1, 2, 1, 1); + } + aGroupArgumentsLayout->addWidget(myTable, 2, 0, 1, 3); + aGroupArgumentsLayout->addWidget(myMidFaceLabel, 3, 0); + aGroupArgumentsLayout->addWidget(myMidFaceSelectButton, 3, 1); + aGroupArgumentsLayout->addWidget(myMidFaceNodes, 3, 2); + aGroupArgumentsLayout->addWidget(myCenterLabel, 4, 0); + aGroupArgumentsLayout->addWidget(myCenterSelectButton, 4, 1); + aGroupArgumentsLayout->addWidget(myCenterNode, 4, 2); + aGroupArgumentsLayout->addWidget(myReverseCB, 5, 0, 1, 3); /***************************************************************/ GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this ); GroupGroups->setCheckable( true ); @@ -501,6 +628,7 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM // function : ~SMESHGUI_AddQuadraticElementDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= + SMESHGUI_AddQuadraticElementDlg::~SMESHGUI_AddQuadraticElementDlg() { delete mySimulation; @@ -510,6 +638,7 @@ SMESHGUI_AddQuadraticElementDlg::~SMESHGUI_AddQuadraticElementDlg() // function : Init() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::Init() { myRadioButton1->setChecked(true); @@ -535,6 +664,12 @@ void SMESHGUI_AddQuadraticElementDlg::Init() myNbCorners = 3; myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_triangles break; + case SMDSEntity_BiQuad_Triangle: + aNumRows = 3; + myNbCorners = 3; + myNbCenterNodes = 1; + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_triangles + break; case SMDSEntity_Quad_Quadrangle: aNumRows = 4; myNbCorners = 4; @@ -635,7 +770,10 @@ void SMESHGUI_AddQuadraticElementDlg::Init() connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(reject())); connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), SLOT(reject())); - + if (myAutomaticPresentation) { + connect(myAutomaticPresentation, SIGNAL(stateChanged(int)), SLOT(SetCurrentSelection())); + connect(myNextPresentationButton, SIGNAL(clicked()), SLOT(SetCurrentSelection())); + } myCurrentLineEdit = myCornerNodes; // set selection mode @@ -651,13 +789,14 @@ void SMESHGUI_AddQuadraticElementDlg::Init() // function : ClickOnApply() // purpose : //================================================================================= -void SMESHGUI_AddQuadraticElementDlg::ClickOnApply() + +bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply() { if( !isValid() ) - return; + return false; if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() ) - return; + return false; BusyLocker lock( myBusy ); @@ -671,6 +810,7 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnApply() break; case SMDSEntity_Quad_Triangle: case SMDSEntity_Quad_Quadrangle: + case SMDSEntity_BiQuad_Triangle: case SMDSEntity_BiQuad_Quadrangle: case SMDSEntity_Quad_Tetra: case SMDSEntity_Quad_Pyramid: @@ -722,7 +862,7 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnApply() int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ), tr( "MESH_STANDALONE_GRP_CHOSEN" ).arg( aGroupName ), tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ); - if ( res == 1 ) return; + if ( res == 1 ) return false; } aGroup = myGroups[idx-1]; } @@ -737,6 +877,7 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnApply() anElemId = aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; case SMDSEntity_Quad_Triangle: case SMDSEntity_Quad_Quadrangle: + case SMDSEntity_BiQuad_Triangle: case SMDSEntity_BiQuad_Quadrangle: anElementType = SMESH::FACE; anElemId = aMeshEditor->AddFace(anArrayOfIdeces.inout()); break; @@ -794,22 +935,26 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnApply() updateButtons(); SMESHGUI::Modified(); + + return true; } //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::ClickOnOk() { - ClickOnApply(); - reject(); + if ( ClickOnApply() ) + reject(); } //================================================================================= // function : reject() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::reject() { mySelectionMgr->clearSelected(); @@ -826,6 +971,7 @@ void SMESHGUI_AddQuadraticElementDlg::reject() // function : ClickOnHelp() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::ClickOnHelp() { LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); @@ -850,6 +996,7 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnHelp() // function : onTextChange() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText) { if (myBusy) return; @@ -892,7 +1039,6 @@ void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText) if ( myCurrentLineEdit == myCornerNodes ) UpdateTable( allOk ); } - updateButtons(); displaySimulation(); } @@ -901,48 +1047,47 @@ void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText) // function : SelectionIntoArgument() // purpose : Called when selection has changed //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() { if (myBusy) return; BusyLocker lock( myBusy ); QString aCurrentEntry = myEntry; - - if ( myCurrentLineEdit ) - { - // clear - myActor = 0; - + QString anOldEditArgument = ""; + // clear + myActor = 0; + if ( myCurrentLineEdit ) { + anOldEditArgument = myCurrentLineEdit->text(); myCurrentLineEdit->setText(""); + } - if (!GroupButtons->isEnabled()) // inactive - return; - - mySimulation->SetVisibility(false); - - // get selected mesh - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + if (!GroupButtons->isEnabled()) // inactive + return; - if (aList.Extent() != 1) - { - UpdateTable(); - updateButtons(); - return; - } + mySimulation->SetVisibility(false); - Handle(SALOME_InteractiveObject) anIO = aList.First(); - myEntry = anIO->getEntry(); - myMesh = SMESH::GetMeshByIO(anIO); - if (myMesh->_is_nil()) { - updateButtons(); - return; - } + // get selected mesh + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); - myActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (aList.Extent() != 1) + { + UpdateTable(); + updateButtons(); + return; + } + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myEntry = anIO->getEntry(); + myMesh = SMESH::GetMeshByIO(anIO); + if (myMesh->_is_nil()) { + updateButtons(); + return; } + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + // process groups if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) { SMESH::ElementType anElementType; @@ -951,6 +1096,7 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() anElementType = SMESH::EDGE; break; case SMDSEntity_Quad_Triangle: case SMDSEntity_Quad_Quadrangle: + case SMDSEntity_BiQuad_Triangle: case SMDSEntity_BiQuad_Quadrangle: anElementType = SMESH::FACE; break; case SMDSEntity_Quad_Tetra: @@ -980,18 +1126,42 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() updateButtons(); return; } - + if ( myAutomaticPresentation ) + myNextPresentationButton->setEnabled(false); // get selected nodes QString aString = ""; - int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString); - + int nbNodes = 0; + while ( aString == "" || anOldEditArgument == aString ) { + if ( myAutomaticPresentation && myAutomaticPresentation->isChecked() ) { + nbNodes = SMESH::GetNameOfSelectedSortedNodes( myGeomType , mySelector, myActor, myShift, aString ); + } + else + nbNodes = SMESH::GetNameOfSelectedNodes( mySelector, myActor->getIO(), aString ); + if ( aString!= "" && myNbCorners == nbNodes && anOldEditArgument == aString && myAutomaticPresentation && myAutomaticPresentation->isChecked()) { + myShift++; + if ( myShift > nbNodes ) { + myShift = 0; + break; + } + continue; + } + if (myNbCorners != nbNodes && myNbCorners != 1) { + myShift = 0; + break; + } + if ( !myAutomaticPresentation || !myAutomaticPresentation->isChecked() ) + break; + } if ( myCurrentLineEdit ) { - if ( myCurrentLineEdit != myCenterNode || nbNodes == 1 ) + if ( myCurrentLineEdit != myCenterNode || nbNodes == 1) myCurrentLineEdit->setText(aString); - if ( myCurrentLineEdit == myCornerNodes ) + if ( myCurrentLineEdit == myCornerNodes ) { UpdateTable(); + if ( myAutomaticPresentation && myAutomaticPresentation->isChecked() && myNbCorners == nbNodes) + myNextPresentationButton->setEnabled(true); + } } else if ( myTable->isEnabled() && nbNodes == 1 ) { @@ -999,7 +1169,6 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() if ( theCol == 1 ) myTable->item(theRow, 1)->setText(aString); } - updateButtons(); displaySimulation(); } @@ -1008,17 +1177,18 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() // function : displaySimulation() // purpose : //================================================================================= -void SMESHGUI_AddQuadraticElementDlg::displaySimulation() + +void SMESHGUI_AddQuadraticElementDlg::displaySimulation(int theRow, int theCol) { - if ( IsValid() ) + bool isValid = IsValid(); + if ( ( isValid || myTable->isEnabled() ) && myActor ) { - SMESH::TElementSimulation::TVTKIds anIds; + SMESH::TElementSimulationQuad::TVTKIds anIds; // Collect ids from the dialog int anID; bool ok; int aDisplayMode = VTK_SURFACE; - if ( myGeomType == SMDSEntity_Quad_Edge ) { anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) ); @@ -1042,20 +1212,33 @@ void SMESHGUI_AddQuadraticElementDlg::displaySimulation() } anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) ); } - if ( myNbMidFaceNodes ) + if ( myNbMidFaceNodes && isValid) { QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts); for (int i = 0; i < aListId.count(); i++) anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() )); } - if ( myNbCenterNodes ) + if ( myNbCenterNodes && isValid) { QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts); anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ 0 ].toInt() )); } } - - mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked()); + if ( isValid ) + mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked()); + mySimulation->SetCornerNodes(myActor, anIds); + if ( theCol == 1 ) { + anIds.clear(); + anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(theRow, 0)->text().toInt() ) ); + anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(theRow, 2)->text().toInt() ) ); + bool ok; + int anID; + anID = myTable->item(theRow, 1)->text().toInt(&ok); + if (ok) + anIds.push_back(myActor->GetObject()->GetNodeVTKId(anID)); + mySimulation->SetSelectedNodes(myActor, anIds); + } + mySimulation->SetVisibility(isValid, true, true, myActor->GetFacesOriented()); } else { @@ -1068,17 +1251,22 @@ void SMESHGUI_AddQuadraticElementDlg::displaySimulation() // function : SetCurrentSelection() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::SetCurrentSelection() { QPushButton* send = (QPushButton*)sender(); myCurrentLineEdit = 0; - if (send == myCornerSelectButton) + if (send == myCornerSelectButton || (QCheckBox*)sender() == myAutomaticPresentation) myCurrentLineEdit = myCornerNodes; else if ( send == myMidFaceSelectButton ) myCurrentLineEdit = myMidFaceNodes; else if ( send == myCenterSelectButton ) myCurrentLineEdit = myCenterNode; + else if (send == myNextPresentationButton ) { + myShift++; + myCurrentLineEdit = myCornerNodes; + } if ( myCurrentLineEdit ) { @@ -1091,6 +1279,7 @@ void SMESHGUI_AddQuadraticElementDlg::SetCurrentSelection() // function : DeactivateActiveDialog() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::DeactivateActiveDialog() { if (GroupConstructors->isEnabled()) { @@ -1107,6 +1296,7 @@ void SMESHGUI_AddQuadraticElementDlg::DeactivateActiveDialog() // function : ActivateThisDialog() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ @@ -1127,6 +1317,7 @@ void SMESHGUI_AddQuadraticElementDlg::ActivateThisDialog() // function : enterEvent() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::enterEvent (QEvent*) { if (GroupConstructors->isEnabled()) @@ -1138,6 +1329,7 @@ void SMESHGUI_AddQuadraticElementDlg::enterEvent (QEvent*) // function : onReverse() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::onReverse (int state) { mySimulation->SetVisibility(false); @@ -1145,11 +1337,11 @@ void SMESHGUI_AddQuadraticElementDlg::onReverse (int state) updateButtons(); } - //================================================================================= // function : IsValid() // purpose : //================================================================================= + bool SMESHGUI_AddQuadraticElementDlg::IsValid() { SMDS_Mesh* aMesh = 0; @@ -1196,6 +1388,7 @@ bool SMESHGUI_AddQuadraticElementDlg::IsValid() // function : UpdateTable() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) { QStringList aListCorners = myCornerNodes->text().split(" ", QString::SkipEmptyParts); @@ -1217,6 +1410,7 @@ void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) aLastColIds = LastEdgeIds; break; case SMDSEntity_Quad_Triangle: + case SMDSEntity_BiQuad_Triangle: aFirstColIds = FirstTriangleIds; aLastColIds = LastTriangleIds; break; @@ -1262,27 +1456,27 @@ void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) } } - //================================================================================= // function : onTableActivate() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol ) { myCurrentLineEdit = 0; - displaySimulation(); + displaySimulation(theRow, theCol); updateButtons(); } - //================================================================================= // function : onCellTextChange() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol) { myCurrentLineEdit = 0; - displaySimulation(); + displaySimulation(theRow, theCol); updateButtons(); } @@ -1290,6 +1484,7 @@ void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol) // function : keyPressEvent() // purpose : //================================================================================= + void SMESHGUI_AddQuadraticElementDlg::keyPressEvent( QKeyEvent* e ) { QDialog::keyPressEvent( e ); @@ -1302,6 +1497,11 @@ void SMESHGUI_AddQuadraticElementDlg::keyPressEvent( QKeyEvent* e ) } } +//======================================================================= +//function : updateButtons +//purpose : +//======================================================================= + void SMESHGUI_AddQuadraticElementDlg::updateButtons() { bool valid = IsValid(); @@ -1313,6 +1513,7 @@ void SMESHGUI_AddQuadraticElementDlg::updateButtons() // function : isValid // purpose : //================================================================================= + bool SMESHGUI_AddQuadraticElementDlg::isValid() { if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {