-// Copyright (C) 2007-2013 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
// 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
#include <SMESH_Actor.h>
#include <SMESH_ActorUtils.h>
+#include <SMESH_DeviceActor.h>
#include <SMESH_FaceOrientationFilter.h>
#include <SMDS_Mesh.hxx>
#include <SVTK_ViewWindow.h>
#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+#include <VTKViewer_PolyDataMapper.h>
#include <SalomeApp_Application.h>
+#include <Qtx.h>
+
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
#include <TColStd_MapOfInteger.hxx>
// VTK includes
+#include <vtkCell.h>
#include <vtkIdList.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkCellType.h>
+#include <vtkCellData.h>
// Qt includes
#include <QComboBox>
}
namespace SMESH
{
- class TElementSimulation {
+ class TElementSimulationQuad {
SalomeApp_Application* myApplication;
SUIT_ViewWindow* myViewWindow;
SVTK_ViewWindow* myVTKViewWindow;
SALOME_Actor* myPreviewActor;
vtkDataSetMapper* myMapper;
vtkUnstructuredGrid* myGrid;
- //vtkProperty* myBackProp, *myProp;
+
+ SALOME_Actor* myCornerActor;
+ VTKViewer_PolyDataMapper* myCornerMapper;
+ vtkPolyData* myCornerPolyData;
+
+ SALOME_Actor* mySelectCornerActor;
+ VTKViewer_PolyDataMapper* mySelectCornerMapper;
+ vtkPolyData* mySelectCornerPolyData;
//double myRGB[3], myBackRGB[3];
SMESH_FaceOrientationFilter* myFaceOrientationFilter;
public:
- TElementSimulation (SalomeApp_Application* theApplication)
+ TElementSimulationQuad (SalomeApp_Application* theApplication)
{
myApplication = theApplication;
SUIT_ViewManager* mgr = theApplication->activeViewManager();
myPreviewActor->PickableOff();
myPreviewActor->VisibilityOff();
myPreviewActor->SetMapper(myMapper);
-
+
+ QColor ffc, bfc;
+ int delta;
vtkProperty* myProp = vtkProperty::New();
- double 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();
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<vtkIdType> TVTKIds;
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();
myGrid->Delete();
+ myCornerMapper->RemoveAllInputs();
+ myCornerMapper->Delete();
+ myCornerPolyData->Delete();
+
+ mySelectCornerMapper->RemoveAllInputs();
+ mySelectCornerMapper->Delete();
+ mySelectCornerPolyData->Delete();
+
// myProp->Delete();
// myBackProp->Delete();
}
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
(SUIT_Session::session()->activeApplication());
- mySimulation = new SMESH::TElementSimulation (anApp);
+ mySimulation = new SMESH::TElementSimulationQuad (anApp);
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
QString anElementName;
QString aCurrentEntry = myEntry;
+ // clear
+ myActor = 0;
if ( myCurrentLineEdit )
- {
- // clear
- myActor = 0;
-
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;
// 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() ) );
}
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
{
void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol )
{
myCurrentLineEdit = 0;
- displaySimulation();
+ displaySimulation(theRow, theCol);
updateButtons();
}
void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol)
{
myCurrentLineEdit = 0;
- displaySimulation();
+ displaySimulation(theRow, theCol);
updateButtons();
}