diff --git a/src/graphics/graphics_mesh_object_driver.cpp b/src/graphics/graphics_mesh_object_driver.cpp index 6d8b7ef3..08b0e496 100644 --- a/src/graphics/graphics_mesh_object_driver.cpp +++ b/src/graphics/graphics_mesh_object_driver.cpp @@ -16,6 +16,7 @@ #include "graphics_mesh_data_source.h" #include "graphics_utils.h" +#include #include #include #include diff --git a/src/graphics/graphics_scene.cpp b/src/graphics/graphics_scene.cpp index a589f2dd..ccede57d 100644 --- a/src/graphics/graphics_scene.cpp +++ b/src/graphics/graphics_scene.cpp @@ -14,6 +14,8 @@ #include #include +#include + namespace Mayo { // Defined in graphics_create_driver.cpp @@ -217,12 +219,12 @@ void GraphicsScene::deactivateObjectSelection(const GraphicsObjectPtr &object) d->m_aisContext->Deactivate(object); } -void GraphicsScene::addSelectionFilter(const Handle_SelectMgr_Filter& filter) +void GraphicsScene::addSelectionFilter(const OccHandle& filter) { d->m_aisContext->AddFilter(filter); } -void GraphicsScene::removeSelectionFilter(const Handle_SelectMgr_Filter& filter) +void GraphicsScene::removeSelectionFilter(const OccHandle& filter) { d->m_aisContext->RemoveFilter(filter); } @@ -308,7 +310,7 @@ void GraphicsScene::toggleOwnerSelection(const GraphicsOwnerPtr& gfxOwner) d->m_aisContext->AddOrRemoveSelected(gfxOwner, false); } -void GraphicsScene::highlightAt(int xPos, int yPos, const Handle_V3d_View& view) +void GraphicsScene::highlightAt(int xPos, int yPos, const OccHandle& view) { d->m_aisContext->MoveTo(xPos, yPos, view, false); } diff --git a/src/graphics/graphics_scene.h b/src/graphics/graphics_scene.h index 68ccc554..b15a812f 100644 --- a/src/graphics/graphics_scene.h +++ b/src/graphics/graphics_scene.h @@ -6,6 +6,7 @@ #pragma once +#include "../base/occ_handle.h" #include "../base/signal.h" #include "graphics_object_ptr.h" #include "graphics_owner_ptr.h" @@ -13,7 +14,6 @@ #include #include #include -#include namespace Mayo { @@ -28,14 +28,14 @@ class GraphicsScene { GraphicsScene(const GraphicsScene&) = delete; GraphicsScene& operator=(const GraphicsScene&) = delete; - opencascade::handle createV3dView(); + OccHandle createV3dView(); - const opencascade::handle& v3dViewer() const; - const opencascade::handle& mainSelector() const; + const OccHandle& v3dViewer() const; + const OccHandle& mainSelector() const; bool hiddenLineDrawingOn() const; - const opencascade::handle& drawerDefault() const; - const opencascade::handle& drawerHighlight(Prs3d_TypeOfHighlight style) const; + const OccHandle& drawerDefault() const; + const OccHandle& drawerHighlight(Prs3d_TypeOfHighlight style) const; enum AddObjectFlag { AddObjectDefault = 0, @@ -57,8 +57,8 @@ class GraphicsScene { void deactivateObjectSelection(const GraphicsObjectPtr& object, int mode); void deactivateObjectSelection(const GraphicsObjectPtr& object); - void addSelectionFilter(const Handle_SelectMgr_Filter& filter); - void removeSelectionFilter(const Handle_SelectMgr_Filter& filter); + void addSelectionFilter(const OccHandle& filter); + void removeSelectionFilter(const OccHandle& filter); void clearSelectionFilters(); void setObjectDisplayMode(const GraphicsObjectPtr& object, int displayMode); @@ -79,7 +79,7 @@ class GraphicsScene { void setSelectionMode(SelectionMode mode); const GraphicsOwnerPtr& currentHighlightedOwner() const; - void highlightAt(int xPos, int yPos, const Handle_V3d_View& view); + void highlightAt(int xPos, int yPos, const OccHandle& view); void select(); int selectedCount() const; diff --git a/src/graphics/graphics_shape_object_driver.cpp b/src/graphics/graphics_shape_object_driver.cpp index 484e7bbd..e63267a9 100644 --- a/src/graphics/graphics_shape_object_driver.cpp +++ b/src/graphics/graphics_shape_object_driver.cpp @@ -14,7 +14,11 @@ #include "graphics_utils.h" #include +#include #include +#include +#include +#include #include namespace Mayo { diff --git a/src/graphics/graphics_utils.cpp b/src/graphics/graphics_utils.cpp index 84cfea4c..4064b0f7 100644 --- a/src/graphics/graphics_utils.cpp +++ b/src/graphics/graphics_utils.cpp @@ -10,13 +10,20 @@ #include "../base/math_utils.h" #include "../base/tkernel_utils.h" +#include +#include #include +#include +#include #include #include +#include #include #include #include #include +#include +#include #include #include @@ -27,7 +34,8 @@ namespace Mayo { namespace Internal { static void AisContext_setObjectVisible( - AIS_InteractiveContext* ptrContext, const Handle_AIS_InteractiveObject& object, bool on) + AIS_InteractiveContext* ptrContext, const OccHandle& object, bool on + ) { if (ptrContext && object) { if (on) @@ -39,21 +47,22 @@ static void AisContext_setObjectVisible( } // namespace Internal -void GraphicsUtils::V3dView_fitAll(const Handle_V3d_View& view) +void GraphicsUtils::V3dView_fitAll(const OccHandle& view) { view->ZFitAll(); view->FitAll(0.01, false/*dontUpdateView*/); } bool GraphicsUtils::V3dView_hasClipPlane( - const Handle_V3d_View& view, const Handle_Graphic3d_ClipPlane& plane) + const OccHandle& view, const OccHandle& plane + ) { - const Handle_Graphic3d_SequenceOfHClipPlane& seqClipPlane = view->ClipPlanes(); + const OccHandle& seqClipPlane = view->ClipPlanes(); if (seqClipPlane.IsNull() || seqClipPlane->Size() == 0) return false; for (Graphic3d_SequenceOfHClipPlane::Iterator it(*seqClipPlane); it.More(); it.Next()) { - const Handle_Graphic3d_ClipPlane& candidate = it.Value(); + const OccHandle& candidate = it.Value(); if (candidate.get() == plane.get()) return true; } @@ -61,7 +70,7 @@ bool GraphicsUtils::V3dView_hasClipPlane( return false; } -gp_Pnt GraphicsUtils::V3dView_to3dPosition(const Handle_V3d_View& view, double x, double y) +gp_Pnt GraphicsUtils::V3dView_to3dPosition(const OccHandle& view, double x, double y) { double xEye, yEye, zEye, xAt, yAt, zAt; view->Eye(xEye, yEye, zEye); @@ -83,7 +92,7 @@ gp_Pnt GraphicsUtils::V3dView_to3dPosition(const Handle_V3d_View& view, double x return ElSLib::Value(pntConvertedOnPlane.X(), pntConvertedOnPlane.Y(), planeView); } -bool GraphicsUtils::V3dViewer_isGridActive(const Handle_V3d_Viewer& viewer) +bool GraphicsUtils::V3dViewer_isGridActive(const OccHandle& viewer) { #if OCC_VERSION_HEX >= OCC_VERSION_CHECK(7, 6, 0) return viewer->IsGridActive(); @@ -92,7 +101,7 @@ bool GraphicsUtils::V3dViewer_isGridActive(const Handle_V3d_Viewer& viewer) #endif } -Handle_Aspect_Grid GraphicsUtils::V3dViewer_grid(const Handle_V3d_Viewer& viewer) +OccHandle GraphicsUtils::V3dViewer_grid(const OccHandle& viewer) { #if OCC_VERSION_HEX >= OCC_VERSION_CHECK(7, 6, 0) return viewer->Grid(false/*dontCreate*/); @@ -101,26 +110,29 @@ Handle_Aspect_Grid GraphicsUtils::V3dViewer_grid(const Handle_V3d_Viewer& viewer #endif } -GraphicsUtils::AspectGridColors GraphicsUtils::V3dViewer_gridColors(const Handle_V3d_Viewer& viewer) +GraphicsUtils::AspectGridColors GraphicsUtils::V3dViewer_gridColors(const OccHandle& viewer) { AspectGridColors colors; - Handle_Aspect_Grid gridAspect = V3dViewer_grid(viewer); + OccHandle gridAspect = V3dViewer_grid(viewer); if (gridAspect) gridAspect->Colors(colors.base, colors.tenth); return colors; } -void GraphicsUtils::V3dViewer_setGridColors(const Handle_V3d_Viewer &viewer, const AspectGridColors &colors) +void GraphicsUtils::V3dViewer_setGridColors( + const OccHandle& viewer, const AspectGridColors& colors + ) { - Handle_Aspect_Grid gridAspect = V3dViewer_grid(viewer); + OccHandle gridAspect = V3dViewer_grid(viewer); if (gridAspect) gridAspect->SetColors(colors.base, colors.tenth); } void GraphicsUtils::AisContext_eraseObject( - const Handle_AIS_InteractiveContext& context, - const Handle_AIS_InteractiveObject& object) + const OccHandle& context, + const OccHandle& object + ) { if (!object.IsNull() && !context.IsNull()) { context->Erase(object, false/*dontUpdateViewer*/); @@ -131,14 +143,15 @@ void GraphicsUtils::AisContext_eraseObject( } void GraphicsUtils::AisContext_setObjectVisible( - const Handle_AIS_InteractiveContext& context, - const Handle_AIS_InteractiveObject& object, - bool on) + const OccHandle& context, + const OccHandle& object, + bool on + ) { Internal::AisContext_setObjectVisible(context.get(), object, on); } -AIS_InteractiveContext* GraphicsUtils::AisObject_contextPtr(const GraphicsObjectPtr& object) +AIS_InteractiveContext* GraphicsUtils::AisObject_contextPtr(const OccHandle& object) { if (!object) return nullptr; @@ -150,18 +163,18 @@ AIS_InteractiveContext* GraphicsUtils::AisObject_contextPtr(const GraphicsObject #endif } -bool GraphicsUtils::AisObject_isVisible(const GraphicsObjectPtr& object) +bool GraphicsUtils::AisObject_isVisible(const OccHandle& object) { const AIS_InteractiveContext* ptrContext = AisObject_contextPtr(object); return ptrContext ? ptrContext->IsDisplayed(object) : false; } -void GraphicsUtils::AisObject_setVisible(const GraphicsObjectPtr& object, bool on) +void GraphicsUtils::AisObject_setVisible(const OccHandle& object, bool on) { Internal::AisContext_setObjectVisible(AisObject_contextPtr(object), object, on); } -Bnd_Box GraphicsUtils::AisObject_boundingBox(const GraphicsObjectPtr& object) +Bnd_Box GraphicsUtils::AisObject_boundingBox(const OccHandle& object) { Bnd_Box box; if (object.IsNull()) @@ -169,7 +182,7 @@ Bnd_Box GraphicsUtils::AisObject_boundingBox(const GraphicsObjectPtr& object) // Ensure bounding box is calculated #if OCC_VERSION_HEX >= OCC_VERSION_CHECK(7, 4, 0) - for (Handle_PrsMgr_Presentation prs : object->Presentations()) { + for (OccHandle prs : object->Presentations()) { if (prs->Mode() == object->DisplayMode() && !prs->CStructure()->BoundingBox().IsValid()) prs->CalculateBoundBox(); } @@ -187,7 +200,7 @@ Bnd_Box GraphicsUtils::AisObject_boundingBox(const GraphicsObjectPtr& object) return box; } -int GraphicsUtils::AspectWindow_width(const Handle_Aspect_Window& wnd) +int GraphicsUtils::AspectWindow_width(const OccHandle& wnd) { if (wnd.IsNull()) return 0; @@ -197,7 +210,7 @@ int GraphicsUtils::AspectWindow_width(const Handle_Aspect_Window& wnd) return w; } -int GraphicsUtils::AspectWindow_height(const Handle_Aspect_Window& wnd) +int GraphicsUtils::AspectWindow_height(const OccHandle& wnd) { if (wnd.IsNull()) return 0; @@ -217,7 +230,7 @@ OccHandle GraphicsUtils::AspectDisplayConnection_creat } void GraphicsUtils::Gfx3dClipPlane_setCappingHatch( - const Handle_Graphic3d_ClipPlane& plane, Aspect_HatchStyle hatch) + const OccHandle& plane, Aspect_HatchStyle hatch) { if (hatch == Aspect_HS_SOLID) plane->SetCappingHatchOff(); @@ -227,14 +240,14 @@ void GraphicsUtils::Gfx3dClipPlane_setCappingHatch( plane->SetCappingHatch(hatch); } -void GraphicsUtils::Gfx3dClipPlane_setNormal(const Handle_Graphic3d_ClipPlane& plane, const gp_Dir& n) +void GraphicsUtils::Gfx3dClipPlane_setNormal(const OccHandle& plane, const gp_Dir& n) { const double planePos = MathUtils::planePosition(plane->ToPlane()); const gp_Vec placement(planePos * gp_Vec(n)); plane->SetEquation(gp_Pln(placement.XYZ(), n)); } -void GraphicsUtils::Gfx3dClipPlane_setPosition(const Handle_Graphic3d_ClipPlane& plane, double pos) +void GraphicsUtils::Gfx3dClipPlane_setPosition(const OccHandle& plane, double pos) { const gp_Dir& n = plane->ToPlane().Axis().Direction(); if (MathUtils::isReversedStandardDir(n)) diff --git a/src/graphics/graphics_utils.h b/src/graphics/graphics_utils.h index 256201c3..69884bcb 100644 --- a/src/graphics/graphics_utils.h +++ b/src/graphics/graphics_utils.h @@ -7,18 +7,24 @@ #pragma once #include "../base/occ_handle.h" -#include "graphics_object_ptr.h" -#include -#include -#include -#include -#include -#include -class Image_PixMap; + +#include +#include +#include + // Note: can't include Aspect_DisplayConnection.hxx as this is causing name conflicts // with XLib in other files(with GraphicsObjectDriver::Support::None) // This seems to happen only for OpenCascade <= v7.5 class Aspect_DisplayConnection; +class Aspect_Grid; +class Aspect_Window; +class AIS_InteractiveContext; +class AIS_InteractiveObject; +class Graphic3d_ClipPlane; +class Image_PixMap; +class V3d_View; +class V3d_Viewer; +class gp_Dir; namespace Mayo { @@ -29,42 +35,42 @@ struct GraphicsUtils { Quantity_Color tenth; }; - static void V3dView_fitAll(const Handle_V3d_View& view); - static bool V3dView_hasClipPlane(const Handle_V3d_View& view, const Handle_Graphic3d_ClipPlane& plane); - static gp_Pnt V3dView_to3dPosition(const Handle_V3d_View& view, double x, double y); + static void V3dView_fitAll(const OccHandle& view); + static bool V3dView_hasClipPlane(const OccHandle& view, const OccHandle& plane); + static gp_Pnt V3dView_to3dPosition(const OccHandle& view, double x, double y); - static bool V3dViewer_isGridActive(const Handle_V3d_Viewer& viewer); - static Handle_Aspect_Grid V3dViewer_grid(const Handle_V3d_Viewer& viewer); - static AspectGridColors V3dViewer_gridColors(const Handle_V3d_Viewer& viewer); - static void V3dViewer_setGridColors(const Handle_V3d_Viewer& viewer, const AspectGridColors& colors); + static bool V3dViewer_isGridActive(const OccHandle& viewer); + static OccHandle V3dViewer_grid(const OccHandle& viewer); + static AspectGridColors V3dViewer_gridColors(const OccHandle& viewer); + static void V3dViewer_setGridColors(const OccHandle& viewer, const AspectGridColors& colors); static void AisContext_eraseObject( - const Handle_AIS_InteractiveContext& context, - const Handle_AIS_InteractiveObject& object + const OccHandle& context, + const OccHandle& object ); static void AisContext_setObjectVisible( - const Handle_AIS_InteractiveContext& context, - const Handle_AIS_InteractiveObject& object, + const OccHandle& context, + const OccHandle& object, bool on ); - static AIS_InteractiveContext* AisObject_contextPtr(const GraphicsObjectPtr& object); - static bool AisObject_isVisible(const GraphicsObjectPtr& object); - static void AisObject_setVisible(const GraphicsObjectPtr& object, bool on); - static Bnd_Box AisObject_boundingBox(const GraphicsObjectPtr& object); + static AIS_InteractiveContext* AisObject_contextPtr(const OccHandle& object); + static bool AisObject_isVisible(const OccHandle& object); + static void AisObject_setVisible(const OccHandle& object, bool on); + static Bnd_Box AisObject_boundingBox(const OccHandle& object); - static int AspectWindow_width(const Handle_Aspect_Window& wnd); - static int AspectWindow_height(const Handle_Aspect_Window& wnd); + static int AspectWindow_width(const OccHandle& wnd); + static int AspectWindow_height(const OccHandle& wnd); static OccHandle AspectDisplayConnection_create(); static void Gfx3dClipPlane_setCappingHatch( - const Handle_Graphic3d_ClipPlane& plane, Aspect_HatchStyle hatch + const OccHandle& plane, Aspect_HatchStyle hatch ); static void Gfx3dClipPlane_setNormal( - const Handle_Graphic3d_ClipPlane& plane, const gp_Dir& n + const OccHandle& plane, const gp_Dir& n ); static void Gfx3dClipPlane_setPosition( - const Handle_Graphic3d_ClipPlane& plane, double pos + const OccHandle& plane, double pos ); static bool ImagePixmap_flipY(Image_PixMap& pixmap);