mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-06 03:54:17 +05:00
first version with display of bbox of shapes
This commit is contained in:
parent
7fc6473be0
commit
6a221923f3
@ -112,7 +112,8 @@ IF(SALOME_BUILD_GUI)
|
|||||||
IF(EXISTS ${GUI_ROOT_DIR})
|
IF(EXISTS ${GUI_ROOT_DIR})
|
||||||
FIND_PACKAGE(SalomeGUI)
|
FIND_PACKAGE(SalomeGUI)
|
||||||
SALOME_GUI_WITH_CORBA() #check whether GUI built with CORBA
|
SALOME_GUI_WITH_CORBA() #check whether GUI built with CORBA
|
||||||
SALOME_GUI_MODE(SALOME_USE_OCCVIEWER SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT
|
#MBS:
|
||||||
|
SALOME_GUI_MODE(SALOME_USE_OCCVIEWER SALOME_USE_VTKVIEWER SALOME_USE_PV3DVIEWER SALOME_USE_SALOMEOBJECT
|
||||||
OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_GRAPHICSVIEW SALOME_USE_PYCONSOLE)
|
OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_GRAPHICSVIEW SALOME_USE_PYCONSOLE)
|
||||||
ADD_DEFINITIONS(${GUI_DEFINITIONS})
|
ADD_DEFINITIONS(${GUI_DEFINITIONS})
|
||||||
INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <GEOM_AISTrihedron.hxx>
|
#include <GEOM_AISTrihedron.hxx>
|
||||||
#include <GEOM_VTKTrihedron.hxx>
|
#include <GEOM_VTKTrihedron.hxx>
|
||||||
#include <GEOM_VTKPropertyMaterial.hxx>
|
#include <GEOM_VTKPropertyMaterial.hxx>
|
||||||
|
#include <GEOM_PainterPolyDataMapper.h>
|
||||||
|
|
||||||
#include <GEOMGUI_DimensionProperty.h>
|
#include <GEOMGUI_DimensionProperty.h>
|
||||||
#include <GEOMGUI_AnnotationAttrs.h>
|
#include <GEOMGUI_AnnotationAttrs.h>
|
||||||
@ -77,10 +78,34 @@
|
|||||||
#include <SVTK_Prs.h>
|
#include <SVTK_Prs.h>
|
||||||
#include <SVTK_ViewModel.h>
|
#include <SVTK_ViewModel.h>
|
||||||
|
|
||||||
|
//MBS:
|
||||||
|
#include <SPV3D_Prs.h>
|
||||||
|
#include <SPV3D_ViewModel.h>
|
||||||
|
|
||||||
#include <OCCViewer_ViewWindow.h>
|
#include <OCCViewer_ViewWindow.h>
|
||||||
#include <OCCViewer_ViewPort3d.h>
|
#include <OCCViewer_ViewPort3d.h>
|
||||||
#include <OCCViewer_Utilities.h>
|
#include <OCCViewer_Utilities.h>
|
||||||
|
|
||||||
|
//MBS:
|
||||||
|
//#include <PV3DViewer_ViewModel.h>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
#include <pqActiveObjects.h>
|
||||||
|
#include <pqApplicationCore.h>
|
||||||
|
#include <pqObjectBuilder.h>
|
||||||
|
#include <vtkSMPropertyHelper.h>
|
||||||
|
#include <vtkSMProxy.h>
|
||||||
|
#include <vtkSMParaViewPipelineControllerWithRendering.h>
|
||||||
|
#include <vtkNamedColors.h>
|
||||||
|
#include <vtkPoints.h>
|
||||||
|
#include <vtkCamera.h>
|
||||||
|
#include <vtkCellArray.h>
|
||||||
|
#include <vtkFloatArray.h>
|
||||||
|
#include <vtkPointData.h>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
#include <vtkRenderer.h>
|
||||||
|
#include <vtkRenderWindow.h>
|
||||||
|
#include <vtkRenderWindowInteractor.h>
|
||||||
|
|
||||||
// OCCT Includes
|
// OCCT Includes
|
||||||
#include <AIS_Dimension.hxx>
|
#include <AIS_Dimension.hxx>
|
||||||
#include <AIS_LengthDimension.hxx>
|
#include <AIS_LengthDimension.hxx>
|
||||||
@ -1718,6 +1743,175 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//MBS:
|
||||||
|
//=================================================================
|
||||||
|
/*!
|
||||||
|
* GEOM_Displayer::Update
|
||||||
|
* Update PV3D presentation
|
||||||
|
* [ Reimplemented from SALOME_Displayer ]
|
||||||
|
*/
|
||||||
|
//=================================================================
|
||||||
|
void GEOM_Displayer::Update( SALOME_PV3DPrs* prs )
|
||||||
|
{
|
||||||
|
DBG_FUN();
|
||||||
|
SPV3D_Prs* pv3dPrs = dynamic_cast<SPV3D_Prs*>( prs );
|
||||||
|
|
||||||
|
SalomeApp_Study* study = getStudy();
|
||||||
|
|
||||||
|
if ( !pv3dPrs || myShape.IsNull() || !study )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// specific processing for local coordinate system presentation
|
||||||
|
//
|
||||||
|
// NYI
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// processing for usual geometry presentation
|
||||||
|
//
|
||||||
|
SHOW(myShape);
|
||||||
|
MSGEL("...-> update SALOME_PV3DPrs");
|
||||||
|
|
||||||
|
// For now, display the bbox instead of the shape itself
|
||||||
|
Standard_Real XMin = -1, YMin = -1, ZMin = -1, XMax = 1, YMax = 1, ZMax = 1;
|
||||||
|
if (!myShape.IsNull())
|
||||||
|
{
|
||||||
|
Bnd_Box aBndBox;
|
||||||
|
BRepBndLib::Add(myShape, aBndBox);
|
||||||
|
aBndBox.Get(XMin, YMin, ZMin, XMax, YMax, ZMax);
|
||||||
|
MSGEL("BBox= X:[" << XMin << "," << XMax << "] Y:[" << YMin << "," << YMax << "] Z: [" << ZMin << "," << ZMax << "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
// if presentation is empty we try to create new one
|
||||||
|
if ( pv3dPrs->IsNull() )
|
||||||
|
{
|
||||||
|
#if 0 // VTK
|
||||||
|
|
||||||
|
vtkNew<vtkNamedColors> colors;
|
||||||
|
|
||||||
|
std::array<std::array<double, 3>, 8> pts = {{{{XMin, YMin, ZMin}},
|
||||||
|
{{XMax, YMin, ZMin}},
|
||||||
|
{{XMax, YMax, ZMin}},
|
||||||
|
{{XMin, YMax, ZMin}},
|
||||||
|
{{XMin, YMin, ZMax}},
|
||||||
|
{{XMax, YMin, ZMax}},
|
||||||
|
{{XMax, YMax, ZMax}},
|
||||||
|
{{XMin, YMax, ZMax}}}};
|
||||||
|
// The ordering of the corner points on each face.
|
||||||
|
std::array<std::array<vtkIdType, 4>, 6> ordering = {{{{0, 3, 2, 1}},
|
||||||
|
{{4, 5, 6, 7}},
|
||||||
|
{{0, 1, 5, 4}},
|
||||||
|
{{1, 2, 6, 5}},
|
||||||
|
{{2, 3, 7, 6}},
|
||||||
|
{{3, 0, 4, 7}}}};
|
||||||
|
|
||||||
|
// We'll create the building blocks of polydata including data attributes.
|
||||||
|
vtkNew<vtkPolyData> cube;
|
||||||
|
vtkNew<vtkPoints> points;
|
||||||
|
vtkNew<vtkCellArray> polys;
|
||||||
|
vtkNew<vtkFloatArray> scalars;
|
||||||
|
|
||||||
|
// Load the point, cell, and data attributes.
|
||||||
|
for (auto i = 0ul; i < pts.size(); ++i)
|
||||||
|
{
|
||||||
|
points->InsertPoint(i, pts[i].data());
|
||||||
|
scalars->InsertTuple1(i, i);
|
||||||
|
}
|
||||||
|
for (auto&& i : ordering)
|
||||||
|
{
|
||||||
|
polys->InsertNextCell(vtkIdType(i.size()), i.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
// We now assign the pieces to the vtkPolyData.
|
||||||
|
cube->SetPoints(points);
|
||||||
|
cube->SetPolys(polys);
|
||||||
|
cube->GetPointData()->SetScalars(scalars);
|
||||||
|
|
||||||
|
// Now we'll look at it.
|
||||||
|
vtkNew<vtkPolyDataMapper> cubeMapper;
|
||||||
|
cubeMapper->SetInputData(cube);
|
||||||
|
cubeMapper->SetScalarRange(cube->GetScalarRange());
|
||||||
|
vtkNew<vtkActor> cubeActor;
|
||||||
|
cubeActor->SetMapper(cubeMapper);
|
||||||
|
|
||||||
|
// The usual rendering stuff.
|
||||||
|
vtkNew<vtkCamera> camera;
|
||||||
|
camera->SetPosition(1, 1, 1);
|
||||||
|
camera->SetFocalPoint(0, 0, 0);
|
||||||
|
|
||||||
|
vtkNew<vtkRenderer> renderer;
|
||||||
|
vtkNew<vtkRenderWindow> renWin;
|
||||||
|
renWin->AddRenderer(renderer);
|
||||||
|
renWin->SetWindowName("Cube");
|
||||||
|
|
||||||
|
vtkNew<vtkRenderWindowInteractor> iren;
|
||||||
|
iren->SetRenderWindow(renWin);
|
||||||
|
|
||||||
|
renderer->AddActor(cubeActor);
|
||||||
|
renderer->SetActiveCamera(camera);
|
||||||
|
renderer->ResetCamera();
|
||||||
|
renderer->SetBackground(colors->GetColor3d("Cornsilk").GetData());
|
||||||
|
|
||||||
|
renWin->SetSize(600, 600);
|
||||||
|
|
||||||
|
// interact with data
|
||||||
|
renWin->Render();
|
||||||
|
iren->Start();
|
||||||
|
|
||||||
|
#else // PV
|
||||||
|
|
||||||
|
// Create a pipeline source with vtkPolyData output from a TopoDS_Shape
|
||||||
|
pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
|
||||||
|
pqServer* activeServer = pqActiveObjects::instance().activeServer();
|
||||||
|
|
||||||
|
pqPipelineSource* source = builder->createSource("sources", "CubeSource", activeServer);
|
||||||
|
if (!source) {
|
||||||
|
MSGEL("ERR: VTK source not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// On SourceCreated signal handler
|
||||||
|
vtkNew<vtkSMParaViewPipelineControllerWithRendering> controller;
|
||||||
|
pqView* activeView = pqActiveObjects::instance().activeView();
|
||||||
|
if (activeView)
|
||||||
|
{
|
||||||
|
if (source)
|
||||||
|
{
|
||||||
|
#if PARAVIEW_VERSION_MINOR <= 10
|
||||||
|
source->updatePipeline();
|
||||||
|
source->setModifiedState(pqProxy::UNMODIFIED);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
controller->Show(source->getSourceProxy(), 0, activeView->getViewProxy());//, "CADRepresentation");
|
||||||
|
}
|
||||||
|
activeView->render();
|
||||||
|
activeView->resetDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set dimensions of bbox
|
||||||
|
vtkSMProxy* proxy = source->getProxy();
|
||||||
|
vtkSMPropertyHelper(proxy, "XLength").Set(XMax-XMin);
|
||||||
|
vtkSMPropertyHelper(proxy, "YLength").Set(YMax-YMin);
|
||||||
|
vtkSMPropertyHelper(proxy, "ZLength").Set(ZMax-ZMin);
|
||||||
|
proxy->UpdateVTKObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// presentation is being updated
|
||||||
|
// NYI
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//=================================================================
|
//=================================================================
|
||||||
/*!
|
/*!
|
||||||
* GEOM_Displayer::BuildPrs
|
* GEOM_Displayer::BuildPrs
|
||||||
@ -2450,7 +2644,7 @@ bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer
|
|||||||
GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(anOrbObj); // enable displaying of whole GEOM component
|
GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(anOrbObj); // enable displaying of whole GEOM component
|
||||||
bool isGeomObj = (!CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj ));
|
bool isGeomObj = (!CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj ));
|
||||||
bool ret = ( isGeomObj ) &&
|
bool ret = ( isGeomObj ) &&
|
||||||
(viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type());
|
(viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type() || viewer_type == SPV3D_ViewModel::Type());//MBS:
|
||||||
MSGEL("..... --> isCorbaObj=" << YesNo(isCorbaObj) << ", isGeomObj=" << YesNo(isGeomObj) << ", canBeDisp=" << YesNo(ret));
|
MSGEL("..... --> isCorbaObj=" << YesNo(isCorbaObj) << ", isGeomObj=" << YesNo(isGeomObj) << ", canBeDisp=" << YesNo(ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ class SALOME_View;
|
|||||||
class SALOME_Prs;
|
class SALOME_Prs;
|
||||||
class SALOME_OCCPrs;
|
class SALOME_OCCPrs;
|
||||||
class SALOME_VTKPrs;
|
class SALOME_VTKPrs;
|
||||||
|
class SALOME_PV3DPrs;//MBS:
|
||||||
class SALOME_OCCViewType;
|
class SALOME_OCCViewType;
|
||||||
|
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
@ -187,6 +188,7 @@ public:
|
|||||||
/* Reimplemented from SALOME_Displayer */
|
/* Reimplemented from SALOME_Displayer */
|
||||||
virtual void Update( SALOME_OCCPrs* );
|
virtual void Update( SALOME_OCCPrs* );
|
||||||
virtual void Update( SALOME_VTKPrs* );
|
virtual void Update( SALOME_VTKPrs* );
|
||||||
|
virtual void Update( SALOME_PV3DPrs* ); // MBS:
|
||||||
virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
|
virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
|
||||||
virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
|
virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
|
||||||
virtual void BeforeErase ( SALOME_View*, const SALOME_OCCPrs* );
|
virtual void BeforeErase ( SALOME_View*, const SALOME_OCCPrs* );
|
||||||
|
@ -60,6 +60,11 @@
|
|||||||
#include <OCCViewer_ViewModel.h>
|
#include <OCCViewer_ViewModel.h>
|
||||||
#include <OCCViewer_ViewManager.h>
|
#include <OCCViewer_ViewManager.h>
|
||||||
|
|
||||||
|
//MBS:
|
||||||
|
#include <PV3DViewer_ViewWindow.h>
|
||||||
|
#include <PV3DViewer_ViewModel.h>
|
||||||
|
#include <PV3DViewer_ViewManager.h>
|
||||||
|
|
||||||
#include <SOCC_ViewModel.h>
|
#include <SOCC_ViewModel.h>
|
||||||
#include <SOCC_ViewWindow.h>
|
#include <SOCC_ViewWindow.h>
|
||||||
|
|
||||||
@ -389,6 +394,7 @@ void GeometryGUI::ActiveWorkingPlane()
|
|||||||
SUIT_ViewWindow* window = application()->desktop()->activeWindow();
|
SUIT_ViewWindow* window = application()->desktop()->activeWindow();
|
||||||
bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
|
bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
|
||||||
bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
|
bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
|
||||||
|
bool ViewPV3D = ( window && window->getViewManager()->getType() == PV3DViewer_ViewModel::Type() ); //MBS:
|
||||||
|
|
||||||
if ( ViewOCC ) {
|
if ( ViewOCC ) {
|
||||||
OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
|
OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
|
||||||
@ -412,6 +418,20 @@ void GeometryGUI::ActiveWorkingPlane()
|
|||||||
vw->onFitAll();
|
vw->onFitAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//MBS:
|
||||||
|
else if ( ViewPV3D ) {
|
||||||
|
PV3DViewer_ViewWindow* vw = dynamic_cast<PV3DViewer_ViewWindow*>( window );
|
||||||
|
if ( vw ) {
|
||||||
|
MSGEL("...(NYI) => orient view to active plane");
|
||||||
|
// vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
|
||||||
|
//
|
||||||
|
// camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
|
||||||
|
// camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
|
||||||
|
// camera->SetFocalPoint(0,0,0);
|
||||||
|
//
|
||||||
|
//vw->onFitAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -2134,6 +2154,7 @@ void GeometryGUI::windows( QMap<int, int>& mappa ) const
|
|||||||
void GeometryGUI::viewManagers( QStringList& lst ) const
|
void GeometryGUI::viewManagers( QStringList& lst ) const
|
||||||
{
|
{
|
||||||
lst.append( OCCViewer_Viewer::Type() );
|
lst.append( OCCViewer_Viewer::Type() );
|
||||||
|
//lst.append( PV3DViewer_ViewModel::Type() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
|
void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
|
||||||
|
Loading…
Reference in New Issue
Block a user