mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +03:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a6e65fe79f | ||
|
1b25c97fbc |
@@ -1,68 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(glfw-occt-demo)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(APP_VERSION_MAJOR 1)
|
||||
set(APP_VERSION_MINOR 0)
|
||||
set(APP_TARGET glfwocct)
|
||||
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
|
||||
file(GLOB SOURCES
|
||||
*.h
|
||||
*.cpp
|
||||
)
|
||||
source_group ("Headers" FILES
|
||||
GlfwOcctView.h
|
||||
GlfwOcctWindow.h)
|
||||
source_group ("Sources" FILES
|
||||
GlfwOcctView.cpp
|
||||
GlfwOcctWindow.cpp
|
||||
main.cpp)
|
||||
|
||||
# OpenGL
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
# Open CASCADE Technology
|
||||
find_package(OpenCASCADE REQUIRED NO_DEFAULT_PATH)
|
||||
if (OpenCASCADE_FOUND)
|
||||
message (STATUS "Using OpenCASCADE from \"${OpenCASCADE_DIR}\"" )
|
||||
INCLUDE_DIRECTORIES(${OpenCASCADE_INCLUDE_DIR})
|
||||
LINK_DIRECTORIES(${OpenCASCADE_LIBRARY_DIR})
|
||||
else()
|
||||
message (WARNING "Could not find OpenCASCADE, please set OpenCASCADE_DIR variable." )
|
||||
set (OCCT_LIBRARY_DIR)
|
||||
set (OCCT_BIN_DIR)
|
||||
endif()
|
||||
|
||||
SET(OpenCASCADE_LIBS
|
||||
TKernel
|
||||
TKService
|
||||
TKV3d
|
||||
TKOpenGl
|
||||
TKBRep
|
||||
TKGeomBase
|
||||
TKGeomAlgo
|
||||
TKG3d
|
||||
TKG2d
|
||||
TKTopAlgo
|
||||
TKPrim
|
||||
)
|
||||
|
||||
# glfw
|
||||
find_package(glfw3 REQUIRED)
|
||||
if (glfw3_FOUND)
|
||||
message (STATUS "Using glfw3 ${glfw3_VERSION}" )
|
||||
INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${GLFW_LIBRARY_DIRS})
|
||||
else()
|
||||
message (STATUS "glfw3 is not found." )
|
||||
endif()
|
||||
|
||||
add_executable(${APP_TARGET} ${SOURCES})
|
||||
target_link_libraries(
|
||||
${APP_TARGET}
|
||||
${OpenCASCADE_LIBS}
|
||||
glfw
|
||||
${OPENGL_LIBRARIES}
|
||||
)
|
@@ -1,324 +0,0 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of the examples of the Open CASCADE Technology software library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
#include "GlfwOcctView.h"
|
||||
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <Aspect_Handle.hxx>
|
||||
#include <Aspect_DisplayConnection.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <BRepPrimAPI_MakeCone.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
// ================================================================
|
||||
// Function : GlfwOcctView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
GlfwOcctView::GlfwOcctView()
|
||||
: myCurAction3d (CurAction3d_Nothing),
|
||||
myToRedraw (true)
|
||||
{
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : ~GlfwOcctView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
GlfwOcctView::~GlfwOcctView()
|
||||
{
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : toView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
GlfwOcctView* GlfwOcctView::toView (GLFWwindow* theWin)
|
||||
{
|
||||
return static_cast<GlfwOcctView*>(glfwGetWindowUserPointer (theWin));
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : errorCallback
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::errorCallback (int theError, const char* theDescription)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error") + theError + ": " + theDescription, Message_Fail);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : run
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::run()
|
||||
{
|
||||
initWindow (800, 600, "glfw occt");
|
||||
initViewer();
|
||||
initDemoScene();
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myView->MustBeResized();
|
||||
myOcctWindow->Map();
|
||||
mainloop();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : initWindow
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::initWindow (int theWidth, int theHeight, const char* theTitle)
|
||||
{
|
||||
glfwSetErrorCallback (GlfwOcctView::errorCallback);
|
||||
glfwInit();
|
||||
const bool toAskCoreProfile = true;
|
||||
if (toAskCoreProfile)
|
||||
{
|
||||
glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
#if defined (__APPLE__)
|
||||
glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
#endif
|
||||
glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
}
|
||||
myOcctWindow = new GlfwOcctWindow (theWidth, theHeight, theTitle);
|
||||
glfwSetWindowUserPointer (myOcctWindow->getGlfwWindow(), this);
|
||||
// window callback
|
||||
glfwSetWindowSizeCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onResizeCallback);
|
||||
glfwSetFramebufferSizeCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onFBResizeCallback);
|
||||
// mouse callback
|
||||
glfwSetScrollCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onMouseScrollCallback);
|
||||
glfwSetMouseButtonCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onMouseButtonCallback);
|
||||
glfwSetCursorPosCallback (myOcctWindow->getGlfwWindow(), GlfwOcctView::onMouseMoveCallback);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : initViewer
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::initViewer()
|
||||
{
|
||||
if (myOcctWindow.IsNull()
|
||||
|| myOcctWindow->getGlfwWindow() == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (myOcctWindow->GetDisplay(), false);
|
||||
Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver);
|
||||
aViewer->SetDefaultLights();
|
||||
aViewer->SetLightOn();
|
||||
aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
|
||||
aViewer->ActivateGrid (Aspect_GT_Rectangular, Aspect_GDM_Lines);
|
||||
myView = aViewer->CreateView();
|
||||
myView->SetImmediateUpdate (false);
|
||||
myView->SetWindow (myOcctWindow, myOcctWindow->NativeGlContext());
|
||||
myView->ChangeRenderingParams().ToShowStats = true;
|
||||
myContext = new AIS_InteractiveContext (aViewer);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : initDemoScene
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::initDemoScene()
|
||||
{
|
||||
if (myContext.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myView->TriedronDisplay (Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.08, V3d_WIREFRAME);
|
||||
|
||||
gp_Ax2 anAxis;
|
||||
anAxis.SetLocation (gp_Pnt (0.0, 0.0, 0.0));
|
||||
Handle(AIS_Shape) aBox = new AIS_Shape (BRepPrimAPI_MakeBox (anAxis, 50, 50, 50).Shape());
|
||||
myContext->Display (aBox, AIS_Shaded, 0, false);
|
||||
anAxis.SetLocation (gp_Pnt (25.0, 125.0, 0.0));
|
||||
Handle(AIS_Shape) aCone = new AIS_Shape (BRepPrimAPI_MakeCone (anAxis, 25, 0, 50).Shape());
|
||||
myContext->Display (aCone, AIS_Shaded, 0, false);
|
||||
|
||||
TCollection_AsciiString aGlInfo;
|
||||
{
|
||||
TColStd_IndexedDataMapOfStringString aRendInfo;
|
||||
myView->DiagnosticInformation (aRendInfo, Graphic3d_DiagnosticInfo_Basic);
|
||||
for (TColStd_IndexedDataMapOfStringString::Iterator aValueIter (aRendInfo); aValueIter.More(); aValueIter.Next())
|
||||
{
|
||||
if (!aGlInfo.IsEmpty()) { aGlInfo += "\n"; }
|
||||
aGlInfo += TCollection_AsciiString(" ") + aValueIter.Key() + ": " + aValueIter.Value();
|
||||
}
|
||||
}
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("OpenGL info:\n") + aGlInfo, Message_Info);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : mainloop
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::mainloop()
|
||||
{
|
||||
while (!glfwWindowShouldClose (myOcctWindow->getGlfwWindow()))
|
||||
{
|
||||
// glfwPollEvents() for continuous rendering (immediate return if there are no new events)
|
||||
// and glfwWaitEvents() for rendering on demand (something actually happened in the viewer)
|
||||
//glfwPollEvents();
|
||||
glfwWaitEvents();
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
if (myView->IsInvalidated())
|
||||
{
|
||||
myView->Redraw();
|
||||
}
|
||||
else if (myToRedraw)
|
||||
{
|
||||
myView->RedrawImmediate();
|
||||
}
|
||||
myToRedraw = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : cleanup
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::cleanup()
|
||||
{
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
myView->Remove();
|
||||
}
|
||||
if (!myOcctWindow.IsNull())
|
||||
{
|
||||
myOcctWindow->Close();
|
||||
}
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onResize
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::onResize (int theWidth, int theHeight)
|
||||
{
|
||||
if (theWidth != 0
|
||||
&& theHeight != 0
|
||||
&& !myView.IsNull())
|
||||
{
|
||||
myView->Window()->DoResize();
|
||||
myView->MustBeResized();
|
||||
myView->Invalidate();
|
||||
myView->Redraw();
|
||||
//myToRedraw = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onMouseScroll
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::onMouseScroll (double theOffsetX, double theOffsetY)
|
||||
{
|
||||
if (myView.IsNull()) { return; }
|
||||
|
||||
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
|
||||
myView->StartZoomAtPoint (aPos.x(), aPos.y());
|
||||
myView->ZoomAtPoint (0, 0, int(theOffsetY * 4.0), int(theOffsetY * 4.0));
|
||||
myView->Invalidate();
|
||||
myToRedraw = true;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onMouseButton
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::onMouseButton (int theButton, int theAction, int theMods)
|
||||
{
|
||||
if (myView.IsNull()) { return; }
|
||||
|
||||
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
|
||||
if (theAction != GLFW_PRESS)
|
||||
{
|
||||
myCurAction3d = CurAction3d_Nothing;
|
||||
return;
|
||||
}
|
||||
|
||||
myMouseMin = aPos;
|
||||
myMouseMax = aPos;
|
||||
switch (theButton)
|
||||
{
|
||||
case GLFW_MOUSE_BUTTON_RIGHT:
|
||||
{
|
||||
myCurAction3d = CurAction3d_DynamicRoation;
|
||||
myView->StartRotation (aPos.x(), aPos.y());
|
||||
break;
|
||||
}
|
||||
case GLFW_MOUSE_BUTTON_MIDDLE:
|
||||
{
|
||||
myCurAction3d = CurAction3d_DynamicPanning;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onMouseMove
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctView::onMouseMove (int thePosX, int thePosY)
|
||||
{
|
||||
if (myView.IsNull()) { return; }
|
||||
|
||||
switch (myCurAction3d)
|
||||
{
|
||||
case CurAction3d_DynamicRoation:
|
||||
{
|
||||
myView->Rotation (thePosX, thePosY);
|
||||
myView->Invalidate();
|
||||
myToRedraw = true;
|
||||
break;
|
||||
}
|
||||
case CurAction3d_DynamicPanning:
|
||||
{
|
||||
myView->Pan (thePosX - myMouseMax.x(), -(thePosY - myMouseMax.y()));
|
||||
myView->Invalidate();
|
||||
myToRedraw = true;
|
||||
myMouseMax.SetValues (thePosX, thePosY);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
myContext->MoveTo (thePosX, thePosY, myView, false);
|
||||
myToRedraw = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,125 +0,0 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of the examples of the Open CASCADE Technology software library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
#ifndef _GlfwOcctView_Header
|
||||
#define _GlfwOcctView_Header
|
||||
|
||||
#include "GlfwOcctWindow.h"
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
//! Sample class creating 3D Viewer within GLFW window.
|
||||
class GlfwOcctView
|
||||
{
|
||||
public:
|
||||
enum CurAction3d
|
||||
{
|
||||
CurAction3d_Nothing,
|
||||
CurAction3d_DynamicZooming,
|
||||
CurAction3d_DynamicPanning,
|
||||
CurAction3d_DynamicRoation
|
||||
};
|
||||
|
||||
public:
|
||||
//! Default constructor.
|
||||
GlfwOcctView();
|
||||
|
||||
//! Destructor.
|
||||
~GlfwOcctView();
|
||||
|
||||
//! Main application entry point.
|
||||
void run();
|
||||
|
||||
private:
|
||||
|
||||
//! Create GLFW window.
|
||||
void initWindow (int theWidth, int theHeight, const char* theTitle);
|
||||
|
||||
//! Create 3D Viewer.
|
||||
void initViewer();
|
||||
|
||||
//! Fill 3D Viewer with a DEMO items.
|
||||
void initDemoScene();
|
||||
|
||||
//! Application event loop.
|
||||
void mainloop();
|
||||
|
||||
//! Clean up before .
|
||||
void cleanup();
|
||||
|
||||
//! @name GLWF callbacks
|
||||
private:
|
||||
//! Window resize event.
|
||||
void onResize (int theWidth, int theHeight);
|
||||
|
||||
//! Mouse scroll event.
|
||||
void onMouseScroll (double theOffsetX, double theOffsetY);
|
||||
|
||||
//! Mouse click event.
|
||||
void onMouseButton (int theButton, int theAction, int theMods);
|
||||
|
||||
//! Mouse move event.
|
||||
void onMouseMove (int thePosX, int thePosY);
|
||||
|
||||
//! @name GLWF callbacks (static functions)
|
||||
private:
|
||||
|
||||
//! GLFW callback redirecting messages into Message::DefaultMessenger().
|
||||
static void errorCallback (int theError, const char* theDescription);
|
||||
|
||||
//! Wrapper for glfwGetWindowUserPointer() returning this class instance.
|
||||
static GlfwOcctView* toView (GLFWwindow* theWin);
|
||||
|
||||
//! Window resize callback.
|
||||
static void onResizeCallback (GLFWwindow* theWin, int theWidth, int theHeight)
|
||||
{ toView(theWin)->onResize (theWidth, theHeight); }
|
||||
|
||||
//! Frame-buffer resize callback.
|
||||
static void onFBResizeCallback (GLFWwindow* theWin, int theWidth, int theHeight)
|
||||
{ toView(theWin)->onResize (theWidth, theHeight); }
|
||||
|
||||
//! Mouse scroll callback.
|
||||
static void onMouseScrollCallback (GLFWwindow* theWin, double theOffsetX, double theOffsetY)
|
||||
{ toView(theWin)->onMouseScroll (theOffsetX, theOffsetY); }
|
||||
|
||||
//! Mouse click callback.
|
||||
static void onMouseButtonCallback (GLFWwindow* theWin, int theButton, int theAction, int theMods)
|
||||
{ toView(theWin)->onMouseButton (theButton, theAction, theMods); }
|
||||
|
||||
//! Mouse move callback.
|
||||
static void onMouseMoveCallback (GLFWwindow* theWin, double thePosX, double thePosY)
|
||||
{ toView(theWin)->onMouseMove ((int )thePosX, (int )thePosY); }
|
||||
|
||||
private:
|
||||
|
||||
Handle(GlfwOcctWindow) myOcctWindow;
|
||||
Handle(V3d_View) myView;
|
||||
Handle(AIS_InteractiveContext) myContext;
|
||||
|
||||
CurAction3d myCurAction3d;
|
||||
Graphic3d_Vec2i myMouseMin;
|
||||
Graphic3d_Vec2i myMouseMax;
|
||||
bool myToRedraw;
|
||||
|
||||
};
|
||||
|
||||
#endif // _GlfwOcctView_Header
|
@@ -1,161 +0,0 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of the examples of the Open CASCADE Technology software library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
#include "GlfwOcctWindow.h"
|
||||
|
||||
#if defined (__APPLE__)
|
||||
#undef Handle // avoid name collisions in macOS headers
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
#define GLFW_EXPOSE_NATIVE_NSGL
|
||||
#elif defined (_WIN32)
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#define GLFW_EXPOSE_NATIVE_WGL
|
||||
#else
|
||||
#define GLFW_EXPOSE_NATIVE_X11
|
||||
#define GLFW_EXPOSE_NATIVE_GLX
|
||||
#endif
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
// ================================================================
|
||||
// Function : GlfwOcctWindow
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
GlfwOcctWindow::GlfwOcctWindow (int theWidth, int theHeight, const TCollection_AsciiString& theTitle)
|
||||
: myGlfwWindow (glfwCreateWindow (theWidth, theHeight, theTitle.ToCString(), NULL, NULL)),
|
||||
myXLeft (0),
|
||||
myYTop (0),
|
||||
myXRight (0),
|
||||
myYBottom(0)
|
||||
{
|
||||
if (myGlfwWindow != nullptr)
|
||||
{
|
||||
int aWidth = 0, aHeight = 0;
|
||||
glfwGetWindowPos (myGlfwWindow, &myXLeft, &myYTop);
|
||||
glfwGetWindowSize(myGlfwWindow, &aWidth, &aHeight);
|
||||
myXRight = myXLeft + aWidth;
|
||||
myYBottom = myYTop + aHeight;
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
myDisplay = new Aspect_DisplayConnection (glfwGetX11Display());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : Close
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctWindow::Close()
|
||||
{
|
||||
if (myGlfwWindow != nullptr)
|
||||
{
|
||||
glfwDestroyWindow (myGlfwWindow);
|
||||
myGlfwWindow = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : NativeHandle
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
Aspect_Drawable GlfwOcctWindow::NativeHandle() const
|
||||
{
|
||||
#if defined (__APPLE__)
|
||||
return (Aspect_Drawable)glfwGetCocoaWindow (myGlfwWindow);
|
||||
#elif defined (_WIN32)
|
||||
return (Aspect_Drawable)glfwGetWin32Window (myGlfwWindow);
|
||||
#else
|
||||
return (Aspect_Drawable)glfwGetX11Window (myGlfwWindow);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : NativeGlContext
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
Aspect_RenderingContext GlfwOcctWindow::NativeGlContext() const
|
||||
{
|
||||
#if defined (__APPLE__)
|
||||
return (NSOpenGLContext*)glfwGetNSGLContext (myGlfwWindow);
|
||||
#elif defined (_WIN32)
|
||||
return glfwGetWGLContext (myGlfwWindow);
|
||||
#else
|
||||
return glfwGetGLXContext (myGlfwWindow);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : IsMapped
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
Standard_Boolean GlfwOcctWindow::IsMapped() const
|
||||
{
|
||||
return glfwGetWindowAttrib (myGlfwWindow, GLFW_VISIBLE) != 0;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : Map
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctWindow::Map() const
|
||||
{
|
||||
glfwShowWindow (myGlfwWindow);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : Unmap
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void GlfwOcctWindow::Unmap() const
|
||||
{
|
||||
glfwHideWindow (myGlfwWindow);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : DoResize
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
Aspect_TypeOfResize GlfwOcctWindow::DoResize() const
|
||||
{
|
||||
if (glfwGetWindowAttrib (myGlfwWindow, GLFW_VISIBLE) == 1)
|
||||
{
|
||||
int anXPos = 0, anYPos = 0, aWidth = 0, aHeight = 0;
|
||||
glfwGetWindowPos (myGlfwWindow, &anXPos, &anYPos);
|
||||
glfwGetWindowSize(myGlfwWindow, &aWidth, &aHeight);
|
||||
*const_cast<Standard_Integer*>(&myXLeft ) = anXPos;
|
||||
*const_cast<Standard_Integer*>(&myXRight ) = anXPos + aWidth;
|
||||
*const_cast<Standard_Integer*>(&myYTop ) = anYPos;
|
||||
*const_cast<Standard_Integer*>(&myYBottom) = anYPos + aHeight;
|
||||
}
|
||||
return Aspect_TOR_UNKNOWN;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : CursorPosition
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
Graphic3d_Vec2i GlfwOcctWindow::CursorPosition() const
|
||||
{
|
||||
Graphic3d_Vec2d aPos;
|
||||
glfwGetCursorPos (myGlfwWindow, &aPos.x(), &aPos.y());
|
||||
return Graphic3d_Vec2i ((int )aPos.x(), (int )aPos.y());
|
||||
}
|
@@ -1,115 +0,0 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of the examples of the Open CASCADE Technology software library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
#ifndef _GlfwOcctWindow_Header
|
||||
#define _GlfwOcctWindow_Header
|
||||
|
||||
#include <Aspect_DisplayConnection.hxx>
|
||||
#include <Aspect_RenderingContext.hxx>
|
||||
#include <Aspect_Window.hxx>
|
||||
#include <Graphic3d_Vec.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
struct GLFWwindow;
|
||||
|
||||
//! GLFWwindow wrapper implementing Aspect_Window interface.
|
||||
class GlfwOcctWindow : public Aspect_Window
|
||||
{
|
||||
DEFINE_STANDARD_RTTI_INLINE(GlfwOcctWindow, Aspect_Window)
|
||||
public:
|
||||
//! Main constructor.
|
||||
GlfwOcctWindow (int theWidth, int theHeight, const TCollection_AsciiString& theTitle);
|
||||
|
||||
//! Close the window.
|
||||
virtual ~GlfwOcctWindow() { Close(); }
|
||||
|
||||
//! Close the window.
|
||||
void Close();
|
||||
|
||||
//! Return X Display connection.
|
||||
const Handle(Aspect_DisplayConnection)& GetDisplay() const { return myDisplay; }
|
||||
|
||||
//! Return GLFW window.
|
||||
GLFWwindow* getGlfwWindow() { return myGlfwWindow; }
|
||||
|
||||
//! Return native OpenGL context.
|
||||
Aspect_RenderingContext NativeGlContext() const;
|
||||
|
||||
//! Return cursor position.
|
||||
Graphic3d_Vec2i CursorPosition() const;
|
||||
|
||||
public:
|
||||
|
||||
//! Returns native Window handle
|
||||
virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns parent of native Window handle.
|
||||
virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
//! Applies the resizing to the window <me>
|
||||
virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns True if the window <me> is opened and False if the window is closed.
|
||||
virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
|
||||
|
||||
//! Apply the mapping change to the window <me> and returns TRUE if the window is mapped at screen.
|
||||
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
|
||||
|
||||
//! Opens the window <me>.
|
||||
virtual void Map() const Standard_OVERRIDE;
|
||||
|
||||
//! Closes the window <me>.
|
||||
virtual void Unmap() const Standard_OVERRIDE;
|
||||
|
||||
virtual void Position (Standard_Integer& theX1, Standard_Integer& theY1,
|
||||
Standard_Integer& theX2, Standard_Integer& theY2) const Standard_OVERRIDE
|
||||
{
|
||||
theX1 = myXLeft;
|
||||
theX2 = myXRight;
|
||||
theY1 = myYTop;
|
||||
theY2 = myYBottom;
|
||||
}
|
||||
|
||||
//! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions.
|
||||
virtual Standard_Real Ratio() const Standard_OVERRIDE
|
||||
{
|
||||
return Standard_Real (myXRight - myXLeft) / Standard_Real (myYBottom - myYTop);
|
||||
}
|
||||
|
||||
//! Return window size.
|
||||
virtual void Size (Standard_Integer& theWidth, Standard_Integer& theHeight) const Standard_OVERRIDE
|
||||
{
|
||||
theWidth = myXRight - myXLeft;
|
||||
theHeight = myYBottom - myYTop;
|
||||
}
|
||||
|
||||
virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
|
||||
|
||||
protected:
|
||||
Handle(Aspect_DisplayConnection) myDisplay;
|
||||
GLFWwindow* myGlfwWindow;
|
||||
Standard_Integer myXLeft;
|
||||
Standard_Integer myYTop;
|
||||
Standard_Integer myXRight;
|
||||
Standard_Integer myYBottom;
|
||||
};
|
||||
|
||||
#endif // _GlfwOcctWindow_Header
|
@@ -1,37 +0,0 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of the examples of the Open CASCADE Technology software library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
#include "GlfwOcctView.h"
|
||||
|
||||
int main (int, char**)
|
||||
{
|
||||
GlfwOcctView anApp;
|
||||
try
|
||||
{
|
||||
anApp.run();
|
||||
}
|
||||
catch (const std::runtime_error& theError)
|
||||
{
|
||||
std::cerr << theError.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
A sample demonstrating usage of OCCT 3D Viewer within a window created using GLFW.
|
||||
|
||||
Platforms: Windows, macOS, Linux
|
||||
Required: glfw
|
@@ -1,285 +0,0 @@
|
||||
// Created on: 2018-12-12
|
||||
// Created by: Olga SURYANINOVA
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <AIS_CameraFrustum.hxx>
|
||||
|
||||
#include <AIS_DisplayMode.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Select3D_SensitiveGroup.hxx>
|
||||
#include <Select3D_SensitivePrimitiveArray.hxx>
|
||||
#include <Select3D_SensitiveSegment.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Standard_ShortReal THE_DEFAULT_TRANSPARENCY = 0.7f;
|
||||
static const Quantity_Color THE_DEFAULT_COLOR = Quantity_NOC_WHITE;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_CameraFrustum::AIS_CameraFrustum()
|
||||
: myPoints (0, Graphic3d_Camera::FrustumVerticesNB)
|
||||
{
|
||||
myDrawer->SetLineAspect (new Prs3d_LineAspect (THE_DEFAULT_COLOR, Aspect_TOL_SOLID, 1.0));
|
||||
|
||||
Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
|
||||
aShadingAspect->SetMaterial (Graphic3d_NOM_PLASTIC);
|
||||
aShadingAspect->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend);
|
||||
aShadingAspect->SetTransparency (THE_DEFAULT_TRANSPARENCY);
|
||||
aShadingAspect->SetColor (THE_DEFAULT_COLOR);
|
||||
myDrawer->SetShadingAspect (aShadingAspect);
|
||||
|
||||
myDrawer->SetTransparency (THE_DEFAULT_TRANSPARENCY);
|
||||
SetDisplayMode (AIS_Shaded);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AcceptDisplayMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_CameraFrustum::AcceptDisplayMode (const Standard_Integer theMode) const
|
||||
{
|
||||
return theMode == AIS_Shaded || theMode == AIS_WireFrame;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCameraFrustum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::SetCameraFrustum (const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
if (theCamera.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
theCamera->FrustumPoints (myPoints);
|
||||
|
||||
fillTriangles();
|
||||
fillBorders();
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::SetColor (const Quantity_Color& theColor)
|
||||
{
|
||||
AIS_InteractiveObject::SetColor (theColor);
|
||||
myDrawer->ShadingAspect()->SetColor (theColor);
|
||||
myDrawer->LineAspect()->SetColor (theColor);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::UnsetColor()
|
||||
{
|
||||
if (!HasColor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AIS_InteractiveObject::UnsetColor();
|
||||
|
||||
myDrawer->ShadingAspect()->SetColor (THE_DEFAULT_COLOR);
|
||||
myDrawer->LineAspect()->SetColor (THE_DEFAULT_COLOR);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::UnsetTransparency()
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetTransparency (0.0f);
|
||||
myDrawer->SetTransparency (0.0f);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : fillTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::fillTriangles()
|
||||
{
|
||||
if (myTriangles.IsNull())
|
||||
{
|
||||
const Standard_Integer aPlaneTriangleVertsNb = 2 * 3;
|
||||
const Standard_Integer aPlanesNb = 3 * 2;
|
||||
|
||||
myTriangles = new Graphic3d_ArrayOfTriangles (Graphic3d_Camera::FrustumVerticesNB, aPlaneTriangleVertsNb * aPlanesNb);
|
||||
myTriangles->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0));
|
||||
|
||||
// Triangles go in order (clockwise vertices traversing for correct normal):
|
||||
// (0, 2, 1), (3, 1, 2)
|
||||
const Standard_Integer aLookup1_clockwise[] = { 0, 1, 0, 1, 0, 1 };
|
||||
const Standard_Integer aLookup2_clockwise[] = { 0, 0, 1, 1, 1, 0 };
|
||||
// Triangles go in order (counterclockwise vertices traversing for correct normal):
|
||||
// (1, 2, 0), (2, 1, 3)
|
||||
const Standard_Integer aLookup1_anticlockwise[] = { 0, 1, 0, 1, 0, 1 };
|
||||
const Standard_Integer aLookup2_anticlockwise[] = { 1, 0, 0, 0, 1, 1 };
|
||||
Standard_Integer aShifts[] = { 0, 0, 0 };
|
||||
|
||||
// Planes go in order:
|
||||
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
|
||||
for (Standard_Integer aFaceIdx = 0; aFaceIdx < 3; ++aFaceIdx)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < 2; ++i)
|
||||
{
|
||||
for (Standard_Integer aPntIter = 0; aPntIter < aPlaneTriangleVertsNb; ++aPntIter)
|
||||
{
|
||||
aShifts[aFaceIdx] = i;
|
||||
if (i == 0)
|
||||
{
|
||||
aShifts[(aFaceIdx + 1) % 3] = aLookup1_clockwise[aPntIter];
|
||||
aShifts[(aFaceIdx + 2) % 3] = aLookup2_clockwise[aPntIter];
|
||||
}
|
||||
else
|
||||
{
|
||||
aShifts[(aFaceIdx + 1) % 3] = aLookup1_anticlockwise[aPntIter];
|
||||
aShifts[(aFaceIdx + 2) % 3] = aLookup2_anticlockwise[aPntIter];
|
||||
}
|
||||
|
||||
Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2];
|
||||
myTriangles->AddEdge (anIndex + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB; ++aPointIter)
|
||||
{
|
||||
const Graphic3d_Vec3d aPnt = myPoints[aPointIter];
|
||||
myTriangles->SetVertice (aPointIter + 1, gp_Pnt (aPnt.x(), aPnt.y(), aPnt.z()));
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : fillBorders
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::fillBorders()
|
||||
{
|
||||
if (myBorders.IsNull())
|
||||
{
|
||||
const Standard_Integer aPlaneSegmVertsNb = 2 * 4;
|
||||
const Standard_Integer aPlanesNb = 3 * 2;
|
||||
myBorders = new Graphic3d_ArrayOfSegments (Graphic3d_Camera::FrustumVerticesNB, aPlaneSegmVertsNb * aPlanesNb);
|
||||
myBorders->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0));
|
||||
|
||||
// Segments go in order:
|
||||
// (0, 2), (2, 3), (3, 1), (1, 0)
|
||||
const Standard_Integer aLookup1[] = { 0, 1, 1, 1, 1, 0, 0, 0 };
|
||||
const Standard_Integer aLookup2[] = { 0, 0, 0, 1, 1, 1, 1, 0 };
|
||||
Standard_Integer aShifts[] = { 0, 0, 0 };
|
||||
|
||||
// Planes go in order:
|
||||
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
|
||||
for (Standard_Integer aFaceIdx = 0; aFaceIdx < 3; ++aFaceIdx)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < 2; ++i)
|
||||
{
|
||||
for (Standard_Integer aSegmVertIter = 0; aSegmVertIter < aPlaneSegmVertsNb; ++aSegmVertIter)
|
||||
{
|
||||
aShifts[aFaceIdx] = i;
|
||||
aShifts[(aFaceIdx + 1) % 3] = aLookup1[aSegmVertIter];
|
||||
aShifts[(aFaceIdx + 2) % 3] = aLookup2[aSegmVertIter];
|
||||
|
||||
Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2];
|
||||
myBorders->AddEdge (anIndex + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB; ++aPointIter)
|
||||
{
|
||||
const Graphic3d_Vec3d aPnt = myPoints[aPointIter];
|
||||
myBorders->SetVertice (aPointIter + 1, gp_Pnt (aPnt.x(), aPnt.y(), aPnt.z()));
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
thePrs->SetInfiniteState (true);
|
||||
if (myTriangles.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
switch (theMode)
|
||||
{
|
||||
case AIS_Shaded:
|
||||
{
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (myTriangles);
|
||||
}
|
||||
Standard_FALLTHROUGH
|
||||
case AIS_WireFrame:
|
||||
{
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (myBorders);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this);
|
||||
switch (theMode)
|
||||
{
|
||||
case SelectionMode_Edges:
|
||||
{
|
||||
Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (anOwner);
|
||||
for (Standard_Integer anIter = 1; anIter <= myBorders->EdgeNumber(); anIter += 2)
|
||||
{
|
||||
aSensitiveEntity->Add (new Select3D_SensitiveSegment (anOwner, myBorders->Vertice (myBorders->Edge (anIter)), myBorders->Vertice(myBorders->Edge (anIter + 1))));
|
||||
}
|
||||
theSelection->Add (aSensitiveEntity);
|
||||
break;
|
||||
}
|
||||
case SelectionMode_Volume:
|
||||
{
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray (anOwner);
|
||||
aSelArray->InitTriangulation (myTriangles->Attributes(), myTriangles->Indices(), TopLoc_Location());
|
||||
theSelection->Add (aSelArray);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
// Created on: 2018-12-12
|
||||
// Created by: Olga SURYANINOVA
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _AIS_CameraFrustum_HeaderFile
|
||||
#define _AIS_CameraFrustum_HeaderFile
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
|
||||
class Graphic3d_ArrayOfSegments;
|
||||
class Graphic3d_ArrayOfTriangles;
|
||||
|
||||
//! Presentation for drawing camera frustum.
|
||||
//! Default configuration is built with filling and some transparency.
|
||||
class AIS_CameraFrustum : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Selection modes supported by this object
|
||||
enum SelectionMode
|
||||
{
|
||||
SelectionMode_Edges = 0, //!< detect by edges (default)
|
||||
SelectionMode_Volume = 1, //!< detect by volume
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Constructs camera frustum with default configuration.
|
||||
Standard_EXPORT AIS_CameraFrustum();
|
||||
|
||||
//! Sets camera frustum.
|
||||
Standard_EXPORT void SetCameraFrustum (const Handle(Graphic3d_Camera)& theCamera);
|
||||
|
||||
//! Setup custom color.
|
||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
|
||||
//! Restore default color.
|
||||
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
|
||||
|
||||
//! Restore transparency setting.
|
||||
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
|
||||
|
||||
//! Return true if specified display mode is supported.
|
||||
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Computes presentation of camera frustum.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute selection.
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
//! Fills triangles primitive array for camera frustum filling.
|
||||
void fillTriangles();
|
||||
|
||||
//! Fills polylines primitive array for camera frustum borders.
|
||||
void fillBorders();
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_Array1<Graphic3d_Vec3d> myPoints; //!< Array of points
|
||||
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for camera frustum filling
|
||||
Handle(Graphic3d_ArrayOfSegments) myBorders; //!< Segments for camera frustum borders
|
||||
|
||||
};
|
||||
|
||||
#endif // _AIS_CameraFrustum_HeaderFile
|
@@ -27,7 +27,6 @@ public:
|
||||
AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink)
|
||||
: myIsHidden (false),
|
||||
myHasOwnColor (false),
|
||||
myHasOwnTransp(false),
|
||||
myHasOwnWidth (false)
|
||||
{
|
||||
Link (theLink);
|
||||
@@ -35,15 +34,9 @@ public:
|
||||
|
||||
bool IsHidden() const { return myIsHidden; }
|
||||
void SetHidden (const bool theToHide) { myIsHidden = theToHide;}
|
||||
|
||||
bool HasOwnColor() const { return myHasOwnColor; }
|
||||
void UnsetOwnColor() { myHasOwnColor = false; }
|
||||
void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
|
||||
|
||||
bool HasOwnTransparency() const { return myHasOwnTransp; }
|
||||
void UnsetOwnTransparency() { myHasOwnTransp = false; }
|
||||
void SetOwnTransparency (Standard_Real /*theTransp*/) { myHasOwnTransp = true; }
|
||||
|
||||
bool HasOwnWidth() const { return myHasOwnWidth; }
|
||||
void UnsetOwnWidth() { myHasOwnWidth = false; }
|
||||
void SetOwnWidth (const Standard_Real /*theWidth*/) { myHasOwnWidth = true; }
|
||||
@@ -52,7 +45,6 @@ public: //! @name list of overridden properties
|
||||
|
||||
bool myIsHidden;
|
||||
bool myHasOwnColor;
|
||||
bool myHasOwnTransp;
|
||||
bool myHasOwnWidth;
|
||||
|
||||
};
|
||||
|
@@ -187,25 +187,6 @@ void AIS_ColoredShape::SetCustomColor (const TopoDS_Shape& theShape,
|
||||
LoadRecomputable (AIS_Shaded);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCustomTransparency
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ColoredShape::SetCustomTransparency (const TopoDS_Shape& theShape,
|
||||
Standard_Real theTransparency)
|
||||
{
|
||||
if (theShape.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
|
||||
setTransparency (aDrawer, theTransparency);
|
||||
aDrawer->SetOwnTransparency (theTransparency);
|
||||
LoadRecomputable (AIS_WireFrame);
|
||||
LoadRecomputable (AIS_Shaded);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCustomWidth
|
||||
//purpose :
|
||||
@@ -219,7 +200,7 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape,
|
||||
}
|
||||
|
||||
const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
|
||||
setWidth (aDrawer, theLineWidth);
|
||||
setWidth (CustomAspects (theShape), theLineWidth);
|
||||
aDrawer->SetOwnWidth (theLineWidth);
|
||||
LoadRecomputable (AIS_WireFrame);
|
||||
LoadRecomputable (AIS_Shaded);
|
||||
@@ -311,12 +292,7 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
|
||||
LoadRecomputable (AIS_Shaded);
|
||||
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
|
||||
if (aDrawer->HasOwnTransparency())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Handle(Prs3d_Drawer)& aDrawer = anIter.Value();
|
||||
if (aDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
aDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
|
||||
@@ -370,7 +346,7 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
|
||||
//if (aDrawer->HasOwnMaterial()) continue;
|
||||
if (aDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());
|
||||
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), Standard_False); // aDrawer->IsTransparent()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -739,29 +715,13 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
|
||||
{
|
||||
const TopoDS_Shape& aFace = aFaceIter.Value();
|
||||
Handle(AIS_ColoredDrawer) aFaceDrawer;
|
||||
if (aFace.ShapeType() != TopAbs_FACE
|
||||
|| !theShapeDrawerMap.Find (aFace, aFaceDrawer))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aFaceDrawer->IsHidden())
|
||||
if (aFace.ShapeType() == TopAbs_FACE
|
||||
&& theShapeDrawerMap.Find (aFace, aFaceDrawer)
|
||||
&& aFaceDrawer->IsHidden())
|
||||
{
|
||||
isClosedShell = Standard_False;
|
||||
break;
|
||||
}
|
||||
else if (aFaceDrawer->HasOwnShadingAspect()
|
||||
&& aFaceDrawer->ShadingAspect()->Aspect()->AlphaMode() != Graphic3d_AlphaMode_Opaque)
|
||||
{
|
||||
if (aFaceDrawer->ShadingAspect()->Aspect()->AlphaMode() != Graphic3d_AlphaMode_BlendAuto
|
||||
|| aFaceDrawer->ShadingAspect()->Aspect()->FrontMaterial().Alpha() < 1.0f
|
||||
|| (aFaceDrawer->ShadingAspect()->Aspect()->Distinguish()
|
||||
&& aFaceDrawer->ShadingAspect()->Aspect()->BackMaterial().Alpha() < 1.0f))
|
||||
{
|
||||
isClosedShell = Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -56,10 +56,6 @@ public: //! @name sub-shape aspects
|
||||
Standard_EXPORT void SetCustomColor (const TopoDS_Shape& theShape,
|
||||
const Quantity_Color& theColor);
|
||||
|
||||
//! Customize transparency of specified sub-shape
|
||||
Standard_EXPORT void SetCustomTransparency (const TopoDS_Shape& theShape,
|
||||
Standard_Real theTransparency);
|
||||
|
||||
//! Customize line width of specified sub-shape
|
||||
Standard_EXPORT void SetCustomWidth (const TopoDS_Shape& theShape,
|
||||
const Standard_Real theLineWidth);
|
||||
|
@@ -416,14 +416,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
|
||||
if (toUpdateViewer
|
||||
&& theToRedrawOnUpdate)
|
||||
{
|
||||
if (theView->ComputedMode())
|
||||
{
|
||||
theView->Viewer()->Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
theView->Viewer()->RedrawImmediate();
|
||||
}
|
||||
theView->Viewer()->Update();
|
||||
}
|
||||
|
||||
return aStatus;
|
||||
|
@@ -335,10 +335,6 @@ void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManag
|
||||
}
|
||||
aGroup->AddPrimitiveArray (arrayOfPrimitives(aPart));
|
||||
|
||||
if (aPresentation->GetZLayer() != theStyle->ZLayer())
|
||||
{
|
||||
aPresentation->SetZLayer (theStyle->ZLayer());
|
||||
}
|
||||
aPresentation->Highlight (theStyle);
|
||||
thePM->AddToImmediateList (aPresentation);
|
||||
}
|
||||
|
@@ -19,8 +19,6 @@ AIS_BadEdgeFilter.cxx
|
||||
AIS_BadEdgeFilter.hxx
|
||||
AIS_C0RegularityFilter.cxx
|
||||
AIS_C0RegularityFilter.hxx
|
||||
AIS_CameraFrustum.cxx
|
||||
AIS_CameraFrustum.hxx
|
||||
AIS_Chamf2dDimension.cxx
|
||||
AIS_Chamf2dDimension.hxx
|
||||
AIS_Chamf2dDimension.lxx
|
||||
|
@@ -26,11 +26,9 @@ IMPLEMENT_STANDARD_RTTIEXT(Aspect_DisplayConnection,Standard_Transient)
|
||||
Aspect_DisplayConnection::Aspect_DisplayConnection()
|
||||
{
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
myDisplay = NULL;
|
||||
myIsOwnDisplay = false;
|
||||
OSD_Environment anEnv ("DISPLAY");
|
||||
myDisplayName = anEnv.Value();
|
||||
Init (NULL);
|
||||
Init();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -41,8 +39,7 @@ Aspect_DisplayConnection::Aspect_DisplayConnection()
|
||||
Aspect_DisplayConnection::~Aspect_DisplayConnection()
|
||||
{
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
if (myDisplay != NULL
|
||||
&& myIsOwnDisplay)
|
||||
if (myDisplay != NULL)
|
||||
{
|
||||
XCloseDisplay (myDisplay);
|
||||
}
|
||||
@@ -55,39 +52,38 @@ Aspect_DisplayConnection::~Aspect_DisplayConnection()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Aspect_DisplayConnection::Aspect_DisplayConnection (const TCollection_AsciiString& theDisplayName)
|
||||
: myDisplay (NULL),
|
||||
myIsOwnDisplay (false)
|
||||
{
|
||||
myDisplayName = theDisplayName;
|
||||
Init (NULL);
|
||||
Init();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Aspect_DisplayConnection
|
||||
// function : GetDisplay
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Aspect_DisplayConnection::Aspect_DisplayConnection (Display* theDisplay)
|
||||
: myDisplay (NULL),
|
||||
myIsOwnDisplay (false)
|
||||
Display* Aspect_DisplayConnection::GetDisplay()
|
||||
{
|
||||
Init (theDisplay);
|
||||
return myDisplay;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetDisplayName
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Aspect_DisplayConnection::GetDisplayName()
|
||||
{
|
||||
return myDisplayName;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Aspect_DisplayConnection::Init (Display* theDisplay)
|
||||
void Aspect_DisplayConnection::Init()
|
||||
{
|
||||
if (myDisplay != NULL
|
||||
&& myIsOwnDisplay)
|
||||
{
|
||||
XCloseDisplay (myDisplay);
|
||||
}
|
||||
myIsOwnDisplay = false;
|
||||
myAtoms.Clear();
|
||||
|
||||
myDisplay = theDisplay != NULL ? theDisplay : XOpenDisplay (myDisplayName.ToCString());
|
||||
myDisplay = XOpenDisplay (myDisplayName.ToCString());
|
||||
myAtoms.Bind (Aspect_XA_DELETE_WINDOW, XInternAtom(myDisplay, "WM_DELETE_WINDOW", False));
|
||||
|
||||
if (myDisplay == NULL)
|
||||
{
|
||||
TCollection_AsciiString aMessage;
|
||||
@@ -95,11 +91,6 @@ void Aspect_DisplayConnection::Init (Display* theDisplay)
|
||||
aMessage += myDisplayName + "\"";
|
||||
throw Aspect_DisplayConnectionDefinitionError(aMessage.ToCString());
|
||||
}
|
||||
else
|
||||
{
|
||||
myIsOwnDisplay = theDisplay == NULL;
|
||||
myAtoms.Bind (Aspect_XA_DELETE_WINDOW, XInternAtom(myDisplay, "WM_DELETE_WINDOW", False));
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -47,37 +47,25 @@ public:
|
||||
//! screen_number - Specifies the screen to be used on that server. Optional variable.
|
||||
Aspect_DisplayConnection (const TCollection_AsciiString& theDisplayName);
|
||||
|
||||
//! Constructor wrapping existing Display instance.
|
||||
//! WARNING! it is a responsibility of application to keep this pointer
|
||||
//! valid while Aspect_DisplayConnection is alive and to close Display when it is no more needed.
|
||||
Aspect_DisplayConnection (Display* theDisplay);
|
||||
|
||||
//! @return pointer to Display structure that serves as the connection to the X server.
|
||||
Display* GetDisplay() { return myDisplay; }
|
||||
|
||||
//! @return TRUE if X Display has been allocated by this class
|
||||
Standard_Boolean IsOwnDisplay() const { return myIsOwnDisplay; }
|
||||
|
||||
Display* GetDisplay();
|
||||
|
||||
//! @return identifier(atom) for custom named property associated with windows that use current connection to X server.
|
||||
Atom GetAtom (const Aspect_XAtom theAtom) const;
|
||||
|
||||
//! @return display name for this connection.
|
||||
const TCollection_AsciiString& GetDisplayName() { return myDisplayName; }
|
||||
TCollection_AsciiString GetDisplayName();
|
||||
|
||||
//! Open connection with display specified in myDisplayName class field
|
||||
//! or takes theDisplay parameter when it is not NULL.
|
||||
//! WARNING! When external Display is specified, it is a responsibility of application
|
||||
//! to keep this pointer valid while Aspect_DisplayConnection is alive
|
||||
//! and to close Display when it is no more needed.
|
||||
//! @param theDisplay external pointer to allocated Display, or NULL if new connection should be created
|
||||
void Init (Display* theDisplay);
|
||||
private:
|
||||
|
||||
//! Open connection with display specified in myDisplayName class field.
|
||||
void Init();
|
||||
|
||||
private:
|
||||
|
||||
Display* myDisplay;
|
||||
NCollection_DataMap<Aspect_XAtom, Atom> myAtoms;
|
||||
TCollection_AsciiString myDisplayName;
|
||||
Standard_Boolean myIsOwnDisplay;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@@ -414,10 +414,6 @@ static void ComputePCA(const TopoDS_Shape& theS,
|
||||
{
|
||||
BRepBndLib::Add(aST, aShapeBox);
|
||||
}
|
||||
if (aShapeBox.IsVoid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Pnt aPMin = aShapeBox.CornerMin();
|
||||
gp_Pnt aPMax = aShapeBox.CornerMax();
|
||||
|
@@ -114,10 +114,7 @@ TopoDS_Shape BRepPrimAPI_MakePrism::LastShape()
|
||||
const TopTools_ListOfShape& BRepPrimAPI_MakePrism::Generated (const TopoDS_Shape& S)
|
||||
{
|
||||
myGenerated.Clear();
|
||||
if (myPrism.IsUsed(S) && myPrism.GenIsUsed(S))
|
||||
{
|
||||
myGenerated.Append(myPrism.Shape(S));
|
||||
}
|
||||
myGenerated.Append(myPrism.Shape (S));
|
||||
return myGenerated;
|
||||
|
||||
}
|
||||
@@ -149,13 +146,3 @@ TopoDS_Shape BRepPrimAPI_MakePrism::LastShape(const TopoDS_Shape &theShape)
|
||||
}
|
||||
|
||||
// Modified by skv - Fri Mar 4 15:50:09 2005 End
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDeleted
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepPrimAPI_MakePrism::IsDeleted(const TopoDS_Shape& S)
|
||||
{
|
||||
return !myPrism.IsUsed(S);
|
||||
}
|
||||
|
||||
|
@@ -87,10 +87,7 @@ public:
|
||||
|
||||
//! Returns ListOfShape from TopTools.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the shape S has been deleted.
|
||||
Standard_EXPORT virtual Standard_Boolean IsDeleted(const TopoDS_Shape& S) Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Returns the TopoDS Shape of the bottom of the prism.
|
||||
//! generated with theShape (subShape of the generating shape).
|
||||
Standard_EXPORT TopoDS_Shape FirstShape (const TopoDS_Shape& theShape);
|
||||
@@ -99,6 +96,9 @@ public:
|
||||
//! generated with theShape (subShape of the generating shape).
|
||||
Standard_EXPORT TopoDS_Shape LastShape (const TopoDS_Shape& theShape);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
@@ -240,49 +240,16 @@ TopoDS_Shape BRepPrimAPI_MakeRevol::LastShape()
|
||||
const TopTools_ListOfShape& BRepPrimAPI_MakeRevol::Generated (const TopoDS_Shape& S)
|
||||
{
|
||||
myGenerated.Clear();
|
||||
|
||||
if (!myRevol.IsUsed(S))
|
||||
{
|
||||
return myGenerated;
|
||||
}
|
||||
|
||||
TopoDS_Shape aGS = myRevol.Shape(S);
|
||||
if (!aGS.IsNull())
|
||||
{
|
||||
if (BRepTools_History::IsSupportedType(aGS))
|
||||
{
|
||||
if (aGS.ShapeType() == TopAbs_EDGE)
|
||||
{
|
||||
Standard_Boolean isDeg = BRep_Tool::Degenerated(TopoDS::Edge(aGS));
|
||||
if (isDeg)
|
||||
{
|
||||
TopTools_ListIteratorOfListOfShape anIt(myDegenerated);
|
||||
for (; anIt.More(); anIt.Next())
|
||||
{
|
||||
if (aGS.IsSame(anIt.Value()))
|
||||
{
|
||||
myGenerated.Append(aGS);
|
||||
if (!myHist.IsNull())
|
||||
{
|
||||
TopTools_ListIteratorOfListOfShape anIt1(myHist->Modified(aGS));
|
||||
for (; anIt1.More(); anIt1.Next())
|
||||
{
|
||||
myGenerated.Append(anIt1.Value());
|
||||
}
|
||||
return myGenerated;
|
||||
}
|
||||
}
|
||||
}
|
||||
return myGenerated;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (myHist.IsNull())
|
||||
{
|
||||
myGenerated.Append(aGS);
|
||||
return myGenerated;
|
||||
}
|
||||
//
|
||||
if (myHist->Modified(aGS).IsEmpty())
|
||||
{
|
||||
myGenerated.Append(aGS);
|
||||
@@ -294,19 +261,18 @@ const TopTools_ListOfShape& BRepPrimAPI_MakeRevol::Generated (const TopoDS_Shape
|
||||
{
|
||||
myGenerated.Append(anIt.Value());
|
||||
}
|
||||
if (aGS.ShapeType() == TopAbs_EDGE)
|
||||
{
|
||||
if (BRep_Tool::Degenerated(TopoDS::Edge(aGS)))
|
||||
{
|
||||
//Append initial common deg. edge
|
||||
myGenerated.Append(aGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return myGenerated;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsDeleted
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepPrimAPI_MakeRevol::IsDeleted(const TopoDS_Shape& S)
|
||||
{
|
||||
return !myRevol.IsUsed(S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FirstShape
|
||||
|
@@ -95,10 +95,6 @@ public:
|
||||
//! Warning: shape S must be shape of type VERTEX, EDGE, FACE, SOLID.
|
||||
//! For shapes of other types method always returns empty list
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the shape S has been deleted.
|
||||
Standard_EXPORT virtual Standard_Boolean IsDeleted(const TopoDS_Shape& S) Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Returns the TopoDS Shape of the beginning of the revolution,
|
||||
//! generated with theShape (subShape of the generating shape).
|
||||
|
@@ -30,7 +30,6 @@
|
||||
#include <TopAbs_Orientation.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_SequenceOfShape.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepSweep_NumLinearRegularSweep
|
||||
@@ -55,12 +54,9 @@ myBuilder(aBuilder),
|
||||
myShapes(1,myGenShapeTool.NbShapes(),
|
||||
1,myDirShapeTool.NbShapes()),
|
||||
myBuiltShapes(1,myGenShapeTool.NbShapes(),
|
||||
1,myDirShapeTool.NbShapes()),
|
||||
myUsedShapes(1, myGenShapeTool.NbShapes(),
|
||||
1, myDirShapeTool.NbShapes())
|
||||
1,myDirShapeTool.NbShapes())
|
||||
{
|
||||
myBuiltShapes.Init(Standard_False);
|
||||
myUsedShapes.Init(Standard_False);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -160,9 +156,7 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
|
||||
Or = It.Orientation();
|
||||
if(HasShape(subGenS,aDirS)){
|
||||
newShape = Shape(subGenS,aDirS);
|
||||
Standard_Integer iNewGenS = myGenShapeTool.Index(subGenS);
|
||||
Standard_Integer iNewDirS = iDirS;
|
||||
if (GGDShapeIsToAdd(myShapes(iGenS, iDirS), newShape,
|
||||
if (GGDShapeIsToAdd(myShapes(iGenS,iDirS),newShape,
|
||||
aGenS,subGenS,aDirS)){
|
||||
//Les "planchers" doivent etre construits par les
|
||||
//fonctions de construcion geometrique identiquement
|
||||
@@ -171,7 +165,6 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
|
||||
//sur.
|
||||
|
||||
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
TopAbs_ShapeEnum subGenSType = myGenShapeTool.Type(subGenS);
|
||||
if (aGenSType==TopAbs_FACE){
|
||||
if(subGenSType==TopAbs_VERTEX){
|
||||
@@ -255,9 +248,7 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
|
||||
subGenS = It.Value();
|
||||
if(HasShape(subGenS,aDirS)){
|
||||
newShape = Shape(subGenS,aDirS);
|
||||
Standard_Integer iNewGenS = myGenShapeTool.Index(subGenS);
|
||||
Standard_Integer iNewDirS = iDirS;
|
||||
if (GGDShapeIsToAdd(myShapes(iGenS, iDirS), newShape,
|
||||
if (GGDShapeIsToAdd(myShapes(iGenS,iDirS),newShape,
|
||||
aGenS,subGenS,aDirS)){
|
||||
TopAbs_ShapeEnum subGenSType = myGenShapeTool.Type(subGenS);
|
||||
if (aGenSType==TopAbs_EDGE){
|
||||
@@ -268,13 +259,11 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
|
||||
TopoDS_Shape wi;
|
||||
myBuilder.MakeWire(wi);
|
||||
myBuilder.Add(wi,newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
wi.Closed(BRep_Tool::IsClosed(wi));
|
||||
WireSeq.Append(wi);
|
||||
}
|
||||
else{
|
||||
myBuilder.Add(newWire,newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
}
|
||||
SetDirectingPCurve (myShapes(iGenS,iDirS),
|
||||
newShape,bGenS,subGenS,aDirS,Or);
|
||||
@@ -282,7 +271,6 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
|
||||
else if (aGenSType==TopAbs_WIRE){
|
||||
Or = It.Orientation();
|
||||
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
}
|
||||
else if (aGenSType==TopAbs_FACE){
|
||||
Or = It.Orientation();
|
||||
@@ -294,23 +282,19 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
|
||||
}
|
||||
else if(subGenSType == TopAbs_EDGE) {
|
||||
myBuilder.Add(newShell,newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
}
|
||||
}
|
||||
else if(aGenSType == TopAbs_SHELL){
|
||||
Or = TopAbs_FORWARD;
|
||||
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
}
|
||||
else if(aGenSType == TopAbs_COMPOUND){
|
||||
Or = TopAbs_FORWARD;
|
||||
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
}
|
||||
else{
|
||||
Or = It.Orientation();
|
||||
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,28 +304,23 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
|
||||
subDirS = Kt.Value();
|
||||
if(HasShape(aGenS,subDirS)){
|
||||
newShape = Shape(aGenS,subDirS);
|
||||
Standard_Integer iNewGenS = iGenS;
|
||||
Standard_Integer iNewDirS = myDirShapeTool.Index(subDirS);
|
||||
if (GDDShapeIsToAdd(myShapes(iGenS,iDirS),newShape,
|
||||
aGenS,aDirS,subDirS)){
|
||||
if (aGenSType==TopAbs_EDGE){
|
||||
Or = TopAbs::Reverse(Kt.Orientation());
|
||||
myBuilder.Add(newWire,newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
SetGeneratingPCurve
|
||||
(myShapes(iGenS,iDirS),newShape,aGenS,aDirS,subDirS,Or);
|
||||
}
|
||||
else if(aGenSType==TopAbs_VERTEX){
|
||||
Or = Kt.Orientation();
|
||||
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
SetDirectingParameter
|
||||
(myShapes(iGenS,iDirS),newShape,aGenS,aDirS,subDirS);
|
||||
}
|
||||
else if(aGenSType==TopAbs_FACE){
|
||||
Or = Kt.Orientation();
|
||||
myBuilder.Add(newShell,newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -411,12 +390,9 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::Shape (const TopoDS_Shape& aGenS,
|
||||
for (Kt.Init(aDirS);Kt.More();Kt.Next()){
|
||||
subDirS = Kt.Value();
|
||||
if(HasShape(aGenS,subDirS)){
|
||||
Standard_Integer iNewGenS = iGenS;
|
||||
Standard_Integer iNewDirS = myDirShapeTool.Index(subDirS);
|
||||
Or = Kt.Orientation();
|
||||
newShape = Shape(aGenS,subDirS);
|
||||
myBuilder.Add(myShapes(iGenS,iDirS),newShape,Or);
|
||||
myUsedShapes(iNewGenS, iNewDirS) = Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,67 +492,3 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::SplitShell(const TopoDS_Shape& aNe
|
||||
return comp;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsUsed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepSweep_NumLinearRegularSweep::IsUsed(const TopoDS_Shape& aGenS) const
|
||||
{
|
||||
Standard_Integer iGenS = myGenShapeTool.Index(aGenS);
|
||||
Standard_OutOfRange_Raise_if(iGenS == 0,
|
||||
"BRepSweep_NumLinearRegularSweep::IsUsed: shape index = 0")
|
||||
Standard_Integer j;
|
||||
Standard_Boolean isBuilt = Standard_False;
|
||||
Standard_Boolean isUsed = Standard_False;
|
||||
for (j = 2; j <= myBuiltShapes.UpperCol(); ++j)
|
||||
{
|
||||
isBuilt = isBuilt || myBuiltShapes(iGenS, j);
|
||||
isUsed = isUsed || myUsedShapes(iGenS, j);
|
||||
}
|
||||
if (isUsed)
|
||||
{
|
||||
if (aGenS.ShapeType() == TopAbs_VERTEX && IsInvariant(aGenS))
|
||||
{
|
||||
if (myUsedShapes(iGenS, 1) || !Closed())
|
||||
{
|
||||
return isUsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return isUsed;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (isBuilt) //&& !IsUsed
|
||||
{
|
||||
if (!HasShape(aGenS, myDirWire) && !Closed())
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
else if (aGenS.ShapeType() == TopAbs_VERTEX && !Closed())
|
||||
{
|
||||
if (!myBuiltShapes(iGenS, 1))
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isUsed;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GenIsUsed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepSweep_NumLinearRegularSweep::GenIsUsed(const TopoDS_Shape& aGenS) const
|
||||
{
|
||||
Standard_Integer iGenS = myGenShapeTool.Index(aGenS);
|
||||
Standard_OutOfRange_Raise_if(iGenS == 0,
|
||||
"BRepSweep_NumLinearRegularSweep::GenIsUsed: shape index = 0")
|
||||
return myBuiltShapes(iGenS, 1) && myUsedShapes(iGenS, 1);
|
||||
}
|
||||
|
@@ -171,10 +171,7 @@ public:
|
||||
//! can be geometrically inexsistant, then this
|
||||
//! function returns false.
|
||||
Standard_EXPORT virtual Standard_Boolean HasShape (const TopoDS_Shape& aGenS, const Sweep_NumShape& aDirS) const = 0;
|
||||
|
||||
//! Returns true if aGenS cannot be transformed.
|
||||
Standard_EXPORT virtual Standard_Boolean IsInvariant(const TopoDS_Shape& aGenS) const = 0;
|
||||
|
||||
|
||||
//! Returns the resulting Shape indexed by aDirS and
|
||||
//! aGenS.
|
||||
Standard_EXPORT TopoDS_Shape Shape (const TopoDS_Shape& aGenS, const Sweep_NumShape& aDirS);
|
||||
@@ -182,15 +179,7 @@ public:
|
||||
//! Returns the resulting Shape indexed by myDirWire
|
||||
//! and aGenS.
|
||||
Standard_EXPORT TopoDS_Shape Shape (const TopoDS_Shape& aGenS);
|
||||
|
||||
//! Returns true if the initial shape aGenS
|
||||
//! is used in result shape
|
||||
Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const;
|
||||
|
||||
//! Returns true if the shape, generated from theS
|
||||
//! is used in result shape
|
||||
Standard_EXPORT Standard_Boolean GenIsUsed(const TopoDS_Shape& theS) const;
|
||||
|
||||
|
||||
//! Returns the resulting Shape indexed by myDirWire
|
||||
//! and myGenShape.
|
||||
Standard_EXPORT TopoDS_Shape Shape();
|
||||
@@ -231,7 +220,6 @@ protected:
|
||||
Sweep_NumShapeTool myDirShapeTool;
|
||||
TopTools_Array2OfShape myShapes;
|
||||
TColStd_Array2OfBoolean myBuiltShapes;
|
||||
TColStd_Array2OfBoolean myUsedShapes;
|
||||
|
||||
|
||||
private:
|
||||
|
@@ -185,21 +185,3 @@ TopLoc_Location BRepSweep_Prism::Location(const gp_Vec& V)const
|
||||
TopLoc_Location L(gpt);
|
||||
return L;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsUsed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepSweep_Prism::IsUsed(const TopoDS_Shape& aGenS) const
|
||||
{
|
||||
return myTranslation.IsUsed(aGenS);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GenIsUsed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepSweep_Prism::GenIsUsed(const TopoDS_Shape& aGenS) const
|
||||
{
|
||||
return myTranslation.GenIsUsed(aGenS);
|
||||
}
|
||||
|
@@ -80,13 +80,7 @@ public:
|
||||
Standard_EXPORT gp_Vec Vec() const;
|
||||
|
||||
|
||||
//! Returns true if the
|
||||
//! aGenS is used in resulting shape
|
||||
Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const;
|
||||
|
||||
//! Returns true if the shape, generated from theS
|
||||
//! is used in result shape
|
||||
Standard_EXPORT Standard_Boolean GenIsUsed(const TopoDS_Shape& theS) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -215,11 +215,3 @@ gp_Ax1 BRepSweep_Revol::Axe()const
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsUsed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepSweep_Revol::IsUsed(const TopoDS_Shape& aGenS) const
|
||||
{
|
||||
return myRotation.IsUsed(aGenS);
|
||||
}
|
||||
|
@@ -77,10 +77,6 @@ public:
|
||||
//! returns the angle.
|
||||
Standard_EXPORT Standard_Real Angle() const;
|
||||
|
||||
//! Returns true if the aGenS is used in resulting Shape
|
||||
Standard_EXPORT Standard_Boolean IsUsed(const TopoDS_Shape& aGenS) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//! builds the NumShape.
|
||||
|
@@ -160,7 +160,7 @@ TopoDS_Shape BRepSweep_Rotation::MakeEmptyVertex
|
||||
{
|
||||
//call only in construction mode with copy.
|
||||
Standard_ConstructionError_Raise_if
|
||||
(!myCopy,"BRepSweep_Rotation::MakeEmptyVertex");
|
||||
(!myCopy,"BRepSweep_Translation::MakeEmptyVertex");
|
||||
gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV));
|
||||
TopoDS_Vertex V;
|
||||
if (aDirV.Index()==2) P.Transform(myLocation.Transformation());
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -254,9 +254,9 @@ public:
|
||||
//! Returns square diagonal of this box
|
||||
Standard_Real SquareExtent() const
|
||||
{
|
||||
return 4.0 * (myHDims[0] * myHDims[0] +
|
||||
myHDims[1] * myHDims[1] +
|
||||
myHDims[2] * myHDims[2]);
|
||||
return (4.0*myHDims[0] * myHDims[0] +
|
||||
myHDims[1] * myHDims[1] +
|
||||
myHDims[1] * myHDims[1]);
|
||||
}
|
||||
|
||||
//! Check if the box do not interfere the other box.
|
||||
|
@@ -636,7 +636,7 @@ static Standard_Integer DPrsStd_AISMode(Draw_Interpretor& di,
|
||||
|
||||
//=======================================================================
|
||||
//function : DPrsStd_AISSelMode
|
||||
//purpose : AISSelMode (DOC,entry,[SelMode1 SelMode2 ...])
|
||||
//purpose : AISSelMode (DOC,entry,[SelMode])
|
||||
//=======================================================================
|
||||
static Standard_Integer DPrsStd_AISSelMode(Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
@@ -645,7 +645,7 @@ static Standard_Integer DPrsStd_AISSelMode(Draw_Interpretor& di,
|
||||
TDF_Label L;
|
||||
Handle(TDocStd_Document) D;
|
||||
Handle(TPrsStd_AISPresentation) prs;
|
||||
if (nb >= 3)
|
||||
if (nb >= 3 && nb <= 4)
|
||||
{
|
||||
if (!DDocStd::GetDocument(arg[1],D))
|
||||
return 1;
|
||||
@@ -653,38 +653,18 @@ static Standard_Integer DPrsStd_AISSelMode(Draw_Interpretor& di,
|
||||
return 1;
|
||||
if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs))
|
||||
return 1;
|
||||
if (nb >= 4)
|
||||
if (nb == 4)
|
||||
{
|
||||
// Set selection mode.
|
||||
Standard_Integer selMode = Draw::Atoi(arg[3]);
|
||||
prs->SetSelectionMode(selMode);
|
||||
// Add other selection modes.
|
||||
for (Standard_Integer i = 4; i < nb; i++)
|
||||
{
|
||||
selMode = Draw::Atoi(arg[i]);
|
||||
prs->AddSelectionMode(selMode);
|
||||
}
|
||||
TPrsStd_AISViewer::Update(L);
|
||||
}
|
||||
else if (nb == 3)
|
||||
{
|
||||
// Print selection mode.
|
||||
Standard_Integer nbSelModes = prs->GetNbSelectionModes();
|
||||
if (nbSelModes == 1)
|
||||
{
|
||||
Standard_Integer selMode = prs->SelectionMode();
|
||||
di << selMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer i = 1; i <= nbSelModes; i++)
|
||||
{
|
||||
Standard_Integer selMode = prs->SelectionMode(i);
|
||||
di << selMode;
|
||||
if (i < nbSelModes)
|
||||
di << " ";
|
||||
}
|
||||
}
|
||||
Standard_Integer selMode = prs->SelectionMode();
|
||||
di<<selMode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -776,6 +756,6 @@ void DPrsStd::AISPresentationCommands (Draw_Interpretor& theCommands)
|
||||
__FILE__, DPrsStd_AISMode, g);
|
||||
|
||||
theCommands.Add ("AISSelMode",
|
||||
"AISSelMode (DOC, entry, [SelMode1 SelMode2 ...])",
|
||||
"AISSelMode (DOC, entry, [SelMode])",
|
||||
__FILE__, DPrsStd_AISSelMode, g);
|
||||
}
|
||||
|
@@ -156,6 +156,9 @@ int GetCommand (HWND hWnd, wchar_t* theBuffer)
|
||||
return aNbChar;
|
||||
}
|
||||
|
||||
extern console_semaphore_value volatile console_semaphore;
|
||||
extern wchar_t console_command[1000];
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| EDIT WINDOW PROCEDURE
|
||||
\*--------------------------------------------------------*/
|
||||
@@ -188,7 +191,7 @@ LRESULT APIENTRY EditProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
|
||||
//TCollection_AsciiString aCmdUtf8 (aCmdBuffer + sizeof(THE_PROMPT) / sizeof(wchar_t) - 1);
|
||||
//Draw_Interprete (aCmdUtf8.ToCString());
|
||||
//if (toExit) { DestroyProc (hWnd); }
|
||||
wcscpy_s (console_command, aCmdBuffer + sizeof(THE_PROMPT) / sizeof(wchar_t) - 1);
|
||||
wcscpy (console_command, aCmdBuffer + sizeof(THE_PROMPT) / sizeof(wchar_t) - 1);
|
||||
console_semaphore = HAS_CONSOLE_COMMAND;
|
||||
// Purge the buffer
|
||||
nbline = SendMessageW (hWnd, EM_GETLINECOUNT, 0l, 0l);
|
||||
|
@@ -66,6 +66,8 @@ filebuf Draw_Spyfile;
|
||||
|
||||
static ostream spystream(&Draw_Spyfile);
|
||||
|
||||
static Standard_Boolean XLoop;
|
||||
|
||||
static Handle(Draw_ProgressIndicator) PInd = NULL;
|
||||
|
||||
Standard_EXPORT Standard_Boolean Draw_Interprete(const char* command);
|
||||
@@ -74,20 +76,23 @@ Standard_EXPORT Standard_Boolean Draw_Interprete(const char* command);
|
||||
// *******************************************************************
|
||||
// read an init file
|
||||
// *******************************************************************
|
||||
#ifdef _WIN32
|
||||
extern console_semaphore_value volatile console_semaphore;
|
||||
extern wchar_t console_command[1000];
|
||||
#endif
|
||||
|
||||
static void ReadInitFile (const TCollection_AsciiString& theFileName)
|
||||
{
|
||||
TCollection_AsciiString aPath = theFileName;
|
||||
#ifdef _WIN32
|
||||
aPath.ChangeAll('\\', '/');
|
||||
if (!Draw_Batch)
|
||||
{
|
||||
try
|
||||
{
|
||||
aPath.ChangeAll ('\\', '/');
|
||||
{
|
||||
TCollection_ExtendedString aCmdWide ("source -encoding utf-8 \"");
|
||||
aCmdWide += TCollection_ExtendedString (aPath) + "\"";
|
||||
wcscpy_s (console_command, aCmdWide.ToWideString());
|
||||
const TCollection_ExtendedString aCmdWide = TCollection_ExtendedString ("source -encoding utf-8 \"") + TCollection_ExtendedString (aPath) + "\"";
|
||||
memcpy (console_command, aCmdWide.ToWideString(), Min (aCmdWide.Length() + 1, 980) * sizeof(wchar_t));
|
||||
}
|
||||
console_semaphore = HAS_CONSOLE_COMMAND;
|
||||
while (console_semaphore == HAS_CONSOLE_COMMAND)
|
||||
@@ -281,13 +286,10 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
|
||||
Draw_Batch=!Init_Appli();
|
||||
#endif
|
||||
else
|
||||
{
|
||||
cout << "DRAW is running in batch mode" << endl;
|
||||
theCommands.Init();
|
||||
Tcl_Init(theCommands.Interp());
|
||||
}
|
||||
|
||||
if (! Draw_Batch)
|
||||
XLoop = !Draw_Batch;
|
||||
if (XLoop)
|
||||
{
|
||||
// Default colors
|
||||
for (int i = 0; i < MAXCOLOR; ++i)
|
||||
@@ -362,21 +364,8 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
|
||||
}
|
||||
|
||||
// execute command from command line
|
||||
if (!aCommand.IsEmpty())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!Draw_Batch)
|
||||
{
|
||||
// on Windows except batch mode, commands are executed in separate thread
|
||||
while (console_semaphore == HAS_CONSOLE_COMMAND) Sleep(10);
|
||||
TCollection_ExtendedString aCmdWide(aCommand);
|
||||
wcscpy_s(console_command, aCmdWide.ToWideString());
|
||||
console_semaphore = HAS_CONSOLE_COMMAND;
|
||||
while (console_semaphore == HAS_CONSOLE_COMMAND) Sleep(10);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
Draw_Interprete (aCommand.ToCString()); // Linux and Windows batch mode
|
||||
if (!aCommand.IsEmpty()) {
|
||||
Draw_Interprete (aCommand.ToCString());
|
||||
// provide a clean exit, this is useful for some analysis tools
|
||||
if ( ! isInteractiveForced )
|
||||
#ifndef _WIN32
|
||||
@@ -389,7 +378,7 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
|
||||
// *****************************************************************
|
||||
// X loop
|
||||
// *****************************************************************
|
||||
if (! Draw_Batch) {
|
||||
if (XLoop) {
|
||||
#ifdef _WIN32
|
||||
Run_Appli(hWnd);
|
||||
#else
|
||||
@@ -398,15 +387,15 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
|
||||
}
|
||||
else
|
||||
{
|
||||
const int MAXCMD = 2048;
|
||||
char cmd[MAXCMD];
|
||||
for (int ncmd = 1;; ++ncmd)
|
||||
char cmd[255];
|
||||
for (;;)
|
||||
{
|
||||
cout << "Draw[" << ncmd << "]> ";
|
||||
if (cin.getline (cmd, MAXCMD).fail())
|
||||
{
|
||||
break;
|
||||
}
|
||||
cout << "Viewer>";
|
||||
int i = -1;
|
||||
do {
|
||||
cin.get(cmd[++i]);
|
||||
} while ((cmd[i] != '\n') && (!cin.fail()));
|
||||
cmd[i] = '\0';
|
||||
Draw_Interprete(cmd);
|
||||
}
|
||||
}
|
||||
|
@@ -270,7 +270,10 @@ void Draw_Interpretor::add (const Standard_CString theCommandName,
|
||||
Draw_Interpretor::CallBackData* theCallback,
|
||||
const Standard_CString theGroup)
|
||||
{
|
||||
Standard_ASSERT_RAISE (myInterp != NULL, "Attempt to add command to Null interpretor");
|
||||
if (myInterp == NULL)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
Standard_PCharacter aName = (Standard_PCharacter )theCommandName;
|
||||
Standard_PCharacter aHelp = (Standard_PCharacter )theHelp;
|
||||
|
@@ -30,8 +30,8 @@
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <NCollection_List.hxx>
|
||||
|
||||
extern Standard_Boolean Draw_Batch;
|
||||
extern Standard_Boolean Draw_VirtualWindows;
|
||||
static Tcl_Interp *interp; /* Interpreter for this application. */
|
||||
static NCollection_List<Draw_Window::FCallbackBeforeTerminate> MyCallbacks;
|
||||
|
||||
void Draw_Window::AddCallbackBeforeTerminate(FCallbackBeforeTerminate theCB)
|
||||
@@ -1109,9 +1109,9 @@ Standard_Boolean Init_Appli()
|
||||
{
|
||||
Draw_Interpretor& aCommands = Draw::GetInterpretor();
|
||||
aCommands.Init();
|
||||
Tcl_Interp *interp = aCommands.Interp();
|
||||
Tcl_Init (interp);
|
||||
interp = aCommands.Interp();
|
||||
|
||||
Tcl_Init(interp) ;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
Tk_Init(interp) ;
|
||||
@@ -1301,7 +1301,7 @@ static void StdinProc(ClientData clientData, int )
|
||||
*/
|
||||
|
||||
prompt:
|
||||
if (tty) Prompt(Draw::GetInterpretor().Interp(), gotPartial);
|
||||
if (tty) Prompt(interp, gotPartial);
|
||||
|
||||
} catch (Standard_Failure) {}
|
||||
|
||||
@@ -2021,7 +2021,8 @@ static Tk_Window mainWindow;
|
||||
//* threads sinchronization *//
|
||||
DWORD dwMainThreadId;
|
||||
console_semaphore_value volatile console_semaphore = WAIT_CONSOLE_COMMAND;
|
||||
wchar_t console_command[DRAW_COMMAND_SIZE + 1];
|
||||
#define THE_COMMAND_SIZE 1000 /* Console Command size */
|
||||
wchar_t console_command[THE_COMMAND_SIZE];
|
||||
bool volatile isTkLoopStarted = false;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
@@ -2030,9 +2031,14 @@ bool volatile isTkLoopStarted = false;
|
||||
Standard_Boolean Init_Appli(HINSTANCE hInst,
|
||||
HINSTANCE hPrevInst, int nShow, HWND& hWndFrame )
|
||||
{
|
||||
Draw_Interpretor& aCommands = Draw::GetInterpretor();
|
||||
|
||||
DWORD IDThread;
|
||||
HANDLE hThread;
|
||||
console_semaphore = STOP_CONSOLE;
|
||||
aCommands.Init();
|
||||
interp = aCommands.Interp();
|
||||
Tcl_Init(interp) ;
|
||||
|
||||
dwMainThreadId = GetCurrentThreadId();
|
||||
|
||||
@@ -2044,18 +2050,13 @@ Standard_Boolean Init_Appli(HINSTANCE hInst,
|
||||
0, // use default creation flags
|
||||
&IDThread);
|
||||
if (!hThread) {
|
||||
cout << "Failed to create Tcl/Tk main loop thread. Switching to batch mode..." << endl;
|
||||
Draw_Batch = Standard_True;
|
||||
Draw_Interpretor& aCommands = Draw::GetInterpretor();
|
||||
aCommands.Init();
|
||||
Tcl_Interp *interp = aCommands.Interp();
|
||||
Tcl_Init(interp);
|
||||
cout << "Tcl/Tk main loop thread not created. Switching to batch mode..." << endl;
|
||||
#ifdef _TK
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
Tk_Init(interp);
|
||||
} catch (Standard_Failure& anExcept) {
|
||||
cout << "Failed to initialize Tk: " << anExcept.GetMessageString() << endl;
|
||||
Tk_Init(interp) ;
|
||||
} catch (Standard_Failure) {
|
||||
cout <<" Pb au lancement de TK_Init "<<endl;
|
||||
}
|
||||
|
||||
Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
|
||||
@@ -2124,7 +2125,7 @@ static DWORD WINAPI readStdinThreadFunc()
|
||||
&& isConsoleInput)
|
||||
{
|
||||
DWORD aNbRead = 0;
|
||||
if (ReadConsoleW (anStdIn, console_command, DRAW_COMMAND_SIZE, &aNbRead, NULL))
|
||||
if (ReadConsoleW (anStdIn, console_command, THE_COMMAND_SIZE, &aNbRead, NULL))
|
||||
{
|
||||
console_command[aNbRead] = L'\0';
|
||||
console_semaphore = HAS_CONSOLE_COMMAND;
|
||||
@@ -2144,7 +2145,7 @@ static DWORD WINAPI readStdinThreadFunc()
|
||||
}
|
||||
|
||||
// fgetws() works only for characters within active locale (see setlocale())
|
||||
if (fgetws (console_command, DRAW_COMMAND_SIZE, stdin))
|
||||
if (fgetws (console_command, THE_COMMAND_SIZE, stdin))
|
||||
{
|
||||
console_semaphore = HAS_CONSOLE_COMMAND;
|
||||
}
|
||||
@@ -2260,11 +2261,6 @@ static DWORD WINAPI tkLoop(VOID)
|
||||
{
|
||||
Tcl_CreateExitHandler(exitProc, 0);
|
||||
|
||||
Draw_Interpretor& aCommands = Draw::GetInterpretor();
|
||||
aCommands.Init();
|
||||
Tcl_Interp *interp = aCommands.Interp();
|
||||
Tcl_Init(interp);
|
||||
|
||||
// Work-around against issue with Tcl standard channels on Windows.
|
||||
// These channels by default use OS handles owned by the system which
|
||||
// may get invalidated e.g. by dup2() (see dlog command).
|
||||
@@ -2282,6 +2278,8 @@ static DWORD WINAPI tkLoop(VOID)
|
||||
// ActiveState Tcl (at least 8.6.4) does not seem to do that, so channels
|
||||
// need to be set into interpretor explicitly
|
||||
{
|
||||
Draw_Interpretor& aCommands = Draw::GetInterpretor();
|
||||
|
||||
Tcl_Channel aChannelIn = Tcl_GetStdChannel (TCL_STDIN);
|
||||
Tcl_Channel aChannelOut = Tcl_GetStdChannel (TCL_STDOUT);
|
||||
Tcl_Channel aChannelErr = Tcl_GetStdChannel (TCL_STDERR);
|
||||
@@ -2375,7 +2373,7 @@ static DWORD WINAPI tkLoop(VOID)
|
||||
}
|
||||
#ifdef _TK
|
||||
// We should not exit until the Main Tk window is closed
|
||||
toLoop = (Draw_VirtualWindows || Tk_GetNumMainWindows() > 0);
|
||||
toLoop = (Tk_GetNumMainWindows() > 0) || Draw_VirtualWindows;
|
||||
#endif
|
||||
}
|
||||
Tcl_Exit(0);
|
||||
|
@@ -516,13 +516,6 @@ typedef enum {
|
||||
WAIT_CONSOLE_COMMAND,
|
||||
HAS_CONSOLE_COMMAND} console_semaphore_value;
|
||||
|
||||
// global variable describing console state
|
||||
extern console_semaphore_value volatile console_semaphore;
|
||||
|
||||
// Console command buffer
|
||||
#define DRAW_COMMAND_SIZE 1000
|
||||
extern wchar_t console_command[DRAW_COMMAND_SIZE + 1];
|
||||
|
||||
// PROCEDURE DE DRAW WINDOW
|
||||
|
||||
Standard_EXPORT Standard_Boolean Init_Appli(HINSTANCE,HINSTANCE,int,HWND&);
|
||||
|
@@ -117,12 +117,11 @@ bool Font_FTFont::Init (const NCollection_String& theFontName,
|
||||
const unsigned int theResolution)
|
||||
{
|
||||
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
|
||||
const TCollection_AsciiString aFontName (theFontName.ToCString());
|
||||
Font_FontAspect aFontAspect = theFontAspect;
|
||||
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, aFontAspect))
|
||||
const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theFontName.ToCString());
|
||||
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, theFontAspect, thePointSize))
|
||||
{
|
||||
myIsSingleLine = aRequestedFont->IsSingleStrokeFont();
|
||||
return Font_FTFont::Init (aRequestedFont->FontPathAny (aFontAspect).ToCString(), thePointSize, theResolution);
|
||||
return Font_FTFont::Init (aRequestedFont->FontPath()->ToCString(), thePointSize, theResolution);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -18,19 +18,11 @@
|
||||
//! Specifies aspect of system font.
|
||||
enum Font_FontAspect
|
||||
{
|
||||
Font_FontAspect_UNDEFINED = -1, //!< special value reserved for undefined aspect
|
||||
Font_FontAspect_Regular = 0, //!< normal (regular) aspect
|
||||
Font_FontAspect_Bold, //!< bold aspect
|
||||
Font_FontAspect_Italic, //!< italic aspect
|
||||
Font_FontAspect_BoldItalic, //!< bold+italic aspect
|
||||
|
||||
// old aliases
|
||||
Font_FA_Undefined = Font_FontAspect_UNDEFINED,
|
||||
Font_FA_Regular = Font_FontAspect_Regular,
|
||||
Font_FA_Bold = Font_FontAspect_Bold,
|
||||
Font_FA_Italic = Font_FontAspect_Italic,
|
||||
Font_FA_BoldItalic = Font_FontAspect_BoldItalic
|
||||
Font_FA_Undefined,
|
||||
Font_FA_Regular,
|
||||
Font_FA_Bold,
|
||||
Font_FA_Italic,
|
||||
Font_FA_BoldItalic
|
||||
};
|
||||
enum { Font_FontAspect_NB = Font_FontAspect_BoldItalic + 1 };
|
||||
|
||||
#endif // _Font_FontAspect_HeaderFile
|
||||
|
@@ -13,13 +13,10 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Font_FontMgr.hxx>
|
||||
|
||||
#include <Font_NameOfFont.hxx>
|
||||
#include <Font_FontMgr.hxx>
|
||||
#include <Font_FTLibrary.hxx>
|
||||
#include <Font_SystemFont.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <NCollection_List.hxx>
|
||||
#include <NCollection_Map.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
@@ -31,6 +28,58 @@
|
||||
#include FT_FREETYPE_H
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient)
|
||||
|
||||
struct Font_FontMgr_FontAliasMapNode
|
||||
{
|
||||
const char * EnumName;
|
||||
const char * FontName;
|
||||
Font_FontAspect FontAspect;
|
||||
};
|
||||
|
||||
static const Font_FontMgr_FontAliasMapNode Font_FontMgr_MapOfFontsAliases[] =
|
||||
{
|
||||
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
|
||||
{ "Courier" , "Courier New" , Font_FA_Regular },
|
||||
{ "Times-Roman" , "Times New Roman", Font_FA_Regular },
|
||||
{ "Times-Bold" , "Times New Roman", Font_FA_Bold },
|
||||
{ "Times-Italic" , "Times New Roman", Font_FA_Italic },
|
||||
{ "Times-BoldItalic" , "Times New Roman", Font_FA_BoldItalic },
|
||||
{ "ZapfChancery-MediumItalic", "Script" , Font_FA_Regular },
|
||||
{ "Symbol" , "Symbol" , Font_FA_Regular },
|
||||
{ "ZapfDingbats" , "WingDings" , Font_FA_Regular },
|
||||
{ "Rock" , "Arial" , Font_FA_Regular },
|
||||
{ "Iris" , "Lucida Console" , Font_FA_Regular },
|
||||
{ "NSimSun" , "SimSun" , Font_FA_Regular }
|
||||
|
||||
#elif defined(__ANDROID__)
|
||||
|
||||
{ "Courier" , "Droid Sans Mono", Font_FA_Regular },
|
||||
{ "Times-Roman" , "Droid Serif" , Font_FA_Regular },
|
||||
{ "Times-Bold" , "Droid Serif" , Font_FA_Bold },
|
||||
{ "Times-Italic" , "Droid Serif" , Font_FA_Italic },
|
||||
{ "Times-BoldItalic" , "Droid Serif" , Font_FA_BoldItalic },
|
||||
{ "Arial" , "Roboto" , Font_FA_Regular },
|
||||
|
||||
#else //X11
|
||||
|
||||
{ "Courier" , "Courier" , Font_FA_Regular },
|
||||
{ "Times-Roman" , "Times" , Font_FA_Regular },
|
||||
{ "Times-Bold" , "Times" , Font_FA_Bold },
|
||||
{ "Times-Italic" , "Times" , Font_FA_Italic },
|
||||
{ "Times-BoldItalic" , "Times" , Font_FA_BoldItalic },
|
||||
{ "Arial" , "Helvetica" , Font_FA_Regular },
|
||||
{ "ZapfChancery-MediumItalic", "-adobe-itc zapf chancery-medium-i-normal--*-*-*-*-*-*-iso8859-1" , Font_FA_Regular },
|
||||
{ "Symbol" , "-adobe-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific" , Font_FA_Regular },
|
||||
{ "ZapfDingbats" , "-adobe-itc zapf dingbats-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific" , Font_FA_Regular },
|
||||
{ "Rock" , "-sgi-rock-medium-r-normal--*-*-*-*-p-*-iso8859-1" , Font_FA_Regular },
|
||||
{ "Iris" , "--iris-medium-r-normal--*-*-*-*-m-*-iso8859-1" , Font_FA_Regular }
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#define NUM_FONT_ENTRIES (int)(sizeof(Font_FontMgr_MapOfFontsAliases)/sizeof(Font_FontMgr_FontAliasMapNode))
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include <windows.h>
|
||||
@@ -167,10 +216,11 @@ static Handle(Font_SystemFont) checkFont (const Handle(Font_FTLibrary)& theFTLib
|
||||
if (aFontFace->family_name != NULL // skip broken fonts (error in FreeType?)
|
||||
&& FT_Select_Charmap (aFontFace, ft_encoding_unicode) == 0) // Font_FTFont supports only UNICODE fonts
|
||||
{
|
||||
aResult = new Font_SystemFont (aFontFace->family_name);
|
||||
aResult->SetFontPath (anAspect, theFontPath);
|
||||
Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (aFontFace->family_name);
|
||||
Handle(TCollection_HAsciiString) aFontPath = new TCollection_HAsciiString (theFontPath);
|
||||
aResult = new Font_SystemFont (aFontName, anAspect, aFontPath);
|
||||
// automatically identify some known single-line fonts
|
||||
aResult->SetSingleStrokeFont (aResult->FontKey().StartsWith ("olf "));
|
||||
aResult->SetSingleStrokeFont (aFontName->String().StartsWith ("OLF "));
|
||||
}
|
||||
|
||||
FT_Done_Face (aFontFace);
|
||||
@@ -193,126 +243,12 @@ Handle(Font_FontMgr) Font_FontMgr::GetInstance()
|
||||
return _mgr;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : addFontAlias
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Font_FontMgr::addFontAlias (const TCollection_AsciiString& theAliasName,
|
||||
const Handle(Font_FontAliasSequence)& theAliases,
|
||||
Font_FontAspect theAspect)
|
||||
{
|
||||
if (theAliases.IsNull()
|
||||
|| theAliases->IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Font_FontAliasSequence) anAliases = theAliases;
|
||||
if (theAspect != Font_FA_Undefined)
|
||||
{
|
||||
anAliases = new Font_FontAliasSequence();
|
||||
for (Font_FontAliasSequence::Iterator anAliasIter (*theAliases); anAliasIter.More(); anAliasIter.Next())
|
||||
{
|
||||
const TCollection_AsciiString& aName = anAliasIter.Value().FontName;
|
||||
anAliases->Append (Font_FontAlias (aName, theAspect));
|
||||
}
|
||||
}
|
||||
|
||||
TCollection_AsciiString anAliasName (theAliasName);
|
||||
anAliasName.LowerCase();
|
||||
myFontAliases.Bind (anAliasName, anAliases);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Font_FontMgr
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Font_FontMgr::Font_FontMgr()
|
||||
: myToTraceAliases (Standard_False)
|
||||
{
|
||||
Handle(Font_FontAliasSequence) aMono = new Font_FontAliasSequence();
|
||||
Handle(Font_FontAliasSequence) aSerif = new Font_FontAliasSequence();
|
||||
Handle(Font_FontAliasSequence) aSans = new Font_FontAliasSequence();
|
||||
Handle(Font_FontAliasSequence) aSymbol = new Font_FontAliasSequence();
|
||||
Handle(Font_FontAliasSequence) aScript = new Font_FontAliasSequence();
|
||||
Handle(Font_FontAliasSequence) aWinDin = new Font_FontAliasSequence();
|
||||
Handle(Font_FontAliasSequence) anIris = new Font_FontAliasSequence();
|
||||
Handle(Font_FontAliasSequence) aCJK = new Font_FontAliasSequence();
|
||||
Handle(Font_FontAliasSequence) aKorean = new Font_FontAliasSequence();
|
||||
|
||||
// best matches - pre-installed on Windows, some of them are pre-installed on macOS,
|
||||
// and sometimes them can be found installed on other systems (by user)
|
||||
aMono ->Append (Font_FontAlias ("courier new"));
|
||||
aSerif ->Append (Font_FontAlias ("times new roman"));
|
||||
aSans ->Append (Font_FontAlias ("arial"));
|
||||
aSymbol->Append (Font_FontAlias ("symbol"));
|
||||
aScript->Append (Font_FontAlias ("script"));
|
||||
aWinDin->Append (Font_FontAlias ("wingdings"));
|
||||
anIris ->Append (Font_FontAlias ("lucida console"));
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
// Noto font family is usually installed on Android 6+ devices
|
||||
aMono ->Append (Font_FontAlias ("noto mono"));
|
||||
aSerif ->Append (Font_FontAlias ("noto serif"));
|
||||
// Droid font family is usually installed on Android 4+ devices
|
||||
aMono ->Append (Font_FontAlias ("droid sans mono"));
|
||||
aSerif ->Append (Font_FontAlias ("droid serif"));
|
||||
aSans ->Append (Font_FontAlias ("roboto")); // actually DroidSans.ttf
|
||||
#elif !defined(_WIN32) && !defined(__APPLE__) //X11
|
||||
aSerif ->Append (Font_FontAlias ("times"));
|
||||
aSans ->Append (Font_FontAlias ("helvetica"));
|
||||
// GNU FreeFonts family is usually installed on Linux
|
||||
aMono ->Append (Font_FontAlias ("freemono"));
|
||||
aSerif ->Append (Font_FontAlias ("freeserif"));
|
||||
aSans ->Append (Font_FontAlias ("freesans"));
|
||||
// DejaVu font family is usually installed on Linux
|
||||
aMono ->Append (Font_FontAlias ("dejavu sans mono"));
|
||||
aSerif ->Append (Font_FontAlias ("dejavu serif"));
|
||||
aSans ->Append (Font_FontAlias ("dejavu sans"));
|
||||
#endif
|
||||
|
||||
// default CJK (Chinese/Japanese/Korean) fonts
|
||||
aCJK ->Append (Font_FontAlias ("simsun")); // Windows
|
||||
aCJK ->Append (Font_FontAlias ("droid sans fallback")); // Android, Linux
|
||||
aCJK ->Append (Font_FontAlias ("noto sans sc")); // Android
|
||||
|
||||
#if defined(_WIN32)
|
||||
aKorean->Append (Font_FontAlias ("malgun gothic")); // introduced since Vista
|
||||
aKorean->Append (Font_FontAlias ("gulim")); // used on older systems (Windows XP)
|
||||
#elif defined(__APPLE__)
|
||||
aKorean->Append (Font_FontAlias ("applegothic"));
|
||||
aKorean->Append (Font_FontAlias ("stfangsong"));
|
||||
#endif
|
||||
aKorean->Append (Font_FontAlias ("nanumgothic")); // Android, Linux
|
||||
aKorean->Append (Font_FontAlias ("noto sans kr")); // Android
|
||||
aKorean->Append (Font_FontAlias ("nanummyeongjo")); // Linux
|
||||
aKorean->Append (Font_FontAlias ("noto serif cjk jp")); // Linux
|
||||
aKorean->Append (Font_FontAlias ("noto sans cjk jp")); // Linux
|
||||
|
||||
addFontAlias ("mono", aMono);
|
||||
addFontAlias ("courier", aMono); // Font_NOF_ASCII_MONO
|
||||
addFontAlias ("monospace", aMono); // Font_NOF_MONOSPACE
|
||||
addFontAlias ("rock", aSans); // Font_NOF_CARTOGRAPHIC_SIMPLEX
|
||||
addFontAlias ("sansserif", aSans); // Font_NOF_SANS_SERIF
|
||||
addFontAlias ("sans-serif", aSans);
|
||||
addFontAlias ("sans", aSans);
|
||||
addFontAlias ("arial", aSans);
|
||||
addFontAlias ("times", aSerif);
|
||||
addFontAlias ("serif", aSerif); // Font_NOF_SERIF
|
||||
addFontAlias ("times-roman", aSerif); // Font_NOF_ASCII_SIMPLEX
|
||||
addFontAlias ("times-bold", aSerif, Font_FA_Bold); // Font_NOF_ASCII_DUPLEX
|
||||
addFontAlias ("times-italic", aSerif, Font_FA_Italic); // Font_NOF_ASCII_ITALIC_COMPLEX
|
||||
addFontAlias ("times-bolditalic", aSerif, Font_FA_BoldItalic); // Font_NOF_ASCII_ITALIC_TRIPLEX
|
||||
addFontAlias ("symbol", aSymbol); // Font_NOF_GREEK_MONO
|
||||
addFontAlias ("iris", anIris); // Font_NOF_KANJI_MONO
|
||||
addFontAlias ("korean", aKorean); // Font_NOF_KOREAN
|
||||
addFontAlias ("cjk", aCJK); // Font_NOF_CJK
|
||||
addFontAlias ("nsimsun", aCJK);
|
||||
addFontAlias (Font_NOF_SYMBOL_MONO, aWinDin);
|
||||
addFontAlias (Font_NOF_ASCII_SCRIPT_SIMPLEX, aScript);
|
||||
|
||||
myFallbackAlias = aSans;
|
||||
|
||||
InitFontDataBase();
|
||||
}
|
||||
|
||||
@@ -338,30 +274,39 @@ Standard_Boolean Font_FontMgr::RegisterFont (const Handle(Font_SystemFont)& theF
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
const Standard_Integer anOldIndex = myFontMap.FindIndex (theFont);
|
||||
if (anOldIndex == 0)
|
||||
for (Font_NListOfSystemFont::Iterator aFontIter (myListOfFonts);
|
||||
aFontIter.More(); aFontIter.Next())
|
||||
{
|
||||
myFontMap.Add (theFont);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Handle(Font_SystemFont) anOldFont = myFontMap.FindKey (anOldIndex);
|
||||
for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
|
||||
{
|
||||
if (anOldFont->FontPath ((Font_FontAspect )anAspectIter).IsEqual (theFont->FontPath ((Font_FontAspect )anAspectIter)))
|
||||
if (!aFontIter.Value()->FontName()->IsSameString (theFont->FontName(), Standard_False))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (theToOverride
|
||||
|| !anOldFont->HasFontAspect ((Font_FontAspect )anAspectIter))
|
||||
|
||||
if (theFont->FontAspect() != Font_FA_Undefined
|
||||
&& aFontIter.Value()->FontAspect() != theFont->FontAspect())
|
||||
{
|
||||
anOldFont->SetFontPath ((Font_FontAspect )anAspectIter, theFont->FontPath ((Font_FontAspect )anAspectIter));
|
||||
continue;
|
||||
}
|
||||
else if (theFont->HasFontAspect ((Font_FontAspect )anAspectIter))
|
||||
|
||||
if (theFont->FontHeight() == -1 || aFontIter.Value()->FontHeight() == -1
|
||||
|| theFont->FontHeight() == aFontIter.Value()->FontHeight())
|
||||
{
|
||||
return Standard_False;
|
||||
if (theFont->FontPath()->String() == aFontIter.Value()->FontPath()->String())
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
else if (theToOverride)
|
||||
{
|
||||
myListOfFonts.Remove (aFontIter);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myListOfFonts.Append (theFont);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -371,7 +316,7 @@ Standard_Boolean Font_FontMgr::RegisterFont (const Handle(Font_SystemFont)& theF
|
||||
// =======================================================================
|
||||
void Font_FontMgr::InitFontDataBase()
|
||||
{
|
||||
myFontMap.Clear();
|
||||
myListOfFonts.Clear();
|
||||
Handle(Font_FTLibrary) aFtLibrary;
|
||||
|
||||
#if defined(OCCT_UWP)
|
||||
@@ -388,8 +333,8 @@ void Font_FontMgr::InitFontDataBase()
|
||||
|
||||
char* aWinDir = new char[aStrLength];
|
||||
GetSystemWindowsDirectoryA (aWinDir, aStrLength);
|
||||
TCollection_AsciiString aFontsDir (aWinDir);
|
||||
aFontsDir.AssignCat ("\\Fonts\\");
|
||||
Handle(TCollection_HAsciiString) aFontsDir = new TCollection_HAsciiString (aWinDir);
|
||||
aFontsDir->AssignCat ("\\Fonts\\");
|
||||
delete[] aWinDir;
|
||||
|
||||
// read fonts list from registry
|
||||
@@ -421,23 +366,25 @@ void Font_FontMgr::InitFontDataBase()
|
||||
{
|
||||
aPathBuff[(aPathSize < aBufferSize) ? aPathSize : (aBufferSize - 1)] = '\0'; // ensure string is NULL-terminated
|
||||
|
||||
TCollection_AsciiString aFontName (aNameBuff), aFontPath (aPathBuff);
|
||||
if (aFontPath.Search ("\\") == -1)
|
||||
Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (aNameBuff);
|
||||
Handle(TCollection_HAsciiString) aFontPath = new TCollection_HAsciiString (aPathBuff);
|
||||
if (aFontPath->Search ("\\") == -1)
|
||||
{
|
||||
aFontPath.Insert (1, aFontsDir); // make absolute path
|
||||
aFontPath->Insert (1, aFontsDir); // make absolute path
|
||||
}
|
||||
|
||||
// check file extension is in list of supported
|
||||
const Standard_Integer anExtensionPosition = aFontPath.SearchFromEnd (".") + 1;
|
||||
if (anExtensionPosition > 0 && anExtensionPosition < aFontPath.Length())
|
||||
const Standard_Integer anExtensionPosition = aFontPath->SearchFromEnd (".") + 1;
|
||||
if (anExtensionPosition > 0 && anExtensionPosition < aFontPath->Length())
|
||||
{
|
||||
TCollection_AsciiString aFontExtension = aFontPath.SubString (anExtensionPosition, aFontPath.Length());
|
||||
aFontExtension.LowerCase();
|
||||
if (aSupportedExtensions.Contains (aFontExtension))
|
||||
Handle(TCollection_HAsciiString) aFontExtension = aFontPath->SubString (anExtensionPosition, aFontPath->Length());
|
||||
aFontExtension->LowerCase();
|
||||
if (aSupportedExtensions.Contains (aFontExtension->String()))
|
||||
{
|
||||
if (Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontPath.ToCString()))
|
||||
Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontPath->ToCString());
|
||||
if (!aNewFont.IsNull())
|
||||
{
|
||||
RegisterFont (aNewFont, false);
|
||||
myListOfFonts.Append (aNewFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -528,29 +475,28 @@ void Font_FontMgr::InitFontDataBase()
|
||||
for (NCollection_Map<TCollection_AsciiString>::Iterator anIter (aMapOfFontsDirs);
|
||||
anIter.More(); anIter.Next())
|
||||
{
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__)
|
||||
#if defined(__ANDROID__) || defined(__APPLE__)
|
||||
OSD_Path aFolderPath (anIter.Value());
|
||||
for (OSD_FileIterator aFileIter (aFolderPath, "*"); aFileIter.More(); aFileIter.Next())
|
||||
{
|
||||
OSD_Path aFontFilePath;
|
||||
aFileIter.Values().Path (aFontFilePath);
|
||||
|
||||
TCollection_AsciiString aFontFileName;
|
||||
aFontFilePath.SystemName (aFontFileName);
|
||||
aFontFileName = anIter.Value() + "/" + aFontFileName;
|
||||
|
||||
Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontFileName.ToCString());
|
||||
if (!aNewFont.IsNull())
|
||||
{
|
||||
myListOfFonts.Append (aNewFont);
|
||||
}
|
||||
}
|
||||
#else
|
||||
OSD_File aReadFile (anIter.Value() + "/fonts.dir");
|
||||
if (!aReadFile.Exists())
|
||||
{
|
||||
#endif
|
||||
OSD_Path aFolderPath (anIter.Value());
|
||||
for (OSD_FileIterator aFileIter (aFolderPath, "*"); aFileIter.More(); aFileIter.Next())
|
||||
{
|
||||
OSD_Path aFontFilePath;
|
||||
aFileIter.Values().Path (aFontFilePath);
|
||||
|
||||
TCollection_AsciiString aFontFileName;
|
||||
aFontFilePath.SystemName (aFontFileName);
|
||||
aFontFileName = anIter.Value() + "/" + aFontFileName;
|
||||
|
||||
if (Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontFileName.ToCString()))
|
||||
{
|
||||
RegisterFont (aNewFont, false);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__)
|
||||
continue;
|
||||
continue; // invalid fonts directory
|
||||
}
|
||||
|
||||
aReadFile.Open (OSD_ReadOnly, aProtectRead);
|
||||
@@ -593,45 +539,34 @@ void Font_FontMgr::InitFontDataBase()
|
||||
// In current implementation use fonts with ISO-8859-1 coding page.
|
||||
// OCCT not give to manage coding page by means of programm interface.
|
||||
// TODO: make high level interface for choosing necessary coding page.
|
||||
TCollection_AsciiString aXLFD (aLine.SubString (anEndOfFileName + 2, aLine.Length()));
|
||||
TCollection_AsciiString aFontPath (anIter.Value().ToCString());
|
||||
if (aFontPath.SearchFromEnd ("/") != aFontPath.Length())
|
||||
Handle(TCollection_HAsciiString) aXLFD =
|
||||
new TCollection_HAsciiString (aLine.SubString (anEndOfFileName + 2, aLine.Length()));
|
||||
Handle(TCollection_HAsciiString) aFontPath =
|
||||
new TCollection_HAsciiString (anIter.Value().ToCString());
|
||||
if (aFontPath->SearchFromEnd ("/") != aFontPath->Length())
|
||||
{
|
||||
aFontPath.AssignCat ("/");
|
||||
aFontPath->AssignCat ("/");
|
||||
}
|
||||
TCollection_AsciiString aFontFileName (aLine.SubString (1, anEndOfFileName));
|
||||
aFontPath.AssignCat (aFontFileName);
|
||||
if (Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontPath.ToCString()))
|
||||
{
|
||||
RegisterFont (aNewFont, false);
|
||||
if (!aXLFD.IsEmpty()
|
||||
&& aXLFD.Search ("-0-0-0-0-") != -1) // ignore non-resizable fonts
|
||||
{
|
||||
const TCollection_AsciiString anXName = aXLFD.Token ("-", 2);
|
||||
Font_FontAspect anXAspect = Font_FA_Regular;
|
||||
if (aXLFD.Token ("-", 3).IsEqual ("bold")
|
||||
&& (aXLFD.Token ("-", 4).IsEqual ("i")
|
||||
|| aXLFD.Token ("-", 4).IsEqual ("o")))
|
||||
{
|
||||
anXAspect = Font_FA_BoldItalic;
|
||||
}
|
||||
else if (aXLFD.Token ("-", 3).IsEqual ("bold"))
|
||||
{
|
||||
anXAspect = Font_FA_Bold;
|
||||
}
|
||||
else if (aXLFD.Token ("-", 4).IsEqual ("i")
|
||||
|| aXLFD.Token ("-", 4).IsEqual ("o"))
|
||||
{
|
||||
anXAspect = Font_FA_Italic;
|
||||
}
|
||||
Handle(TCollection_HAsciiString) aFontFileName =
|
||||
new TCollection_HAsciiString (aLine.SubString (1, anEndOfFileName));
|
||||
aFontPath->AssignCat (aFontFileName);
|
||||
|
||||
Handle(Font_SystemFont) aNewFontFromXLFD = new Font_SystemFont (anXName);
|
||||
aNewFontFromXLFD->SetFontPath (anXAspect, aFontPath);
|
||||
if (!aNewFont->IsEqual (aNewFontFromXLFD))
|
||||
{
|
||||
RegisterFont (aNewFontFromXLFD, false);
|
||||
}
|
||||
}
|
||||
Handle(Font_SystemFont) aNewFontFromXLFD = new Font_SystemFont (aXLFD, aFontPath);
|
||||
Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontPath->ToCString());
|
||||
|
||||
if (aNewFontFromXLFD->IsValid() && !aNewFont.IsNull() &&
|
||||
!aNewFont->IsEqual (aNewFontFromXLFD))
|
||||
{
|
||||
myListOfFonts.Append (aNewFont);
|
||||
myListOfFonts.Append (aNewFontFromXLFD);
|
||||
}
|
||||
else if (!aNewFont.IsNull())
|
||||
{
|
||||
myListOfFonts.Append (aNewFont);
|
||||
}
|
||||
else if (aNewFontFromXLFD->IsValid())
|
||||
{
|
||||
myListOfFonts.Append (aNewFontFromXLFD);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -641,6 +576,15 @@ void Font_FontMgr::InitFontDataBase()
|
||||
#endif
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetAvailableFonts
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Font_NListOfSystemFont& Font_FontMgr::GetAvailableFonts() const
|
||||
{
|
||||
return myListOfFonts;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetAvailableFontsNames
|
||||
// purpose :
|
||||
@@ -648,11 +592,9 @@ void Font_FontMgr::InitFontDataBase()
|
||||
void Font_FontMgr::GetAvailableFontsNames (TColStd_SequenceOfHAsciiString& theFontsNames) const
|
||||
{
|
||||
theFontsNames.Clear();
|
||||
for (NCollection_IndexedMap<Handle(Font_SystemFont), Font_SystemFont>::Iterator aFontIter (myFontMap);
|
||||
aFontIter.More(); aFontIter.Next())
|
||||
for (Font_NListOfSystemFont::Iterator anIter(myListOfFonts); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(Font_SystemFont)& aFont = aFontIter.Value();
|
||||
theFontsNames.Append (new TCollection_HAsciiString(aFont->FontName()));
|
||||
theFontsNames.Append (anIter.Value()->FontName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,149 +606,101 @@ Handle(Font_SystemFont) Font_FontMgr::GetFont (const Handle(TCollection_HAsciiSt
|
||||
const Font_FontAspect theFontAspect,
|
||||
const Standard_Integer theFontSize) const
|
||||
{
|
||||
if ((theFontSize < 2 && theFontSize != -1) || theFontName.IsNull())
|
||||
if ( (theFontSize < 2 && theFontSize != -1) || theFontName.IsNull())
|
||||
{
|
||||
return Handle(Font_SystemFont)();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Handle(Font_SystemFont) aFont = myFontMap.Find (theFontName->String());
|
||||
return (aFont.IsNull()
|
||||
|| theFontAspect == Font_FontAspect_UNDEFINED
|
||||
|| aFont->HasFontAspect (theFontAspect))
|
||||
? aFont
|
||||
: Handle(Font_SystemFont)();
|
||||
}
|
||||
for (Font_NListOfSystemFont::Iterator aFontsIterator (myListOfFonts);
|
||||
aFontsIterator.More(); aFontsIterator.Next())
|
||||
{
|
||||
if (!theFontName->IsEmpty() && !aFontsIterator.Value()->FontName()->IsSameString (theFontName, Standard_False))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetFont
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Font_SystemFont) Font_FontMgr::GetFont (const TCollection_AsciiString& theFontName) const
|
||||
{
|
||||
return myFontMap.Find (theFontName);
|
||||
if (theFontAspect != Font_FA_Undefined && aFontsIterator.Value()->FontAspect() != theFontAspect)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (theFontSize == -1 || aFontsIterator.Value()->FontHeight() == -1 ||
|
||||
theFontSize == aFontsIterator.Value()->FontHeight())
|
||||
{
|
||||
return aFontsIterator.Value();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FindFont
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Font_SystemFont) Font_FontMgr::FindFont (const TCollection_AsciiString& theFontName,
|
||||
Font_FontAspect& theFontAspect) const
|
||||
Handle(Font_SystemFont) Font_FontMgr::FindFont (const Handle(TCollection_HAsciiString)& theFontName,
|
||||
const Font_FontAspect theFontAspect,
|
||||
const Standard_Integer theFontSize) const
|
||||
{
|
||||
TCollection_AsciiString aFontName (theFontName);
|
||||
aFontName.LowerCase();
|
||||
Handle(Font_SystemFont) aFont = myFontMap.Find (aFontName);
|
||||
Handle(TCollection_HAsciiString) aFontName = theFontName;
|
||||
Font_FontAspect aFontAspect = theFontAspect;
|
||||
Standard_Integer aFontSize = theFontSize;
|
||||
|
||||
Handle(Font_SystemFont) aFont = GetFont (aFontName, aFontAspect, aFontSize);
|
||||
if (!aFont.IsNull())
|
||||
{
|
||||
return aFont;
|
||||
}
|
||||
|
||||
// Trying to use font names mapping
|
||||
Handle(Font_FontAliasSequence) anAliases;
|
||||
const Standard_Boolean hasAliases = myFontAliases.Find (aFontName, anAliases)
|
||||
&& !anAliases.IsNull()
|
||||
&& !anAliases->IsEmpty();
|
||||
if (!hasAliases
|
||||
&& aFont.IsNull())
|
||||
for (Standard_Integer anIter = 0; anIter < NUM_FONT_ENTRIES; ++anIter)
|
||||
{
|
||||
anAliases = myFallbackAlias;
|
||||
}
|
||||
Handle(TCollection_HAsciiString) aFontAlias =
|
||||
new TCollection_HAsciiString (Font_FontMgr_MapOfFontsAliases[anIter].EnumName);
|
||||
|
||||
bool isAliasUsed = false, isBestAlias = false;
|
||||
if (!anAliases.IsNull()
|
||||
&& !anAliases->IsEmpty())
|
||||
{
|
||||
for (Font_FontAliasSequence::Iterator anAliasIter (*anAliases); anAliasIter.More(); anAliasIter.Next())
|
||||
if (aFontAlias->IsSameString (aFontName, Standard_False))
|
||||
{
|
||||
const Font_FontAlias& anAlias = anAliasIter.Value();
|
||||
if (Handle(Font_SystemFont) aFont2 = myFontMap.Find (anAlias.FontName))
|
||||
{
|
||||
if (aFont.IsNull())
|
||||
{
|
||||
aFont = aFont2;
|
||||
isAliasUsed = true;
|
||||
}
|
||||
|
||||
if ((anAlias.FontAspect != Font_FontAspect_UNDEFINED
|
||||
&& aFont2->HasFontAspect (anAlias.FontAspect)))
|
||||
{
|
||||
// special case - alias refers to styled font (e.g. "times-bold")
|
||||
isBestAlias = true;
|
||||
theFontAspect = anAlias.FontAspect;
|
||||
break;
|
||||
}
|
||||
else if (anAlias.FontAspect == Font_FontAspect_UNDEFINED
|
||||
&& (theFontAspect == Font_FontAspect_UNDEFINED
|
||||
|| aFont2->HasFontAspect (theFontAspect)))
|
||||
{
|
||||
isBestAlias = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasAliases)
|
||||
{
|
||||
if (isAliasUsed && myToTraceAliases)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Font_FontMgr, using font alias '") + aFont->FontName() + "'"
|
||||
" instead of requested '" + theFontName +"'", Message_Trace);
|
||||
}
|
||||
if (isBestAlias)
|
||||
{
|
||||
return aFont;
|
||||
}
|
||||
aFontName = new TCollection_HAsciiString (Font_FontMgr_MapOfFontsAliases[anIter].FontName);
|
||||
aFontAspect = Font_FontMgr_MapOfFontsAliases[anIter].FontAspect;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (aFont.IsNull())
|
||||
// check font family alias with specified font aspect
|
||||
if (theFontAspect != Font_FA_Undefined
|
||||
&& theFontAspect != Font_FA_Regular
|
||||
&& theFontAspect != aFontAspect)
|
||||
{
|
||||
// try finding ANY font in case if even default fallback alias myFallbackAlias cannot be found
|
||||
aFont = myFontMap.Find (TCollection_AsciiString());
|
||||
}
|
||||
if (aFont.IsNull())
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Font_FontMgr, error: unable to find any font!", Message_Fail));
|
||||
return Handle(Font_SystemFont)();
|
||||
aFont = GetFont (aFontName, theFontAspect, aFontSize);
|
||||
if (!aFont.IsNull())
|
||||
{
|
||||
return aFont;
|
||||
}
|
||||
}
|
||||
|
||||
if ((theFontAspect != Font_FA_Undefined
|
||||
&& !aFont->HasFontAspect (theFontAspect))
|
||||
|| (!aFontName.IsEmpty()
|
||||
&& !aFontName.IsEqual (aFont->FontKey())))
|
||||
// check font alias with aspect in the name
|
||||
aFont = GetFont (aFontName, aFontAspect, aFontSize);
|
||||
if (!aFont.IsNull())
|
||||
{
|
||||
TCollection_AsciiString aDesc = TCollection_AsciiString() + "'" + theFontName + "'"
|
||||
+ TCollection_AsciiString() + " [" + Font_FontMgr::FontAspectToString (theFontAspect) + "]";
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Font_FontMgr, warning: unable to find font ")
|
||||
+ aDesc + "; " + aFont->ToString() + " is used instead");
|
||||
return aFont;
|
||||
}
|
||||
return aFont;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Font_FontMap::Find
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Font_SystemFont) Font_FontMgr::Font_FontMap::Find (const TCollection_AsciiString& theFontName) const
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
return Handle(Font_SystemFont)();
|
||||
}
|
||||
else if (theFontName.IsEmpty())
|
||||
{
|
||||
return FindKey (1); // return any font
|
||||
}
|
||||
|
||||
TCollection_AsciiString aFontName (theFontName);
|
||||
aFontName.LowerCase();
|
||||
for (IndexedMapNode* aNodeIter = (IndexedMapNode* )myData1[::HashCode (aFontName, NbBuckets())];
|
||||
aNodeIter != NULL; aNodeIter = (IndexedMapNode* )aNodeIter->Next())
|
||||
{
|
||||
const Handle(Font_SystemFont)& aKey = aNodeIter->Key1();
|
||||
if (aKey->FontKey().IsEqual (aFontName))
|
||||
{
|
||||
return aKey;
|
||||
}
|
||||
}
|
||||
return Handle(Font_SystemFont)();
|
||||
|
||||
// Requested family name not found -> search for any font family with given aspect and height
|
||||
aFontName = new TCollection_HAsciiString ("");
|
||||
aFont = GetFont (aFontName, aFontAspect, aFontSize);
|
||||
if (!aFont.IsNull())
|
||||
{
|
||||
return aFont;
|
||||
}
|
||||
|
||||
// The last resort: trying to use ANY font available in the system
|
||||
aFontAspect = Font_FA_Undefined;
|
||||
aFontSize = -1;
|
||||
aFont = GetFont (aFontName, aFontAspect, aFontSize);
|
||||
if (!aFont.IsNull())
|
||||
{
|
||||
return aFont;
|
||||
}
|
||||
|
||||
return NULL; // Fonts are not found in the system.
|
||||
}
|
||||
|
@@ -17,63 +17,33 @@
|
||||
#define _Font_FontMgr_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Font_FontAspect.hxx>
|
||||
#include <Font_NListOfSystemFont.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <NCollection_IndexedMap.hxx>
|
||||
#include <NCollection_Shared.hxx>
|
||||
#include <TColStd_SequenceOfHAsciiString.hxx>
|
||||
|
||||
#include <Font_NListOfSystemFont.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TColStd_SequenceOfHAsciiString.hxx>
|
||||
#include <Font_FontAspect.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
class Font_SystemFont;
|
||||
class TCollection_HAsciiString;
|
||||
|
||||
|
||||
class Font_FontMgr;
|
||||
DEFINE_STANDARD_HANDLE(Font_FontMgr, Standard_Transient)
|
||||
|
||||
//! Collects and provides information about available fonts in system.
|
||||
class Font_FontMgr : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Font_FontMgr, Standard_Transient)
|
||||
|
||||
public:
|
||||
|
||||
//! Return global instance of font manager.
|
||||
|
||||
Standard_EXPORT static Handle(Font_FontMgr) GetInstance();
|
||||
|
||||
//! Return font aspect as string.
|
||||
static const char* FontAspectToString (Font_FontAspect theAspect)
|
||||
{
|
||||
switch (theAspect)
|
||||
{
|
||||
case Font_FontAspect_UNDEFINED: return "undefined";
|
||||
case Font_FontAspect_Regular: return "regular";
|
||||
case Font_FontAspect_Bold: return "bold";
|
||||
case Font_FontAspect_Italic: return "italic";
|
||||
case Font_FontAspect_BoldItalic: return "bold-italic";
|
||||
}
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Return the list of available fonts.
|
||||
void AvailableFonts (Font_NListOfSystemFont& theList) const
|
||||
{
|
||||
for (Font_FontMap::Iterator aFontIter (myFontMap); aFontIter.More(); aFontIter.Next())
|
||||
{
|
||||
theList.Append (aFontIter.Value());
|
||||
}
|
||||
}
|
||||
|
||||
//! Return the list of available fonts.
|
||||
Font_NListOfSystemFont GetAvailableFonts() const
|
||||
{
|
||||
Font_NListOfSystemFont aList;
|
||||
AvailableFonts (aList);
|
||||
return aList;
|
||||
}
|
||||
|
||||
|
||||
Standard_EXPORT const Font_NListOfSystemFont& GetAvailableFonts() const;
|
||||
|
||||
//! Returns sequence of available fonts names
|
||||
Standard_EXPORT void GetAvailableFontsNames (TColStd_SequenceOfHAsciiString& theFontsNames) const;
|
||||
|
||||
@@ -82,103 +52,51 @@ public:
|
||||
//! If theFontAspect is Font_FA_Undefined returned font can have any FontAspect.
|
||||
//! If theFontSize is "-1" returned font can have any FontSize.
|
||||
Standard_EXPORT Handle(Font_SystemFont) GetFont (const Handle(TCollection_HAsciiString)& theFontName, const Font_FontAspect theFontAspect, const Standard_Integer theFontSize) const;
|
||||
|
||||
//! Returns font that match given name or NULL if such font family is NOT registered.
|
||||
//! Note that unlike FindFont(), this method ignores font aliases and does not look for fall-back.
|
||||
Standard_EXPORT Handle(Font_SystemFont) GetFont (const TCollection_AsciiString& theFontName) const;
|
||||
|
||||
|
||||
//! Tries to find font by given parameters.
|
||||
//! If the specified font is not found tries to use font names mapping.
|
||||
//! If the requested family name not found -> search for any font family with given aspect and height.
|
||||
//! If the font is still not found, returns any font available in the system.
|
||||
//! Returns NULL in case when the fonts are not found in the system.
|
||||
//! @param theFontName [in] font family to find or alias name
|
||||
//! @param theFontAspect [in] [out] font aspect to find (considered only if family name is not found);
|
||||
//! can be modified if specified font alias refers to another style (compatibility with obsolete aliases)
|
||||
Standard_EXPORT Handle(Font_SystemFont) FindFont (const TCollection_AsciiString& theFontName,
|
||||
Font_FontAspect& theFontAspect) const;
|
||||
//! If the requested family name not found -> search for any font family
|
||||
//! with given aspect and height. If the font is still not found, returns
|
||||
//! any font available in the system. Returns NULL in case when the fonts
|
||||
//! are not found in the system.
|
||||
Standard_EXPORT Handle(Font_SystemFont) FindFont (const Handle(TCollection_HAsciiString)& theFontName, const Font_FontAspect theFontAspect, const Standard_Integer theFontSize) const;
|
||||
|
||||
//! Read font file and retrieve information from it.
|
||||
Standard_EXPORT Handle(Font_SystemFont) CheckFont (const Standard_CString theFontPath) const;
|
||||
|
||||
//! Register new font.
|
||||
//! If there is existing entity with the same name and properties but different path
|
||||
//! then font will be overridden or ignored depending on theToOverride flag.
|
||||
//! then font will will be overridden or ignored depending on theToOverride flag.
|
||||
Standard_EXPORT Standard_Boolean RegisterFont (const Handle(Font_SystemFont)& theFont, const Standard_Boolean theToOverride);
|
||||
|
||||
//! Return flag for tracing font aliases usage via Message_Trace messages; TRUE by default.
|
||||
Standard_Boolean ToTraceAliases() const { return myToTraceAliases; }
|
||||
|
||||
//! Set flag for tracing font alias usage; useful to trace which fonts are actually used.
|
||||
//! Can be disabled to avoid redundant messages with Message_Trace level.
|
||||
void SetTraceAliases (Standard_Boolean theToTrace) { myToTraceAliases = theToTrace; }
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
//! Creates empty font manager object
|
||||
//! Creates empty font object
|
||||
Standard_EXPORT Font_FontMgr();
|
||||
|
||||
//! Collects available fonts paths.
|
||||
Standard_EXPORT void InitFontDataBase();
|
||||
|
||||
private:
|
||||
Font_NListOfSystemFont myListOfFonts;
|
||||
|
||||
//! Map storing registered fonts.
|
||||
class Font_FontMap : public NCollection_IndexedMap<Handle(Font_SystemFont), Font_SystemFont>
|
||||
{
|
||||
public:
|
||||
//! Empty constructor.
|
||||
Font_FontMap() {}
|
||||
|
||||
//! Try finding font with specified parameters or the closest one.
|
||||
//! @param theFontName [in] font family to find (or empty string if family name can be ignored)
|
||||
//! @return best match font or NULL if not found
|
||||
Handle(Font_SystemFont) Find (const TCollection_AsciiString& theFontName) const;
|
||||
|
||||
public:
|
||||
|
||||
//! Hash value, for Map interface.
|
||||
//! Based on Font Family, so that the whole family with different aspects can be found within the same bucket.
|
||||
static Standard_Integer HashCode (const Handle(Font_SystemFont)& theFont,
|
||||
const Standard_Integer theUpper)
|
||||
{
|
||||
return ::HashCode (theFont->FontKey(), theUpper);
|
||||
}
|
||||
|
||||
//! Matching two instances, for Map interface.
|
||||
static bool IsEqual (const Handle(Font_SystemFont)& theFont1,
|
||||
const Handle(Font_SystemFont)& theFont2)
|
||||
{
|
||||
return theFont1->IsEqual (theFont2);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//! Structure defining font alias.
|
||||
struct Font_FontAlias
|
||||
{
|
||||
TCollection_AsciiString FontName;
|
||||
Font_FontAspect FontAspect;
|
||||
|
||||
Font_FontAlias (const TCollection_AsciiString& theFontName, Font_FontAspect theFontAspect = Font_FontAspect_UNDEFINED) : FontName (theFontName), FontAspect (theFontAspect) {}
|
||||
Font_FontAlias() : FontAspect (Font_FontAspect_UNDEFINED) {}
|
||||
};
|
||||
|
||||
//! Sequence of font aliases.
|
||||
typedef NCollection_Shared< NCollection_Sequence<Font_FontAlias> > Font_FontAliasSequence;
|
||||
|
||||
//! Register font alias.
|
||||
void addFontAlias (const TCollection_AsciiString& theAliasName,
|
||||
const Handle(Font_FontAliasSequence)& theAliases,
|
||||
Font_FontAspect theAspect = Font_FontAspect_UNDEFINED);
|
||||
|
||||
private:
|
||||
|
||||
Font_FontMap myFontMap;
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(Font_FontAliasSequence)> myFontAliases;
|
||||
Handle(Font_FontAliasSequence) myFallbackAlias;
|
||||
Standard_Boolean myToTraceAliases;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Font_FontMgr_HeaderFile
|
||||
|
@@ -13,13 +13,7 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#define Font_NOF_MONOSPACE "monospace"
|
||||
#define Font_NOF_SERIF "serif"
|
||||
#define Font_NOF_SANS_SERIF "sans-serif"
|
||||
#define Font_NOF_CJK "cjk"
|
||||
#define Font_NOF_KOREAN "korean"
|
||||
|
||||
#define Font_NOF_ASCII_MONO "Courier"
|
||||
#define Font_NOF_ASCII_MONO "Courier"
|
||||
#define Font_NOF_ASCII_SIMPLEX "Times-Roman"
|
||||
#define Font_NOF_ASCII_COMPLEX "Times-Roman"
|
||||
#define Font_NOF_ASCII_DUPLEX "Times-Bold"
|
||||
|
@@ -15,8 +15,9 @@
|
||||
|
||||
#include <Font_SystemFont.hxx>
|
||||
|
||||
#include <Font_FontMgr.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Font_SystemFont, Standard_Transient)
|
||||
|
||||
@@ -24,24 +25,92 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_SystemFont, Standard_Transient)
|
||||
// function : Font_SystemFont
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Font_SystemFont::Font_SystemFont (const TCollection_AsciiString& theFontName)
|
||||
: myFontKey (theFontName),
|
||||
myFontName (theFontName),
|
||||
myIsSingleLine (Standard_False)
|
||||
Font_SystemFont::Font_SystemFont()
|
||||
: myFontAspect (Font_FA_Undefined),
|
||||
myFaceSize (-1),
|
||||
myIsSingleLine (Standard_False),
|
||||
myIsDefined (Standard_False)
|
||||
{
|
||||
if (theFontName.IsEmpty()) { throw Standard_ProgramError ("Font_SystemFont constructor called with empty font name"); }
|
||||
myFontKey.LowerCase();
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetFontPath
|
||||
// function : Font_SystemFont
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Font_SystemFont::SetFontPath (Font_FontAspect theAspect,
|
||||
const TCollection_AsciiString& thePath)
|
||||
Font_SystemFont::Font_SystemFont (const Handle(TCollection_HAsciiString)& theFontName,
|
||||
const Font_FontAspect theFontAspect,
|
||||
const Handle(TCollection_HAsciiString)& theFilePath)
|
||||
: myFontName (theFontName),
|
||||
myFontAspect (theFontAspect),
|
||||
myFaceSize (-1),
|
||||
myFilePath (theFilePath),
|
||||
myIsSingleLine (Standard_False),
|
||||
myIsDefined (Standard_True)
|
||||
{
|
||||
if (theAspect == Font_FontAspect_UNDEFINED) { throw Standard_ProgramError ("Font_SystemFont::SetFontPath() called with UNDEFINED aspect"); }
|
||||
myFilePaths[theAspect] = thePath;
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Font_SystemFont
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Font_SystemFont::Font_SystemFont (const Handle(TCollection_HAsciiString)& theXLFD,
|
||||
const Handle(TCollection_HAsciiString)& theFilePath)
|
||||
: myFontAspect (Font_FA_Regular),
|
||||
myFaceSize (-1),
|
||||
myFilePath (theFilePath),
|
||||
myIsSingleLine (Standard_False),
|
||||
myIsDefined (Standard_True)
|
||||
{
|
||||
if (theXLFD.IsNull()
|
||||
|| theXLFD->IsEmpty())
|
||||
{
|
||||
myIsDefined = Standard_False;
|
||||
return;
|
||||
}
|
||||
|
||||
myFontName = theXLFD->Token ("-", 2);
|
||||
const TCollection_AsciiString& aXLFD = theXLFD->String();
|
||||
|
||||
// Getting font size for fixed size fonts
|
||||
if (aXLFD.Search ("-0-0-0-0-") >= 0)
|
||||
{
|
||||
myFaceSize = -1; // Scalable font
|
||||
}
|
||||
else
|
||||
{
|
||||
myFaceSize = aXLFD.Token ("-", 7).IntegerValue();
|
||||
}
|
||||
|
||||
// Detect font aspect
|
||||
if (aXLFD.Token ("-", 3).IsEqual ("bold")
|
||||
&& (aXLFD.Token ("-", 4).IsEqual ("i")
|
||||
|| aXLFD.Token ("-", 4).IsEqual ("o")))
|
||||
{
|
||||
myFontAspect = Font_FA_BoldItalic;
|
||||
}
|
||||
else if (aXLFD.Token ("-", 3).IsEqual ("bold"))
|
||||
{
|
||||
myFontAspect = Font_FA_Bold;
|
||||
}
|
||||
else if (aXLFD.Token ("-", 4).IsEqual ("i")
|
||||
|| aXLFD.Token ("-", 4).IsEqual ("o"))
|
||||
{
|
||||
myFontAspect = Font_FA_Italic;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsValid
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Font_SystemFont::IsValid() const
|
||||
{
|
||||
return myIsDefined
|
||||
&& myFontAspect != Font_FA_Undefined
|
||||
&& !myFontName->IsEmpty()
|
||||
&& OSD_Path::IsValid (myFilePath->String());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -50,59 +119,7 @@ void Font_SystemFont::SetFontPath (Font_FontAspect theAspect,
|
||||
// =======================================================================
|
||||
Standard_Boolean Font_SystemFont::IsEqual (const Handle(Font_SystemFont)& theOtherFont) const
|
||||
{
|
||||
return theOtherFont.get() == this
|
||||
|| myFontKey.IsEqual (theOtherFont->myFontKey);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ToString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Font_SystemFont::ToString() const
|
||||
{
|
||||
TCollection_AsciiString aDesc;
|
||||
aDesc += TCollection_AsciiString() + "'" + myFontName + "'";
|
||||
|
||||
bool isFirstAspect = true;
|
||||
aDesc += " [aspects: ";
|
||||
for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
|
||||
{
|
||||
if (!HasFontAspect ((Font_FontAspect )anAspectIter))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isFirstAspect)
|
||||
{
|
||||
aDesc += ",";
|
||||
}
|
||||
else
|
||||
{
|
||||
isFirstAspect = false;
|
||||
}
|
||||
aDesc += Font_FontMgr::FontAspectToString ((Font_FontAspect )anAspectIter);
|
||||
}
|
||||
aDesc += "]";
|
||||
|
||||
isFirstAspect = true;
|
||||
aDesc += " [paths: ";
|
||||
for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
|
||||
{
|
||||
if (!HasFontAspect ((Font_FontAspect )anAspectIter))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isFirstAspect)
|
||||
{
|
||||
aDesc += ";";
|
||||
}
|
||||
else
|
||||
{
|
||||
isFirstAspect = false;
|
||||
}
|
||||
aDesc += FontPath ((Font_FontAspect )anAspectIter);
|
||||
}
|
||||
aDesc += "]";
|
||||
return aDesc;
|
||||
return myFontName->IsSameString (myFontName, Standard_False)
|
||||
&& myFontAspect == theOtherFont->myFontAspect
|
||||
&& myFaceSize == theOtherFont->myFaceSize;
|
||||
}
|
||||
|
@@ -16,11 +16,14 @@
|
||||
#ifndef _Font_SystemFont_HeaderFile
|
||||
#define _Font_SystemFont_HeaderFile
|
||||
|
||||
#include <Font_FontAspect.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <Font_FontAspect.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
class TCollection_HAsciiString;
|
||||
|
||||
//! This class stores information about the font, which is merely a file path and cached metadata about the font.
|
||||
class Font_SystemFont : public Standard_Transient
|
||||
@@ -28,53 +31,33 @@ class Font_SystemFont : public Standard_Transient
|
||||
DEFINE_STANDARD_RTTIEXT(Font_SystemFont, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Creates a new font object.
|
||||
Standard_EXPORT Font_SystemFont (const TCollection_AsciiString& theFontName);
|
||||
//! Creates an empty font object.
|
||||
Standard_EXPORT Font_SystemFont();
|
||||
|
||||
//! Returns font family name (lower-cased).
|
||||
const TCollection_AsciiString& FontKey() const { return myFontKey; }
|
||||
//! Creates a new font object.
|
||||
Standard_EXPORT Font_SystemFont (const Handle(TCollection_HAsciiString)& theFontName,
|
||||
const Font_FontAspect theFontAspect,
|
||||
const Handle(TCollection_HAsciiString)& theFilePath);
|
||||
|
||||
//! Creates a font object and initialize class fields with values taken from XLFD (X Logical Font Description)
|
||||
Standard_EXPORT Font_SystemFont (const Handle(TCollection_HAsciiString)& theXLFD,
|
||||
const Handle(TCollection_HAsciiString)& theFilePath);
|
||||
|
||||
//! Returns font family name.
|
||||
const TCollection_AsciiString& FontName() const { return myFontName; }
|
||||
const Handle(TCollection_HAsciiString)& FontName() const { return myFontName; }
|
||||
|
||||
//! Returns font file path.
|
||||
const TCollection_AsciiString& FontPath (Font_FontAspect theAspect) const
|
||||
{
|
||||
return myFilePaths[theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular];
|
||||
}
|
||||
|
||||
//! Sets font file path for specific aspect.
|
||||
Standard_EXPORT void SetFontPath (Font_FontAspect theAspect,
|
||||
const TCollection_AsciiString& thePath);
|
||||
|
||||
//! Returns TRUE if dedicated file for specified font aspect has been defined.
|
||||
bool HasFontAspect (Font_FontAspect theAspect) const
|
||||
{
|
||||
return !myFilePaths[theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular].IsEmpty();
|
||||
}
|
||||
|
||||
//! Returns any defined font file path.
|
||||
const TCollection_AsciiString& FontPathAny (Font_FontAspect theAspect) const
|
||||
{
|
||||
const TCollection_AsciiString& aPath = myFilePaths[theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular];
|
||||
if (!aPath.IsEmpty())
|
||||
{
|
||||
return aPath;
|
||||
}
|
||||
else if (!myFilePaths[Font_FontAspect_Regular].IsEmpty())
|
||||
{
|
||||
return myFilePaths[Font_FontAspect_Regular];
|
||||
}
|
||||
for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
|
||||
{
|
||||
if (!myFilePaths[anAspectIter].IsEmpty())
|
||||
{
|
||||
return myFilePaths[anAspectIter];
|
||||
}
|
||||
}
|
||||
return myFilePaths[Font_FontAspect_Regular];
|
||||
}
|
||||
const Handle(TCollection_HAsciiString)& FontPath() const { return myFilePath; }
|
||||
|
||||
//! Returns font aspect.
|
||||
Font_FontAspect FontAspect() const { return myFontAspect; }
|
||||
|
||||
//! Returns font height.
|
||||
//! If returned value is equal -1 it means that font is resizable.
|
||||
Standard_Integer FontHeight() const { return myFaceSize; }
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsValid() const;
|
||||
|
||||
//! Return true if the FontName, FontAspect and FontSize are the same.
|
||||
Standard_EXPORT Standard_Boolean IsEqual (const Handle(Font_SystemFont)& theOtherFont) const;
|
||||
|
||||
@@ -85,32 +68,14 @@ public:
|
||||
//! Set if this font should be rendered as single-stroke (one-line).
|
||||
void SetSingleStrokeFont (Standard_Boolean theIsSingleLine) { myIsSingleLine = theIsSingleLine; }
|
||||
|
||||
//! Format font description.
|
||||
Standard_EXPORT TCollection_AsciiString ToString() const;
|
||||
|
||||
public:
|
||||
|
||||
//! Hash value, for Map interface.
|
||||
//! Based on Font Family, so that the whole family with different aspects can be found within the same bucket.
|
||||
static Standard_Integer HashCode (const Handle(Font_SystemFont)& theFont,
|
||||
const Standard_Integer theUpper)
|
||||
{
|
||||
return ::HashCode (theFont->FontKey(), theUpper);
|
||||
}
|
||||
|
||||
//! Matching two instances, for Map interface.
|
||||
static bool IsEqual (const Handle(Font_SystemFont)& theFont1,
|
||||
const Handle(Font_SystemFont)& theFont2)
|
||||
{
|
||||
return theFont1->IsEqual (theFont2);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
TCollection_AsciiString myFilePaths[Font_FontAspect_NB]; //!< paths to the font file
|
||||
TCollection_AsciiString myFontKey; //!< font family name, lower cased
|
||||
TCollection_AsciiString myFontName; //!< font family name
|
||||
Standard_Boolean myIsSingleLine; //!< single stroke font flag, FALSE by default
|
||||
Handle(TCollection_HAsciiString) myFontName;
|
||||
Font_FontAspect myFontAspect;
|
||||
Standard_Integer myFaceSize;
|
||||
Handle(TCollection_HAsciiString) myFilePath;
|
||||
Standard_Boolean myIsSingleLine; //!< single stroke font flag, FALSE by default
|
||||
Standard_Boolean myIsDefined;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -1082,6 +1082,7 @@ void Graphic3d_CView::CopySettings (const Handle(Graphic3d_CView)& theOther)
|
||||
SetBackgroundImage (theOther->BackgroundImage());
|
||||
SetBackgroundImageStyle (theOther->BackgroundImageStyle());
|
||||
SetTextureEnv (theOther->TextureEnv());
|
||||
SetCullingEnabled (theOther->IsCullingEnabled());
|
||||
SetShadingModel (theOther->ShadingModel());
|
||||
SetBackfacingModel (theOther->BackfacingModel());
|
||||
SetCamera (new Graphic3d_Camera (theOther->Camera()));
|
||||
|
@@ -381,6 +381,12 @@ public:
|
||||
//! Sets environment texture for the view.
|
||||
virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) = 0;
|
||||
|
||||
//! Returns the state of frustum culling optimization.
|
||||
virtual Standard_Boolean IsCullingEnabled() const = 0;
|
||||
|
||||
//! Enables or disables frustum culling optimization.
|
||||
virtual void SetCullingEnabled (const Standard_Boolean theIsEnabled) = 0;
|
||||
|
||||
//! Return backfacing model used for the view.
|
||||
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const = 0;
|
||||
|
||||
@@ -415,12 +421,6 @@ public:
|
||||
virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
|
||||
Graphic3d_DiagnosticInfo theFlags) const = 0;
|
||||
|
||||
//! Returns string with statistic performance info.
|
||||
virtual TCollection_AsciiString StatisticInformation() const = 0;
|
||||
|
||||
//! Fills in the dictionary with statistic performance info.
|
||||
virtual void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const = 0;
|
||||
|
||||
private:
|
||||
|
||||
//! Adds the structure to display lists of the view.
|
||||
|
@@ -1388,79 +1388,3 @@ Standard_EXPORT void NCollection_Lerp<Handle(Graphic3d_Camera)>::Interpolate (co
|
||||
theCamera->SetScale (aScale);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FrustumPoints
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_Camera::FrustumPoints (NCollection_Array1<Graphic3d_Vec3d>& thePoints) const
|
||||
{
|
||||
if (thePoints.Length() != FrustumVerticesNB)
|
||||
{
|
||||
thePoints.Resize (0, FrustumVerticesNB, Standard_False);
|
||||
}
|
||||
|
||||
const Graphic3d_Mat4d& aProjectionMat = ProjectionMatrix();
|
||||
const Graphic3d_Mat4d& aWorldViewMat = OrientationMatrix();
|
||||
|
||||
Standard_Real nLeft = 0.0, nRight = 0.0, nTop = 0.0, nBottom = 0.0;
|
||||
Standard_Real fLeft = 0.0, fRight = 0.0, fTop = 0.0, fBottom = 0.0;
|
||||
Standard_Real aNear = 0.0, aFar = 0.0;
|
||||
if (!IsOrthographic())
|
||||
{
|
||||
// handle perspective projection
|
||||
aNear = aProjectionMat.GetValue (2, 3) / (-1.0 + aProjectionMat.GetValue (2, 2));
|
||||
aFar = aProjectionMat.GetValue (2, 3) / ( 1.0 + aProjectionMat.GetValue (2, 2));
|
||||
// Near plane
|
||||
nLeft = aNear * (aProjectionMat.GetValue (0, 2) - 1.0) / aProjectionMat.GetValue (0, 0);
|
||||
nRight = aNear * (aProjectionMat.GetValue (0, 2) + 1.0) / aProjectionMat.GetValue (0, 0);
|
||||
nTop = aNear * (aProjectionMat.GetValue (1, 2) + 1.0) / aProjectionMat.GetValue (1, 1);
|
||||
nBottom = aNear * (aProjectionMat.GetValue (1, 2) - 1.0) / aProjectionMat.GetValue (1, 1);
|
||||
// Far plane
|
||||
fLeft = aFar * (aProjectionMat.GetValue (0, 2) - 1.0) / aProjectionMat.GetValue (0, 0);
|
||||
fRight = aFar * (aProjectionMat.GetValue (0, 2) + 1.0) / aProjectionMat.GetValue (0, 0);
|
||||
fTop = aFar * (aProjectionMat.GetValue (1, 2) + 1.0) / aProjectionMat.GetValue (1, 1);
|
||||
fBottom = aFar * (aProjectionMat.GetValue (1, 2) - 1.0) / aProjectionMat.GetValue (1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle orthographic projection
|
||||
aNear = (1.0 / aProjectionMat.GetValue (2, 2)) * (aProjectionMat.GetValue (2, 3) + 1.0);
|
||||
aFar = (1.0 / aProjectionMat.GetValue (2, 2)) * (aProjectionMat.GetValue (2, 3) - 1.0);
|
||||
// Near plane
|
||||
nLeft = ( 1.0 + aProjectionMat.GetValue (0, 3)) / (-aProjectionMat.GetValue (0, 0));
|
||||
fLeft = nLeft;
|
||||
nRight = ( 1.0 - aProjectionMat.GetValue (0, 3)) / aProjectionMat.GetValue (0, 0);
|
||||
fRight = nRight;
|
||||
nTop = ( 1.0 - aProjectionMat.GetValue (1, 3)) / aProjectionMat.GetValue (1, 1);
|
||||
fTop = nTop;
|
||||
nBottom = (-1.0 - aProjectionMat.GetValue (1, 3)) / aProjectionMat.GetValue (1, 1);
|
||||
fBottom = nBottom;
|
||||
}
|
||||
|
||||
Graphic3d_Vec4d aLeftTopNear (nLeft, nTop, -aNear, 1.0), aRightBottomFar (fRight, fBottom, -aFar, 1.0);
|
||||
Graphic3d_Vec4d aLeftBottomNear (nLeft, nBottom, -aNear, 1.0), aRightTopFar (fRight, fTop, -aFar, 1.0);
|
||||
Graphic3d_Vec4d aRightBottomNear (nRight, nBottom, -aNear, 1.0), aLeftTopFar (fLeft, fTop, -aFar, 1.0);
|
||||
Graphic3d_Vec4d aRightTopNear (nRight, nTop, -aNear, 1.0), aLeftBottomFar (fLeft, fBottom, -aFar, 1.0);
|
||||
|
||||
Graphic3d_Mat4d anInvWorldView;
|
||||
aWorldViewMat.Inverted (anInvWorldView);
|
||||
|
||||
Graphic3d_Vec4d aTmpPnt;
|
||||
aTmpPnt = anInvWorldView * aLeftTopNear;
|
||||
thePoints.SetValue (FrustumVert_LeftTopNear, aTmpPnt.xyz() / aTmpPnt.w());
|
||||
aTmpPnt = anInvWorldView * aRightBottomFar;
|
||||
thePoints.SetValue (FrustumVert_RightBottomFar, aTmpPnt.xyz() / aTmpPnt.w());
|
||||
aTmpPnt = anInvWorldView * aLeftBottomNear;
|
||||
thePoints.SetValue (FrustumVert_LeftBottomNear, aTmpPnt.xyz() / aTmpPnt.w());
|
||||
aTmpPnt = anInvWorldView * aRightTopFar;
|
||||
thePoints.SetValue (FrustumVert_RightTopFar, aTmpPnt.xyz() / aTmpPnt.w());
|
||||
aTmpPnt = anInvWorldView * aRightBottomNear;
|
||||
thePoints.SetValue (FrustumVert_RightBottomNear, aTmpPnt.xyz() / aTmpPnt.w());
|
||||
aTmpPnt = anInvWorldView * aLeftTopFar;
|
||||
thePoints.SetValue (FrustumVert_LeftTopFar, aTmpPnt.xyz() / aTmpPnt.w());
|
||||
aTmpPnt = anInvWorldView * aRightTopNear;
|
||||
thePoints.SetValue (FrustumVert_RightTopNear, aTmpPnt.xyz() / aTmpPnt.w());
|
||||
aTmpPnt = anInvWorldView * aLeftBottomFar;
|
||||
thePoints.SetValue (FrustumVert_LeftBottomFar, aTmpPnt.xyz() / aTmpPnt.w());
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include <Graphic3d_Vec3.hxx>
|
||||
#include <Graphic3d_WorldViewProjState.hxx>
|
||||
#include <NCollection_Lerp.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
@@ -631,27 +630,6 @@ private:
|
||||
const NCollection_Vec3<Elem_t>& theAxialScale,
|
||||
NCollection_Mat4<Elem_t>& theOutMx);
|
||||
|
||||
public:
|
||||
|
||||
//! Enumerates vertices of view volume.
|
||||
enum
|
||||
{
|
||||
FrustumVert_LeftBottomNear,
|
||||
FrustumVert_LeftBottomFar,
|
||||
FrustumVert_LeftTopNear,
|
||||
FrustumVert_LeftTopFar,
|
||||
FrustumVert_RightBottomNear,
|
||||
FrustumVert_RightBottomFar,
|
||||
FrustumVert_RightTopNear,
|
||||
FrustumVert_RightTopFar,
|
||||
FrustumVerticesNB
|
||||
};
|
||||
|
||||
//! Fill array of current view frustum corners.
|
||||
//! The size of this array is equal to FrustumVerticesNB.
|
||||
//! The order of vertices is as defined in FrustumVert_* enumeration.
|
||||
Standard_EXPORT void FrustumPoints (NCollection_Array1<Graphic3d_Vec3d>& thePoints) const;
|
||||
|
||||
private:
|
||||
|
||||
gp_Dir myUp; //!< Camera up direction vector.
|
||||
|
@@ -149,71 +149,6 @@ namespace
|
||||
}
|
||||
return theStream;
|
||||
}
|
||||
|
||||
//! Add key-value pair to the dictionary.
|
||||
static void addInfo (TColStd_IndexedDataMapOfStringString& theDict,
|
||||
const TCollection_AsciiString& theKey,
|
||||
const char* theValue)
|
||||
{
|
||||
TCollection_AsciiString aValue (theValue != NULL ? theValue : "");
|
||||
theDict.ChangeFromIndex (theDict.Add (theKey, aValue)) = aValue;
|
||||
}
|
||||
|
||||
//! Add key-value pair to the dictionary.
|
||||
static void addInfo (TColStd_IndexedDataMapOfStringString& theDict,
|
||||
const TCollection_AsciiString& theKey,
|
||||
const Standard_Real theValue)
|
||||
{
|
||||
char aTmp[50];
|
||||
Sprintf (aTmp, "%.1g", theValue);
|
||||
addInfo (theDict, theKey, aTmp);
|
||||
}
|
||||
|
||||
//! Add key-value pair to the dictionary.
|
||||
static void addInfo (TColStd_IndexedDataMapOfStringString& theDict,
|
||||
const TCollection_AsciiString& theKey,
|
||||
const Standard_Size theValue)
|
||||
{
|
||||
char aTmp[50];
|
||||
Sprintf (aTmp, "%zu", theValue);
|
||||
addInfo (theDict, theKey, aTmp);
|
||||
}
|
||||
|
||||
//! Format time.
|
||||
static void addTimeInfo (TColStd_IndexedDataMapOfStringString& theDict,
|
||||
const TCollection_AsciiString& theKey,
|
||||
Standard_Real theSeconds)
|
||||
{
|
||||
Standard_Real aSecIn = theSeconds;
|
||||
unsigned int aHours = (unsigned int )(aSecIn * THE_SECOND_IN_HOUR);
|
||||
aSecIn -= Standard_Real(aHours) * THE_SECONDS_IN_HOUR;
|
||||
unsigned int aMinutes = (unsigned int )(aSecIn * THE_SECOND_IN_MINUTE);
|
||||
aSecIn -= Standard_Real(aMinutes) * THE_SECONDS_IN_MINUTE;
|
||||
unsigned int aSeconds = (unsigned int )aSecIn;
|
||||
aSecIn -= Standard_Real(aSeconds);
|
||||
Standard_Real aMilliSeconds = 1000.0 * aSecIn;
|
||||
|
||||
char aBuffer[64];
|
||||
if (aHours > 0)
|
||||
{
|
||||
Sprintf (aBuffer, "%02u:%02u:%02u", aHours, aMinutes, aSeconds);
|
||||
}
|
||||
else if (aMinutes > 0)
|
||||
{
|
||||
Sprintf (aBuffer, "%02u:%02u", aMinutes, aSeconds);
|
||||
}
|
||||
else if (aSeconds > 0)
|
||||
{
|
||||
Sprintf (aBuffer, "%2u", aSeconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
addInfo (theDict, theKey, aMilliSeconds);
|
||||
return;
|
||||
}
|
||||
|
||||
addInfo (theDict, theKey, aBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -389,100 +324,6 @@ TCollection_AsciiString Graphic3d_FrameStats::FormatStats (Graphic3d_RenderingPa
|
||||
return TCollection_AsciiString (aBuf.str().c_str());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FormatStats
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_FrameStats::FormatStats (TColStd_IndexedDataMapOfStringString& theDict,
|
||||
Graphic3d_RenderingParams::PerfCounters theFlags) const
|
||||
{
|
||||
const Graphic3d_FrameStatsData& aStats = LastDataFrame();
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_FrameRate) != 0)
|
||||
{
|
||||
addInfo (theDict, "FPS", aStats.FrameRate());
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_CPU) != 0)
|
||||
{
|
||||
addInfo (theDict, "CPU FPS", aStats.FrameRateCpu());
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_Layers) != 0)
|
||||
{
|
||||
addInfo (theDict, "Layers", aStats[Graphic3d_FrameStatsCounter_NbLayers]);
|
||||
if (HasCulledLayers())
|
||||
{
|
||||
addInfo (theDict, "Rendered layers", aStats[Graphic3d_FrameStatsCounter_NbLayersNotCulled]);
|
||||
}
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_Structures) != 0)
|
||||
{
|
||||
addInfo (theDict, "Structs", aStats[Graphic3d_FrameStatsCounter_NbStructs]);
|
||||
if (HasCulledStructs())
|
||||
{
|
||||
addInfo (theDict, "Rendered structs", aStats[Graphic3d_FrameStatsCounter_NbStructsNotCulled]);
|
||||
}
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_Groups) != 0)
|
||||
{
|
||||
addInfo (theDict, "Rendered groups", aStats[Graphic3d_FrameStatsCounter_NbGroupsNotCulled]);
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_GroupArrays) != 0)
|
||||
{
|
||||
addInfo (theDict, "Rendered arrays", aStats[Graphic3d_FrameStatsCounter_NbElemsNotCulled]);
|
||||
addInfo (theDict, "Rendered [fill] arrays", aStats[Graphic3d_FrameStatsCounter_NbElemsFillNotCulled]);
|
||||
addInfo (theDict, "Rendered [line] arrays", aStats[Graphic3d_FrameStatsCounter_NbElemsLineNotCulled]);
|
||||
addInfo (theDict, "Rendered [point] arrays", aStats[Graphic3d_FrameStatsCounter_NbElemsPointNotCulled]);
|
||||
addInfo (theDict, "Rendered [text] arrays", aStats[Graphic3d_FrameStatsCounter_NbElemsTextNotCulled]);
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_Triangles) != 0)
|
||||
{
|
||||
addInfo (theDict, "Rendered triangles", aStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled]);
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_Points) != 0)
|
||||
{
|
||||
addInfo (theDict, "Rendered points", aStats[Graphic3d_FrameStatsCounter_NbPointsNotCulled]);
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_EstimMem) != 0)
|
||||
{
|
||||
addInfo (theDict, "GPU Memory [geometry]", aStats[Graphic3d_FrameStatsCounter_EstimatedBytesGeom]);
|
||||
addInfo (theDict, "GPU Memory [textures]", aStats[Graphic3d_FrameStatsCounter_EstimatedBytesTextures]);
|
||||
addInfo (theDict, "GPU Memory [frames]", aStats[Graphic3d_FrameStatsCounter_EstimatedBytesFbos]);
|
||||
}
|
||||
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_FrameTime) != 0)
|
||||
{
|
||||
addTimeInfo (theDict, "Elapsed Frame (average)", aStats[Graphic3d_FrameStatsTimer_ElapsedFrame]);
|
||||
addTimeInfo (theDict, "CPU Frame (average)", aStats[Graphic3d_FrameStatsTimer_CpuFrame]);
|
||||
if (myCountersMax[Graphic3d_FrameStatsTimer_CpuPicking] > 0.0)
|
||||
{
|
||||
addTimeInfo (theDict, "CPU Picking (average)", aStats[Graphic3d_FrameStatsTimer_CpuPicking]);
|
||||
}
|
||||
if (myCountersMax[Graphic3d_FrameStatsTimer_CpuCulling] > 0.0)
|
||||
{
|
||||
addTimeInfo (theDict, "CPU Culling (average)", aStats[Graphic3d_FrameStatsTimer_CpuCulling]);
|
||||
}
|
||||
if (myCountersMax[Graphic3d_FrameStatsTimer_CpuDynamics])
|
||||
{
|
||||
addTimeInfo (theDict, "CPU Dynamics (average)", aStats[Graphic3d_FrameStatsTimer_CpuDynamics]);
|
||||
}
|
||||
if ((theFlags & Graphic3d_RenderingParams::PerfCounters_FrameTimeMax) != 0)
|
||||
{
|
||||
addTimeInfo (theDict, "CPU Frame (max)", myCountersMax[Graphic3d_FrameStatsTimer_CpuFrame]);
|
||||
if (myCountersMax[Graphic3d_FrameStatsTimer_CpuPicking] > 0.0)
|
||||
{
|
||||
addTimeInfo (theDict, "CPU Picking (max)", myCountersMax[Graphic3d_FrameStatsTimer_CpuPicking]);
|
||||
}
|
||||
if (myCountersMax[Graphic3d_FrameStatsTimer_CpuCulling] > 0.0)
|
||||
{
|
||||
addTimeInfo (theDict, "CPU Culling (max)", myCountersMax[Graphic3d_FrameStatsTimer_CpuCulling]);
|
||||
}
|
||||
if (myCountersMax[Graphic3d_FrameStatsTimer_CpuDynamics])
|
||||
{
|
||||
addTimeInfo (theDict, "CPU Dynamics (max)", myCountersMax[Graphic3d_FrameStatsTimer_CpuDynamics]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FrameStart
|
||||
// purpose :
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include <Graphic3d_RenderingParams.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TColStd_IndexedDataMapOfStringString.hxx>
|
||||
|
||||
class Graphic3d_CView;
|
||||
|
||||
@@ -59,10 +58,6 @@ public:
|
||||
//! Returns formatted string.
|
||||
Standard_EXPORT virtual TCollection_AsciiString FormatStats (Graphic3d_RenderingParams::PerfCounters theFlags) const;
|
||||
|
||||
//! Fill in the dictionary with formatted statistic info.
|
||||
Standard_EXPORT virtual void FormatStats (TColStd_IndexedDataMapOfStringString& theDict,
|
||||
Graphic3d_RenderingParams::PerfCounters theFlags) const;
|
||||
|
||||
//! Returns duration of the last frame in seconds.
|
||||
Standard_Real FrameDuration() const { return myFrameDuration; }
|
||||
|
||||
|
@@ -80,14 +80,6 @@ public:
|
||||
| PerfCounters_FrameTimeMax,
|
||||
};
|
||||
|
||||
//! State of frustum culling optimization.
|
||||
enum FrustumCulling
|
||||
{
|
||||
FrustumCulling_Off, //!< culling is disabled
|
||||
FrustumCulling_On, //!< culling is active, and the list of culled entities is automatically updated before redraw
|
||||
FrustumCulling_NoUpdate //!< culling is active, but the list of culled entities is not updated
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Creates default rendering parameters.
|
||||
@@ -116,7 +108,6 @@ public:
|
||||
NbRayTracingTiles (16 * 16),
|
||||
CameraApertureRadius (0.0f),
|
||||
CameraFocalPlaneDist (1.0f),
|
||||
FrustumCullingState (FrustumCulling_On),
|
||||
ToneMappingMethod (Graphic3d_ToneMappingMethod_Disabled),
|
||||
Exposure (0.f),
|
||||
WhitePoint (1.f),
|
||||
@@ -190,7 +181,6 @@ public:
|
||||
Standard_Integer NbRayTracingTiles; //!< total number of screen tiles used in adaptive sampling mode (PT only)
|
||||
Standard_ShortReal CameraApertureRadius; //!< aperture radius of perspective camera used for depth-of-field, 0.0 by default (no DOF) (path tracing only)
|
||||
Standard_ShortReal CameraFocalPlaneDist; //!< focal distance of perspective camera used for depth-of field, 1.0 by default (path tracing only)
|
||||
FrustumCulling FrustumCullingState; //!< state of frustum culling optimization; FrustumCulling_On by default
|
||||
|
||||
Graphic3d_ToneMappingMethod ToneMappingMethod; //!< specifies tone mapping method for path tracing, Graphic3d_ToneMappingMethod_Disabled by default
|
||||
Standard_ShortReal Exposure; //!< exposure value used for tone mapping (path tracing), 0.0 by default
|
||||
|
@@ -32,8 +32,6 @@
|
||||
|
||||
#include <Image_PixMap.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectFace, OpenGl_Element)
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Initialize default material in this way for backward compatibility.
|
||||
@@ -68,7 +66,6 @@ OpenGl_AspectFace::OpenGl_AspectFace()
|
||||
THE_DEFAULT_MATERIAL, THE_DEFAULT_MATERIAL)),
|
||||
myShadingModel (Graphic3d_TOSM_UNLIT)
|
||||
{
|
||||
myAspectEdge = new OpenGl_AspectLine();
|
||||
myAspect->SetShadingModel (myShadingModel);
|
||||
myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
|
||||
}
|
||||
@@ -80,8 +77,6 @@ OpenGl_AspectFace::OpenGl_AspectFace()
|
||||
OpenGl_AspectFace::OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
||||
: myShadingModel (Graphic3d_TOSM_DEFAULT)
|
||||
{
|
||||
myAspectEdge = new OpenGl_AspectLine();
|
||||
|
||||
SetAspect (theAspect);
|
||||
}
|
||||
|
||||
@@ -102,9 +97,9 @@ void OpenGl_AspectFace::SetAspect (const Handle(Graphic3d_AspectFillArea3d)& the
|
||||
? theAspect->ShadingModel()
|
||||
: Graphic3d_TOSM_UNLIT;
|
||||
|
||||
myAspectEdge->Aspect()->SetColor (theAspect->EdgeColor());
|
||||
myAspectEdge->Aspect()->SetType (theAspect->EdgeLineType());
|
||||
myAspectEdge->Aspect()->SetWidth (theAspect->EdgeWidth());
|
||||
myAspectEdge.Aspect()->SetColor (theAspect->EdgeColor());
|
||||
myAspectEdge.Aspect()->SetType (theAspect->EdgeLineType());
|
||||
myAspectEdge.Aspect()->SetWidth (theAspect->EdgeWidth());
|
||||
|
||||
// update texture binding
|
||||
myResources.UpdateTexturesRediness (myAspect->TextureSet());
|
||||
|
@@ -28,7 +28,7 @@ class OpenGl_Texture;
|
||||
//! The element holding Graphic3d_AspectFillArea3d.
|
||||
class OpenGl_AspectFace : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_AspectFace, OpenGl_Element)
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
@@ -44,10 +44,10 @@ public:
|
||||
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
|
||||
|
||||
//! Set edge aspect.
|
||||
void SetAspectEdge (const Handle(OpenGl_AspectLine)& theAspectEdge) { myAspectEdge = theAspectEdge; }
|
||||
void SetAspectEdge (const OpenGl_AspectLine* theAspectEdge) { myAspectEdge = *theAspectEdge; }
|
||||
|
||||
//! @return edge aspect.
|
||||
const Handle(OpenGl_AspectLine)& AspectEdge() const { return myAspectEdge; }
|
||||
const OpenGl_AspectLine* AspectEdge() const { return &myAspectEdge; }
|
||||
|
||||
//! Returns Shading Model.
|
||||
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
|
||||
@@ -140,7 +140,7 @@ protected:
|
||||
} myResources;
|
||||
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspect;
|
||||
Handle(OpenGl_AspectLine) myAspectEdge;
|
||||
OpenGl_AspectLine myAspectEdge;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
|
||||
public:
|
||||
|
@@ -21,8 +21,6 @@
|
||||
#include <OpenGl_ShaderProgram.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectLine, OpenGl_Element)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const TCollection_AsciiString THE_EMPTY_KEY;
|
||||
|
@@ -26,7 +26,6 @@ class OpenGl_ShaderProgram;
|
||||
//! The element holding Graphic3d_AspectLine3d.
|
||||
class OpenGl_AspectLine : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_AspectLine, OpenGl_Element)
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
|
@@ -27,8 +27,6 @@
|
||||
#include <NCollection_Vec4.hxx>
|
||||
#include <TColStd_HArray1OfByte.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectMarker, OpenGl_Element)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const TCollection_AsciiString THE_EMPTY_KEY;
|
||||
|
@@ -29,7 +29,6 @@ class OpenGl_ShaderProgram;
|
||||
//! The element holding Graphic3d_AspectMarker3d.
|
||||
class OpenGl_AspectMarker : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_AspectMarker, OpenGl_Element)
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
|
@@ -21,8 +21,6 @@
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
#include <OpenGl_ShaderProgram.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectText, OpenGl_Element)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const TCollection_AsciiString THE_EMPTY_KEY;
|
||||
|
@@ -28,7 +28,7 @@ class OpenGl_ShaderProgram;
|
||||
//! Text representation parameters
|
||||
class OpenGl_AspectText : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_AspectText, OpenGl_Element)
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
|
@@ -24,8 +24,7 @@
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_BVHTreeSelector::OpenGl_BVHTreeSelector()
|
||||
: myClipVerts (0, Graphic3d_Camera::FrustumVerticesNB),
|
||||
myIsProjectionParallel (Standard_True),
|
||||
: myIsProjectionParallel (Standard_True),
|
||||
myCamScale (1.0),
|
||||
myPixelSize (1.0)
|
||||
{
|
||||
@@ -54,37 +53,78 @@ void OpenGl_BVHTreeSelector::SetViewVolume (const Handle(Graphic3d_Camera)& theC
|
||||
? theCamera->Scale()
|
||||
: 2.0 * Tan (theCamera->FOVy() * M_PI / 360.0); // same as theCamera->Scale()/theCamera->Distance()
|
||||
|
||||
// Compute frustum points
|
||||
theCamera->FrustumPoints (myClipVerts);
|
||||
|
||||
// Compute frustum planes
|
||||
// Vertices go in order:
|
||||
// 0, 2, 1
|
||||
const Standard_Integer aLookup1[] = { 0, 1, 0 };
|
||||
const Standard_Integer aLookup2[] = { 0, 0, 1 };
|
||||
Standard_Integer aShifts[] = { 0, 0, 0 };
|
||||
|
||||
// Planes go in order:
|
||||
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
|
||||
for (Standard_Integer aFaceIdx = 0; aFaceIdx < 3; ++aFaceIdx)
|
||||
Standard_Real nLeft = 0.0, nRight = 0.0, nTop = 0.0, nBottom = 0.0;
|
||||
Standard_Real fLeft = 0.0, fRight = 0.0, fTop = 0.0, fBottom = 0.0;
|
||||
Standard_Real aNear = 0.0, aFar = 0.0;
|
||||
if (!myIsProjectionParallel)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < 2; ++i)
|
||||
// handle perspective projection
|
||||
aNear = myProjectionMat.GetValue (2, 3) / (- 1.0 + myProjectionMat.GetValue (2, 2));
|
||||
aFar = myProjectionMat.GetValue (2, 3) / ( 1.0 + myProjectionMat.GetValue (2, 2));
|
||||
// Near plane
|
||||
nLeft = aNear * (myProjectionMat.GetValue (0, 2) - 1.0) / myProjectionMat.GetValue (0, 0);
|
||||
nRight = aNear * (myProjectionMat.GetValue (0, 2) + 1.0) / myProjectionMat.GetValue (0, 0);
|
||||
nTop = aNear * (myProjectionMat.GetValue (1, 2) + 1.0) / myProjectionMat.GetValue (1, 1);
|
||||
nBottom = aNear * (myProjectionMat.GetValue (1, 2) - 1.0) / myProjectionMat.GetValue (1, 1);
|
||||
// Far plane
|
||||
fLeft = aFar * (myProjectionMat.GetValue (0, 2) - 1.0) / myProjectionMat.GetValue (0, 0);
|
||||
fRight = aFar * (myProjectionMat.GetValue (0, 2) + 1.0) / myProjectionMat.GetValue (0, 0);
|
||||
fTop = aFar * (myProjectionMat.GetValue (1, 2) + 1.0) / myProjectionMat.GetValue (1, 1);
|
||||
fBottom = aFar * (myProjectionMat.GetValue (1, 2) - 1.0) / myProjectionMat.GetValue (1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle orthographic projection
|
||||
aNear = (1.0 / myProjectionMat.GetValue (2, 2)) * (myProjectionMat.GetValue (2, 3) + 1.0);
|
||||
aFar = (1.0 / myProjectionMat.GetValue (2, 2)) * (myProjectionMat.GetValue (2, 3) - 1.0);
|
||||
// Near plane
|
||||
nLeft = ( 1.0 + myProjectionMat.GetValue (0, 3)) / (-myProjectionMat.GetValue (0, 0));
|
||||
fLeft = nLeft;
|
||||
nRight = ( 1.0 - myProjectionMat.GetValue (0, 3)) / myProjectionMat.GetValue (0, 0);
|
||||
fRight = nRight;
|
||||
nTop = ( 1.0 - myProjectionMat.GetValue (1, 3)) / myProjectionMat.GetValue (1, 1);
|
||||
fTop = nTop;
|
||||
nBottom = (-1.0 - myProjectionMat.GetValue (1, 3)) / myProjectionMat.GetValue (1, 1);
|
||||
fBottom = nBottom;
|
||||
}
|
||||
|
||||
OpenGl_Vec4d aLeftTopNear (nLeft, nTop, -aNear, 1.0), aRightBottomFar (fRight, fBottom, -aFar, 1.0);
|
||||
OpenGl_Vec4d aLeftBottomNear (nLeft, nBottom, -aNear, 1.0), aRightTopFar (fRight, fTop, -aFar, 1.0);
|
||||
OpenGl_Vec4d aRightBottomNear (nRight, nBottom, -aNear, 1.0), aLeftTopFar (fLeft, fTop, -aFar, 1.0);
|
||||
OpenGl_Vec4d aRightTopNear (nRight, nTop, -aNear, 1.0), aLeftBottomFar (fLeft, fBottom, -aFar, 1.0);
|
||||
|
||||
const OpenGl_Mat4d aViewProj = myProjectionMat * myWorldViewMat;
|
||||
OpenGl_Mat4d anInvWorldView;
|
||||
myWorldViewMat.Inverted (anInvWorldView);
|
||||
|
||||
myClipVerts[ClipVert_LeftTopNear] = anInvWorldView * aLeftTopNear;
|
||||
myClipVerts[ClipVert_RightBottomFar] = anInvWorldView * aRightBottomFar;
|
||||
myClipVerts[ClipVert_LeftBottomNear] = anInvWorldView * aLeftBottomNear;
|
||||
myClipVerts[ClipVert_RightTopFar] = anInvWorldView * aRightTopFar;
|
||||
myClipVerts[ClipVert_RightBottomNear] = anInvWorldView * aRightBottomNear;
|
||||
myClipVerts[ClipVert_LeftTopFar] = anInvWorldView * aLeftTopFar;
|
||||
myClipVerts[ClipVert_RightTopNear] = anInvWorldView * aRightTopNear;
|
||||
myClipVerts[ClipVert_LeftBottomFar] = anInvWorldView * aLeftBottomFar;
|
||||
|
||||
// UNNORMALIZED!
|
||||
myClipPlanes[Plane_Left] = aViewProj.GetRow (3) + aViewProj.GetRow (0);
|
||||
myClipPlanes[Plane_Right] = aViewProj.GetRow (3) - aViewProj.GetRow (0);
|
||||
myClipPlanes[Plane_Top] = aViewProj.GetRow (3) - aViewProj.GetRow (1);
|
||||
myClipPlanes[Plane_Bottom] = aViewProj.GetRow (3) + aViewProj.GetRow (1);
|
||||
myClipPlanes[Plane_Near] = aViewProj.GetRow (3) + aViewProj.GetRow (2);
|
||||
myClipPlanes[Plane_Far] = aViewProj.GetRow (3) - aViewProj.GetRow (2);
|
||||
|
||||
gp_Pnt aPtCenter = theCamera->Center();
|
||||
OpenGl_Vec4d aCenter (aPtCenter.X(), aPtCenter.Y(), aPtCenter.Z(), 1.0);
|
||||
|
||||
for (Standard_Integer aPlaneIter = 0; aPlaneIter < PlanesNB; ++aPlaneIter)
|
||||
{
|
||||
OpenGl_Vec4d anEq = myClipPlanes[aPlaneIter];
|
||||
if (SignedPlanePointDistance (anEq, aCenter) > 0)
|
||||
{
|
||||
OpenGl_Vec3d aPlanePnts[3];
|
||||
for (Standard_Integer aPntIter = 0; aPntIter < 3; ++aPntIter)
|
||||
{
|
||||
aShifts[aFaceIdx] = i;
|
||||
aShifts[(aFaceIdx + 1) % 3] = aLookup1[aPntIter];
|
||||
aShifts[(aFaceIdx + 2) % 3] = aLookup2[aPntIter];
|
||||
|
||||
aPlanePnts[aPntIter] = myClipVerts[aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2]];
|
||||
}
|
||||
|
||||
myClipPlanes[aFaceIdx * 2 + i].Origin = aPlanePnts[0];
|
||||
myClipPlanes[aFaceIdx * 2 + i].Normal =
|
||||
OpenGl_Vec3d::Cross (aPlanePnts[1] - aPlanePnts[0],
|
||||
aPlanePnts[2] - aPlanePnts[0]).Normalized() * (i == 0 ? -1.f : 1.f);
|
||||
}
|
||||
anEq *= -1.0;
|
||||
myClipPlanes[aPlaneIter] = anEq;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,15 +202,17 @@ void OpenGl_BVHTreeSelector::SetCullingSize (CullingContext& theCtx,
|
||||
// =======================================================================
|
||||
void OpenGl_BVHTreeSelector::CacheClipPtsProjections()
|
||||
{
|
||||
// project frustum onto its own normals
|
||||
const Standard_Integer anIncFactor = myIsProjectionParallel ? 2 : 1;
|
||||
for (Standard_Integer aPlaneIter = 0; aPlaneIter < PlanesNB - 1; aPlaneIter += anIncFactor)
|
||||
for (Standard_Integer aPlaneIter = 0; aPlaneIter < 5; aPlaneIter += anIncFactor)
|
||||
{
|
||||
const OpenGl_Vec4d aPlane = myClipPlanes[aPlaneIter];
|
||||
Standard_Real aMaxProj = -std::numeric_limits<Standard_Real>::max();
|
||||
Standard_Real aMinProj = std::numeric_limits<Standard_Real>::max();
|
||||
for (Standard_Integer aCornerIter = 0; aCornerIter < Graphic3d_Camera::FrustumVerticesNB; ++aCornerIter)
|
||||
for (Standard_Integer aCornerIter = 0; aCornerIter < ClipVerticesNB; ++aCornerIter)
|
||||
{
|
||||
Standard_Real aProjection = myClipVerts[aCornerIter].Dot (myClipPlanes[aPlaneIter].Normal);
|
||||
Standard_Real aProjection = aPlane.x() * myClipVerts[aCornerIter].x()
|
||||
+ aPlane.y() * myClipVerts[aCornerIter].y()
|
||||
+ aPlane.z() * myClipVerts[aCornerIter].z();
|
||||
aMaxProj = Max (aProjection, aMaxProj);
|
||||
aMinProj = Min (aProjection, aMinProj);
|
||||
}
|
||||
@@ -178,17 +220,17 @@ void OpenGl_BVHTreeSelector::CacheClipPtsProjections()
|
||||
myMinClipProjectionPts[aPlaneIter] = aMinProj;
|
||||
}
|
||||
|
||||
// project frustum onto main axes
|
||||
OpenGl_Vec3d anAxes[] = { OpenGl_Vec3d (1.0, 0.0, 0.0),
|
||||
OpenGl_Vec3d (0.0, 1.0, 0.0),
|
||||
OpenGl_Vec3d (0.0, 0.0, 1.0) };
|
||||
for (Standard_Integer aDim = 0; aDim < 3; ++aDim)
|
||||
{
|
||||
Standard_Real aMaxProj = -std::numeric_limits<Standard_Real>::max();
|
||||
Standard_Real aMinProj = std::numeric_limits<Standard_Real>::max();
|
||||
for (Standard_Integer aCornerIter = 0; aCornerIter < Graphic3d_Camera::FrustumVerticesNB; ++aCornerIter)
|
||||
for (Standard_Integer aCornerIter = 0; aCornerIter < ClipVerticesNB; ++aCornerIter)
|
||||
{
|
||||
Standard_Real aProjection = myClipVerts[aCornerIter].Dot (anAxes[aDim]);
|
||||
Standard_Real aProjection = aDim == 0
|
||||
? myClipVerts[aCornerIter].x()
|
||||
: (aDim == 1
|
||||
? myClipVerts[aCornerIter].y()
|
||||
: myClipVerts[aCornerIter].z());
|
||||
aMaxProj = Max (aProjection, aMaxProj);
|
||||
aMinProj = Min (aProjection, aMinProj);
|
||||
}
|
||||
|
@@ -35,25 +35,6 @@ public:
|
||||
//! Empty constructor.
|
||||
CullingContext() : DistCull (-1.0), SizeCull2 (-1.0) {}
|
||||
};
|
||||
|
||||
//! Auxiliary structure representing 3D plane.
|
||||
struct Plane
|
||||
{
|
||||
//! Creates default plane.
|
||||
Plane()
|
||||
: Origin (0.0, 0.0, 0.0),
|
||||
Normal (0.0, 0.0, 1.0) {}
|
||||
|
||||
//! Creates plane with specific parameters.
|
||||
Plane (const OpenGl_Vec3d& theOrigin,
|
||||
const OpenGl_Vec3d& theNormal)
|
||||
: Origin (theOrigin),
|
||||
Normal (theNormal) {}
|
||||
|
||||
OpenGl_Vec3d Origin;
|
||||
OpenGl_Vec3d Normal;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Creates an empty selector object with parallel projection type by default.
|
||||
@@ -143,54 +124,46 @@ protected:
|
||||
// /
|
||||
// E2
|
||||
|
||||
// E0 test (x axis)
|
||||
// E0 test
|
||||
if (theMinPt.x() > myMaxOrthoProjectionPts[0]
|
||||
|| theMaxPt.x() < myMinOrthoProjectionPts[0])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// E1 test (y axis)
|
||||
// E1 test
|
||||
if (theMinPt.y() > myMaxOrthoProjectionPts[1]
|
||||
|| theMaxPt.y() < myMinOrthoProjectionPts[1])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// E2 test (z axis)
|
||||
// E2 test
|
||||
if (theMinPt.z() > myMaxOrthoProjectionPts[2]
|
||||
|| theMaxPt.z() < myMinOrthoProjectionPts[2])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Standard_Real aBoxProjMax = 0.0, aBoxProjMin = 0.0;
|
||||
const Standard_Integer anIncFactor = myIsProjectionParallel ? 2 : 1;
|
||||
for (Standard_Integer aPlaneIter = 0; aPlaneIter < PlanesNB - 1; aPlaneIter += anIncFactor)
|
||||
for (Standard_Integer aPlaneIter = 0; aPlaneIter < 5; aPlaneIter += anIncFactor)
|
||||
{
|
||||
// frustum normals
|
||||
const OpenGl_Vec3d anAxis = myClipPlanes[aPlaneIter].Normal;
|
||||
|
||||
const OpenGl_Vec3d aPVertex (anAxis.x() > 0.0 ? theMaxPt.x() : theMinPt.x(),
|
||||
anAxis.y() > 0.0 ? theMaxPt.y() : theMinPt.y(),
|
||||
anAxis.z() > 0.0 ? theMaxPt.z() : theMinPt.z());
|
||||
Standard_Real aPnt0 = aPVertex.Dot (anAxis);
|
||||
|
||||
if (aPnt0 >= myMinClipProjectionPts[aPlaneIter]
|
||||
&& aPnt0 <= myMaxClipProjectionPts[aPlaneIter])
|
||||
OpenGl_Vec4d aPlane = myClipPlanes[aPlaneIter];
|
||||
aBoxProjMax = (aPlane.x() > 0.0 ? (aPlane.x() * theMaxPt.x()) : aPlane.x() * theMinPt.x())
|
||||
+ (aPlane.y() > 0.0 ? (aPlane.y() * theMaxPt.y()) : aPlane.y() * theMinPt.y())
|
||||
+ (aPlane.z() > 0.0 ? (aPlane.z() * theMaxPt.z()) : aPlane.z() * theMinPt.z());
|
||||
if (aBoxProjMax > myMinClipProjectionPts[aPlaneIter]
|
||||
&& aBoxProjMax < myMaxClipProjectionPts[aPlaneIter])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const OpenGl_Vec3d aNVertex (anAxis.x() > 0.0 ? theMinPt.x() : theMaxPt.x(),
|
||||
anAxis.y() > 0.0 ? theMinPt.y() : theMaxPt.y(),
|
||||
anAxis.z() > 0.0 ? theMinPt.z() : theMaxPt.z());
|
||||
Standard_Real aPnt1 = aNVertex.Dot (anAxis);
|
||||
|
||||
const Standard_Real aMin = aPnt0 < aPnt1 ? aPnt0 : aPnt1;
|
||||
const Standard_Real aMax = aPnt0 > aPnt1 ? aPnt0 : aPnt1;
|
||||
|
||||
if (aMin > myMaxClipProjectionPts[aPlaneIter]
|
||||
|| aMax < myMinClipProjectionPts[aPlaneIter])
|
||||
aBoxProjMin = (aPlane.x() < 0.0 ? aPlane.x() * theMaxPt.x() : aPlane.x() * theMinPt.x())
|
||||
+ (aPlane.y() < 0.0 ? aPlane.y() * theMaxPt.y() : aPlane.y() * theMinPt.y())
|
||||
+ (aPlane.z() < 0.0 ? aPlane.z() * theMaxPt.z() : aPlane.z() * theMinPt.z());
|
||||
if (aBoxProjMin > myMaxClipProjectionPts[aPlaneIter]
|
||||
|| aBoxProjMax < myMinClipProjectionPts[aPlaneIter])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -242,24 +215,38 @@ protected:
|
||||
//! Enumerates planes of view volume.
|
||||
enum
|
||||
{
|
||||
Plane_Top,
|
||||
Plane_Bottom,
|
||||
Plane_Left,
|
||||
Plane_Right,
|
||||
Plane_Bottom,
|
||||
Plane_Top,
|
||||
Plane_Near,
|
||||
Plane_Far,
|
||||
PlanesNB
|
||||
};
|
||||
|
||||
//! Enumerates vertices of view volume.
|
||||
enum
|
||||
{
|
||||
ClipVert_LeftTopNear,
|
||||
ClipVert_LeftBottomNear,
|
||||
ClipVert_RightTopNear,
|
||||
ClipVert_RightBottomNear,
|
||||
ClipVert_LeftTopFar,
|
||||
ClipVert_LeftBottomFar,
|
||||
ClipVert_RightTopFar,
|
||||
ClipVert_RightBottomFar,
|
||||
ClipVerticesNB
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
Plane myClipPlanes[PlanesNB]; //!< Planes
|
||||
NCollection_Array1<OpenGl_Vec3d> myClipVerts; //!< Vertices
|
||||
OpenGl_Vec4d myClipPlanes[PlanesNB]; //!< Plane equations
|
||||
OpenGl_Vec4d myClipVerts[ClipVerticesNB]; //!< Vertices
|
||||
|
||||
Handle(Graphic3d_Camera) myCamera; //!< camera definition
|
||||
|
||||
// for caching clip points projections onto viewing area normals once per traverse
|
||||
// ORDER: LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
|
||||
// ORDER: TOP, BOTTOM, LEFT, RIGHT, NEAR, FAR
|
||||
Standard_Real myMaxClipProjectionPts[PlanesNB]; //!< Max view volume's vertices projections onto its normals
|
||||
Standard_Real myMinClipProjectionPts[PlanesNB]; //!< Min view volume's vertices projections onto its normals
|
||||
|
||||
|
@@ -21,8 +21,6 @@
|
||||
#include <OpenGl_View.hxx>
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_BackgroundArray, OpenGl_PrimitiveArray)
|
||||
|
||||
// =======================================================================
|
||||
// method : Constructor
|
||||
// purpose :
|
||||
@@ -339,7 +337,7 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
|
||||
|
||||
// Get texture parameters
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
const Handle(OpenGl_AspectFace)& anAspectFace = theWorkspace->AspectFace();
|
||||
const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace();
|
||||
GLfloat aTextureWidth = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeX();
|
||||
GLfloat aTextureHeight = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeY();
|
||||
|
||||
|
@@ -28,7 +28,6 @@
|
||||
//! gradient or texture background rendering.
|
||||
class OpenGl_BackgroundArray : public OpenGl_PrimitiveArray
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_BackgroundArray, OpenGl_PrimitiveArray)
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
|
@@ -72,7 +72,7 @@ namespace
|
||||
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
|
||||
aContext->ApplyModelViewMatrix();
|
||||
|
||||
thePlane->Primitives()->Render (theWorkspace);
|
||||
thePlane->Primitives().Render (theWorkspace);
|
||||
|
||||
aContext->ModelWorldState.Pop();
|
||||
aContext->ApplyModelViewMatrix();
|
||||
@@ -104,11 +104,11 @@ namespace
|
||||
theStencilSentry.Init();
|
||||
|
||||
// check if capping plane should be rendered within current pass (only opaque / only transparent)
|
||||
const Handle(OpenGl_AspectFace) anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->AspectFace() : NULL;
|
||||
thePlane->Update (aContext, !anObjAspectFace.IsNull() ? anObjAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
|
||||
const OpenGl_AspectFace* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->AspectFace() : NULL;
|
||||
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
|
||||
theWorkspace->SetAspectFace (thePlane->AspectFace());
|
||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||
if (!theWorkspace->ShouldRender (thePlane->Primitives()))
|
||||
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ namespace
|
||||
const bool aColorMaskBack = aContext->SetColorMask (false);
|
||||
|
||||
// override aspects, disable culling
|
||||
theWorkspace->SetAspectFace (theWorkspace->NoneCulling());
|
||||
theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
|
||||
theWorkspace->ApplyAspectFace();
|
||||
|
||||
// evaluate number of pair faces
|
||||
@@ -156,7 +156,7 @@ namespace
|
||||
}
|
||||
|
||||
// override material, cull back faces
|
||||
theWorkspace->SetAspectFace (theWorkspace->FrontCulling());
|
||||
theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
|
||||
theWorkspace->ApplyAspectFace();
|
||||
|
||||
// enable all clip plane except the rendered one
|
||||
@@ -207,7 +207,7 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
}
|
||||
|
||||
// remember current aspect face defined in workspace
|
||||
const Handle(OpenGl_AspectFace)& aFaceAsp = theWorkspace->AspectFace();
|
||||
const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace();
|
||||
|
||||
// only filled primitives should be rendered
|
||||
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
|
||||
|
@@ -63,7 +63,7 @@ namespace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
|
||||
: myPrimitives (new OpenGl_PrimitiveArray(NULL)),
|
||||
: myPrimitives (NULL),
|
||||
myOrientation (OpenGl_IdentityMatrix),
|
||||
myAspect (NULL),
|
||||
myPlaneRoot (thePlane),
|
||||
@@ -82,7 +82,7 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
|
||||
if (anAttribs->Init (12, anAttribInfo, 3))
|
||||
{
|
||||
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
|
||||
myPrimitives->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& ,
|
||||
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
|
||||
{
|
||||
OpenGl_Element::Destroy (theContext, myAspect);
|
||||
myPrimitives->Release (theContext);
|
||||
myPrimitives.Release (theContext);
|
||||
myEquationMod = (unsigned int )-1;
|
||||
myAspectMod = (unsigned int )-1;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
|
||||
{
|
||||
if (myAspect.IsNull())
|
||||
if (myAspect == NULL)
|
||||
{
|
||||
myAspect = new OpenGl_AspectFace();
|
||||
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
|
||||
|
@@ -61,13 +61,13 @@ public:
|
||||
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
|
||||
|
||||
//! @return aspect face for rendering capping surface.
|
||||
inline const Handle(OpenGl_AspectFace)& AspectFace() const { return myAspect; }
|
||||
inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
|
||||
|
||||
//! @return evaluated orientation matrix to transform infinite plane.
|
||||
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
|
||||
|
||||
//! @return primitive array of vertices to render infinite plane.
|
||||
inline const Handle(OpenGl_PrimitiveArray)& Primitives() const { return myPrimitives; }
|
||||
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -79,9 +79,9 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
Handle(OpenGl_PrimitiveArray) myPrimitives; //!< vertices and texture coordinates for rendering
|
||||
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
|
||||
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
|
||||
Handle(OpenGl_AspectFace) myAspect; //!< capping face aspect.
|
||||
OpenGl_AspectFace* myAspect; //!< capping face aspect.
|
||||
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
|
||||
Handle(Graphic3d_AspectFillArea3d) myFillAreaAspect; //!< own capping aspect
|
||||
unsigned int myEquationMod; //!< modification counter for plane equation.
|
||||
|
@@ -544,6 +544,7 @@ Standard_Boolean OpenGl_Context::IsCurrent() const
|
||||
{
|
||||
#if defined(HAVE_EGL)
|
||||
if ((EGLDisplay )myDisplay == EGL_NO_DISPLAY
|
||||
|| (EGLSurface )myWindow == EGL_NO_SURFACE
|
||||
|| (EGLContext )myGContext == EGL_NO_CONTEXT)
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -579,6 +580,7 @@ Standard_Boolean OpenGl_Context::MakeCurrent()
|
||||
{
|
||||
#if defined(HAVE_EGL)
|
||||
if ((EGLDisplay )myDisplay == EGL_NO_DISPLAY
|
||||
|| (EGLSurface )myWindow == EGL_NO_SURFACE
|
||||
|| (EGLContext )myGContext == EGL_NO_CONTEXT)
|
||||
{
|
||||
Standard_ProgramError_Raise_if (myIsInitialized, "OpenGl_Context::Init() should be called before!");
|
||||
@@ -3165,7 +3167,7 @@ Handle(OpenGl_FrameBuffer) OpenGl_Context::SetDefaultFrameBuffer (const Handle(O
|
||||
// function : SetShadingMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Context::SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAspect,
|
||||
void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
|
||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
|
||||
{
|
||||
const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
|
||||
@@ -3237,7 +3239,7 @@ void OpenGl_Context::SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAsp
|
||||
// function : CheckIsTransparent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Context::CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
|
||||
Standard_Boolean OpenGl_Context::CheckIsTransparent (const OpenGl_AspectFace* theAspect,
|
||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
|
||||
Standard_ShortReal& theAlphaFront,
|
||||
Standard_ShortReal& theAlphaBack)
|
||||
|
@@ -696,17 +696,17 @@ public: //! @name methods to alter or retrieve current state
|
||||
Standard_EXPORT Standard_Boolean BindProgram (const Handle(OpenGl_ShaderProgram)& theProgram);
|
||||
|
||||
//! Setup current shading material.
|
||||
Standard_EXPORT void SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAspect,
|
||||
Standard_EXPORT void SetShadingMaterial (const OpenGl_AspectFace* theAspect,
|
||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight);
|
||||
|
||||
//! Checks if transparency is required for the given aspect and highlight style.
|
||||
Standard_EXPORT static Standard_Boolean CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
|
||||
Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
|
||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
|
||||
Standard_ShortReal& theAlphaFront,
|
||||
Standard_ShortReal& theAlphaBack);
|
||||
|
||||
//! Checks if transparency is required for the given aspect and highlight style.
|
||||
static Standard_Boolean CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
|
||||
static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
|
||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
|
||||
{
|
||||
Standard_ShortReal anAlphaFront = 1.0f, anAlphaBack = 1.0f;
|
||||
|
@@ -15,8 +15,6 @@
|
||||
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Element, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_Element
|
||||
// purpose :
|
||||
|
@@ -23,9 +23,8 @@ class OpenGl_Workspace;
|
||||
class OpenGl_Context;
|
||||
|
||||
//! Base interface for drawable elements.
|
||||
class OpenGl_Element : public Standard_Transient
|
||||
class OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_Element, Standard_Transient)
|
||||
public:
|
||||
|
||||
Standard_EXPORT OpenGl_Element();
|
||||
@@ -41,14 +40,18 @@ public:
|
||||
//! Pointer to the context is used because this method might be called
|
||||
//! when the context is already being destroyed and usage of a handle
|
||||
//! would be unsafe
|
||||
template <typename theResource_t>
|
||||
static void Destroy (OpenGl_Context* theContext,
|
||||
Handle(OpenGl_Element)& theElement)
|
||||
theResource_t*& theElement)
|
||||
{
|
||||
if (theElement.IsNull())
|
||||
if (theElement == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
theElement->Release (theContext);
|
||||
OpenGl_Element* anElement = theElement;
|
||||
delete anElement;
|
||||
theElement = NULL;
|
||||
}
|
||||
|
||||
|
@@ -22,8 +22,6 @@
|
||||
|
||||
#include <gp_Ax2.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Flipper, OpenGl_Element)
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
|
@@ -27,7 +27,6 @@ class gp_Ax2;
|
||||
//! Originally, this element serves for need of flipping the 3D text of dimension presentations.
|
||||
class OpenGl_Flipper : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_Flipper, OpenGl_Element)
|
||||
public:
|
||||
|
||||
//! Construct rendering element to flip model-view matrix
|
||||
|
@@ -203,10 +203,9 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
const OpenGl_Group* aGroup = aGroupIter.Value();
|
||||
for (OpenGl_ElementNodes::Iterator anElemIterator (aGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
||||
for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
||||
{
|
||||
Handle(OpenGl_PrimitiveArray) aPrim = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
|
||||
if (!aPrim.IsNull())
|
||||
if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
|
||||
{
|
||||
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
|
||||
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
|
||||
@@ -226,10 +225,9 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
const OpenGl_Group* aGroup = aGroupIter.Value();
|
||||
for (OpenGl_ElementNodes::Iterator anElemIterator (aGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
||||
for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
||||
{
|
||||
Handle(OpenGl_PrimitiveArray) aPrim = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
|
||||
if (!aPrim.IsNull())
|
||||
if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
|
||||
{
|
||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
|
||||
if (theToCountMem)
|
||||
@@ -313,8 +311,9 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
|
||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsLineNotCulled];
|
||||
}
|
||||
}
|
||||
else if (!Handle(OpenGl_Text)::DownCast(anElemIterator.Value()).IsNull())
|
||||
else if (const OpenGl_Text* aText = dynamic_cast<const OpenGl_Text*> (aNodeIter->elem))
|
||||
{
|
||||
(void )aText;
|
||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
|
||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsTextNotCulled];
|
||||
}
|
||||
|
@@ -19,8 +19,6 @@
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_FrameStatsPrs, OpenGl_Element)
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Auxiliary structure defining vertex with two attributes.
|
||||
@@ -52,11 +50,7 @@ OpenGl_FrameStatsPrs::OpenGl_FrameStatsPrs()
|
||||
myChartIndices (new OpenGl_IndexBuffer()),
|
||||
myChartLines (new OpenGl_VertexBuffer())
|
||||
{
|
||||
myCountersText = new OpenGl_Text();
|
||||
myTextAspect = new OpenGl_AspectText();
|
||||
myChartLabels[0] = new OpenGl_Text();
|
||||
myChartLabels[1] = new OpenGl_Text();
|
||||
myChartLabels[2] = new OpenGl_Text();
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -74,10 +68,10 @@ OpenGl_FrameStatsPrs::~OpenGl_FrameStatsPrs()
|
||||
// =======================================================================
|
||||
void OpenGl_FrameStatsPrs::Release (OpenGl_Context* theCtx)
|
||||
{
|
||||
myCountersText->Release (theCtx);
|
||||
myChartLabels[0]->Release (theCtx);
|
||||
myChartLabels[1]->Release (theCtx);
|
||||
myChartLabels[2]->Release (theCtx);
|
||||
myCountersText.Release (theCtx);
|
||||
myChartLabels[0].Release (theCtx);
|
||||
myChartLabels[1].Release (theCtx);
|
||||
myChartLabels[2].Release (theCtx);
|
||||
myChartVertices->Release (theCtx);
|
||||
myChartIndices->Release (theCtx);
|
||||
myChartLines->Release (theCtx);
|
||||
@@ -94,7 +88,7 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
|
||||
const Graphic3d_RenderingParams& aRendParams = theWorkspace->View()->RenderingParams();
|
||||
myCountersTrsfPers = theWorkspace->View()->RenderingParams().StatsPosition;
|
||||
myChartTrsfPers = theWorkspace->View()->RenderingParams().ChartPosition;
|
||||
myTextAspect->SetAspect (aRendParams.StatsTextAspect);
|
||||
myTextAspect.SetAspect (aRendParams.StatsTextAspect);
|
||||
|
||||
// adjust text alignment depending on corner
|
||||
OpenGl_TextParam aParams;
|
||||
@@ -117,21 +111,21 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
|
||||
{
|
||||
aParams.VAlign = Graphic3d_VTA_BOTTOM;
|
||||
}
|
||||
if (aParams.Height != myCountersText->FormatParams().Height
|
||||
|| aParams.HAlign != myCountersText->FormatParams().HAlign
|
||||
|| aParams.VAlign != myCountersText->FormatParams().VAlign)
|
||||
if (aParams.Height != myCountersText.FormatParams().Height
|
||||
|| aParams.HAlign != myCountersText.FormatParams().HAlign
|
||||
|| aParams.VAlign != myCountersText.FormatParams().VAlign)
|
||||
{
|
||||
myCountersText->Release (aCtx.operator->());
|
||||
myCountersText.Release (aCtx.operator->());
|
||||
}
|
||||
|
||||
if (!aStats->IsFrameUpdated (myStatsPrev)
|
||||
&& !myCountersText->Text().IsEmpty())
|
||||
&& !myCountersText.Text().IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats);
|
||||
myCountersText->Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
|
||||
myCountersText.Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
|
||||
|
||||
updateChart (theWorkspace);
|
||||
}
|
||||
@@ -347,9 +341,9 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
|
||||
const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT
|
||||
? float(anOffset.x())
|
||||
: float(anOffset.x() + aCharSize.x());
|
||||
myChartLabels[0]->Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f), aParams);
|
||||
myChartLabels[1]->Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
|
||||
myChartLabels[2]->Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f), aParams);
|
||||
myChartLabels[0].Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f), aParams);
|
||||
myChartLabels[1].Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
|
||||
myChartLabels[2].Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f), aParams);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,8 +361,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
|
||||
glDepthMask (GL_FALSE);
|
||||
}
|
||||
|
||||
const Handle(OpenGl_AspectText)& aTextAspectBack = theWorkspace->AspectText();
|
||||
theWorkspace->SetAspectText (myTextAspect);
|
||||
const OpenGl_AspectText* aTextAspectBack = theWorkspace->SetAspectText (&myTextAspect);
|
||||
|
||||
aCtx->ModelWorldState.Push();
|
||||
aCtx->ModelWorldState.ChangeCurrent().InitIdentity();
|
||||
@@ -383,7 +376,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
|
||||
aCtx->VirtualViewport()[2], aCtx->VirtualViewport()[3]);
|
||||
}
|
||||
aCtx->ApplyModelViewMatrix();
|
||||
myCountersText->Render (theWorkspace);
|
||||
myCountersText.Render (theWorkspace);
|
||||
aCtx->WorldViewState.Pop();
|
||||
}
|
||||
|
||||
@@ -426,9 +419,9 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
|
||||
myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_COLOR);
|
||||
myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_POS);
|
||||
|
||||
myChartLabels[0]->Render (theWorkspace);
|
||||
myChartLabels[1]->Render (theWorkspace);
|
||||
myChartLabels[2]->Render (theWorkspace);
|
||||
myChartLabels[0].Render (theWorkspace);
|
||||
myChartLabels[1].Render (theWorkspace);
|
||||
myChartLabels[2].Render (theWorkspace);
|
||||
|
||||
aCtx->WorldViewState.Pop();
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ class OpenGl_VertexBuffer;
|
||||
//! Element rendering frame statistics.
|
||||
class OpenGl_FrameStatsPrs : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_FrameStatsPrs, OpenGl_Element)
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
@@ -44,7 +43,7 @@ public:
|
||||
Standard_EXPORT void Update (const Handle(OpenGl_Workspace)& theWorkspace);
|
||||
|
||||
//! Assign text aspect.
|
||||
void SetTextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect->SetAspect (theAspect); }
|
||||
void SetTextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect.SetAspect (theAspect); }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -55,14 +54,14 @@ protected:
|
||||
|
||||
Handle(OpenGl_FrameStats) myStatsPrev; //!< currently displayed stats
|
||||
Handle(Graphic3d_TransformPers) myCountersTrsfPers; //!< transformation persistence for counters presentation
|
||||
Handle(OpenGl_Text) myCountersText; //!< counters presentation
|
||||
Handle(OpenGl_AspectText) myTextAspect; //!< text aspect
|
||||
OpenGl_Text myCountersText; //!< counters presentation
|
||||
OpenGl_AspectText myTextAspect; //!< text aspect
|
||||
Handle(Graphic3d_TransformPers) myChartTrsfPers; //!< transformation persistence for chart presentation
|
||||
Handle(Graphic3d_ArrayOfTriangles) myChartArray; //!< array of chart triangles
|
||||
Handle(OpenGl_VertexBuffer) myChartVertices; //!< VBO with chart triangles
|
||||
Handle(OpenGl_IndexBuffer) myChartIndices; //!< VBO with chart triangle indexes
|
||||
Handle(OpenGl_VertexBuffer) myChartLines; //!< array of chart lines
|
||||
Handle(OpenGl_Text) myChartLabels[3]; //!< chart labels
|
||||
OpenGl_Text myChartLabels[3]; //!< chart labels
|
||||
|
||||
};
|
||||
|
||||
|
@@ -32,8 +32,6 @@
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraduatedTrihedron, OpenGl_Element)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const OpenGl_TextParam THE_LABEL_PARAMS =
|
||||
@@ -51,11 +49,7 @@ OpenGl_GraduatedTrihedron::OpenGl_GraduatedTrihedron()
|
||||
myMax (100.0f, 100.0f, 100.0f),
|
||||
myIsInitialized (Standard_False)
|
||||
{
|
||||
myGridLineAspect = new OpenGl_AspectLine();
|
||||
|
||||
myLabelValues = new OpenGl_Text();
|
||||
myAspectLabels = new OpenGl_AspectText();
|
||||
myAspectValues = new OpenGl_AspectText();
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -86,7 +80,7 @@ void OpenGl_GraduatedTrihedron::Release (OpenGl_Context* theCtx)
|
||||
myAxes[0].Release (theCtx);
|
||||
myAxes[1].Release (theCtx);
|
||||
myAxes[2].Release (theCtx);
|
||||
myLabelValues->Release (theCtx);
|
||||
myLabelValues.Release (theCtx);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -98,7 +92,7 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t
|
||||
myAxes[0].Release (theCtx.operator->());
|
||||
myAxes[1].Release (theCtx.operator->());
|
||||
myAxes[2].Release (theCtx.operator->());
|
||||
myLabelValues->Release (theCtx.operator->());
|
||||
myLabelValues.Release (theCtx.operator->());
|
||||
|
||||
// Initialize text label parameters for x, y, and z axes
|
||||
myAxes[0] = Axis (myData.XAxisAspect(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
|
||||
@@ -111,19 +105,19 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t
|
||||
myAxes[2].InitArrow (theCtx, myData.ArrowsLength(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
|
||||
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
|
||||
{
|
||||
myAxes[anIt].Label->SetFontSize (theCtx, myData.NamesSize());
|
||||
myAxes[anIt].Label.SetFontSize (theCtx, myData.NamesSize());
|
||||
}
|
||||
|
||||
myLabelValues->SetFontSize (theCtx, myData.ValuesSize());
|
||||
myLabelValues.SetFontSize (theCtx, myData.ValuesSize());
|
||||
|
||||
myAspectLabels->Aspect()->SetTextFontAspect (myData.NamesFontAspect());
|
||||
myAspectLabels->Aspect()->SetFont (myData.NamesFont());
|
||||
myAspectLabels.Aspect()->SetTextFontAspect (myData.NamesFontAspect());
|
||||
myAspectLabels.Aspect()->SetFont (myData.NamesFont());
|
||||
|
||||
myAspectValues->Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
|
||||
myAspectValues->Aspect()->SetFont (myData.ValuesFont());
|
||||
myAspectValues.Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
|
||||
myAspectValues.Aspect()->SetFont (myData.ValuesFont());
|
||||
|
||||
// Grid aspect
|
||||
myGridLineAspect->Aspect()->SetColor (myData.GridColor());
|
||||
myGridLineAspect.Aspect()->SetColor (myData.GridColor());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -332,7 +326,7 @@ Standard_ExtCharacter OpenGl_GraduatedTrihedron::getGridAxes (const Standard_Sho
|
||||
// function : renderLine
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_GraduatedTrihedron::renderLine (const Handle(OpenGl_PrimitiveArray)& theLine,
|
||||
void OpenGl_GraduatedTrihedron::renderLine (const OpenGl_PrimitiveArray& theLine,
|
||||
const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const OpenGl_Mat4& theMat,
|
||||
const Standard_ShortReal theXt,
|
||||
@@ -344,7 +338,7 @@ void OpenGl_GraduatedTrihedron::renderLine (const Handle(OpenGl_PrimitiveArray)&
|
||||
Graphic3d_TransformUtils::Translate (aMat, theXt, theYt, theZt);
|
||||
aContext->WorldViewState.SetCurrent (aMat);
|
||||
aContext->ApplyWorldViewMatrix();
|
||||
theLine->Render (theWorkspace);
|
||||
theLine.Render (theWorkspace);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -391,7 +385,7 @@ void OpenGl_GraduatedTrihedron::renderGridPlane (const Handle(OpenGl_Workspace)&
|
||||
Graphic3d_TransformUtils::Translate (aMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
|
||||
aContext->WorldViewState.SetCurrent (aMat);
|
||||
aContext->ApplyWorldViewMatrix();
|
||||
anAxis.Line->Render (theWorkspace);
|
||||
anAxis.Line.Render (theWorkspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,7 +400,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
|
||||
{
|
||||
const Axis& anAxis = myAxes[theIndex];
|
||||
|
||||
theWorkspace->SetAspectLine (anAxis.LineAspect);
|
||||
theWorkspace->SetAspectLine (&anAxis.LineAspect);
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
|
||||
// Reset transformations
|
||||
@@ -428,7 +422,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
|
||||
aContext->ModelWorldState.SetCurrent (aTransMode.Compute (theWorkspace->View()->Camera(), aProjection, aWorldView, aWidth, aHeight));
|
||||
aContext->ApplyModelViewMatrix();
|
||||
|
||||
anAxis.Arrow->Render (theWorkspace);
|
||||
anAxis.Arrow.Render (theWorkspace);
|
||||
|
||||
// Get current Model-View and Projection states
|
||||
OpenGl_Mat4 aModelMat;
|
||||
@@ -463,7 +457,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
|
||||
|
||||
aContext->WorldViewState.SetCurrent (aModelMat);
|
||||
aContext->ApplyWorldViewMatrix();
|
||||
anAxis.Line->Render (theWorkspace);
|
||||
anAxis.Line.Render (theWorkspace);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -493,7 +487,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
||||
|
||||
if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0)
|
||||
{
|
||||
theWorkspace->SetAspectLine (myGridLineAspect);
|
||||
theWorkspace->SetAspectLine (&myGridLineAspect);
|
||||
|
||||
OpenGl_Mat4 aModelMat (theMat);
|
||||
|
||||
@@ -506,7 +500,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
||||
OpenGl_Vec3 aStepVec = anAxis.Direction * aStep;
|
||||
for (Standard_Integer anIter = 0; anIter <= aCurAspect.TickmarksNumber(); ++anIter)
|
||||
{
|
||||
anAxis.Tickmark->Render (theWorkspace);
|
||||
anAxis.Tickmark.Render (theWorkspace);
|
||||
Graphic3d_TransformUtils::Translate (aModelMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
|
||||
aContext->WorldViewState.SetCurrent (aModelMat);
|
||||
aContext->ApplyWorldViewMatrix();
|
||||
@@ -523,24 +517,24 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
||||
|
||||
OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset));
|
||||
|
||||
myAspectLabels->Aspect()->SetColor (anAxis.NameColor);
|
||||
theWorkspace->SetAspectText (myAspectLabels);
|
||||
anAxis.Label->SetPosition (aMiddle);
|
||||
anAxis.Label->Render (theWorkspace);
|
||||
myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
|
||||
theWorkspace->SetAspectText (&myAspectLabels);
|
||||
anAxis.Label.SetPosition (aMiddle);
|
||||
anAxis.Label.Render (theWorkspace);
|
||||
}
|
||||
|
||||
if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0)
|
||||
{
|
||||
myAspectValues->Aspect()->SetColor (anAxis.LineAspect->Aspect()->Color());
|
||||
theWorkspace->SetAspectText (myAspectValues);
|
||||
myAspectValues.Aspect()->SetColor (anAxis.LineAspect.Aspect()->Color());
|
||||
theWorkspace->SetAspectText (&myAspectValues);
|
||||
Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength();
|
||||
|
||||
for (Standard_Integer anIt = 0; anIt <= aCurAspect.TickmarksNumber(); ++anIt)
|
||||
{
|
||||
sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep);
|
||||
OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset));
|
||||
myLabelValues->Init (theWorkspace->GetGlContext(), aTextValue, aPos);
|
||||
myLabelValues->Render (theWorkspace);
|
||||
myLabelValues.Init (theWorkspace->GetGlContext(), aTextValue, aPos);
|
||||
myLabelValues.Render (theWorkspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -565,9 +559,9 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
|
||||
if (myData.CubicAxesCallback)
|
||||
{
|
||||
myData.CubicAxesCallback (myData.PtrView);
|
||||
if (!myAxes[0].Line->IsInitialized()
|
||||
|| !myAxes[1].Line->IsInitialized()
|
||||
|| !myAxes[2].Line->IsInitialized()
|
||||
if (!myAxes[0].Line.IsInitialized()
|
||||
|| !myAxes[1].Line.IsInitialized()
|
||||
|| !myAxes[2].Line.IsInitialized()
|
||||
|| OpenGl_Vec3 (anOldMin - myMin).Modulus() > Precision::Confusion()
|
||||
|| OpenGl_Vec3 (anOldMax - myMax).Modulus() > Precision::Confusion())
|
||||
{
|
||||
@@ -611,8 +605,8 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
|
||||
Standard_ExtCharacter anAxesState = getGridAxes (aCorners, aGridAxes);
|
||||
|
||||
// Remember current aspects
|
||||
const Handle(OpenGl_AspectLine)& anOldAspectLine = theWorkspace->AspectLine();
|
||||
const Handle(OpenGl_AspectText)& anOldAspectText = theWorkspace->AspectText();
|
||||
const OpenGl_AspectLine* anOldAspectLine = theWorkspace->AspectLine();
|
||||
const OpenGl_AspectText* anOldAspectText = theWorkspace->AspectText();
|
||||
|
||||
OpenGl_Mat4 aModelMatrix;
|
||||
aModelMatrix.Convert (aContext->WorldViewState.Current());
|
||||
@@ -624,7 +618,7 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
|
||||
|
||||
if (myData.ToDrawGrid())
|
||||
{
|
||||
theWorkspace->SetAspectLine (myGridLineAspect);
|
||||
theWorkspace->SetAspectLine (&myGridLineAspect);
|
||||
|
||||
// render grid edges
|
||||
if (anAxesState & XOO_XYO)
|
||||
@@ -720,14 +714,13 @@ void OpenGl_GraduatedTrihedron::SetMinMax (const OpenGl_Vec3& theMin, const Open
|
||||
OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
|
||||
const OpenGl_Vec3& theDirection)
|
||||
: Direction (theDirection),
|
||||
Label (new OpenGl_Text(NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS)),
|
||||
Tickmark (new OpenGl_PrimitiveArray (NULL)),
|
||||
Line (new OpenGl_PrimitiveArray (NULL)),
|
||||
Arrow (new OpenGl_PrimitiveArray (NULL))
|
||||
Label (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS),
|
||||
Tickmark (NULL),
|
||||
Line (NULL),
|
||||
Arrow (NULL)
|
||||
{
|
||||
NameColor = theAspect.NameColor();
|
||||
LineAspect = new OpenGl_AspectLine();
|
||||
LineAspect->Aspect()->SetColor (theAspect.Color());
|
||||
LineAspect.Aspect()->SetColor (theAspect.Color());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -750,9 +743,9 @@ OpenGl_GraduatedTrihedron::Axis& OpenGl_GraduatedTrihedron::Axis::operator= (con
|
||||
LineAspect = theOther.LineAspect;
|
||||
Label = theOther.Label;
|
||||
|
||||
Line ->InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Line->Indices(), theOther.Line->Attributes(), theOther.Line->Bounds());
|
||||
Tickmark->InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Tickmark->Indices(), theOther.Tickmark->Attributes(), theOther.Tickmark->Bounds());
|
||||
Arrow ->InitBuffers (NULL, Graphic3d_TOPA_POLYLINES, theOther.Arrow->Indices(), theOther.Arrow->Attributes(), theOther.Arrow->Bounds());
|
||||
Line .InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Line.Indices(), theOther.Line.Attributes(), theOther.Line.Bounds());
|
||||
Tickmark.InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Tickmark.Indices(), theOther.Tickmark.Attributes(), theOther.Tickmark.Bounds());
|
||||
Arrow .InitBuffers (NULL, Graphic3d_TOPA_POLYLINES, theOther.Arrow.Indices(), theOther.Arrow.Attributes(), theOther.Arrow.Bounds());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -787,8 +780,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitArrow (const Handle(OpenGl_Context)& t
|
||||
anArray->AddVertex (aPoint3);
|
||||
anArray->AddVertex (aPoint1);
|
||||
|
||||
Arrow->InitBuffers (theContext, Graphic3d_TOPA_POLYLINES,
|
||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||
Arrow.InitBuffers (theContext, Graphic3d_TOPA_POLYLINES,
|
||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -802,8 +795,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitTickmark (const Handle(OpenGl_Context)
|
||||
Handle(Graphic3d_ArrayOfSegments) anArray = new Graphic3d_ArrayOfSegments (2);
|
||||
anArray->AddVertex (0.0f, 0.0f, 0.0f);
|
||||
anArray->AddVertex (theDir);
|
||||
Tickmark->InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
|
||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||
Tickmark.InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
|
||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||
|
||||
}
|
||||
|
||||
@@ -819,8 +812,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitLine (const Handle(OpenGl_Context)& th
|
||||
anArray->AddVertex (0.0f, 0.0f, 0.0f);
|
||||
anArray->AddVertex (theDir);
|
||||
|
||||
Line->InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
|
||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||
Line.InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
|
||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -829,8 +822,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitLine (const Handle(OpenGl_Context)& th
|
||||
// =======================================================================
|
||||
void OpenGl_GraduatedTrihedron::Axis::Release (OpenGl_Context* theCtx)
|
||||
{
|
||||
Label ->Release (theCtx);
|
||||
Tickmark->Release (theCtx);
|
||||
Line ->Release (theCtx);
|
||||
Arrow ->Release (theCtx);
|
||||
Label .Release (theCtx);
|
||||
Tickmark.Release (theCtx);
|
||||
Line .Release (theCtx);
|
||||
Arrow .Release (theCtx);
|
||||
}
|
||||
|
@@ -34,7 +34,6 @@ class OpenGl_View;
|
||||
//! @sa Graphic3d_GraduatedTrihedron
|
||||
class OpenGl_GraduatedTrihedron : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_GraduatedTrihedron, OpenGl_Element)
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
@@ -71,11 +70,11 @@ private:
|
||||
|
||||
OpenGl_Vec3 Direction;
|
||||
Quantity_Color NameColor;
|
||||
Handle(OpenGl_AspectLine) LineAspect;
|
||||
mutable Handle(OpenGl_Text) Label;
|
||||
mutable Handle(OpenGl_PrimitiveArray) Tickmark;
|
||||
mutable Handle(OpenGl_PrimitiveArray) Line;
|
||||
mutable Handle(OpenGl_PrimitiveArray) Arrow;
|
||||
OpenGl_AspectLine LineAspect;
|
||||
mutable OpenGl_Text Label;
|
||||
mutable OpenGl_PrimitiveArray Tickmark;
|
||||
mutable OpenGl_PrimitiveArray Line;
|
||||
mutable OpenGl_PrimitiveArray Arrow;
|
||||
|
||||
public:
|
||||
|
||||
@@ -166,7 +165,7 @@ private:
|
||||
//! @param thaTx the X for vector of translation
|
||||
//! @param thaTy the Y for vector of translation
|
||||
//! @param thaTz the Z for vector of translation
|
||||
void renderLine (const Handle(OpenGl_PrimitiveArray)& theLine,
|
||||
void renderLine (const OpenGl_PrimitiveArray& theLine,
|
||||
const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const OpenGl_Mat4& theMat,
|
||||
const Standard_ShortReal theXt,
|
||||
@@ -216,13 +215,13 @@ protected:
|
||||
|
||||
mutable Axis myAxes[3]; //!< Axes for trihedron
|
||||
mutable Graphic3d_GraduatedTrihedron myData;
|
||||
mutable Handle(OpenGl_AspectLine) myGridLineAspect; //!< Color grid properties
|
||||
mutable OpenGl_AspectLine myGridLineAspect; //!< Color grid properties
|
||||
|
||||
protected: //! @name Labels properties
|
||||
|
||||
mutable Handle(OpenGl_Text) myLabelValues;
|
||||
mutable Handle(OpenGl_AspectText) myAspectLabels;
|
||||
mutable Handle(OpenGl_AspectText) myAspectValues;
|
||||
mutable OpenGl_Text myLabelValues;
|
||||
mutable OpenGl_AspectText myAspectLabels;
|
||||
mutable OpenGl_AspectText myAspectValues;
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -55,45 +55,6 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriver,Graphic3d_GraphicDriver)
|
||||
namespace
|
||||
{
|
||||
static const Handle(OpenGl_Context) TheNullGlCtx;
|
||||
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
//! Wrapper over eglChooseConfig() called with preferred defaults.
|
||||
static EGLConfig chooseEglSurfConfig (EGLDisplay theDisplay)
|
||||
{
|
||||
EGLint aConfigAttribs[] =
|
||||
{
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_DEPTH_SIZE, 24,
|
||||
EGL_STENCIL_SIZE, 8,
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
#else
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
#endif
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
EGLConfig aCfg = NULL;
|
||||
EGLint aNbConfigs = 0;
|
||||
if (eglChooseConfig (theDisplay, aConfigAttribs, &aCfg, 1, &aNbConfigs) == EGL_TRUE
|
||||
|| aCfg != NULL)
|
||||
{
|
||||
return aCfg;
|
||||
}
|
||||
|
||||
eglGetError();
|
||||
aConfigAttribs[4 * 2 + 1] = 16; // try config with smaller depth buffer
|
||||
if (eglChooseConfig (theDisplay, aConfigAttribs, &aCfg, 1, &aNbConfigs) != EGL_TRUE
|
||||
|| aCfg == NULL)
|
||||
{
|
||||
eglGetError();
|
||||
}
|
||||
return aCfg;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -338,11 +299,34 @@ Standard_Boolean OpenGl_GraphicDriver::InitContext()
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myEglConfig = chooseEglSurfConfig ((EGLDisplay )myEglDisplay);
|
||||
if (myEglConfig == NULL)
|
||||
EGLint aConfigAttribs[] =
|
||||
{
|
||||
::Message::DefaultMessenger()->Send ("Error: EGL does not provide compatible configurations!", Message_Fail);
|
||||
return Standard_False;
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_DEPTH_SIZE, 24,
|
||||
EGL_STENCIL_SIZE, 8,
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
#else
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
#endif
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
EGLint aNbConfigs = 0;
|
||||
if (eglChooseConfig ((EGLDisplay )myEglDisplay, aConfigAttribs, &myEglConfig, 1, &aNbConfigs) != EGL_TRUE
|
||||
|| myEglConfig == NULL)
|
||||
{
|
||||
eglGetError();
|
||||
aConfigAttribs[4 * 2 + 1] = 16; // try config with smaller depth buffer
|
||||
if (eglChooseConfig ((EGLDisplay )myEglDisplay, aConfigAttribs, &myEglConfig, 1, &aNbConfigs) != EGL_TRUE
|
||||
|| myEglConfig == NULL)
|
||||
{
|
||||
::Message::DefaultMessenger()->Send ("Error: EGL does not provide compatible configurations!", Message_Fail);
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
@@ -400,22 +384,14 @@ Standard_Boolean OpenGl_GraphicDriver::InitEglContext (Aspect_Display t
|
||||
#endif
|
||||
|
||||
if ((EGLDisplay )theEglDisplay == EGL_NO_DISPLAY
|
||||
|| (EGLContext )theEglContext == EGL_NO_CONTEXT)
|
||||
|| (EGLContext )theEglContext == EGL_NO_CONTEXT
|
||||
|| theEglConfig == NULL)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
myEglDisplay = theEglDisplay;
|
||||
myEglContext = theEglContext;
|
||||
myEglConfig = theEglConfig;
|
||||
if (theEglConfig == NULL)
|
||||
{
|
||||
myEglConfig = chooseEglSurfConfig ((EGLDisplay )myEglDisplay);
|
||||
if (myEglConfig == NULL)
|
||||
{
|
||||
::Message::DefaultMessenger()->Send ("Error: EGL does not provide compatible configurations!", Message_Fail);
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
#endif
|
||||
@@ -560,8 +536,8 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
|
||||
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
|
||||
OpenGl_TextParam aTextParam;
|
||||
aTextParam.Height = (int )aHeight;
|
||||
Handle(OpenGl_AspectText) aTextAspect = new OpenGl_AspectText();
|
||||
aTextAspect->Aspect()->SetSpace (0.3);
|
||||
OpenGl_AspectText aTextAspect;
|
||||
aTextAspect.Aspect()->SetSpace (0.3);
|
||||
TCollection_ExtendedString anExtText = theText;
|
||||
NCollection_String aText (anExtText.ToExtString());
|
||||
OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
|
||||
|
@@ -40,7 +40,7 @@ namespace
|
||||
//! should be rendered or not.
|
||||
//! @return True if element passes the check and renders,
|
||||
static bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const Handle(OpenGl_Element)& theElement)
|
||||
OpenGl_Element* theElement)
|
||||
{
|
||||
if (!theWorkspace->ShouldRender (theElement))
|
||||
{
|
||||
@@ -58,6 +58,12 @@ namespace
|
||||
// =======================================================================
|
||||
OpenGl_Group::OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct)
|
||||
: Graphic3d_Group (theStruct),
|
||||
myAspectLine(NULL),
|
||||
myAspectFace(NULL),
|
||||
myAspectMarker(NULL),
|
||||
myAspectText(NULL),
|
||||
myFirst(NULL),
|
||||
myLast(NULL),
|
||||
myIsRaytracable (Standard_False)
|
||||
{
|
||||
Handle(OpenGl_Structure) aStruct = Handle(OpenGl_Structure)::DownCast (myStructure->CStructure());
|
||||
@@ -87,7 +93,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspectLine.IsNull())
|
||||
if (myAspectLine == NULL)
|
||||
{
|
||||
myAspectLine = new OpenGl_AspectLine (theAspect);
|
||||
}
|
||||
@@ -104,7 +110,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
|
||||
// =======================================================================
|
||||
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
|
||||
{
|
||||
if (myAspectLine.IsNull())
|
||||
if (myAspectLine == NULL)
|
||||
{
|
||||
SetGroupPrimitivesAspect (theAspect);
|
||||
return;
|
||||
@@ -114,7 +120,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& th
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(OpenGl_AspectLine) anAspectLine = new OpenGl_AspectLine (theAspect);
|
||||
OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine (theAspect);
|
||||
AddElement (anAspectLine);
|
||||
Update();
|
||||
}
|
||||
@@ -130,7 +136,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillAr
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspectFace.IsNull())
|
||||
if (myAspectFace == NULL)
|
||||
{
|
||||
myAspectFace = new OpenGl_AspectFace (theAspect);
|
||||
}
|
||||
@@ -157,7 +163,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillAr
|
||||
// =======================================================================
|
||||
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
||||
{
|
||||
if (myAspectFace.IsNull())
|
||||
if (myAspectFace == NULL)
|
||||
{
|
||||
SetGroupPrimitivesAspect (theAspect);
|
||||
return;
|
||||
@@ -167,7 +173,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(OpenGl_AspectFace) anAspectFace = new OpenGl_AspectFace (theAspect);
|
||||
OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace (theAspect);
|
||||
AddElement (anAspectFace);
|
||||
Update();
|
||||
}
|
||||
@@ -183,7 +189,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspectMarker.IsNull())
|
||||
if (myAspectMarker == NULL)
|
||||
{
|
||||
myAspectMarker = new OpenGl_AspectMarker (theAspMarker);
|
||||
}
|
||||
@@ -200,7 +206,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker
|
||||
// =======================================================================
|
||||
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
|
||||
{
|
||||
if (myAspectMarker.IsNull())
|
||||
if (myAspectMarker == NULL)
|
||||
{
|
||||
SetGroupPrimitivesAspect (theAspMarker);
|
||||
return;
|
||||
@@ -210,7 +216,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)&
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(OpenGl_AspectMarker) anAspectMarker = new OpenGl_AspectMarker (theAspMarker);
|
||||
OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker (theAspMarker);
|
||||
AddElement (anAspectMarker);
|
||||
Update();
|
||||
}
|
||||
@@ -226,7 +232,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspectText.IsNull())
|
||||
if (myAspectText == NULL)
|
||||
{
|
||||
myAspectText = new OpenGl_AspectText (theAspText);
|
||||
}
|
||||
@@ -243,7 +249,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d
|
||||
// =======================================================================
|
||||
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
|
||||
{
|
||||
if (myAspectText.IsNull())
|
||||
if (myAspectText == NULL)
|
||||
{
|
||||
SetGroupPrimitivesAspect (theAspText);
|
||||
return;
|
||||
@@ -253,7 +259,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& th
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(OpenGl_AspectText) anAspectText = new OpenGl_AspectText (theAspText);
|
||||
OpenGl_AspectText* anAspectText = new OpenGl_AspectText (theAspText);
|
||||
AddElement (anAspectText);
|
||||
Update();
|
||||
}
|
||||
@@ -264,25 +270,25 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& th
|
||||
// =======================================================================
|
||||
void OpenGl_Group::SynchronizeAspects()
|
||||
{
|
||||
if (!myAspectFace.IsNull())
|
||||
if (myAspectFace != NULL)
|
||||
{
|
||||
myAspectFace->SynchronizeAspects();
|
||||
}
|
||||
if (!myAspectLine.IsNull())
|
||||
if (myAspectLine != NULL)
|
||||
{
|
||||
myAspectLine->SynchronizeAspects();
|
||||
}
|
||||
if (!myAspectMarker.IsNull())
|
||||
if (myAspectMarker != NULL)
|
||||
{
|
||||
myAspectMarker->SynchronizeAspects();
|
||||
}
|
||||
if (!myAspectText.IsNull())
|
||||
if (myAspectText != NULL)
|
||||
{
|
||||
myAspectText->SynchronizeAspects();
|
||||
}
|
||||
for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
|
||||
for (OpenGl_ElementNode* aNode = myFirst; aNode != NULL; aNode = aNode->next)
|
||||
{
|
||||
anElemIterator.ChangeValue()->SynchronizeAspects();
|
||||
aNode->elem->SynchronizeAspects();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +311,7 @@ void OpenGl_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theTy
|
||||
OpenGl_Structure* aStruct = GlStruct();
|
||||
const OpenGl_GraphicDriver* aDriver = aStruct->GlDriver();
|
||||
|
||||
Handle(OpenGl_PrimitiveArray) anArray = new OpenGl_PrimitiveArray (aDriver, theType, theIndices, theAttribs, theBounds);
|
||||
OpenGl_PrimitiveArray* anArray = new OpenGl_PrimitiveArray (aDriver, theType, theIndices, theAttribs, theBounds);
|
||||
AddElement (anArray);
|
||||
|
||||
Graphic3d_Group::AddPrimitiveArray (theType, theIndices, theAttribs, theBounds, theToEvalMinMax);
|
||||
@@ -335,7 +341,7 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
||||
aParams.HAlign = theHta;
|
||||
aParams.VAlign = theVta;
|
||||
const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
|
||||
Handle(OpenGl_Text) aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
|
||||
OpenGl_Text* aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
|
||||
AddElement (aText);
|
||||
Graphic3d_Group::Text (theTextUtf, thePoint, theHeight, theAngle,
|
||||
theTp, theHta, theVta, theToEvalMinMax);
|
||||
@@ -367,7 +373,7 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
||||
aParams.HAlign = theHTA;
|
||||
aParams.VAlign = theVTA;
|
||||
|
||||
Handle(OpenGl_Text) aText = new OpenGl_Text (theTextUtf, theOrientation, aParams, theHasOwnAnchor != Standard_False);
|
||||
OpenGl_Text* aText = new OpenGl_Text (theTextUtf, theOrientation, aParams, theHasOwnAnchor != Standard_False);
|
||||
|
||||
AddElement (aText);
|
||||
|
||||
@@ -390,7 +396,7 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
||||
void OpenGl_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
|
||||
const gp_Ax2& theRefPlane)
|
||||
{
|
||||
Handle(OpenGl_Flipper) aFlipper = new OpenGl_Flipper (theRefPlane);
|
||||
OpenGl_Flipper* aFlipper = new OpenGl_Flipper (theRefPlane);
|
||||
aFlipper->SetOptions (theIsEnabled);
|
||||
AddElement (aFlipper);
|
||||
}
|
||||
@@ -401,7 +407,7 @@ void OpenGl_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
|
||||
// =======================================================================
|
||||
void OpenGl_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
|
||||
{
|
||||
Handle(OpenGl_StencilTest) aStencilTest = new OpenGl_StencilTest();
|
||||
OpenGl_StencilTest* aStencilTest = new OpenGl_StencilTest();
|
||||
aStencilTest->SetOptions (theIsEnabled);
|
||||
AddElement (aStencilTest);
|
||||
}
|
||||
@@ -410,11 +416,16 @@ void OpenGl_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
|
||||
// function : AddElement
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Group::AddElement (Handle(OpenGl_Element) theElem)
|
||||
void OpenGl_Group::AddElement (OpenGl_Element* theElem)
|
||||
{
|
||||
myElements.Append (theElem);
|
||||
OpenGl_ElementNode *aNode = new OpenGl_ElementNode();
|
||||
|
||||
if (OpenGl_Raytrace::IsRaytracedElement (theElem))
|
||||
aNode->elem = theElem;
|
||||
aNode->next = NULL;
|
||||
(myLast? myLast->next : myFirst) = aNode;
|
||||
myLast = aNode;
|
||||
|
||||
if (OpenGl_Raytrace::IsRaytracedElement (aNode))
|
||||
{
|
||||
myIsRaytracable = Standard_True;
|
||||
|
||||
@@ -435,19 +446,19 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
// Setup aspects
|
||||
theWorkspace->SetAllowFaceCulling (myIsClosed
|
||||
&& !theWorkspace->GetGlContext()->Clipping().IsClippingOrCappingOn());
|
||||
const Handle(OpenGl_AspectLine)& aBackAspectLine = theWorkspace->AspectLine();
|
||||
const Handle(OpenGl_AspectFace)& aBackAspectFace = theWorkspace->AspectFace();
|
||||
const Handle(OpenGl_AspectMarker)& aBackAspectMarker = theWorkspace->AspectMarker();
|
||||
const Handle(OpenGl_AspectText)& aBackAspectText = theWorkspace->AspectText();
|
||||
const bool isLineSet = !myAspectLine.IsNull() && renderFiltered (theWorkspace, myAspectLine);
|
||||
const bool isFaceSet = !myAspectFace.IsNull() && renderFiltered (theWorkspace, myAspectFace);
|
||||
const bool isMarkerSet = !myAspectMarker.IsNull() && renderFiltered (theWorkspace, myAspectMarker);
|
||||
const bool isTextSet = !myAspectText.IsNull() && renderFiltered (theWorkspace, myAspectText);
|
||||
const OpenGl_AspectLine* aBackAspectLine = theWorkspace->AspectLine();
|
||||
const OpenGl_AspectFace* aBackAspectFace = theWorkspace->AspectFace();
|
||||
const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker();
|
||||
const OpenGl_AspectText* aBackAspectText = theWorkspace->AspectText();
|
||||
const bool isLineSet = myAspectLine && renderFiltered (theWorkspace, myAspectLine);
|
||||
const bool isFaceSet = myAspectFace && renderFiltered (theWorkspace, myAspectFace);
|
||||
const bool isMarkerSet = myAspectMarker && renderFiltered (theWorkspace, myAspectMarker);
|
||||
const bool isTextSet = myAspectText && renderFiltered (theWorkspace, myAspectText);
|
||||
|
||||
// Render group elements
|
||||
for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
|
||||
for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
||||
{
|
||||
renderFiltered (theWorkspace, anElemIterator.Value());
|
||||
renderFiltered (theWorkspace, aNodeIter->elem);
|
||||
}
|
||||
|
||||
// Restore aspects
|
||||
@@ -488,11 +499,14 @@ void OpenGl_Group::Clear (const Standard_Boolean theToUpdateStructureMgr)
|
||||
void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
|
||||
{
|
||||
// Delete elements
|
||||
for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
|
||||
while (myFirst != NULL)
|
||||
{
|
||||
OpenGl_Element::Destroy (theGlCtx.operator->(), anElemIterator.ChangeValue());
|
||||
OpenGl_ElementNode* aNext = myFirst->next;
|
||||
OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
|
||||
delete myFirst;
|
||||
myFirst = aNext;
|
||||
}
|
||||
myElements.Clear();
|
||||
myLast = NULL;
|
||||
|
||||
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
|
||||
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
|
||||
|
@@ -29,7 +29,12 @@
|
||||
class OpenGl_Group;
|
||||
class OpenGl_Structure;
|
||||
|
||||
typedef NCollection_List<Handle(OpenGl_Element)> OpenGl_ElementNodes;
|
||||
struct OpenGl_ElementNode
|
||||
{
|
||||
OpenGl_Element* elem;
|
||||
OpenGl_ElementNode* next;
|
||||
DEFINE_STANDARD_ALLOC
|
||||
};
|
||||
|
||||
//! Implementation of low-level graphic group.
|
||||
class OpenGl_Group : public Graphic3d_Group
|
||||
@@ -45,9 +50,9 @@ public:
|
||||
//! Return line aspect.
|
||||
virtual Handle(Graphic3d_AspectLine3d) LineAspect() const Standard_OVERRIDE
|
||||
{
|
||||
return !myAspectLine.IsNull()
|
||||
? myAspectLine->Aspect()
|
||||
: Handle(Graphic3d_AspectLine3d)();
|
||||
return myAspectLine != NULL
|
||||
? myAspectLine->Aspect()
|
||||
: Handle(Graphic3d_AspectLine3d)();
|
||||
}
|
||||
|
||||
//! Update line aspect.
|
||||
@@ -59,9 +64,9 @@ public:
|
||||
//! Return marker aspect.
|
||||
virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const Standard_OVERRIDE
|
||||
{
|
||||
return !myAspectMarker.IsNull()
|
||||
? myAspectMarker->Aspect()
|
||||
: Handle(Graphic3d_AspectMarker3d)();
|
||||
return myAspectMarker != NULL
|
||||
? myAspectMarker->Aspect()
|
||||
: Handle(Graphic3d_AspectMarker3d)();
|
||||
}
|
||||
|
||||
//! Update marker aspect.
|
||||
@@ -73,7 +78,7 @@ public:
|
||||
//! Return fill area aspect.
|
||||
virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const Standard_OVERRIDE
|
||||
{
|
||||
return !myAspectFace.IsNull()
|
||||
return myAspectFace != NULL
|
||||
? myAspectFace->Aspect()
|
||||
: Handle(Graphic3d_AspectFillArea3d)();
|
||||
}
|
||||
@@ -87,7 +92,7 @@ public:
|
||||
//! Return marker aspect.
|
||||
virtual Handle(Graphic3d_AspectText3d) TextAspect() const Standard_OVERRIDE
|
||||
{
|
||||
return !myAspectText.IsNull()
|
||||
return myAspectText != NULL
|
||||
? myAspectText->Aspect()
|
||||
: Handle(Graphic3d_AspectText3d)();
|
||||
}
|
||||
@@ -140,16 +145,16 @@ public:
|
||||
|
||||
OpenGl_Structure* GlStruct() const { return (OpenGl_Structure* )(myStructure->CStructure().operator->()); }
|
||||
|
||||
Standard_EXPORT void AddElement (Handle(OpenGl_Element) theElem);
|
||||
Standard_EXPORT void AddElement (OpenGl_Element* theElem);
|
||||
|
||||
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
|
||||
|
||||
//! Returns OpenGl elements of the group
|
||||
const OpenGl_ElementNodes& GetElements() const { return myElements; }
|
||||
//! Returns first OpenGL element node of the group.
|
||||
const OpenGl_ElementNode* FirstNode() const { return myFirst; }
|
||||
|
||||
//! Returns OpenGL face aspect.
|
||||
const Handle(OpenGl_AspectFace)& AspectFace() const { return myAspectFace; }
|
||||
const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
|
||||
|
||||
//! Is the group ray-tracable (contains ray-tracable elements)?
|
||||
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
|
||||
@@ -160,12 +165,13 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
Handle(OpenGl_AspectLine) myAspectLine;
|
||||
Handle(OpenGl_AspectFace) myAspectFace;
|
||||
Handle(OpenGl_AspectMarker) myAspectMarker;
|
||||
Handle(OpenGl_AspectText) myAspectText;
|
||||
OpenGl_AspectLine* myAspectLine;
|
||||
OpenGl_AspectFace* myAspectFace;
|
||||
OpenGl_AspectMarker* myAspectMarker;
|
||||
OpenGl_AspectText* myAspectText;
|
||||
|
||||
OpenGl_ElementNodes myElements;
|
||||
OpenGl_ElementNode* myFirst;
|
||||
OpenGl_ElementNode* myLast;
|
||||
|
||||
Standard_Boolean myIsRaytracable;
|
||||
|
||||
|
@@ -485,28 +485,23 @@ void OpenGl_Layer::updateBVH() const
|
||||
// =======================================================================
|
||||
void OpenGl_Layer::UpdateCulling (const Standard_Integer theViewId,
|
||||
const OpenGl_BVHTreeSelector& theSelector,
|
||||
const Graphic3d_RenderingParams::FrustumCulling theFrustumCullingState)
|
||||
const Standard_Boolean theToTraverse)
|
||||
{
|
||||
updateBVH();
|
||||
|
||||
myNbStructuresNotCulled = myNbStructures;
|
||||
if (theFrustumCullingState != Graphic3d_RenderingParams::FrustumCulling_NoUpdate)
|
||||
for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (myBVHPrimitives.Structures()); aStructIter.More(); aStructIter.Next())
|
||||
{
|
||||
Standard_Boolean toTraverse =
|
||||
(theFrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On);
|
||||
for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (myBVHPrimitives.Structures()); aStructIter.More(); aStructIter.Next())
|
||||
{
|
||||
const OpenGl_Structure* aStruct = aStructIter.Value();
|
||||
aStruct->SetCulled (toTraverse);
|
||||
}
|
||||
for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (myBVHPrimitivesTrsfPers.Structures()); aStructIter.More(); aStructIter.Next())
|
||||
{
|
||||
const OpenGl_Structure* aStruct = aStructIter.Value();
|
||||
aStruct->SetCulled (toTraverse);
|
||||
}
|
||||
const OpenGl_Structure* aStruct = aStructIter.Value();
|
||||
aStruct->SetCulled (theToTraverse);
|
||||
}
|
||||
for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (myBVHPrimitivesTrsfPers.Structures()); aStructIter.More(); aStructIter.Next())
|
||||
{
|
||||
const OpenGl_Structure* aStruct = aStructIter.Value();
|
||||
aStruct->SetCulled (theToTraverse);
|
||||
}
|
||||
|
||||
if (theFrustumCullingState != Graphic3d_RenderingParams::FrustumCulling_On)
|
||||
if (!theToTraverse)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ public:
|
||||
//! Traverses through BVH tree to determine which structures are in view volume.
|
||||
void UpdateCulling (const Standard_Integer theViewId,
|
||||
const OpenGl_BVHTreeSelector& theSelector,
|
||||
const Graphic3d_RenderingParams::FrustumCulling theFrustumCullingState);
|
||||
const Standard_Boolean theToTraverse);
|
||||
|
||||
//! Returns TRUE if layer is empty or has been discarded entirely by culling test.
|
||||
bool IsCulled() const { return myNbStructuresNotCulled == 0; }
|
||||
|
@@ -528,7 +528,7 @@ void OpenGl_LayerList::UpdateCulling (const Handle(OpenGl_Workspace)& theWorkspa
|
||||
continue;
|
||||
}
|
||||
|
||||
aLayer.UpdateCulling (aViewId, aSelector, theWorkspace->View()->RenderingParams().FrustumCullingState);
|
||||
aLayer.UpdateCulling (aViewId, aSelector, theWorkspace->IsCullingEnabled());
|
||||
}
|
||||
|
||||
aTimer.Stop();
|
||||
|
@@ -13,13 +13,12 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <OpenGl_PrimitiveArray.hxx>
|
||||
|
||||
#include <OpenGl_AspectFace.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
#include <OpenGl_IndexBuffer.hxx>
|
||||
#include <OpenGl_PointSprite.hxx>
|
||||
#include <OpenGl_PrimitiveArray.hxx>
|
||||
#include <OpenGl_Sampler.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
#include <OpenGl_ShaderProgram.hxx>
|
||||
@@ -29,8 +28,6 @@
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
#include <NCollection_AlignedAllocator.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_PrimitiveArray, OpenGl_Element)
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Convert data type to GL info
|
||||
@@ -505,10 +502,8 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(OpenGl_AspectLine) anAspectLineOld = theWorkspace->AspectLine();
|
||||
theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
|
||||
|
||||
const Handle(OpenGl_AspectLine)& anAspect = theWorkspace->ApplyAspectLine();
|
||||
const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
|
||||
const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
||||
@@ -593,8 +588,8 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
|
||||
// =======================================================================
|
||||
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
const Handle(OpenGl_AspectMarker)& anAspectMarker = theWorkspace->ApplyAspectMarker();
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
const OpenGl_AspectMarker* anAspectMarker = theWorkspace->ApplyAspectMarker();
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
|
||||
&& aCtx->ActiveProgram()->HasTessellationStage()
|
||||
? GL_PATCHES
|
||||
@@ -770,9 +765,9 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(OpenGl_AspectFace)& anAspectFace = theWorkspace->ApplyAspectFace();
|
||||
const Handle(OpenGl_AspectLine)& anAspectLine = theWorkspace->ApplyAspectLine();
|
||||
const Handle(OpenGl_AspectMarker)& anAspectMarker = myDrawMode == GL_POINTS
|
||||
const OpenGl_AspectFace* anAspectFace = theWorkspace->ApplyAspectFace();
|
||||
const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
|
||||
const OpenGl_AspectMarker* anAspectMarker = myDrawMode == GL_POINTS
|
||||
? theWorkspace->ApplyAspectMarker()
|
||||
: theWorkspace->AspectMarker();
|
||||
|
||||
@@ -1046,7 +1041,7 @@ Standard_Boolean OpenGl_PrimitiveArray::processIndices (const Handle(OpenGl_Cont
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
if (myAttribs->NbElements > IntegerLast()/*std::numeric_limits<GLushort>::max()*/)
|
||||
if (myAttribs->NbElements > std::numeric_limits<GLushort>::max())
|
||||
{
|
||||
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (new NCollection_AlignedAllocator (16));
|
||||
if (!anAttribs->Init (myIndices->NbElements, myAttribs->AttributesArray(), myAttribs->NbAttributes))
|
||||
|
@@ -31,7 +31,6 @@ class OpenGl_GraphicDriver;
|
||||
//! Class for rendering of arbitrary primitive array.
|
||||
class OpenGl_PrimitiveArray : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_PrimitiveArray, OpenGl_Element)
|
||||
public:
|
||||
//! OpenGL does not provide a constant for "none" draw mode.
|
||||
//! So we define our own one that does not conflict with GL constants and utilizes common GL invalid value.
|
||||
|
@@ -593,10 +593,21 @@ namespace OpenGl_Raytrace
|
||||
// function : IsRaytracedElement
|
||||
// purpose : Checks to see if the element contains ray-trace geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean IsRaytracedElement (const Handle(OpenGl_Element) theElement)
|
||||
Standard_Boolean IsRaytracedElement (const OpenGl_ElementNode* theNode)
|
||||
{
|
||||
Handle(OpenGl_PrimitiveArray) anArray = Handle(OpenGl_PrimitiveArray)::DownCast (theElement);
|
||||
return !anArray.IsNull()
|
||||
OpenGl_PrimitiveArray* anArray = dynamic_cast<OpenGl_PrimitiveArray*> (theNode->elem);
|
||||
return anArray != NULL
|
||||
&& anArray->DrawMode() >= GL_TRIANGLES;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsRaytracedElement
|
||||
// purpose : Checks to see if the element contains ray-trace geometry
|
||||
// =======================================================================
|
||||
Standard_Boolean IsRaytracedElement (const OpenGl_Element* theElement)
|
||||
{
|
||||
const OpenGl_PrimitiveArray* anArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theElement);
|
||||
return anArray != NULL
|
||||
&& anArray->DrawMode() >= GL_TRIANGLES;
|
||||
}
|
||||
|
||||
@@ -606,9 +617,9 @@ namespace OpenGl_Raytrace
|
||||
// =======================================================================
|
||||
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup)
|
||||
{
|
||||
for (OpenGl_ElementNodes::Iterator anElemIterator (theGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
||||
for (const OpenGl_ElementNode* aNode = theGroup->FirstNode(); aNode != NULL; aNode = aNode->next)
|
||||
{
|
||||
if (IsRaytracedElement (anElemIterator.Value()))
|
||||
if (IsRaytracedElement (aNode))
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -36,7 +36,10 @@ namespace OpenGl_Raytrace
|
||||
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup);
|
||||
|
||||
//! Checks to see if the element contains ray-trace geometry.
|
||||
Standard_Boolean IsRaytracedElement (const Handle(OpenGl_Element) theElement);
|
||||
Standard_Boolean IsRaytracedElement (const OpenGl_ElementNode* theNode);
|
||||
|
||||
//! Checks to see if the element contains ray-trace geometry.
|
||||
Standard_Boolean IsRaytracedElement (const OpenGl_Element* theElement);
|
||||
}
|
||||
|
||||
//! Stores properties of surface material.
|
||||
|
@@ -16,8 +16,6 @@
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_StencilTest.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_StencilTest, OpenGl_Element)
|
||||
|
||||
OpenGl_StencilTest::OpenGl_StencilTest()
|
||||
{
|
||||
//
|
||||
|
@@ -20,7 +20,6 @@
|
||||
|
||||
class OpenGl_StencilTest : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_StencilTest, OpenGl_Element)
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
|
@@ -460,10 +460,10 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
|
||||
aCtx->ApplyModelViewMatrix();
|
||||
|
||||
// remember aspects
|
||||
const Handle(OpenGl_AspectLine)& aPrevAspectLine = theWorkspace->AspectLine();
|
||||
const Handle(OpenGl_AspectFace)& aPrevAspectFace = theWorkspace->AspectFace();
|
||||
const Handle(OpenGl_AspectMarker)& aPrevAspectMarker = theWorkspace->AspectMarker();
|
||||
const Handle(OpenGl_AspectText)& aPrevAspectText = theWorkspace->AspectText();
|
||||
const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->AspectLine();
|
||||
const OpenGl_AspectFace* aPrevAspectFace = theWorkspace->AspectFace();
|
||||
const OpenGl_AspectMarker* aPrevAspectMarker = theWorkspace->AspectMarker();
|
||||
const OpenGl_AspectText* aPrevAspectText = theWorkspace->AspectText();
|
||||
|
||||
// Apply correction for mirror transform
|
||||
if (myIsMirrored)
|
||||
|
@@ -29,8 +29,6 @@
|
||||
#include <Graphic3d_TransformUtils.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Text, OpenGl_Element)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const GLdouble THE_IDENTITY_MATRIX[16] =
|
||||
@@ -289,7 +287,7 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx)
|
||||
// =======================================================================
|
||||
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||
const NCollection_String& theText,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const OpenGl_TextParam& theParams,
|
||||
const unsigned int theResolution,
|
||||
Standard_ShortReal& theWidth,
|
||||
@@ -355,10 +353,10 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||
// =======================================================================
|
||||
void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
theWorkspace->SetAspectFace (theWorkspace->FontFaceAspect());
|
||||
theWorkspace->SetAspectFace (&theWorkspace->FontFaceAspect());
|
||||
theWorkspace->ApplyAspectFace();
|
||||
const Handle(OpenGl_AspectText)& aTextAspect = theWorkspace->ApplyAspectText();
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
const OpenGl_AspectText* aTextAspect = theWorkspace->ApplyAspectText();
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
const Handle(OpenGl_TextureSet) aPrevTexture = aCtx->BindTextures (Handle(OpenGl_TextureSet)());
|
||||
|
||||
// Bind custom shader program or generate default version
|
||||
@@ -369,7 +367,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
|
||||
// use highlight color or colors from aspect
|
||||
render (aCtx,
|
||||
aTextAspect,
|
||||
*aTextAspect,
|
||||
theWorkspace->TextColor(),
|
||||
theWorkspace->TextSubtitleColor(),
|
||||
aCtx->Resolution());
|
||||
@@ -392,12 +390,12 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const unsigned int theResolution) const
|
||||
{
|
||||
render (theCtx, theTextAspect,
|
||||
theTextAspect->Aspect()->ColorRGBA(),
|
||||
theTextAspect->Aspect()->ColorSubTitleRGBA(),
|
||||
theTextAspect.Aspect()->ColorRGBA(),
|
||||
theTextAspect.Aspect()->ColorSubTitleRGBA(),
|
||||
theResolution);
|
||||
}
|
||||
|
||||
@@ -406,7 +404,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const OpenGl_Vec3 theDVec) const
|
||||
{
|
||||
OpenGl_Mat4d aModViewMat;
|
||||
@@ -424,7 +422,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
|
||||
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
|
||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
|
||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -466,10 +464,10 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
else
|
||||
{
|
||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
|
||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
|
||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
if (!theTextAspect->Aspect()->GetTextZoomable())
|
||||
if (!theTextAspect.Aspect()->GetTextZoomable())
|
||||
{
|
||||
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
|
||||
}
|
||||
@@ -506,7 +504,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect) const
|
||||
const OpenGl_AspectText& theTextAspect) const
|
||||
{
|
||||
(void )theTextAspect;
|
||||
if (myVertsVbo.Length() != myTextures.Length()
|
||||
@@ -537,14 +535,14 @@ void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
|
||||
// function : FontKey
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString OpenGl_Text::FontKey (const Handle(OpenGl_AspectText)& theAspect,
|
||||
TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect,
|
||||
const Standard_Integer theHeight,
|
||||
const unsigned int theResolution)
|
||||
{
|
||||
const Font_FontAspect anAspect = theAspect->Aspect()->GetTextFontAspect() != Font_FA_Undefined
|
||||
? theAspect->Aspect()->GetTextFontAspect()
|
||||
const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
|
||||
? theAspect.Aspect()->GetTextFontAspect()
|
||||
: Font_FA_Regular;
|
||||
return theAspect->Aspect()->Font()
|
||||
return theAspect.Aspect()->Font()
|
||||
+ TCollection_AsciiString(":") + Standard_Integer(anAspect)
|
||||
+ TCollection_AsciiString(":") + Standard_Integer(theResolution)
|
||||
+ TCollection_AsciiString(":") + theHeight;
|
||||
@@ -555,7 +553,7 @@ TCollection_AsciiString OpenGl_Text::FontKey (const Handle(OpenGl_AspectText)& t
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theAspect,
|
||||
const OpenGl_AspectText& theAspect,
|
||||
const Standard_Integer theHeight,
|
||||
const unsigned int theResolution,
|
||||
const TCollection_AsciiString theKey)
|
||||
@@ -569,23 +567,24 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
||||
if (!theCtx->GetResource (theKey, aFont))
|
||||
{
|
||||
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
|
||||
const TCollection_AsciiString& aFontName = theAspect->Aspect()->Font();
|
||||
Font_FontAspect anAspect = theAspect->Aspect()->GetTextFontAspect() != Font_FA_Undefined
|
||||
? theAspect->Aspect()->GetTextFontAspect()
|
||||
: Font_FA_Regular;
|
||||
const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect.Aspect()->Font());
|
||||
const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
|
||||
? theAspect.Aspect()->GetTextFontAspect()
|
||||
: Font_FA_Regular;
|
||||
Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect, theHeight);
|
||||
Handle(Font_FTFont) aFontFt;
|
||||
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect))
|
||||
if (!aRequestedFont.IsNull())
|
||||
{
|
||||
aFontFt = new Font_FTFont (Handle(Font_FTLibrary)());
|
||||
|
||||
if (aFontFt->Init (aRequestedFont->FontPathAny (anAspect).ToCString(), theHeight, theResolution))
|
||||
if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight, theResolution))
|
||||
{
|
||||
aFont = new OpenGl_Font (aFontFt, theKey);
|
||||
if (!aFont->Init (theCtx))
|
||||
{
|
||||
TCollection_ExtendedString aMsg;
|
||||
aMsg += "Font '";
|
||||
aMsg += theAspect->Aspect()->Font();
|
||||
aMsg += theAspect.Aspect()->Font();
|
||||
aMsg += "' - initialization of GL resources has failed!";
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
||||
aFontFt.Nullify();
|
||||
@@ -597,9 +596,9 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
TCollection_ExtendedString aMsg;
|
||||
aMsg += "Font '";
|
||||
aMsg += theAspect->Aspect()->Font();
|
||||
aMsg += theAspect.Aspect()->Font();
|
||||
aMsg += "' is broken or has incompatible format! File path: ";
|
||||
aMsg += aRequestedFont->FontPathAny (anAspect);
|
||||
aMsg += aRequestedFont->FontPath()->ToCString();
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
||||
aFontFt.Nullify();
|
||||
aFont = new OpenGl_Font (aFontFt, theKey);
|
||||
@@ -609,7 +608,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
TCollection_ExtendedString aMsg;
|
||||
aMsg += "Font '";
|
||||
aMsg += theAspect->Aspect()->Font();
|
||||
aMsg += theAspect.Aspect()->Font();
|
||||
aMsg += "' is not found in the system!";
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
||||
aFont = new OpenGl_Font (aFontFt, theKey);
|
||||
@@ -625,7 +624,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const OpenGl_Vec4& theColorSubs) const
|
||||
{
|
||||
Handle(OpenGl_ShaderProgram) aPrevProgram = theCtx->ActiveProgram();
|
||||
@@ -676,7 +675,7 @@ void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const OpenGl_Vec4& theColorText,
|
||||
const OpenGl_Vec4& theColorSubs,
|
||||
const unsigned int theResolution) const
|
||||
@@ -749,7 +748,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
myWinX, myWinY, myWinZ);
|
||||
|
||||
// compute scale factor for constant text height
|
||||
if (theTextAspect->Aspect()->GetTextZoomable())
|
||||
if (theTextAspect.Aspect()->GetTextZoomable())
|
||||
{
|
||||
myExportHeight = aPointSize;
|
||||
}
|
||||
@@ -780,7 +779,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
|
||||
// setup depth test
|
||||
const bool hasDepthTest = !myIs2d
|
||||
&& theTextAspect->Aspect()->Style() != Aspect_TOST_ANNOTATION;
|
||||
&& theTextAspect.Aspect()->Style() != Aspect_TOST_ANNOTATION;
|
||||
if (!hasDepthTest)
|
||||
{
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
@@ -811,7 +810,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
|
||||
|
||||
// extra drawings
|
||||
switch (theTextAspect->Aspect()->DisplayType())
|
||||
switch (theTextAspect.Aspect()->DisplayType())
|
||||
{
|
||||
case Aspect_TODT_BLEND:
|
||||
{
|
||||
@@ -874,7 +873,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (theTextAspect->Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
|
||||
if (theTextAspect.Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
|
||||
{
|
||||
glDisable (GL_BLEND);
|
||||
if (!myIs2d)
|
||||
|
@@ -33,7 +33,7 @@
|
||||
//! Text rendering
|
||||
class OpenGl_Text : public OpenGl_Element
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_Text, OpenGl_Element)
|
||||
|
||||
public:
|
||||
|
||||
//! Main constructor
|
||||
@@ -83,13 +83,13 @@ public: //! @name methods for compatibility with layers
|
||||
Standard_EXPORT OpenGl_Text();
|
||||
|
||||
//! Create key for shared resource
|
||||
Standard_EXPORT static TCollection_AsciiString FontKey (const Handle(OpenGl_AspectText)& theAspect,
|
||||
Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_AspectText& theAspect,
|
||||
const Standard_Integer theHeight,
|
||||
const unsigned int theResolution);
|
||||
|
||||
//! Find shared resource for specified font or initialize new one
|
||||
Standard_EXPORT static Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theAspect,
|
||||
const OpenGl_AspectText& theAspect,
|
||||
const Standard_Integer theHeight,
|
||||
const unsigned int theResolution,
|
||||
const TCollection_AsciiString theKey);
|
||||
@@ -97,7 +97,7 @@ public: //! @name methods for compatibility with layers
|
||||
//! Compute text width
|
||||
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||
const NCollection_String& theText,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const OpenGl_TextParam& theParams,
|
||||
const unsigned int theResolution,
|
||||
Standard_ShortReal& theWidth,
|
||||
@@ -112,8 +112,8 @@ public: //! @name methods for compatibility with layers
|
||||
|
||||
//! Perform rendering
|
||||
Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -127,21 +127,21 @@ private:
|
||||
|
||||
//! Setup matrix.
|
||||
void setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const OpenGl_Vec3 theDVec) const;
|
||||
|
||||
//! Draw arrays of vertices.
|
||||
void drawText (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect) const;
|
||||
const OpenGl_AspectText& theTextAspect) const;
|
||||
|
||||
//! Draw rectangle from bounding text box.
|
||||
void drawRect (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const OpenGl_Vec4& theColorSubs) const;
|
||||
|
||||
//! Main rendering code
|
||||
void render (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const OpenGl_Vec4& theColorText,
|
||||
const OpenGl_Vec4& theColorSubs,
|
||||
const unsigned int theResolution) const;
|
||||
|
@@ -50,6 +50,7 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
myDriver (theDriver.operator->()),
|
||||
myCaps (theCaps),
|
||||
myWasRedrawnGL (Standard_False),
|
||||
myCulling (Standard_True),
|
||||
myBackfacing (Graphic3d_TOBM_AUTOMATIC),
|
||||
myBgColor (Quantity_NOC_BLACK),
|
||||
myCamera (new Graphic3d_Camera()),
|
||||
@@ -110,9 +111,6 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
myRaytraceFBO1[1] = new OpenGl_FrameBuffer();
|
||||
myRaytraceFBO2[0] = new OpenGl_FrameBuffer();
|
||||
myRaytraceFBO2[1] = new OpenGl_FrameBuffer();
|
||||
|
||||
myGraduatedTrihedron = new OpenGl_GraduatedTrihedron();
|
||||
myFrameStatsPrs = new OpenGl_FrameStatsPrs();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -133,8 +131,8 @@ OpenGl_View::~OpenGl_View()
|
||||
// =======================================================================
|
||||
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
myGraduatedTrihedron->Release (theCtx.operator->());
|
||||
myFrameStatsPrs->Release (theCtx.operator->());
|
||||
myGraduatedTrihedron.Release (theCtx.operator->());
|
||||
myFrameStatsPrs.Release (theCtx.operator->());
|
||||
|
||||
if (!myTextureEnv.IsNull())
|
||||
{
|
||||
@@ -146,15 +144,15 @@ void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
||||
myTextureEnv.Nullify();
|
||||
}
|
||||
|
||||
if (!myTextureParams.IsNull())
|
||||
if (myTextureParams != NULL)
|
||||
{
|
||||
myTextureParams->Release (theCtx.operator->());
|
||||
}
|
||||
if (!myBgGradientArray.IsNull())
|
||||
if (myBgGradientArray != NULL)
|
||||
{
|
||||
myBgGradientArray->Release (theCtx.operator->());
|
||||
}
|
||||
if (!myBgTextureArray.IsNull())
|
||||
if (myBgTextureArray != NULL)
|
||||
{
|
||||
myBgTextureArray->Release (theCtx.operator->());
|
||||
}
|
||||
@@ -336,7 +334,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron&
|
||||
myGTrihedronData = theTrihedronData;
|
||||
myGTrihedronData.PtrView = this;
|
||||
myGTrihedronData.CubicAxesCallback = SetMinMaxValuesCallback;
|
||||
myGraduatedTrihedron->SetValues (myGTrihedronData);
|
||||
myGraduatedTrihedron.SetValues (myGTrihedronData);
|
||||
myToShowGradTrihedron = true;
|
||||
}
|
||||
|
||||
@@ -347,7 +345,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron&
|
||||
void OpenGl_View::GraduatedTrihedronErase()
|
||||
{
|
||||
myGTrihedronData.PtrView = NULL;
|
||||
myGraduatedTrihedron->Release (myWorkspace->GetGlContext().operator->());
|
||||
myGraduatedTrihedron.Release (myWorkspace->GetGlContext().operator->());
|
||||
myToShowGradTrihedron = false;
|
||||
}
|
||||
|
||||
@@ -357,7 +355,7 @@ void OpenGl_View::GraduatedTrihedronErase()
|
||||
// =======================================================================
|
||||
void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
|
||||
{
|
||||
myGraduatedTrihedron->SetMinMax (theMin, theMax);
|
||||
myGraduatedTrihedron.SetMinMax (theMin, theMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -808,32 +806,3 @@ void OpenGl_View::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& t
|
||||
theDict.ChangeFromIndex (theDict.Add ("ResolutionRatio", aResRatio)) = aResRatio;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : StatisticInformation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_View::StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const
|
||||
{
|
||||
if (const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext())
|
||||
{
|
||||
const Handle(OpenGl_FrameStats)& aStats = aCtx->FrameStats();
|
||||
const Graphic3d_RenderingParams& aRendParams = myWorkspace->View()->RenderingParams();
|
||||
aStats->FormatStats (theDict, aRendParams.CollectedStats);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : StatisticInformation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString OpenGl_View::StatisticInformation() const
|
||||
{
|
||||
if (const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext())
|
||||
{
|
||||
const Handle(OpenGl_FrameStats)& aStats = aCtx->FrameStats();
|
||||
const Graphic3d_RenderingParams& aRendParams = myWorkspace->View()->RenderingParams();
|
||||
return aStats->FormatStats (aRendParams.CollectedStats);
|
||||
}
|
||||
return TCollection_AsciiString();
|
||||
}
|
||||
|
@@ -241,6 +241,12 @@ public:
|
||||
//! Sets environment texture for the view.
|
||||
Standard_EXPORT virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) Standard_OVERRIDE;
|
||||
|
||||
//! Returns the state of frustum culling optimization.
|
||||
virtual Standard_Boolean IsCullingEnabled() const Standard_OVERRIDE { return myCulling; }
|
||||
|
||||
//! Enables or disables frustum culling optimization.
|
||||
virtual void SetCullingEnabled (const Standard_Boolean theIsEnabled) Standard_OVERRIDE { myCulling = theIsEnabled; }
|
||||
|
||||
//! Return backfacing model used for the view.
|
||||
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const Standard_OVERRIDE { return myBackfacing; }
|
||||
|
||||
@@ -285,19 +291,13 @@ public:
|
||||
Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
|
||||
Graphic3d_DiagnosticInfo theFlags) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns string with statistic performance info.
|
||||
Standard_EXPORT virtual TCollection_AsciiString StatisticInformation() const Standard_OVERRIDE;
|
||||
|
||||
//! Fills in the dictionary with statistic performance info.
|
||||
Standard_EXPORT virtual void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Returns background color.
|
||||
const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; }
|
||||
|
||||
//! Change graduated trihedron.
|
||||
const Handle(OpenGl_GraduatedTrihedron)& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
|
||||
OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
|
||||
|
||||
void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_TextureEnv)& theTexture);
|
||||
@@ -457,6 +457,7 @@ protected:
|
||||
Handle(OpenGl_Caps) myCaps;
|
||||
Standard_Boolean myWasRedrawnGL;
|
||||
|
||||
Standard_Boolean myCulling;
|
||||
Graphic3d_TypeOfBackfacingModel myBackfacing;
|
||||
Quantity_ColorRGBA myBgColor;
|
||||
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
|
||||
@@ -486,8 +487,8 @@ protected:
|
||||
//! Is needed for selection of overlapping objects and storage of the current view volume
|
||||
OpenGl_BVHTreeSelector myBVHSelector;
|
||||
|
||||
Handle(OpenGl_GraduatedTrihedron) myGraduatedTrihedron;
|
||||
Handle(OpenGl_FrameStatsPrs) myFrameStatsPrs;
|
||||
OpenGl_GraduatedTrihedron myGraduatedTrihedron;
|
||||
OpenGl_FrameStatsPrs myFrameStatsPrs;
|
||||
|
||||
Handle(OpenGl_TextureSet) myTextureEnv;
|
||||
|
||||
@@ -520,9 +521,9 @@ protected: //! @name Rendering properties
|
||||
|
||||
protected: //! @name Background parameters
|
||||
|
||||
Handle(OpenGl_AspectFace) myTextureParams; //!< Stores texture and its parameters for textured background
|
||||
Handle(OpenGl_BackgroundArray) myBgGradientArray; //!< Primitive array for gradient background
|
||||
Handle(OpenGl_BackgroundArray) myBgTextureArray; //!< Primitive array for texture background
|
||||
OpenGl_AspectFace* myTextureParams; //!< Stores texture and its parameters for textured background
|
||||
OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
|
||||
OpenGl_BackgroundArray* myBgTextureArray; //!< Primitive array for texture background
|
||||
|
||||
protected: //! @name data types related to ray-tracing
|
||||
|
||||
@@ -776,11 +777,11 @@ protected: //! @name methods related to ray-tracing
|
||||
const Handle(OpenGl_Context)& theGlContext);
|
||||
|
||||
//! Creates ray-tracing material properties.
|
||||
OpenGl_RaytraceMaterial convertMaterial (const Handle(OpenGl_AspectFace)& theAspect,
|
||||
OpenGl_RaytraceMaterial convertMaterial (const OpenGl_AspectFace* theAspect,
|
||||
const Handle(OpenGl_Context)& theGlContext);
|
||||
|
||||
//! Adds OpenGL primitive array to ray-traced scene geometry.
|
||||
Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray)& theArray,
|
||||
Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
|
||||
const Standard_Integer theMatID,
|
||||
const OpenGl_Mat4* theTrans);
|
||||
|
||||
@@ -789,7 +790,7 @@ protected: //! @name methods related to ray-tracing
|
||||
const Standard_Integer theMatID,
|
||||
const Standard_Integer theCount,
|
||||
const Standard_Integer theOffset,
|
||||
const Handle(OpenGl_PrimitiveArray)& theArray);
|
||||
const OpenGl_PrimitiveArray& theArray);
|
||||
|
||||
//! Adds OpenGL triangle array to ray-traced scene geometry.
|
||||
Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
|
||||
|
@@ -144,10 +144,11 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (aStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
// Extract OpenGL elements from the group (primitives arrays)
|
||||
for (OpenGl_ElementNodes::Iterator anElemIterator (aGroupIter.Value()->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
||||
for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
|
||||
{
|
||||
Handle(OpenGl_PrimitiveArray) aPrimArray = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
|
||||
if (!aPrimArray.IsNull())
|
||||
OpenGl_PrimitiveArray* aPrimArray = dynamic_cast<OpenGl_PrimitiveArray*> (aNode->elem);
|
||||
|
||||
if (aPrimArray != NULL)
|
||||
{
|
||||
anArrayIDs.insert (aPrimArray->GetUID());
|
||||
}
|
||||
@@ -343,7 +344,7 @@ void buildTextureTransform (const Handle(Graphic3d_TextureParams)& theParams, BV
|
||||
// function : convertMaterial
|
||||
// purpose : Creates ray-tracing material properties
|
||||
// =======================================================================
|
||||
OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const Handle(OpenGl_AspectFace)& theAspect,
|
||||
OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_AspectFace* theAspect,
|
||||
const Handle(OpenGl_Context)& theGlContext)
|
||||
{
|
||||
OpenGl_RaytraceMaterial theMaterial;
|
||||
@@ -508,7 +509,7 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
|
||||
{
|
||||
// Get group material
|
||||
OpenGl_RaytraceMaterial aGroupMaterial;
|
||||
if (!aGroupIter.Value()->AspectFace().IsNull())
|
||||
if (aGroupIter.Value()->AspectFace() != NULL)
|
||||
{
|
||||
aGroupMaterial = convertMaterial (
|
||||
aGroupIter.Value()->AspectFace(), theGlContext);
|
||||
@@ -518,14 +519,14 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
|
||||
|
||||
// Use group material if available, otherwise use structure material
|
||||
myRaytraceGeometry.Materials.push_back (
|
||||
!aGroupIter.Value()->AspectFace().IsNull() ? aGroupMaterial : theStructMat);
|
||||
aGroupIter.Value()->AspectFace() != NULL ? aGroupMaterial : theStructMat);
|
||||
|
||||
// Add OpenGL elements from group (extract primitives arrays and aspects)
|
||||
for (OpenGl_ElementNodes::Iterator anElemIterator (aGroupIter.Value()->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
||||
for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
|
||||
{
|
||||
Handle(OpenGl_AspectFace) anAspect = Handle(OpenGl_AspectFace)::DownCast (anElemIterator.Value());
|
||||
OpenGl_AspectFace* anAspect = dynamic_cast<OpenGl_AspectFace*> (aNode->elem);
|
||||
|
||||
if (!anAspect.IsNull())
|
||||
if (anAspect != NULL)
|
||||
{
|
||||
aMatID = static_cast<Standard_Integer> (myRaytraceGeometry.Materials.size());
|
||||
|
||||
@@ -535,9 +536,9 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(OpenGl_PrimitiveArray) aPrimArray = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
|
||||
OpenGl_PrimitiveArray* aPrimArray = dynamic_cast<OpenGl_PrimitiveArray*> (aNode->elem);
|
||||
|
||||
if (!aPrimArray.IsNull())
|
||||
if (aPrimArray != NULL)
|
||||
{
|
||||
std::map<Standard_Size, OpenGl_TriangleSet*>::iterator aSetIter = myArrayToTrianglesMap.find (aPrimArray->GetUID());
|
||||
|
||||
@@ -584,7 +585,7 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
|
||||
// function : addRaytracePrimitiveArray
|
||||
// purpose : Adds OpenGL primitive array to ray-traced scene geometry
|
||||
// =======================================================================
|
||||
Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray)& theArray,
|
||||
Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
|
||||
const Standard_Integer theMaterial,
|
||||
const OpenGl_Mat4* theTransform)
|
||||
{
|
||||
@@ -704,7 +705,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(
|
||||
{
|
||||
const Standard_Integer aVertNum = aBounds->Bounds[aBound];
|
||||
|
||||
if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, aBoundStart, theArray))
|
||||
if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, aBoundStart, *theArray))
|
||||
{
|
||||
aSet.Nullify();
|
||||
return Handle(OpenGl_TriangleSet)();
|
||||
@@ -717,7 +718,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(
|
||||
{
|
||||
const Standard_Integer aVertNum = !anIndices.IsNull() ? anIndices->NbElements : anAttribs->NbElements;
|
||||
|
||||
if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, 0, theArray))
|
||||
if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, 0, *theArray))
|
||||
{
|
||||
aSet.Nullify();
|
||||
return Handle(OpenGl_TriangleSet)();
|
||||
@@ -741,17 +742,17 @@ Standard_Boolean OpenGl_View::addRaytraceVertexIndices (OpenGl_TriangleSet&
|
||||
const Standard_Integer theMatID,
|
||||
const Standard_Integer theCount,
|
||||
const Standard_Integer theOffset,
|
||||
const Handle(OpenGl_PrimitiveArray)& theArray)
|
||||
const OpenGl_PrimitiveArray& theArray)
|
||||
{
|
||||
switch (theArray->DrawMode())
|
||||
switch (theArray.DrawMode())
|
||||
{
|
||||
case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
||||
case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
||||
case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
||||
case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||
case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||
case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
||||
case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
||||
case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
||||
case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||
case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||
case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2679,7 +2680,7 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer the
|
||||
}
|
||||
|
||||
// Set background colors (only gradient background supported)
|
||||
if (!myBgGradientArray.IsNull() && myBgGradientArray->IsDefined())
|
||||
if (myBgGradientArray != NULL && myBgGradientArray->IsDefined())
|
||||
{
|
||||
theProgram->SetUniform (theGlContext,
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBgGradientArray->GradientColor (0));
|
||||
|
@@ -125,9 +125,7 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
|
||||
{
|
||||
aCtx->core11fwd->glDisable (GL_BLEND);
|
||||
|
||||
const Handle(OpenGl_AspectFace) anOldAspectFace = theWorkspace->AspectFace();
|
||||
theWorkspace->SetAspectFace (myTextureParams);
|
||||
|
||||
const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace (myTextureParams);
|
||||
myBgTextureArray->Render (theWorkspace);
|
||||
theWorkspace->SetAspectFace (anOldAspectFace);
|
||||
}
|
||||
@@ -1163,7 +1161,7 @@ void OpenGl_View::renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace)
|
||||
{
|
||||
if (myToShowGradTrihedron)
|
||||
{
|
||||
myGraduatedTrihedron->Render (theWorkspace);
|
||||
myGraduatedTrihedron.Render (theWorkspace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,8 +1174,8 @@ void OpenGl_View::renderFrameStats()
|
||||
if (myRenderParams.ToShowStats
|
||||
&& myRenderParams.CollectedStats != Graphic3d_RenderingParams::PerfCounters_NONE)
|
||||
{
|
||||
myFrameStatsPrs->Update (myWorkspace);
|
||||
myFrameStatsPrs->Render (myWorkspace);
|
||||
myFrameStatsPrs.Update (myWorkspace);
|
||||
myFrameStatsPrs.Render (myWorkspace);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
#include <OpenGl_Window.hxx>
|
||||
#include <OpenGl_FrameBuffer.hxx>
|
||||
|
||||
#include <Aspect_GraphicDeviceDefinitionError.hxx>
|
||||
#include <Graphic3d_TransformUtils.hxx>
|
||||
@@ -182,15 +181,14 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
|
||||
EGLConfig anEglConfig = (EGLConfig )theDriver->getRawGlConfig();
|
||||
if (anEglDisplay == EGL_NO_DISPLAY
|
||||
|| anEglContext == EGL_NO_CONTEXT
|
||||
|| (anEglConfig == NULL
|
||||
&& (EGLContext )theGContext == EGL_NO_CONTEXT))
|
||||
|| anEglConfig == NULL)
|
||||
{
|
||||
throw Aspect_GraphicDeviceDefinitionError("OpenGl_Window, EGL does not provide compatible configurations!");
|
||||
return;
|
||||
}
|
||||
|
||||
EGLSurface anEglSurf = EGL_NO_SURFACE;
|
||||
if ((EGLContext )theGContext == EGL_NO_CONTEXT)
|
||||
if (theGContext == (EGLContext )EGL_NO_CONTEXT)
|
||||
{
|
||||
// create new surface
|
||||
anEglSurf = eglCreateWindowSurface (anEglDisplay,
|
||||
@@ -213,24 +211,8 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
|
||||
anEglSurf = eglGetCurrentSurface(EGL_DRAW);
|
||||
if (anEglSurf == EGL_NO_SURFACE)
|
||||
{
|
||||
// window-less EGL context (off-screen)
|
||||
//throw Aspect_GraphicDeviceDefinitionError("OpenGl_Window, EGL is unable to retrieve current surface!");
|
||||
if (anEglConfig != NULL)
|
||||
{
|
||||
const int aSurfAttribs[] =
|
||||
{
|
||||
EGL_WIDTH, myWidth,
|
||||
EGL_HEIGHT, myHeight,
|
||||
EGL_NONE
|
||||
};
|
||||
anEglSurf = eglCreatePbufferSurface (anEglDisplay, anEglConfig, aSurfAttribs);
|
||||
if (anEglSurf == EGL_NO_SURFACE)
|
||||
{
|
||||
throw Aspect_GraphicDeviceDefinitionError("OpenGl_Window, EGL is unable to create off-screen surface!");
|
||||
}
|
||||
}
|
||||
myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
||||
"OpenGl_Window::CreateWindow: WARNING, a Window is created without a EGL Surface!");
|
||||
throw Aspect_GraphicDeviceDefinitionError("OpenGl_Window, EGL is unable to retrieve current surface!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,30 +715,7 @@ void OpenGl_Window::Init()
|
||||
return;
|
||||
|
||||
#if defined(HAVE_EGL)
|
||||
if ((EGLSurface )myGlContext->myWindow == EGL_NO_SURFACE)
|
||||
{
|
||||
// define an offscreen default FBO to avoid rendering into EGL_NO_SURFACE;
|
||||
// note that this code is currently never called, since eglCreatePbufferSurface() is used instead as more robust solution
|
||||
// for offscreen rendering on bugged OpenGL ES drivers
|
||||
Handle(OpenGl_FrameBuffer) aDefFbo = myGlContext->SetDefaultFrameBuffer (Handle(OpenGl_FrameBuffer)());
|
||||
if (!aDefFbo.IsNull())
|
||||
{
|
||||
aDefFbo->Release (myGlContext.operator->());
|
||||
}
|
||||
else
|
||||
{
|
||||
aDefFbo = new OpenGl_FrameBuffer();
|
||||
}
|
||||
|
||||
if (!aDefFbo->InitWithRB (myGlContext, myWidth, myHeight, GL_RGBA8, GL_DEPTH24_STENCIL8))
|
||||
{
|
||||
TCollection_AsciiString aMsg ("OpenGl_Window::CreateWindow: default FBO creation failed");
|
||||
throw Aspect_GraphicDeviceDefinitionError(aMsg.ToCString());
|
||||
}
|
||||
myGlContext->SetDefaultFrameBuffer (aDefFbo);
|
||||
aDefFbo->BindBuffer (myGlContext);
|
||||
}
|
||||
else if (!myPlatformWindow->IsVirtual())
|
||||
if (!myPlatformWindow->IsVirtual())
|
||||
{
|
||||
eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_WIDTH, &myWidth);
|
||||
eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_HEIGHT, &myHeight);
|
||||
|
@@ -123,25 +123,16 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
|
||||
myNbSkippedTranspElems (0),
|
||||
myRenderFilter (OpenGl_RenderFilter_Empty),
|
||||
//
|
||||
myAspectLineSet (&myDefaultAspectLine),
|
||||
myAspectFaceSet (&myDefaultAspectFace),
|
||||
myAspectMarkerSet (&myDefaultAspectMarker),
|
||||
myAspectTextSet (&myDefaultAspectText),
|
||||
//
|
||||
ViewMatrix_applied (&myDefaultMatrix),
|
||||
StructureMatrix_applied (&myDefaultMatrix),
|
||||
myToAllowFaceCulling (false),
|
||||
myModelViewMatrix (myDefaultMatrix)
|
||||
{
|
||||
myDefaultAspectLine = new OpenGl_AspectLine();
|
||||
myDefaultAspectFace = new OpenGl_AspectFace();
|
||||
myDefaultAspectMarker = new OpenGl_AspectMarker();
|
||||
myDefaultAspectText = new OpenGl_AspectText();
|
||||
|
||||
myNoneCulling = new OpenGl_AspectFace();
|
||||
myFrontCulling = new OpenGl_AspectFace();
|
||||
myFontFaceAspect = new OpenGl_AspectFace();
|
||||
|
||||
myAspectLineSet = myDefaultAspectLine;
|
||||
myAspectFaceSet = myDefaultAspectFace;
|
||||
myAspectMarkerSet = myDefaultAspectMarker;
|
||||
myAspectTextSet = myDefaultAspectText;
|
||||
|
||||
if (!myGlContext.IsNull() && myGlContext->MakeCurrent())
|
||||
{
|
||||
myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||
@@ -164,16 +155,16 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
|
||||
#endif
|
||||
}
|
||||
|
||||
myFontFaceAspect->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
|
||||
myFontFaceAspect->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
|
||||
myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
|
||||
myNoneCulling->Aspect()->SetSuppressBackFaces (false);
|
||||
myNoneCulling->Aspect()->SetDrawEdges (false);
|
||||
myNoneCulling->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||
myNoneCulling .Aspect()->SetSuppressBackFaces (false);
|
||||
myNoneCulling .Aspect()->SetDrawEdges (false);
|
||||
myNoneCulling .Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||
|
||||
myFrontCulling->Aspect()->SetSuppressBackFaces (true);
|
||||
myFrontCulling->Aspect()->SetDrawEdges (false);
|
||||
myFrontCulling->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||
myFrontCulling.Aspect()->SetSuppressBackFaces (true);
|
||||
myFrontCulling.Aspect()->SetDrawEdges (false);
|
||||
myFrontCulling.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -215,12 +206,12 @@ void OpenGl_Workspace::ResetAppliedAspect()
|
||||
|
||||
myHighlightStyle.Nullify();
|
||||
myToAllowFaceCulling = false;
|
||||
myAspectLineSet = myDefaultAspectLine;
|
||||
myAspectFaceSet = myDefaultAspectFace;
|
||||
myAspectLineSet = &myDefaultAspectLine;
|
||||
myAspectFaceSet = &myDefaultAspectFace;
|
||||
myAspectFaceApplied.Nullify();
|
||||
myAspectMarkerSet = myDefaultAspectMarker;
|
||||
myAspectMarkerSet = &myDefaultAspectMarker;
|
||||
myAspectMarkerApplied.Nullify();
|
||||
myAspectTextSet = myDefaultAspectText;
|
||||
myAspectTextSet = &myDefaultAspectText;
|
||||
myGlContext->SetPolygonOffset (Graphic3d_PolygonOffset());
|
||||
|
||||
ApplyAspectLine();
|
||||
@@ -228,8 +219,8 @@ void OpenGl_Workspace::ResetAppliedAspect()
|
||||
ApplyAspectMarker();
|
||||
ApplyAspectText();
|
||||
|
||||
myGlContext->SetTypeOfLine (myDefaultAspectLine->Aspect()->Type());
|
||||
myGlContext->SetLineWidth (myDefaultAspectLine->Aspect()->Width());
|
||||
myGlContext->SetTypeOfLine (myDefaultAspectLine.Aspect()->Type());
|
||||
myGlContext->SetLineWidth (myDefaultAspectLine.Aspect()->Width());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -238,9 +229,9 @@ void OpenGl_Workspace::ResetAppliedAspect()
|
||||
// =======================================================================
|
||||
Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset)
|
||||
{
|
||||
Graphic3d_PolygonOffset aPrev = myDefaultAspectFace->Aspect()->PolygonOffset();
|
||||
myDefaultAspectFace->Aspect()->SetPolygonOffset (theOffset);
|
||||
if (myAspectFaceApplied == myDefaultAspectFace->Aspect()
|
||||
Graphic3d_PolygonOffset aPrev = myDefaultAspectFace.Aspect()->PolygonOffset();
|
||||
myDefaultAspectFace.Aspect()->SetPolygonOffset (theOffset);
|
||||
if (myAspectFaceApplied == myDefaultAspectFace.Aspect()
|
||||
|| myAspectFaceApplied.IsNull()
|
||||
|| (myAspectFaceApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
|
||||
{
|
||||
@@ -253,43 +244,51 @@ Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic
|
||||
// function : SetAspectLine
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Workspace::SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect)
|
||||
const OpenGl_AspectLine* OpenGl_Workspace::SetAspectLine (const OpenGl_AspectLine* theAspect)
|
||||
{
|
||||
const OpenGl_AspectLine* aPrevAspectLine = myAspectLineSet;
|
||||
myAspectLineSet = theAspect;
|
||||
return aPrevAspectLine;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAspectFace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Workspace::SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect)
|
||||
const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace (const OpenGl_AspectFace* theAspect)
|
||||
{
|
||||
const OpenGl_AspectFace* aPrevAspectFace = myAspectFaceSet;
|
||||
myAspectFaceSet = theAspect;
|
||||
return aPrevAspectFace;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAspectMarker
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Workspace::SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect)
|
||||
const OpenGl_AspectMarker* OpenGl_Workspace::SetAspectMarker (const OpenGl_AspectMarker* theAspect)
|
||||
{
|
||||
const OpenGl_AspectMarker* aPrevAspectMarker = myAspectMarkerSet;
|
||||
myAspectMarkerSet = theAspect;
|
||||
return aPrevAspectMarker;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAspectText
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Workspace::SetAspectText (const Handle(OpenGl_AspectText)& theAspect)
|
||||
const OpenGl_AspectText * OpenGl_Workspace::SetAspectText (const OpenGl_AspectText* theAspect)
|
||||
{
|
||||
const OpenGl_AspectText* aPrevAspectText = myAspectTextSet;
|
||||
myAspectTextSet = theAspect;
|
||||
return aPrevAspectText;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ApplyAspectFace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Handle(OpenGl_AspectFace)& OpenGl_Workspace::ApplyAspectFace()
|
||||
const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
|
||||
{
|
||||
if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
|
||||
{
|
||||
@@ -396,7 +395,7 @@ const Handle(OpenGl_AspectFace)& OpenGl_Workspace::ApplyAspectFace()
|
||||
// function : ApplyAspectMarker
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Handle(OpenGl_AspectMarker)& OpenGl_Workspace::ApplyAspectMarker()
|
||||
const OpenGl_AspectMarker* OpenGl_Workspace::ApplyAspectMarker()
|
||||
{
|
||||
if (myAspectMarkerSet->Aspect() != myAspectMarkerApplied)
|
||||
{
|
||||
@@ -430,6 +429,15 @@ Standard_Integer OpenGl_Workspace::Height() const
|
||||
return !myView->GlWindow().IsNull() ? myView->GlWindow()->Height() : 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsCullingEnabled
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Workspace::IsCullingEnabled() const
|
||||
{
|
||||
return myView->IsCullingEnabled();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FBOCreate
|
||||
// purpose :
|
||||
@@ -487,7 +495,7 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
|
||||
// function : ShouldRender
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_Workspace::ShouldRender (const Handle(OpenGl_Element)& theElement)
|
||||
bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
|
||||
{
|
||||
// render only non-raytracable elements when RayTracing is enabled
|
||||
if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0)
|
||||
@@ -523,7 +531,7 @@ bool OpenGl_Workspace::ShouldRender (const Handle(OpenGl_Element)& theElement)
|
||||
{
|
||||
if (!theElement->IsFillDrawMode())
|
||||
{
|
||||
if (Handle(OpenGl_AspectFace)::DownCast(theElement).IsNull())
|
||||
if (dynamic_cast<const OpenGl_AspectFace*> (theElement) == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -163,44 +163,44 @@ public:
|
||||
}
|
||||
|
||||
//! Currently set line aspect (can differ from applied).
|
||||
const Handle(OpenGl_AspectLine)& AspectLine() const { return myAspectLineSet; }
|
||||
const OpenGl_AspectLine* AspectLine() const { return myAspectLineSet; }
|
||||
|
||||
//! Currently set face aspect (can differ from applied).
|
||||
const Handle(OpenGl_AspectFace)& AspectFace() const { return myAspectFaceSet; }
|
||||
const OpenGl_AspectFace* AspectFace() const { return myAspectFaceSet; }
|
||||
|
||||
//! Currently set marker aspect (can differ from applied).
|
||||
const Handle(OpenGl_AspectMarker)& AspectMarker() const { return myAspectMarkerSet; }
|
||||
const OpenGl_AspectMarker* AspectMarker() const { return myAspectMarkerSet; }
|
||||
|
||||
//! Currently set text aspect (can differ from applied).
|
||||
const Handle(OpenGl_AspectText)& AspectText() const { return myAspectTextSet; }
|
||||
const OpenGl_AspectText* AspectText() const { return myAspectTextSet; }
|
||||
|
||||
//! Assign new line aspect (will be applied within ApplyAspectLine()).
|
||||
Standard_EXPORT void SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect);
|
||||
Standard_EXPORT const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
|
||||
|
||||
//! Assign new face aspect (will be applied within ApplyAspectFace()).
|
||||
Standard_EXPORT void SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect);
|
||||
Standard_EXPORT const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
|
||||
|
||||
//! Assign new marker aspect (will be applied within ApplyAspectMarker()).
|
||||
Standard_EXPORT void SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect);
|
||||
Standard_EXPORT const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
|
||||
|
||||
//! Assign new text aspect (will be applied within ApplyAspectText()).
|
||||
Standard_EXPORT void SetAspectText (const Handle(OpenGl_AspectText)& theAspect);
|
||||
Standard_EXPORT const OpenGl_AspectText* SetAspectText (const OpenGl_AspectText* theAspect);
|
||||
|
||||
//! Apply line aspect.
|
||||
//! @return aspect set by SetAspectLine()
|
||||
const Handle(OpenGl_AspectLine)& ApplyAspectLine() { return myAspectLineSet; }
|
||||
const OpenGl_AspectLine* ApplyAspectLine() { return myAspectLineSet; }
|
||||
|
||||
//! Apply face aspect.
|
||||
//! @return aspect set by SetAspectFace()
|
||||
Standard_EXPORT const Handle(OpenGl_AspectFace)& ApplyAspectFace();
|
||||
Standard_EXPORT const OpenGl_AspectFace* ApplyAspectFace();
|
||||
|
||||
//! Apply marker aspect.
|
||||
//! @return aspect set by SetAspectMarker()
|
||||
Standard_EXPORT const Handle(OpenGl_AspectMarker)& ApplyAspectMarker();
|
||||
Standard_EXPORT const OpenGl_AspectMarker* ApplyAspectMarker();
|
||||
|
||||
//! Apply text aspect.
|
||||
//! @return aspect set by SetAspectText()
|
||||
const Handle(OpenGl_AspectText)& ApplyAspectText() { return myAspectTextSet; }
|
||||
const OpenGl_AspectText* ApplyAspectText() { return myAspectTextSet; }
|
||||
|
||||
//! Clear the applied aspect state to default values.
|
||||
void ResetAppliedAspect();
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
//! Checks whether the element can be rendered or not.
|
||||
//! @param theElement [in] the element to check
|
||||
//! @return True if element can be rendered
|
||||
bool ShouldRender (const Handle(OpenGl_Element)& theElement);
|
||||
bool ShouldRender (const OpenGl_Element* theElement);
|
||||
|
||||
//! Return the number of skipped transparent elements within active OpenGl_RenderFilter_OpaqueOnly filter.
|
||||
//! @sa OpenGl_LayerList::Render()
|
||||
@@ -233,13 +233,13 @@ public:
|
||||
inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
|
||||
|
||||
//! Returns face aspect for textured font rendering.
|
||||
const Handle(OpenGl_AspectFace)& FontFaceAspect() const { return myFontFaceAspect; }
|
||||
const OpenGl_AspectFace& FontFaceAspect() const { return myFontFaceAspect; }
|
||||
|
||||
//! Returns face aspect for none culling mode.
|
||||
const Handle(OpenGl_AspectFace)& NoneCulling() const { return myNoneCulling; }
|
||||
const OpenGl_AspectFace& NoneCulling() const { return myNoneCulling; }
|
||||
|
||||
//! Returns face aspect for front face culling mode.
|
||||
const Handle(OpenGl_AspectFace)& FrontCulling() const { return myFrontCulling; }
|
||||
const OpenGl_AspectFace& FrontCulling() const { return myFrontCulling; }
|
||||
|
||||
//! Sets a new environment texture.
|
||||
void SetEnvironmentTexture (const Handle(OpenGl_TextureSet)& theTexture) { myEnvironmentTexture = theTexture; }
|
||||
@@ -254,26 +254,26 @@ protected: //! @name protected fields
|
||||
Handle(OpenGl_Context) myGlContext;
|
||||
Standard_Boolean myUseZBuffer;
|
||||
Standard_Boolean myUseDepthWrite;
|
||||
Handle(OpenGl_AspectFace) myNoneCulling;
|
||||
Handle(OpenGl_AspectFace) myFrontCulling;
|
||||
Handle(OpenGl_AspectFace) myFontFaceAspect;
|
||||
OpenGl_AspectFace myNoneCulling;
|
||||
OpenGl_AspectFace myFrontCulling;
|
||||
OpenGl_AspectFace myFontFaceAspect;
|
||||
|
||||
protected: //! @name fields related to status
|
||||
|
||||
Standard_Integer myNbSkippedTranspElems; //!< counter of skipped transparent elements for OpenGl_LayerList two rendering passes method
|
||||
Standard_Integer myRenderFilter; //!< active filter for skipping rendering of elements by some criteria (multiple render passes)
|
||||
|
||||
Handle(OpenGl_AspectLine) myDefaultAspectLine;
|
||||
Handle(OpenGl_AspectFace) myDefaultAspectFace;
|
||||
Handle(OpenGl_AspectMarker) myDefaultAspectMarker;
|
||||
Handle(OpenGl_AspectText) myDefaultAspectText;
|
||||
OpenGl_AspectLine myDefaultAspectLine;
|
||||
OpenGl_AspectFace myDefaultAspectFace;
|
||||
OpenGl_AspectMarker myDefaultAspectMarker;
|
||||
OpenGl_AspectText myDefaultAspectText;
|
||||
|
||||
Handle(OpenGl_AspectLine) myAspectLineSet;
|
||||
Handle(OpenGl_AspectFace) myAspectFaceSet;
|
||||
const OpenGl_AspectLine* myAspectLineSet;
|
||||
const OpenGl_AspectFace* myAspectFaceSet;
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
|
||||
Handle(OpenGl_AspectMarker) myAspectMarkerSet;
|
||||
const OpenGl_AspectMarker* myAspectMarkerSet;
|
||||
Handle(Graphic3d_AspectMarker3d) myAspectMarkerApplied;
|
||||
Handle(OpenGl_AspectText) myAspectTextSet;
|
||||
const OpenGl_AspectText* myAspectTextSet;
|
||||
Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
|
||||
|
||||
const OpenGl_Matrix* ViewMatrix_applied;
|
||||
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user