X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MakeNodeAtPointDlg.cxx;h=f1b55af95c457e537a1d81eab8b1f7c91de93ec9;hp=2754b34a92436c064a1a15b786e5bdc3d0ac919b;hb=7abad597ce551f1465e71bcea533b5ac558679f6;hpb=0c5188fd2cf587b6c74c6adce920158f7edd4419 diff --git a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx index 2754b34a9..f1b55af95 100644 --- a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -84,6 +84,11 @@ #define SPACING 6 #define MARGIN 11 +namespace +{ + enum { MANUAL_MODE = 0, SEARCH_MODE }; // how a node to move is specified +} + /*! * \brief Dialog to publish a sub-shape of the mesh main shape * by selecting mesh elements @@ -326,7 +331,8 @@ void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId) myDestDX->hide(); myDestDY->hide(); myDestDZ->hide(); - if (myNodeToMoveGrp->isVisible()) {myNodeToMoveGrp->hide();} + if (myNodeToMoveGrp->isVisible()) myNodeToMoveGrp->hide(); + myDestBtn->setChecked( true ); break; } } @@ -346,23 +352,25 @@ void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId) SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp() { mySimulation = 0; + mySMESHGUI = 0; myDlg = new SMESHGUI_MakeNodeAtPointDlg; myFilter = 0; - myHelpFileName = "mesh_through_point_page.html"; + myHelpFileName = "mesh_through_point.html"; myNoPreview = false; myUpdateDestination = false; myDestCoordChanged = true; // connect signals and slots - connect(myDlg->myDestinationX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myDestinationY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myDestinationZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myDestDX, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); - connect(myDlg->myDestDY, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); - connect(myDlg->myDestDZ, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); - connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview())); - connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),SLOT(redisplayPreview())); + connect(myDlg->myDestinationX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestinationY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestinationZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestDX, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myDestDY, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myDestDZ, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myId, SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview())); + connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)), SLOT(redisplayPreview())); + connect(myDlg->myButtonGroup, SIGNAL (buttonClicked(int)), SLOT(redisplayPreview())); // IPAL22913: TC6.5.0: selected in "Move node" dialog box node is not highlighted // note: this slot seems to be lost together with removed obsolete SMESHGUI_MoveNodesDlg class @@ -395,7 +403,10 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation() // init simulation with a current View if ( mySimulation ) delete mySimulation; - mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() )); + mySMESHGUI = getSMESHGUI(); + mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ) ); + connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView())); + connect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView())); vtkProperty* aProp = vtkProperty::New(); aProp->SetRepresentationToWireframe(); aProp->SetColor(250, 0, 250); @@ -431,18 +442,11 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation() myDlg->myDestDZ->setReadOnly(true); myDlg->myRButNodeToMove->setChecked(true); - myDlg->ConstructorsClicked(GetConstructorId()); + myDlg->ConstructorsClicked( GetConstructorId() ); myDlg->show(); onSelectionDone(); // init myMeshActor - - if ( myMeshActor ) { -// myMeshActor->SetRepresentation( VTK_WIREFRAME ); - myMeshActor->SetPointRepresentation(true); - SMESH::RepaintCurrentView(); - redisplayPreview(); - } } //================================================================================= @@ -463,12 +467,20 @@ int SMESHGUI_MakeNodeAtPointOp::GetConstructorId() void SMESHGUI_MakeNodeAtPointOp::stopOperation() { myNoPreview = true; - mySimulation->SetVisibility(false); + if ( mySimulation ) + { + mySimulation->SetVisibility(false); + delete mySimulation; + mySimulation = 0; + } if ( myMeshActor ) { - myMeshActor->SetPointRepresentation(false); - SMESH::RepaintCurrentView(); myMeshActor = 0; } + SMESH::SetPointRepresentation( false ); + SMESH::RepaintCurrentView(); + + disconnect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView())); + disconnect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView())); selectionMgr()->removeFilter( myFilter ); SMESHGUI_SelectionOp::stopOperation(); } @@ -481,7 +493,7 @@ void SMESHGUI_MakeNodeAtPointOp::stopOperation() bool SMESHGUI_MakeNodeAtPointOp::onApply() { - if( isStudyLocked() ) + if( SMESHGUI::isStudyLocked() ) return false; if ( !myMeshActor ) { @@ -516,7 +528,7 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() if (aMeshEditor->_is_nil()) return true; - aMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); + aMesh->SetParameters( aParameters.join(":").toUtf8().constData() ); bool ok; int anId = myDlg->myId->text().toInt( &ok ); @@ -593,6 +605,8 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() { if ( !myDlg->isVisible() || !myDlg->isEnabled() ) return; + + myNoPreview = true; try { SALOME_ListIO aList; selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type()); @@ -601,6 +615,10 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() Handle(SALOME_InteractiveObject) anIO = aList.First(); SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) || + ( !myDlg->myNodeToMoveGrp->isVisible() )) + myMeshActor = aMeshActor; + if (!aMeshActor) { // coord by geom if ( myDlg->myDestBtn->isChecked() ) { GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface(anIO); @@ -609,63 +627,56 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() if ( GEOMBase::GetShape(geom, aShape) && aShape.ShapeType() == TopAbs_VERTEX ) { gp_Pnt P = BRep_Tool::Pnt(aShape); - myNoPreview = true; myDlg->myDestinationX->SetValue(P.X()); myDlg->myDestinationY->SetValue(P.Y()); myDlg->myDestinationZ->SetValue(P.Z()); - myNoPreview = false; - redisplayPreview(); } } + myNoPreview = false; + redisplayPreview(); return; } } - if ( !myMeshActor ) - myMeshActor = aMeshActor; - QString aString; int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString); if (nbElems == 1) { if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) { if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) { - myNoPreview = true; if ( myDlg->myDestBtn->isChecked() ) { // set coord myDlg->myDestinationX->SetValue(aNode->X()); myDlg->myDestinationY->SetValue(aNode->Y()); myDlg->myDestinationZ->SetValue(aNode->Z()); - myNoPreview = false; - redisplayPreview(); } else if ( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) { // set node to move myDlg->myId->setText(aString); - myNoPreview = false; + myDlg->myCurrentX->SetValue( aNode->X() ); + myDlg->myCurrentY->SetValue( aNode->Y() ); + myDlg->myCurrentZ->SetValue( aNode->Z() ); redisplayPreview(); } - if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) { - double x = aCurrentNode->X(); - double y = aCurrentNode->Y(); - double z = aCurrentNode->Z(); - double dx = myDlg->myDestinationX->GetValue() - x; - double dy = myDlg->myDestinationY->GetValue() - y; - double dz = myDlg->myDestinationZ->GetValue() - z; - myDlg->myCurrentX->SetValue(x); - myDlg->myCurrentY->SetValue(y); - myDlg->myCurrentZ->SetValue(z); - myDlg->myDestDX->SetValue(dx); - myDlg->myDestDY->SetValue(dy); - myDlg->myDestDZ->SetValue(dz); - myDlg->myDestDX->setReadOnly(false); - myDlg->myDestDY->setReadOnly(false); - myDlg->myDestDZ->setReadOnly(false); - } + double x = myDlg->myCurrentX->GetValue(); + double y = myDlg->myCurrentY->GetValue(); + double z = myDlg->myCurrentZ->GetValue(); + double dx = myDlg->myDestinationX->GetValue() - x; + double dy = myDlg->myDestinationY->GetValue() - y; + double dz = myDlg->myDestinationZ->GetValue() - z; + myDlg->myDestDX->SetValue(dx); + myDlg->myDestDY->SetValue(dy); + myDlg->myDestDZ->SetValue(dz); + myDlg->myDestDX->setReadOnly(false); + myDlg->myDestDY->setReadOnly(false); + myDlg->myDestDZ->setReadOnly(false); } } } } catch (...) { } + + myNoPreview = false; + redisplayPreview(); } //================================================================================ @@ -680,12 +691,15 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() return; myNoPreview = true; + if ( !myMeshActor && GetConstructorId() == SEARCH_MODE ) + onSelectionDone(); + SMESH::MeshPreviewStruct_var aMeshPreviewStruct; bool moveShown = false; if ( myMeshActor) { - const bool isPreview = myDlg->myPreviewChkBox->isChecked(); + const bool isPreview = myDlg->myPreviewChkBox->isChecked(); const bool isMoveNode = myDlg->myRButMoveWithoutNode->isChecked(); QString msg; if ( isValid( msg ) ) @@ -714,22 +728,28 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() myDlg->myDestinationX->SetValue(x); myDlg->myDestinationY->SetValue(y); myDlg->myDestinationZ->SetValue(z); - } - if ( myDestCoordChanged ) { - dx = myDlg->myDestinationX->GetValue() - x; - dy = myDlg->myDestinationY->GetValue() - y; - dz = myDlg->myDestinationZ->GetValue() - z; myDlg->myDestDX->SetValue(dx); myDlg->myDestDY->SetValue(dy); myDlg->myDestDZ->SetValue(dz); } - else { - dx = myDlg->myDestDX->GetValue() + x; - dy = myDlg->myDestDY->GetValue() + y; - dz = myDlg->myDestDZ->GetValue() + z; - myDlg->myDestinationX->SetValue(dx); - myDlg->myDestinationY->SetValue(dy); - myDlg->myDestinationZ->SetValue(dz); + else + { + if ( myDestCoordChanged ) { + dx = myDlg->myDestinationX->GetValue() - x; + dy = myDlg->myDestinationY->GetValue() - y; + dz = myDlg->myDestinationZ->GetValue() - z; + myDlg->myDestDX->SetValue(dx); + myDlg->myDestDY->SetValue(dy); + myDlg->myDestDZ->SetValue(dz); + } + else { + dx = myDlg->myDestDX->GetValue() + x; + dy = myDlg->myDestDY->GetValue() + y; + dz = myDlg->myDestDZ->GetValue() + z; + myDlg->myDestinationX->SetValue(dx); + myDlg->myDestinationY->SetValue(dy); + myDlg->myDestinationZ->SetValue(dz); + } } myDlg->myCurrentX->SetValue(x); myDlg->myCurrentY->SetValue(y); @@ -765,7 +785,8 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() } } } - }catch (...) { + } + catch (...) { } } } @@ -787,11 +808,12 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() aMeshPreviewStruct->elementConnectivities.length(1); aMeshPreviewStruct->elementConnectivities[0] = 0; } - + if (!mySimulation) + mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); // display data - if ( aMeshPreviewStruct.operator->() ) + if ( & aMeshPreviewStruct.in() ) { - mySimulation->SetData(aMeshPreviewStruct._retn()); + mySimulation->SetData( aMeshPreviewStruct.in() ); } else { @@ -801,6 +823,33 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() myNoPreview = false; } +//================================================================================= +/*! + * \brief SLOT called when the viewer opened + */ +//================================================================================= +void SMESHGUI_MakeNodeAtPointOp::onOpenView() +{ + if ( mySimulation ) { + mySimulation->SetVisibility(false); + SMESH::SetPointRepresentation(false); + } + else { + mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); + } +} + +//================================================================================= +/*! + * \brief SLOT called when the viewer closed + */ +//================================================================================= +void SMESHGUI_MakeNodeAtPointOp::onCloseView() +{ + delete mySimulation; + mySimulation = 0; +} + //================================================================================ /*! * \brief SLOT called when the node id is manually changed @@ -839,7 +888,7 @@ void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText ) void SMESHGUI_MakeNodeAtPointOp::activateSelection() { selectionMgr()->clearFilters(); - SMESH::SetPointRepresentation(false); + SMESH::SetPointRepresentation( true ); selectionMgr()->installFilter( myFilter ); setSelectionMode( NodeSelection ); }