Adaption of FreeCAD to QuarterWidget
-removes all soqtviewer references -create a quarter adaptor class which implements missing functionality -adopts freecad code to make use of SoRenderManager and changed View3DInventorViewer interface
This commit is contained in:
parent
e1265c874d
commit
72cab0c002
|
@ -339,7 +339,6 @@ if(FREECAD_LIBPACK_USE)
|
|||
set(FREECAD_USE_EXTERNAL_PIVY ON CACHE BOOL "Switch off local pivy" FORCE)
|
||||
set(FREECAD_LIBPACK_PYSIDEUIC_REL "${FREECAD_LIBPACK_DIR}/pyside-tools/Lib/site-packages")
|
||||
file(GLOB FREECAD_LIBPACK_PIVY_COIN "${FREECAD_LIBPACK_DIR}/pivy/*.*")
|
||||
file(GLOB FREECAD_LIBPACK_PIVY_SOQT "${FREECAD_LIBPACK_DIR}/pivy/gui/*.*")
|
||||
file(GLOB FREECAD_LIBPACK_SHIBOKEN "${FREECAD_LIBPACK_DIR}/shiboken-1.2.1/lib/site-packages/*.pyd")
|
||||
file(GLOB FREECAD_LIBPACK_PYSIDE "${FREECAD_LIBPACK_DIR}/pyside/lib/site-packages/PySide/*.py*")
|
||||
file(GLOB_RECURSE FREECAD_LIBPACK_PYSIDEUIC RELATIVE "${FREECAD_LIBPACK_PYSIDEUIC_REL}" "${FREECAD_LIBPACK_PYSIDEUIC_REL}/pysideuic/*.py")
|
||||
|
@ -613,7 +612,6 @@ else(FREECAD_LIBPACK_USE)
|
|||
# -------------------------------- Coin3D --------------------------------
|
||||
|
||||
find_package(Coin3D REQUIRED)
|
||||
find_package(SoQt REQUIRED)
|
||||
|
||||
# ------------------------------ Spaceball -------------------------------
|
||||
|
||||
|
@ -757,7 +755,7 @@ if(FREECAD_MAINTAINERS_BUILD AND NOT WIN32)
|
|||
set(PKG_ARCH amd64)
|
||||
ENDIF( CMAKE_SIZEOF_VOID_P EQUAL 4 )
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "science")
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python, oce | opencascade, libqtgui4, libcoin60, libsoqt4-20, libxerces-c3.1, zlib1g, libboost-dev, libeigen2-dev")
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python, oce | opencascade, libqtgui4, libcoin60, libxerces-c3.1, zlib1g, libboost-dev, libeigen2-dev")
|
||||
set(CPACK_PACKAGE_CONTACT "<root@localhost>")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${PACKAGE_VERSION}_${PKG_ARCH}")
|
||||
|
||||
|
|
|
@ -33,21 +33,6 @@ if (WIN32 AND FREECAD_LIBPACK_USE)
|
|||
endforeach (it)
|
||||
SOURCE_GROUP("pivy" FILES ${FREECAD_LIBPACK_PIVY_COIN})
|
||||
|
||||
# pivy/gui
|
||||
foreach (it ${FREECAD_LIBPACK_PIVY_SOQT})
|
||||
get_filename_component(libfile ${it} NAME)
|
||||
set(out "${CMAKE_BINARY_DIR}/lib/pivy/gui/${libfile}")
|
||||
add_custom_command(
|
||||
DEPENDS ${it}
|
||||
OUTPUT ${out}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different ${it} ${out}
|
||||
MAIN_DEPENDENCY ${it}
|
||||
COMMENT "Copy file to ${out}"
|
||||
)
|
||||
endforeach (it)
|
||||
SOURCE_GROUP("pivy\\gui" FILES ${FREECAD_LIBPACK_PIVY_SOQT})
|
||||
|
||||
# shiboken
|
||||
foreach (it ${FREECAD_LIBPACK_SHIBOKEN})
|
||||
get_filename_component(libfile ${it} NAME)
|
||||
|
@ -130,7 +115,6 @@ if (WIN32 AND FREECAD_LIBPACK_USE)
|
|||
|
||||
set(FREECAD_LIBPACK_FILES
|
||||
${FREECAD_LIBPACK_PIVY_COIN}
|
||||
${FREECAD_LIBPACK_PIVY_SOQT}
|
||||
${FREECAD_LIBPACK_SHIBOKEN}
|
||||
${FREECAD_LIBPACK_PYSIDE}
|
||||
${FREECAD_LIBPACK_PYSIDEUIC_ABS}
|
||||
|
|
44
src/3rdParty/Pivy-0.5/CMakeLists.txt
vendored
44
src/3rdParty/Pivy-0.5/CMakeLists.txt
vendored
|
@ -1,10 +1,9 @@
|
|||
add_definitions(-DSOQT_DLL -DCOIN_DLL)
|
||||
add_definitions(-DCOIN_DLL)
|
||||
|
||||
include_directories(
|
||||
../include
|
||||
${COIN3D_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
|
@ -51,44 +50,3 @@ fc_copy_sources(coin "${CMAKE_BINARY_DIR}/bin/pivy"
|
|||
|
||||
install(TARGETS coin DESTINATION bin/pivy)
|
||||
install(FILES __init__.py coin.py sogui.py DESTINATION bin/pivy)
|
||||
|
||||
########################### SoQtPy ###########################
|
||||
|
||||
set(SoQtPy_SRCS
|
||||
soqt_wrap.cpp
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
set(SoQtPy_LIBS
|
||||
debug MSVCRTD.LIB
|
||||
debug MSVCPRTD.LIB
|
||||
optimized MSVCRT.LIB
|
||||
optimized MSVCPRT.LIB
|
||||
Rpcrt4.lib
|
||||
debug ${SOQT_LIBRARY_DEBUG}
|
||||
optimized ${SOQT_LIBRARY_RELEASE}
|
||||
debug ${COIN3D_LIBRARY_DEBUG}
|
||||
optimized ${COIN3D_LIBRARY_RELEASE}
|
||||
debug ${PYTHON_DEBUG_LIBRARY}
|
||||
optimized ${PYTHON_LIBRARY})
|
||||
else(MSVC)
|
||||
set(SoQtPy_LIBS
|
||||
${SOQT_LIBRARIES}
|
||||
${COIN3D_LIBRARY}
|
||||
${PYTHON_LIBRARY})
|
||||
endif(MSVC)
|
||||
|
||||
add_library(soqt SHARED ${SoQtPy_SRCS})
|
||||
|
||||
target_link_libraries(soqt ${SoQtPy_LIBS})
|
||||
|
||||
SET_BIN_DIR(soqt _soqt /bin/pivy/gui)
|
||||
SET_PYTHON_PREFIX_SUFFIX(soqt)
|
||||
|
||||
fc_copy_sources(soqt "${CMAKE_BINARY_DIR}/bin/pivy"
|
||||
gui/soqt.py
|
||||
gui/__init__.py
|
||||
)
|
||||
|
||||
install(TARGETS soqt DESTINATION bin/pivy/gui)
|
||||
install(FILES gui/__init__.py soqt.py DESTINATION bin/pivy/gui)
|
||||
|
|
44
src/3rdParty/Pivy/CMakeLists.txt
vendored
44
src/3rdParty/Pivy/CMakeLists.txt
vendored
|
@ -1,10 +1,9 @@
|
|||
add_definitions(-DSOQT_DLL -DCOIN_DLL)
|
||||
add_definitions(-DCOIN_DLL)
|
||||
|
||||
include_directories(
|
||||
../include
|
||||
${COIN3D_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
|
@ -51,44 +50,3 @@ fc_copy_sources(coin "${CMAKE_BINARY_DIR}/bin/pivy"
|
|||
|
||||
install(TARGETS coin DESTINATION bin/pivy)
|
||||
install(FILES __init__.py coin.py sogui.py DESTINATION bin/pivy)
|
||||
|
||||
########################### SoQtPy ###########################
|
||||
|
||||
set(SoQtPy_SRCS
|
||||
soqt_wrap.cpp
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
set(SoQtPy_LIBS
|
||||
debug MSVCRTD.LIB
|
||||
debug MSVCPRTD.LIB
|
||||
optimized MSVCRT.LIB
|
||||
optimized MSVCPRT.LIB
|
||||
Rpcrt4.lib
|
||||
debug ${SOQT_LIBRARY_DEBUG}
|
||||
optimized ${SOQT_LIBRARY_RELEASE}
|
||||
debug ${COIN3D_LIBRARY_DEBUG}
|
||||
optimized ${COIN3D_LIBRARY_RELEASE}
|
||||
debug ${PYTHON_DEBUG_LIBRARY}
|
||||
optimized ${PYTHON_LIBRARY})
|
||||
else(MSVC)
|
||||
set(SoQtPy_LIBS
|
||||
${SOQT_LIBRARIES}
|
||||
${COIN3D_LIBRARY}
|
||||
${PYTHON_LIBRARY})
|
||||
endif(MSVC)
|
||||
|
||||
add_library(soqt SHARED ${SoQtPy_SRCS})
|
||||
|
||||
target_link_libraries(soqt ${SoQtPy_LIBS})
|
||||
|
||||
SET_BIN_DIR(soqt _soqt /bin/pivy/gui)
|
||||
SET_PYTHON_PREFIX_SUFFIX(soqt)
|
||||
|
||||
fc_copy_sources(soqt "${CMAKE_BINARY_DIR}/bin/pivy"
|
||||
gui/soqt.py
|
||||
gui/__init__.py
|
||||
)
|
||||
|
||||
install(TARGETS soqt DESTINATION bin/pivy/gui)
|
||||
install(FILES gui/__init__.py gui/soqt.py DESTINATION bin/pivy/gui)
|
||||
|
|
|
@ -102,6 +102,8 @@
|
|||
|
||||
#include "Language/Translator.h"
|
||||
#include "TaskView/TaskDialogPython.h"
|
||||
#include <Gui/Quarter/Quarter.h>
|
||||
#include "View3DViewerPy.h"
|
||||
#include "GuiInitScript.h"
|
||||
|
||||
|
||||
|
@ -300,14 +302,6 @@ FreeCADGui_getSoDBVersion(PyObject * /*self*/, PyObject *args)
|
|||
return PyString_FromString(SoDB::getVersion());
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
FreeCADGui_getSoQtVersion(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return PyString_FromString(SoQt::getVersionString());
|
||||
}
|
||||
|
||||
struct PyMethodDef FreeCADGui_methods[] = {
|
||||
{"subgraphFromObject",FreeCADGui_subgraphFromObject,METH_VARARGS,
|
||||
"subgraphFromObject(object) -> Node\n\n"
|
||||
|
@ -316,10 +310,6 @@ struct PyMethodDef FreeCADGui_methods[] = {
|
|||
"getSoDBVersion() -> String\n\n"
|
||||
"Return a text string containing the name\n"
|
||||
"of the Coin library and version information"},
|
||||
{"getSoQtVersion",FreeCADGui_getSoQtVersion,METH_VARARGS,
|
||||
"getSoQtVersion() -> String\n\n"
|
||||
"Return a text string containing the name\n"
|
||||
"of the SoQt library and version information"},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
@ -450,12 +440,11 @@ Application::~Application()
|
|||
BitmapFactoryInst::destruct();
|
||||
|
||||
#if 0
|
||||
// we must run the garbage collector before shutting down the SoDB or SoQt
|
||||
// we must run the garbage collector before shutting down the SoDB
|
||||
// subsystem because we may reference some class objects of them in Python
|
||||
Base::Interpreter().cleanupSWIG("SoBase *");
|
||||
// finish also Inventor subsystem
|
||||
SoFCDB::finish();
|
||||
SoQt::done();
|
||||
|
||||
#if (COIN_MAJOR_VERSION >= 2) && (COIN_MINOR_VERSION >= 4)
|
||||
SoDB::finish();
|
||||
|
@ -1440,10 +1429,6 @@ void messageHandlerCoin(const SoError * error, void * userdata)
|
|||
}
|
||||
}
|
||||
|
||||
void messageHandlerSoQt(const SbString errmsg, SoQt::FatalErrors errcode, void *userdata)
|
||||
{
|
||||
Base::Console().Error( errmsg.getString() );
|
||||
}
|
||||
#endif
|
||||
|
||||
// To fix bug #0000345 move Q_INIT_RESOURCE() outside initApplication()
|
||||
|
@ -1673,7 +1658,7 @@ void Application::runApplication(void)
|
|||
|
||||
// init the Inventor subsystem
|
||||
SoDB::init();
|
||||
SoQt::init(&mw);
|
||||
SIM::Coin3D::Quarter::Quarter::init();
|
||||
SoFCDB::init();
|
||||
|
||||
QString home = QString::fromUtf8(App::GetApplication().GetHomePath());
|
||||
|
@ -1775,7 +1760,6 @@ void Application::runApplication(void)
|
|||
|
||||
#ifdef FC_DEBUG // redirect Coin messages to FreeCAD
|
||||
SoDebugError::setHandlerCallback( messageHandlerCoin, 0 );
|
||||
SoQt::setFatalErrorHandler( messageHandlerSoQt, 0 );
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -89,12 +89,12 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
|
||||
const SoType type(ev->getTypeId());
|
||||
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
const SbVec2s size(vp.getViewportSizePixels());
|
||||
const SbVec2f prevnormalized = this->lastmouseposition;
|
||||
const SbVec2s pos(ev->getPosition());
|
||||
const SbVec2f posn((float) pos[0] / (float) SoQtMax((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) SoQtMax((int)(size[1] - 1), 1));
|
||||
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
|
||||
|
||||
this->lastmouseposition = posn;
|
||||
|
||||
|
@ -167,7 +167,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
const int button = event->getButton();
|
||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
|
||||
|
||||
// SoDebugError::postInfo("processSoEvent", "button = %d", button);
|
||||
//SoDebugError::postInfo("processSoEvent", "button = %d", button);
|
||||
switch (button) {
|
||||
case SoMouseButtonEvent::BUTTON1:
|
||||
this->lockrecenter = TRUE;
|
||||
|
@ -243,8 +243,8 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
if (press) {
|
||||
this->centerTime = ev->getTime();
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
SbViewVolume vv = viewer->getCamera()->getViewVolume(ratio);
|
||||
this->panningplane = vv.getPlane(viewer->getCamera()->focalDistance.getValue());
|
||||
SbViewVolume vv = viewer->getSoRenderManager()->getCamera()->getViewVolume(ratio);
|
||||
this->panningplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue());
|
||||
this->lockrecenter = FALSE;
|
||||
}
|
||||
else {
|
||||
|
@ -262,11 +262,11 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
this->button3down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getCamera(), TRUE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), TRUE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getCamera(), FALSE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), FALSE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -284,7 +284,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
}
|
||||
else if (this->currentmode == NavigationStyle::PANNING) {
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
panCamera(viewer->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (this->currentmode == NavigationStyle::DRAGGING) {
|
||||
|
|
|
@ -93,12 +93,12 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
|
||||
const SoType type(ev->getTypeId());
|
||||
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
const SbVec2s size(vp.getViewportSizePixels());
|
||||
const SbVec2f prevnormalized = this->lastmouseposition;
|
||||
const SbVec2s pos(ev->getPosition());
|
||||
const SbVec2f posn((float) pos[0] / (float) SoQtMax((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) SoQtMax((int)(size[1] - 1), 1));
|
||||
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
|
||||
|
||||
this->lastmouseposition = posn;
|
||||
|
||||
|
@ -271,8 +271,8 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
if (press) {
|
||||
this->centerTime = ev->getTime();
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
SbViewVolume vv = viewer->getCamera()->getViewVolume(ratio);
|
||||
this->panningplane = vv.getPlane(viewer->getCamera()->focalDistance.getValue());
|
||||
SbViewVolume vv = viewer->getSoRenderManager()->getCamera()->getViewVolume(ratio);
|
||||
this->panningplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue());
|
||||
this->lockrecenter = FALSE;
|
||||
}
|
||||
else {
|
||||
|
@ -290,11 +290,11 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
this->button3down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getCamera(), TRUE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), TRUE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getCamera(), FALSE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), FALSE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -312,7 +312,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
}
|
||||
else if (this->currentmode == NavigationStyle::PANNING) {
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
panCamera(viewer->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (this->currentmode == NavigationStyle::DRAGGING) {
|
||||
|
|
|
@ -14,16 +14,17 @@ endif(BUILD_VR)
|
|||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Quarter
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
${CMAKE_CURRENT_BINARY_DIR}/..
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Language
|
||||
${CMAKE_CURRENT_BINARY_DIR}/propertyeditor
|
||||
${CMAKE_CURRENT_BINARY_DIR}/TaskView
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Quarter
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
|
@ -34,8 +35,6 @@ if(MSVC)
|
|||
FreeCADApp
|
||||
debug ${COIN3D_LIBRARY_DEBUG}
|
||||
optimized ${COIN3D_LIBRARY_RELEASE}
|
||||
debug ${SOQT_LIBRARY_DEBUG}
|
||||
optimized ${SOQT_LIBRARY_RELEASE}
|
||||
${QT_DEBUG_LIBRARIES}
|
||||
${QT_LIBRARIES}
|
||||
optimized QtUiTools.lib
|
||||
|
@ -47,7 +46,6 @@ else(MSVC)
|
|||
FreeCADBase
|
||||
FreeCADApp
|
||||
${COIN3D_LIBRARY}
|
||||
${SOQT_LIBRARIES}
|
||||
${QT_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${OPENGL_gl_LIBRARY}
|
||||
|
@ -682,6 +680,17 @@ SET(View3D_SRCS
|
|||
)
|
||||
SOURCE_GROUP("View3D" FILES ${View3D_SRCS})
|
||||
|
||||
#quarter sources
|
||||
FILE(GLOB_RECURSE Quarter_CPP_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Quarter/*.cpp)
|
||||
FILE(GLOB_RECURSE Quarter_H_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Quarter/*.h)
|
||||
fc_wrap_cpp(Quarter_MOC_SRCS ${Quarter_H_SRC})
|
||||
SET(Quarter_SRCS
|
||||
${Quarter_CPP_SRC}
|
||||
${Quarter_H_SRC}
|
||||
${Quarter_MOC_SRCS}
|
||||
)
|
||||
SOURCE_GROUP("Quarter" FILES ${Quarter_SRCS})
|
||||
|
||||
# The view provider sources
|
||||
SET(Viewprovider_CPP_SRCS
|
||||
ViewProvider.cpp
|
||||
|
@ -872,7 +881,7 @@ SET(FreeCADGui_CPP_SRCS
|
|||
WaitCursor.cpp
|
||||
ManualAlignment.cpp
|
||||
)
|
||||
SET(FreeCADGui_SRCS
|
||||
SET(FreeCADGui_SRCS
|
||||
Application.h
|
||||
BitmapFactory.h
|
||||
Document.h
|
||||
|
@ -914,6 +923,7 @@ SET(FreeCADGui_SRCS
|
|||
${Task_View_SRCS}
|
||||
${iisTaskPanel_SRCS}
|
||||
${Resource_SRCS}
|
||||
${Quarter_SRCS}
|
||||
${View3D_SRCS}
|
||||
${Viewprovider_SRCS}
|
||||
${Widget_SRCS}
|
||||
|
@ -943,6 +953,7 @@ if(MSVC)
|
|||
${Editor_CPP_SRCS}
|
||||
${Help_CPP_SRCS}
|
||||
${Inventor_CPP_SRCS}
|
||||
${Quarter_SRCS}
|
||||
${View3D_CPP_SRCS}
|
||||
${Viewprovider_CPP_SRCS}
|
||||
${Widget_CPP_SRCS}
|
||||
|
|
|
@ -128,7 +128,7 @@ Clipping::Clipping(Gui::View3DInventor* view, QWidget* parent)
|
|||
d->node->insertChild(d->clipZ, 0);
|
||||
d->node->insertChild(d->clipView, 0);
|
||||
|
||||
SoGetBoundingBoxAction action(viewer->getViewportRegion());
|
||||
SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion());
|
||||
action.apply(viewer->getSceneGraph());
|
||||
SbBox3f box = action.getBoundingBox();
|
||||
|
||||
|
|
|
@ -491,14 +491,14 @@ std::string Command::getPythonTuple(const std::string& name, const std::vector<s
|
|||
{
|
||||
std::stringstream str;
|
||||
std::vector<std::string>::const_iterator last = --subnames.end();
|
||||
str << "(App.ActiveDocument." << name << ",[";
|
||||
for (std::vector<std::string>::const_iterator it = subnames.begin();it!=subnames.end();++it){
|
||||
str << "\"" << *it << "\"";
|
||||
if (it != last)
|
||||
str << ",";
|
||||
}
|
||||
str << "])";
|
||||
return str.str();
|
||||
str << "(App.ActiveDocument." << name << ",[";
|
||||
for (std::vector<std::string>::const_iterator it = subnames.begin();it!=subnames.end();++it){
|
||||
str << "\"" << *it << "\"";
|
||||
if (it != last)
|
||||
str << ",";
|
||||
}
|
||||
str << "])";
|
||||
return str.str();
|
||||
}
|
||||
|
||||
const std::string Command::strToPython(const char* Str)
|
||||
|
@ -614,12 +614,12 @@ void Command::adjustCameraPosition()
|
|||
if (doc) {
|
||||
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
|
||||
Gui::View3DInventorViewer* viewer = view->getViewer();
|
||||
SoCamera* camera = viewer->getCamera();
|
||||
SoCamera* camera = viewer->getSoRenderManager()->getCamera();
|
||||
if (!camera || !camera->isOfType(SoOrthographicCamera::getClassTypeId()))
|
||||
return;
|
||||
|
||||
// get scene bounding box
|
||||
SoGetBoundingBoxAction action(viewer->getViewportRegion());
|
||||
SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion());
|
||||
action.apply(viewer->getSceneGraph());
|
||||
SbBox3f box = action.getBoundingBox();
|
||||
if (box.isEmpty()) return;
|
||||
|
|
|
@ -1232,7 +1232,7 @@ void StdCmdAlignment::activated(int iMsg)
|
|||
View3DInventor* mdi = qobject_cast<View3DInventor*>(doc->getActiveView());
|
||||
if (mdi) {
|
||||
View3DInventorViewer* viewer = mdi->getViewer();
|
||||
SoCamera* camera = viewer->getCamera();
|
||||
SoCamera* camera = viewer->getSoRenderManager()->getCamera();
|
||||
if (camera) {
|
||||
SbVec3f up(0,1,0), dir(0,0,-1);
|
||||
camera->orientation.getValue().multVec(dir, dir);
|
||||
|
|
|
@ -103,7 +103,7 @@ void StdOrthographicCamera::activated(int iMsg)
|
|||
{
|
||||
if (iMsg == 1) {
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (view->getViewer()->getCameraType() != SoOrthographicCamera::getClassTypeId())
|
||||
if (view->getViewer()->getSoRenderManager()->getCamera()->getTypeId() != SoOrthographicCamera::getClassTypeId())
|
||||
doCommand(Command::Gui,"Gui.activeDocument().activeView().setCameraType(\"Orthographic\")");
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ bool StdOrthographicCamera::isActive(void)
|
|||
if (view) {
|
||||
// update the action group if needed
|
||||
bool check = _pcAction->isChecked();
|
||||
bool mode = view->getViewer()->getCameraType() == SoOrthographicCamera::getClassTypeId();
|
||||
bool mode = view->getViewer()->getSoRenderManager()->getCamera()->getTypeId() == SoOrthographicCamera::getClassTypeId();
|
||||
if (mode != check)
|
||||
_pcAction->setChecked(mode);
|
||||
return true;
|
||||
|
@ -149,7 +149,7 @@ void StdPerspectiveCamera::activated(int iMsg)
|
|||
{
|
||||
if (iMsg == 1) {
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (view->getViewer()->getCameraType() != SoPerspectiveCamera::getClassTypeId())
|
||||
if (view->getViewer()->getSoRenderManager()->getCamera()->getTypeId() != SoPerspectiveCamera::getClassTypeId())
|
||||
doCommand(Command::Gui,"Gui.activeDocument().activeView().setCameraType(\"Perspective\")");
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ bool StdPerspectiveCamera::isActive(void)
|
|||
if (view) {
|
||||
// update the action group if needed
|
||||
bool check = _pcAction->isChecked();
|
||||
bool mode = view->getViewer()->getCameraType() == SoPerspectiveCamera::getClassTypeId();
|
||||
bool mode = view->getViewer()->getSoRenderManager()->getCamera()->getTypeId() == SoPerspectiveCamera::getClassTypeId();
|
||||
if (mode != check)
|
||||
_pcAction->setChecked(mode);
|
||||
|
||||
|
@ -1461,7 +1461,7 @@ void StdViewScreenShot::activated(int iMsg)
|
|||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (view) {
|
||||
QStringList formats;
|
||||
SbViewportRegion vp(view->getViewer()->getViewportRegion());
|
||||
SbViewportRegion vp(view->getViewer()->getSoRenderManager()->getViewportRegion());
|
||||
{
|
||||
SoFCOffscreenRenderer& rd = SoFCOffscreenRenderer::instance();
|
||||
formats = rd.getWriteImageFiletypeInfo();
|
||||
|
@ -2151,7 +2151,7 @@ static void selectionCallback(void * ud, SoEventCallback * cb)
|
|||
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(TRUE);
|
||||
|
||||
std::vector<SbVec2f> picked = view->getGLPolygon();
|
||||
SoCamera* cam = view->getCamera();
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
|
|
|
@ -138,7 +138,7 @@ float DemoMode::getSpeed(int v) const
|
|||
|
||||
SbVec3f DemoMode::getDirection(Gui::View3DInventor* view) const
|
||||
{
|
||||
SoCamera* cam = view->getViewer()->getCamera();
|
||||
SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera();
|
||||
if (!cam) return this->viewAxis;
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
SbRotation inv = rot.inverse();
|
||||
|
@ -154,7 +154,7 @@ void DemoMode::on_angleSlider_valueChanged(int v)
|
|||
{
|
||||
Gui::View3DInventor* view = activeView();
|
||||
if (view) {
|
||||
SoCamera* cam = view->getViewer()->getCamera();
|
||||
SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera();
|
||||
if (!cam) return;
|
||||
float angle = Base::toRadians<float>(/*90-v*/v-this->oldvalue);
|
||||
SbRotation rot(SbVec3f(-1,0,0),angle);
|
||||
|
@ -195,7 +195,7 @@ void DemoMode::on_playButton_clicked()
|
|||
Gui::View3DInventor* view = activeView();
|
||||
if (view) {
|
||||
if (!view->getViewer()->isAnimating()) {
|
||||
SoCamera* cam = view->getViewer()->getCamera();
|
||||
SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera();
|
||||
if (cam) {
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
SbVec3f vec(0,-1,0);
|
||||
|
|
|
@ -487,13 +487,13 @@ void GLFlagWindow::addFlag(Flag* item, FlagLayout::Position pos)
|
|||
{
|
||||
if (!_flagLayout) {
|
||||
_flagLayout = new FlagLayout(3);
|
||||
_viewer->getGLWidget()->setLayout(_flagLayout);
|
||||
_viewer->setLayout(_flagLayout);
|
||||
}
|
||||
|
||||
item->setParent(_viewer->getGLWidget());
|
||||
item->setParent(_viewer);
|
||||
_flagLayout->addWidget(item, pos);
|
||||
item->show();
|
||||
_viewer->scheduleRedraw();
|
||||
_viewer->getSoRenderManager()->scheduleRedraw();
|
||||
}
|
||||
|
||||
void GLFlagWindow::removeFlag(Flag* item)
|
||||
|
@ -525,13 +525,13 @@ void GLFlagWindow::paintGL()
|
|||
{
|
||||
// draw lines for the flags
|
||||
if (_flagLayout) {
|
||||
// it can happen that the GL widget gets replaced internally by SoQt which
|
||||
// it can happen that the GL widget gets replaced internally (SoQt only, not with quarter) which
|
||||
// causes to destroy the FlagLayout instance
|
||||
int ct = _flagLayout->count();
|
||||
const SbViewportRegion vp = _viewer->getViewportRegion();
|
||||
const SbViewportRegion vp = _viewer->getSoRenderManager()->getViewportRegion();
|
||||
SbVec2s size = vp.getViewportSizePixels();
|
||||
float aspectratio = float(size[0])/float(size[1]);
|
||||
SbViewVolume vv = _viewer->getCamera()->getViewVolume(aspectratio);
|
||||
float aspectratio = float(size[0])/float(size[1]);
|
||||
SbViewVolume vv = _viewer->getSoRenderManager()->getCamera()->getViewVolume(aspectratio);
|
||||
for (int i=0; i<ct;i++) {
|
||||
Flag* flag = qobject_cast<Flag*>(_flagLayout->itemAt(i)->widget());
|
||||
if (flag) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "GLPainter.h"
|
||||
#include "View3DInventorViewer.h"
|
||||
#include <Base/Console.h>
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
|
@ -44,16 +45,17 @@ GLPainter::~GLPainter()
|
|||
|
||||
bool GLPainter::begin(View3DInventorViewer* v)
|
||||
{
|
||||
if (viewer)
|
||||
if(viewer)
|
||||
return false;
|
||||
|
||||
viewer = v;
|
||||
|
||||
// Make current context
|
||||
SbVec2s view = viewer->getGLSize();
|
||||
SbVec2s view = viewer->getSoRenderManager()->getSize();
|
||||
this->width = view[0];
|
||||
this->height = view[1];
|
||||
|
||||
viewer->glLockNormal();
|
||||
viewer->makeCurrent();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
@ -83,15 +85,17 @@ bool GLPainter::begin(View3DInventorViewer* v)
|
|||
|
||||
bool GLPainter::end()
|
||||
{
|
||||
if (!viewer)
|
||||
if(!viewer)
|
||||
return false;
|
||||
|
||||
glFlush();
|
||||
if (this->logicOp) {
|
||||
|
||||
if(this->logicOp) {
|
||||
this->logicOp = false;
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
}
|
||||
if (this->lineStipple) {
|
||||
|
||||
if(this->lineStipple) {
|
||||
this->lineStipple = false;
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
}
|
||||
|
@ -103,9 +107,6 @@ bool GLPainter::end()
|
|||
|
||||
glPopAttrib();
|
||||
glPopMatrix();
|
||||
|
||||
// Release the context
|
||||
viewer->glUnlockNormal();
|
||||
|
||||
viewer = 0;
|
||||
return true;
|
||||
|
@ -165,34 +166,110 @@ void GLPainter::resetLineStipple()
|
|||
// Draw routines
|
||||
void GLPainter::drawRect(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
if (!viewer)
|
||||
if(!viewer)
|
||||
return;
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex3i(x1, this->height-y1, 0);
|
||||
glVertex3i(x2, this->height-y1, 0);
|
||||
glVertex3i(x2, this->height-y2, 0);
|
||||
glVertex3i(x1, this->height-y2, 0);
|
||||
glVertex3i(x1, this->height-y1, 0);
|
||||
glVertex3i(x2, this->height-y1, 0);
|
||||
glVertex3i(x2, this->height-y2, 0);
|
||||
glVertex3i(x1, this->height-y2, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void GLPainter::drawLine (int x1, int y1, int x2, int y2)
|
||||
void GLPainter::drawLine(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
if (!viewer)
|
||||
if(!viewer)
|
||||
return;
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex3i(x1, this->height-y1, 0);
|
||||
glVertex3i(x2, this->height-y2, 0);
|
||||
glVertex3i(x1, this->height-y1, 0);
|
||||
glVertex3i(x2, this->height-y2, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void GLPainter::drawPoint(int x, int y)
|
||||
{
|
||||
if (!viewer)
|
||||
if(!viewer)
|
||||
return;
|
||||
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3i(x, this->height-y, 0);
|
||||
glVertex3i(x, this->height-y, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Rubberband::Rubberband(Gui::View3DInventorViewer* v) : viewer(v)
|
||||
{
|
||||
x_old = y_old = x_new = y_new = 0;
|
||||
working = false;
|
||||
}
|
||||
|
||||
Rubberband::Rubberband()
|
||||
{
|
||||
x_old = y_old = x_new = y_new = 0;
|
||||
working = false;
|
||||
}
|
||||
|
||||
Rubberband::~Rubberband()
|
||||
{
|
||||
}
|
||||
|
||||
void Rubberband::setWorking(bool on)
|
||||
{
|
||||
working = on;
|
||||
}
|
||||
|
||||
void Rubberband::setViewer(View3DInventorViewer* v)
|
||||
{
|
||||
viewer = v;
|
||||
}
|
||||
|
||||
void Rubberband::setCoords(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
x_old = x1;
|
||||
y_old = y1;
|
||||
x_new = x2;
|
||||
y_new = y2;
|
||||
}
|
||||
|
||||
void Rubberband::paintGL()
|
||||
{
|
||||
if(!working)
|
||||
return;
|
||||
|
||||
const SbViewportRegion vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
SbVec2s size = vp.getViewportSizePixels();
|
||||
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
||||
glOrtho(0, size[0], size[1], 0, 0, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glLineWidth(4.0);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
glRecti(x_old, y_old, x_new, y_new);
|
||||
glColor4f(0.0, 0.0, 1.0, 1.0);
|
||||
glLineStipple(3, 0xAAAA);
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
|
||||
glLineWidth(4.0);
|
||||
glColor4f(0.0, 0.0, 1.0, 1.0);
|
||||
glLineStipple(3, 0xAAAA);
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2i(x_old, y_old);
|
||||
glVertex2i(x_old, y_new);
|
||||
glVertex2i(x_new, y_new);
|
||||
glVertex2i(x_new, y_old);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,22 @@ public:
|
|||
virtual void paintGL() = 0;
|
||||
};
|
||||
|
||||
class GuiExport Rubberband : public Gui::GLGraphicsItem
|
||||
{
|
||||
Gui::View3DInventorViewer* viewer;
|
||||
int x_old, y_old, x_new, y_new;
|
||||
bool working;
|
||||
public:
|
||||
Rubberband(Gui::View3DInventorViewer* v);
|
||||
Rubberband();
|
||||
~Rubberband();
|
||||
void setWorking(bool on);
|
||||
void setViewer(Gui::View3DInventorViewer* v);
|
||||
void setCoords(int x1, int y1, int x2, int y2);
|
||||
void paintGL();
|
||||
};
|
||||
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_GLPAINTER_H
|
||||
|
|
|
@ -69,7 +69,7 @@ float SoAutoZoomTranslation::getScaleFactor()
|
|||
Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView();
|
||||
if (mdi && mdi->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
Gui::View3DInventorViewer *viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
|
||||
float fScale = viewer->getCamera()->getViewVolume(viewer->getCamera()->aspectRatio.getValue()).getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / 5;
|
||||
float fScale = viewer->getSoRenderManager()->getCamera()->getViewVolume(viewer->getSoRenderManager()->getCamera()->aspectRatio.getValue()).getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / 5;
|
||||
if (fScale != this->scale) this->touch();
|
||||
this->scale = fScale;
|
||||
return this->scale;
|
||||
|
|
|
@ -89,12 +89,12 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
|
||||
const SoType type(ev->getTypeId());
|
||||
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
const SbVec2s size(vp.getViewportSizePixels());
|
||||
const SbVec2f prevnormalized = this->lastmouseposition;
|
||||
const SbVec2s pos(ev->getPosition());
|
||||
const SbVec2f posn((float) pos[0] / (float) SoQtMax((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) SoQtMax((int)(size[1] - 1), 1));
|
||||
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
|
||||
|
||||
this->lastmouseposition = posn;
|
||||
|
||||
|
@ -175,8 +175,8 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
(this->currentmode != NavigationStyle::SELECTION)) {
|
||||
this->centerTime = ev->getTime();
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
SbViewVolume vv = viewer->getCamera()->getViewVolume(ratio);
|
||||
this->panningplane = vv.getPlane(viewer->getCamera()->focalDistance.getValue());
|
||||
SbViewVolume vv = viewer->getSoRenderManager()->getCamera()->getViewVolume(ratio);
|
||||
this->panningplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue());
|
||||
this->lockrecenter = FALSE;
|
||||
}
|
||||
else if (!press && ev->wasShiftDown() &&
|
||||
|
@ -235,8 +235,8 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
if (press) {
|
||||
this->centerTime = ev->getTime();
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
SbViewVolume vv = viewer->getCamera()->getViewVolume(ratio);
|
||||
this->panningplane = vv.getPlane(viewer->getCamera()->focalDistance.getValue());
|
||||
SbViewVolume vv = viewer->getSoRenderManager()->getCamera()->getViewVolume(ratio);
|
||||
this->panningplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue());
|
||||
this->lockrecenter = FALSE;
|
||||
}
|
||||
else {
|
||||
|
@ -254,11 +254,11 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
this->button3down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getCamera(), TRUE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), TRUE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getCamera(), FALSE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), FALSE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -276,7 +276,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
}
|
||||
else if (this->currentmode == NavigationStyle::PANNING) {
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
panCamera(viewer->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (this->currentmode == NavigationStyle::DRAGGING) {
|
||||
|
|
|
@ -367,9 +367,9 @@ public:
|
|||
// apply the user settings
|
||||
setupSettings();
|
||||
|
||||
static_cast<SoGroup*>(getViewer(0)->getSceneManager()->getSceneGraph())->
|
||||
static_cast<SoGroup*>(getViewer(0)->getSceneGraph())->
|
||||
addChild(setupHeadUpDisplay(tr("Movable object")));
|
||||
static_cast<SoGroup*>(getViewer(1)->getSceneManager()->getSceneGraph())->
|
||||
static_cast<SoGroup*>(getViewer(1)->getSceneGraph())->
|
||||
addChild(setupHeadUpDisplay(tr("Fixed object")));
|
||||
}
|
||||
~AlignmentView()
|
||||
|
@ -518,8 +518,8 @@ public:
|
|||
ManualAlignment* self = reinterpret_cast<ManualAlignment*>(data);
|
||||
if (!self->myViewer)
|
||||
return; // already destroyed
|
||||
SoCamera* cam1 = self->myViewer->getViewer(0)->getCamera();
|
||||
SoCamera* cam2 = self->myViewer->getViewer(1)->getCamera();
|
||||
SoCamera* cam1 = self->myViewer->getViewer(0)->getSoRenderManager()->getCamera();
|
||||
SoCamera* cam2 = self->myViewer->getViewer(1)->getSoRenderManager()->getCamera();
|
||||
if (!cam1 || !cam2)
|
||||
return; // missing camera
|
||||
SoNodeSensor* sensor = static_cast<SoNodeSensor*>(s);
|
||||
|
@ -528,12 +528,12 @@ public:
|
|||
if (node == cam1) {
|
||||
Private::copyCameraSettings(cam1, self->d->rot_cam1, self->d->pos_cam1,
|
||||
cam2, self->d->rot_cam2, self->d->pos_cam2);
|
||||
self->myViewer->getViewer(1)->render();
|
||||
self->myViewer->getViewer(1)->redraw();
|
||||
}
|
||||
else if (node == cam2) {
|
||||
Private::copyCameraSettings(cam2, self->d->rot_cam2, self->d->pos_cam2,
|
||||
cam1, self->d->rot_cam1, self->d->pos_cam1);
|
||||
self->myViewer->getViewer(0)->render();
|
||||
self->myViewer->getViewer(0)->redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ void ManualAlignment::setViewingDirections(const Base::Vector3d& view1, const Ba
|
|||
SbVec3f up(0.0f, 1.0f, 0.0f);
|
||||
rot.multVec(up, up);
|
||||
rot2.setValue(up, SbVec3f(up1.x, up1.y, up1.z));
|
||||
myViewer->getViewer(0)->getCamera()->orientation.setValue(rot * rot2);
|
||||
myViewer->getViewer(0)->getSoRenderManager()->getCamera()->orientation.setValue(rot * rot2);
|
||||
myViewer->getViewer(0)->viewAll();
|
||||
}
|
||||
|
||||
|
@ -699,7 +699,7 @@ void ManualAlignment::setViewingDirections(const Base::Vector3d& view1, const Ba
|
|||
SbVec3f up(0.0f, 1.0f, 0.0f);
|
||||
rot.multVec(up, up);
|
||||
rot2.setValue(up, SbVec3f(up2.x, up2.y, up2.z));
|
||||
myViewer->getViewer(1)->getCamera()->orientation.setValue(rot * rot2);
|
||||
myViewer->getViewer(1)->getSoRenderManager()->getCamera()->orientation.setValue(rot * rot2);
|
||||
myViewer->getViewer(1)->viewAll();
|
||||
}
|
||||
}
|
||||
|
@ -1209,8 +1209,8 @@ void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n)
|
|||
else if (id == sync) {
|
||||
// setup sensor connection
|
||||
if (sync->isChecked()) {
|
||||
SoCamera* cam1 = self->myViewer->getViewer(0)->getCamera();
|
||||
SoCamera* cam2 = self->myViewer->getViewer(1)->getCamera();
|
||||
SoCamera* cam1 = self->myViewer->getViewer(0)->getSoRenderManager()->getCamera();
|
||||
SoCamera* cam2 = self->myViewer->getViewer(1)->getSoRenderManager()->getCamera();
|
||||
if (cam1 && cam2) {
|
||||
self->d->sensorCam1->attach(cam1);
|
||||
self->d->rot_cam1 = cam1->orientation.getValue();
|
||||
|
|
|
@ -811,7 +811,7 @@ public:
|
|||
{
|
||||
if (!working)
|
||||
return;
|
||||
const SbViewportRegion vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
SbVec2s size = vp.getViewportSizePixels();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
@ -853,20 +853,22 @@ void RubberbandSelection::initialize()
|
|||
{
|
||||
d = new Private(_pcView3D);
|
||||
_pcView3D->addGraphicsItem(d);
|
||||
|
||||
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||
_pcView3D->setRenderFramebuffer(true);
|
||||
}
|
||||
_pcView3D->scheduleRedraw();
|
||||
_pcView3D->redraw();
|
||||
}
|
||||
|
||||
void RubberbandSelection::terminate()
|
||||
{
|
||||
_pcView3D->removeGraphicsItem(d);
|
||||
delete d; d = 0;
|
||||
|
||||
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||
_pcView3D->setRenderFramebuffer(false);
|
||||
}
|
||||
_pcView3D->scheduleRedraw();
|
||||
_pcView3D->redraw();
|
||||
}
|
||||
|
||||
void RubberbandSelection::draw ()
|
||||
|
@ -917,7 +919,7 @@ int RubberbandSelection::locationEvent(const SoLocation2Event * const e, const Q
|
|||
m_iXnew = pos.x();
|
||||
m_iYnew = pos.y();
|
||||
d->setCoords(m_iXold, m_iYold, m_iXnew, m_iYnew);
|
||||
_pcView3D->render();
|
||||
_pcView3D->redraw();
|
||||
return Continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -304,13 +304,13 @@ void NavigationStyle::seekToPoint(const SbVec3f& scenepos)
|
|||
|
||||
SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos)
|
||||
{
|
||||
SoCamera* cam = viewer->getCamera();
|
||||
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
|
||||
if (cam == 0) return FALSE;
|
||||
|
||||
SoRayPickAction rpaction(viewer->getViewportRegion());
|
||||
SoRayPickAction rpaction(viewer->getSoRenderManager()->getViewportRegion());
|
||||
rpaction.setPoint(screenpos);
|
||||
rpaction.setRadius(2);
|
||||
rpaction.apply(viewer->getSceneManager()->getSceneGraph());
|
||||
rpaction.apply(viewer->getSoRenderManager()->getSceneGraph());
|
||||
|
||||
SoPickedPoint * picked = rpaction.getPickedPoint();
|
||||
if (!picked) {
|
||||
|
@ -326,7 +326,7 @@ SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos)
|
|||
|
||||
void NavigationStyle::lookAtPoint(const SbVec3f& pos)
|
||||
{
|
||||
SoCamera* cam = viewer->getCamera();
|
||||
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
|
||||
if (cam == 0) return;
|
||||
PRIVATE(this)->dragPointFound = FALSE;
|
||||
|
||||
|
@ -384,7 +384,7 @@ void NavigationStyle::lookAtPoint(const SbVec3f& pos)
|
|||
|
||||
void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToCenter)
|
||||
{
|
||||
SoCamera* cam = viewer->getCamera();
|
||||
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
|
||||
if (cam == 0) return;
|
||||
|
||||
// Find global coordinates of focal point.
|
||||
|
@ -394,7 +394,7 @@ void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToC
|
|||
cam->focalDistance.getValue() * direction;
|
||||
PRIVATE(this)->focal2 = PRIVATE(this)->focal1;
|
||||
if (moveToCenter) {
|
||||
SoGetBoundingBoxAction action(viewer->getViewportRegion());
|
||||
SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion());
|
||||
action.apply(viewer->getSceneGraph());
|
||||
SbBox3f box = action.getBoundingBox();
|
||||
if (!box.isEmpty()) {
|
||||
|
@ -461,7 +461,7 @@ void NavigationStyleP::viewAnimationCB(void * data, SoSensor * sensor)
|
|||
float step = std::min<float>((float)PRIVATE(that)->animationsteps/100.0f, 1.0f);
|
||||
SbRotation slerp = SbRotation::slerp(that->spinRotation, PRIVATE(that)->endRotation, step);
|
||||
SbVec3f focalpoint = (1.0f-step)*PRIVATE(that)->focal1 + step*PRIVATE(that)->focal2;
|
||||
SoCamera* cam = that->viewer->getCamera();
|
||||
SoCamera* cam = that->viewer->getSoRenderManager()->getCamera();
|
||||
SbVec3f direction;
|
||||
cam->orientation.setValue(slerp);
|
||||
cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction);
|
||||
|
@ -483,9 +483,9 @@ void NavigationStyleP::viewAnimationCB(void * data, SoSensor * sensor)
|
|||
|
||||
void NavigationStyle::boxZoom(const SbBox2s& box)
|
||||
{
|
||||
SoCamera* cam = viewer->getCamera();
|
||||
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
|
||||
if (!cam) return; // no camera
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
SbViewVolume vv = cam->getViewVolume(vp.getViewportAspectRatio());
|
||||
|
||||
short sizeX,sizeY;
|
||||
|
@ -500,8 +500,8 @@ void NavigationStyle::boxZoom(const SbBox2s& box)
|
|||
// Get the new center in normalized pixel coordinates
|
||||
short xmin,xmax,ymin,ymax;
|
||||
box.getBounds(xmin,ymin,xmax,ymax);
|
||||
const SbVec2f center((float) ((xmin+xmax)/2) / (float) SoQtMax((int)(size[0] - 1), 1),
|
||||
(float) (size[1]-(ymin+ymax)/2) / (float) SoQtMax((int)(size[1] - 1), 1));
|
||||
const SbVec2f center((float) ((xmin+xmax)/2) / (float) std::max((int)(size[0] - 1), 1),
|
||||
(float) (size[1]-(ymin+ymax)/2) / (float) std::max((int)(size[1] - 1), 1));
|
||||
|
||||
SbPlane plane = vv.getPlane(cam->focalDistance.getValue());
|
||||
panCamera(cam,vp.getViewportAspectRatio(),plane, SbVec2f(0.5,0.5), center);
|
||||
|
@ -524,7 +524,7 @@ void NavigationStyle::boxZoom(const SbBox2s& box)
|
|||
void NavigationStyle::viewAll()
|
||||
{
|
||||
// Get the bounding box of the scene
|
||||
SoGetBoundingBoxAction action(viewer->getViewportRegion());
|
||||
SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion());
|
||||
action.apply(viewer->getSceneGraph());
|
||||
SbBox3f box = action.getBoundingBox();
|
||||
if (box.isEmpty()) return;
|
||||
|
@ -539,14 +539,14 @@ void NavigationStyle::viewAll()
|
|||
return;
|
||||
#endif
|
||||
|
||||
SoCamera* cam = viewer->getCamera();
|
||||
SoCamera* cam = viewer->getSoRenderManager()->getCamera();
|
||||
if (!cam) return;
|
||||
|
||||
SbViewVolume vol = cam->getViewVolume();
|
||||
if (vol.ulf == vol.llf)
|
||||
return; // empty frustum (no view up vector defined)
|
||||
SbVec2f s = vol.projectBox(box);
|
||||
SbVec2s size = viewer->getSize();
|
||||
SbVec2s size = viewer->getSoRenderManager()->getSize();
|
||||
|
||||
SbVec3f pt1, pt2, pt3, tmp;
|
||||
vol.projectPointToLine( SbVec2f(0.0f,0.0f), pt1, tmp );
|
||||
|
@ -643,7 +643,7 @@ void NavigationStyle::pan(SoCamera* camera)
|
|||
this->panningplane = SbPlane(SbVec3f(0, 0, 1), 0);
|
||||
}
|
||||
else {
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
float aspectratio = vp.getViewportAspectRatio();
|
||||
SbViewVolume vv = camera->getViewVolume(aspectratio);
|
||||
|
||||
|
@ -657,9 +657,9 @@ void NavigationStyle::pan(SoCamera* camera)
|
|||
|
||||
void NavigationStyle::panToCenter(const SbPlane & pplane, const SbVec2f & currpos)
|
||||
{
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
panCamera(viewer->getCamera(), ratio, pplane, SbVec2f(0.5,0.5), currpos);
|
||||
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, pplane, SbVec2f(0.5,0.5), currpos);
|
||||
PRIVATE(this)->dragPointFound = FALSE;
|
||||
}
|
||||
|
||||
|
@ -745,28 +745,28 @@ void NavigationStyle::zoomByCursor(const SbVec2f & thispos, const SbVec2f & prev
|
|||
float value = (thispos[1] - prevpos[1]) * 10.0f/*20.0f*/;
|
||||
if (this->invertZoom)
|
||||
value = -value;
|
||||
zoom(viewer->getCamera(), value);
|
||||
zoom(viewer->getSoRenderManager()->getCamera(), value);
|
||||
}
|
||||
|
||||
void NavigationStyle::zoomIn()
|
||||
{
|
||||
zoom(viewer->getCamera(), -this->zoomStep);
|
||||
zoom(viewer->getSoRenderManager()->getCamera(), -this->zoomStep);
|
||||
}
|
||||
|
||||
void NavigationStyle::zoomOut()
|
||||
{
|
||||
zoom(viewer->getCamera(), this->zoomStep);
|
||||
zoom(viewer->getSoRenderManager()->getCamera(), this->zoomStep);
|
||||
}
|
||||
|
||||
void NavigationStyle::doZoom(SoCamera* camera, SbBool forward, const SbVec2f& pos)
|
||||
{
|
||||
SbBool zoomAtCur = this->zoomAtCursor;
|
||||
if (zoomAtCur) {
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
SbViewVolume vv = camera->getViewVolume(vp.getViewportAspectRatio());
|
||||
SbPlane panplane = vv.getPlane(camera->focalDistance.getValue());
|
||||
panCamera(viewer->getCamera(), ratio, panplane, SbVec2f(0.5,0.5), pos);
|
||||
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, panplane, SbVec2f(0.5,0.5), pos);
|
||||
}
|
||||
|
||||
float value = this->zoomStep;
|
||||
|
@ -777,11 +777,11 @@ void NavigationStyle::doZoom(SoCamera* camera, SbBool forward, const SbVec2f& po
|
|||
zoom(camera, value);
|
||||
|
||||
if (zoomAtCur) {
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
SbViewVolume vv = camera->getViewVolume(vp.getViewportAspectRatio());
|
||||
SbPlane panplane = vv.getPlane(camera->focalDistance.getValue());
|
||||
panCamera(viewer->getCamera(), ratio, panplane, pos, SbVec2f(0.5,0.5));
|
||||
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, panplane, pos, SbVec2f(0.5,0.5));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -793,24 +793,24 @@ void NavigationStyle::spin(const SbVec2f & pointerpos)
|
|||
if (this->log.historysize < 2) return;
|
||||
assert(this->spinprojector != NULL);
|
||||
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
SbVec2s glsize(vp.getViewportSizePixels());
|
||||
SbVec2f lastpos;
|
||||
lastpos[0] = float(this->log.position[1][0]) / float(SoQtMax((int)(glsize[0]-1), 1));
|
||||
lastpos[1] = float(this->log.position[1][1]) / float(SoQtMax((int)(glsize[1]-1), 1));
|
||||
lastpos[0] = float(this->log.position[1][0]) / float(std::max((int)(glsize[0]-1), 1));
|
||||
lastpos[1] = float(this->log.position[1][1]) / float(std::max((int)(glsize[1]-1), 1));
|
||||
|
||||
if (PRIVATE(this)->dragAtCursor && PRIVATE(this)->dragPointFound) {
|
||||
SbVec3f hitpoint = PRIVATE(this)->startDragPoint;
|
||||
|
||||
// set to the given position
|
||||
SbVec3f direction;
|
||||
viewer->getCamera()->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction);
|
||||
viewer->getCamera()->position = hitpoint - viewer->getCamera()->focalDistance.getValue() * direction;
|
||||
viewer->getSoRenderManager()->getCamera()->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction);
|
||||
viewer->getSoRenderManager()->getCamera()->position = hitpoint - viewer->getSoRenderManager()->getCamera()->focalDistance.getValue() * direction;
|
||||
}
|
||||
|
||||
// 0000333: Turntable camera rotation
|
||||
SbMatrix mat;
|
||||
viewer->getCamera()->orientation.getValue().getValue(mat);
|
||||
viewer->getSoRenderManager()->getCamera()->orientation.getValue().getValue(mat);
|
||||
this->spinprojector->setWorkingSpace(mat);
|
||||
|
||||
this->spinprojector->project(lastpos);
|
||||
|
@ -825,16 +825,16 @@ void NavigationStyle::spin(const SbVec2f & pointerpos)
|
|||
r.setValue(axis, radians);
|
||||
}
|
||||
r.invert();
|
||||
this->reorientCamera(viewer->getCamera(), r);
|
||||
this->reorientCamera(viewer->getSoRenderManager()->getCamera(), r);
|
||||
|
||||
if (PRIVATE(this)->dragAtCursor && PRIVATE(this)->dragPointFound) {
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
SbViewVolume vv = viewer->getCamera()->getViewVolume(vp.getViewportAspectRatio());
|
||||
SbPlane panplane = vv.getPlane(viewer->getCamera()->focalDistance.getValue());
|
||||
SbViewVolume vv = viewer->getSoRenderManager()->getCamera()->getViewVolume(vp.getViewportAspectRatio());
|
||||
SbPlane panplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue());
|
||||
SbVec2f posn;
|
||||
posn[0] = float(this->localPos[0]) / float(SoQtMax((int)(glsize[0]-1), 1));
|
||||
posn[1] = float(this->localPos[1]) / float(SoQtMax((int)(glsize[1]-1), 1));
|
||||
panCamera(viewer->getCamera(), ratio, panplane, posn, SbVec2f(0.5,0.5));
|
||||
posn[0] = float(this->localPos[0]) / float(std::max((int)(glsize[0]-1), 1));
|
||||
posn[1] = float(this->localPos[1]) / float(std::max((int)(glsize[1]-1), 1));
|
||||
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, panplane, posn, SbVec2f(0.5,0.5));
|
||||
}
|
||||
|
||||
// Calculate an average angle magnitude value to make the transition
|
||||
|
@ -863,10 +863,10 @@ SbBool NavigationStyle::doSpin()
|
|||
if (this->log.historysize >= 3) {
|
||||
SbTime stoptime = (SbTime::getTimeOfDay() - this->log.time[0]);
|
||||
if (this->spinanimatingallowed && stoptime.getValue() < 0.100) {
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
const SbVec2s glsize(vp.getViewportSizePixels());
|
||||
SbVec3f from = this->spinprojector->project(SbVec2f(float(this->log.position[2][0]) / float(SoQtMax(glsize[0]-1, 1)),
|
||||
float(this->log.position[2][1]) / float(SoQtMax(glsize[1]-1, 1))));
|
||||
SbVec3f from = this->spinprojector->project(SbVec2f(float(this->log.position[2][0]) / float(std::max(glsize[0]-1, 1)),
|
||||
float(this->log.position[2][1]) / float(std::max(glsize[1]-1, 1))));
|
||||
SbVec3f to = this->spinprojector->project(this->lastmouseposition);
|
||||
SbRotation rot = this->spinprojector->getRotation(from, to);
|
||||
|
||||
|
@ -895,10 +895,10 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev)
|
|||
|
||||
// get the 3d point to the screen position, if possible
|
||||
if (PRIVATE(this)->dragAtCursor) {
|
||||
SoRayPickAction rpaction(viewer->getViewportRegion());
|
||||
SoRayPickAction rpaction(viewer->getSoRenderManager()->getViewportRegion());
|
||||
rpaction.setPoint(this->localPos);
|
||||
rpaction.setRadius(2);
|
||||
rpaction.apply(viewer->getSceneManager()->getSceneGraph());
|
||||
rpaction.apply(viewer->getSoRenderManager()->getSceneGraph());
|
||||
|
||||
SoPickedPoint * picked = rpaction.getPickedPoint();
|
||||
if (picked) {
|
||||
|
@ -931,7 +931,7 @@ void NavigationStyle::updateAnimation()
|
|||
// here the camera rotates around a fix axis
|
||||
SbRotation deltaRotation = this->spinRotation;
|
||||
deltaRotation.scaleAngle(secs * 5.0);
|
||||
this->reorientCamera(viewer->getCamera(), deltaRotation);
|
||||
this->reorientCamera(viewer->getSoRenderManager()->getCamera(), deltaRotation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -943,7 +943,7 @@ void NavigationStyle::redraw()
|
|||
|
||||
SbBool NavigationStyle::handleEventInForeground(const SoEvent* const e)
|
||||
{
|
||||
SoHandleEventAction action(viewer->getViewportRegion());
|
||||
SoHandleEventAction action(viewer->getSoRenderManager()->getViewportRegion());
|
||||
action.setEvent(e);
|
||||
action.apply(viewer->foregroundroot);
|
||||
return action.isHandled();
|
||||
|
@ -1127,10 +1127,6 @@ void NavigationStyle::addToLog(const SbVec2s pos, const SbTime time)
|
|||
assert (this->log.size > 2 && "mouse log too small!");
|
||||
|
||||
if (this->log.historysize > 0 && pos == this->log.position[0]) {
|
||||
#if SOQt_DEBUG && 0 // debug
|
||||
// This can at least happen under SoQt.
|
||||
SoDebugError::postInfo("NavigationStyle::addToLog", "got position already!");
|
||||
#endif // debug
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1175,11 +1171,11 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode)
|
|||
|
||||
case SPINNING:
|
||||
this->interactiveCountInc();
|
||||
viewer->scheduleRedraw();
|
||||
viewer->getSoRenderManager()->scheduleRedraw();
|
||||
break;
|
||||
|
||||
case PANNING:
|
||||
pan(viewer->getCamera());
|
||||
pan(viewer->getSoRenderManager()->getCamera());
|
||||
this->interactiveCountInc();
|
||||
break;
|
||||
|
||||
|
@ -1222,7 +1218,7 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev)
|
|||
// If we're in picking mode then all events must be redirected to the
|
||||
// appropriate mouse model.
|
||||
if (mouseSelection) {
|
||||
int hd=mouseSelection->handleEvent(ev,viewer->getViewportRegion());
|
||||
int hd=mouseSelection->handleEvent(ev,viewer->getSoRenderManager()->getViewportRegion());
|
||||
if (hd==AbstractMouseSelection::Continue||
|
||||
hd==AbstractMouseSelection::Restart) {
|
||||
return TRUE;
|
||||
|
@ -1333,7 +1329,7 @@ void NavigationStyle::syncWithEvent(const SoEvent * const ev)
|
|||
|
||||
SbBool NavigationStyle::processMotionEvent(const SoMotion3Event * const ev)
|
||||
{
|
||||
SoCamera * const camera = viewer->getCamera();
|
||||
SoCamera * const camera = viewer->getSoRenderManager()->getCamera();
|
||||
if (!camera)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\**************************************************************************/
|
||||
|
||||
#include <Quarter/Basic.h>
|
||||
#include <Gui/Quarter/Basic.h>
|
||||
|
||||
namespace SIM { namespace Coin3D { namespace Quarter {
|
||||
|
||||
|
|
|
@ -24,6 +24,10 @@ class QuarterP {
|
|||
|
||||
}}};
|
||||
|
||||
#define QUARTER_MAJOR_VERSION 1
|
||||
#define QUARTER_MINOR_VERSION 0
|
||||
#define QUARTER_MICRO_VERSION 0
|
||||
|
||||
#define COIN_CT_ASSERT(expr) \
|
||||
do { switch ( 0 ) { case 0: case (expr): break; } } while ( 0 )
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ QuarterWidget::headlightEnabled(void) const
|
|||
Returns the light used for the headlight.
|
||||
*/
|
||||
SoDirectionalLight *
|
||||
QuarterWidget::getHeadlight(void)
|
||||
QuarterWidget::getHeadlight(void) const
|
||||
{
|
||||
return PRIVATE(this)->headlight;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <QtGui/QColor>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtOpenGL/QGLWidget>
|
||||
#include <Quarter/Basic.h>
|
||||
#include "Gui/Quarter/Basic.h"
|
||||
|
||||
class QMenu;
|
||||
class SoNode;
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
QColor backgroundColor(void) const;
|
||||
|
||||
void resetNavigationModeFile(void);
|
||||
void setNavigationModeFile(const QUrl & url = QUrl(DEFAULT_NAVIGATIONFILE));
|
||||
void setNavigationModeFile(const QUrl & url = QUrl(QString::fromAscii(DEFAULT_NAVIGATIONFILE)));
|
||||
const QUrl & navigationModeFile(void) const;
|
||||
|
||||
void setContextMenuEnabled(bool yes);
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
|
||||
bool headlightEnabled(void) const;
|
||||
void setHeadlightEnabled(bool onoff);
|
||||
SoDirectionalLight * getHeadlight(void);
|
||||
SoDirectionalLight * getHeadlight(void) const;
|
||||
|
||||
bool clearZBuffer(void) const;
|
||||
void setClearZBuffer(bool onoff);
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
QList<QAction *> stereoModeActions(void) const;
|
||||
QList<QAction *> renderModeActions(void) const;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
virtual void viewAll(void);
|
||||
virtual void seek(void);
|
||||
|
||||
|
|
457
src/Gui/Quarter/SoQTQuarterAdaptor.cpp
Normal file
457
src/Gui/Quarter/SoQTQuarterAdaptor.cpp
Normal file
|
@ -0,0 +1,457 @@
|
|||
/*
|
||||
* <one line to give the library's name and an idea of what it does.>
|
||||
* Copyright (C) 2014 Stefan Tröger <stefantroeger@gmx.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "SoQTQuarterAdaptor.h"
|
||||
#include "PreCompiled.h"
|
||||
#include <Base/Console.h>
|
||||
#include <Inventor/Qt/SoQt.h>
|
||||
#include <Inventor/nodes/SoPerspectiveCamera.h>
|
||||
#include <Inventor/nodes/SoOrthographicCamera.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoLocateHighlight.h>
|
||||
#include <Inventor/SoEventManager.h>
|
||||
#include <Inventor/actions/SoSearchAction.h>
|
||||
#include <Inventor/actions/SoRayPickAction.h>
|
||||
#include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
#include <Inventor/SoPickedPoint.h>
|
||||
|
||||
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QWidget* parent, const QGLWidget* sharewidget, Qt::WindowFlags f)
|
||||
: QuarterWidget(parent, sharewidget, f), matrixaction(SbViewportRegion(100,100))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(const QGLFormat& format, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f)
|
||||
: QuarterWidget(format, parent, shareWidget, f), matrixaction(SbViewportRegion(100,100))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QGLContext* context, QWidget* parent, const QGLWidget* sharewidget, Qt::WindowFlags f)
|
||||
: QuarterWidget(context, parent, sharewidget, f), matrixaction(SbViewportRegion(100,100))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::~SoQTQuarterAdaptor()
|
||||
{
|
||||
delete m_seeksensor;
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::init()
|
||||
{
|
||||
m_interactionnesting = 0;
|
||||
m_seekdistance = 50.0f;
|
||||
m_seekdistanceabs = FALSE;
|
||||
m_seekperiod = 2.0f;
|
||||
m_inseekmode = FALSE;
|
||||
|
||||
m_seeksensor = new SoTimerSensor(SoQTQuarterAdaptor::seeksensorCB, (void*)this);
|
||||
getSoEventManager()->setNavigationState(SoEventManager::NO_NAVIGATION);
|
||||
}
|
||||
|
||||
|
||||
QWidget* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getWidget()
|
||||
{
|
||||
//we keep the function from SoQt as we want to introduce the QGraphicsView and then the GLWidget
|
||||
//is seperated from the Widget used in layouts again
|
||||
return this;
|
||||
}
|
||||
|
||||
QWidget* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getGLWidget()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
QWidget* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getWidget() const
|
||||
{
|
||||
//we keep the function from SoQt as we want to introduce the QGraphicsView and then the GLWidget
|
||||
//is seperated from the Widget used in layouts again
|
||||
return const_cast<SoQTQuarterAdaptor*>(this);
|
||||
}
|
||||
|
||||
QWidget* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getGLWidget() const
|
||||
{
|
||||
return const_cast<SoQTQuarterAdaptor*>(this);
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setCameraType(SoType type)
|
||||
{
|
||||
if(!getSoRenderManager()->getCamera()->isOfType(SoPerspectiveCamera::getClassTypeId()) &&
|
||||
!getSoRenderManager()->getCamera()->isOfType(SoOrthographicCamera::getClassTypeId())) {
|
||||
Base::Console().Warning("Quarter::setCameraType",
|
||||
"Only SoPerspectiveCamera and SoOrthographicCamera is supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SoType perspectivetype = SoPerspectiveCamera::getClassTypeId();
|
||||
SoType orthotype = SoOrthographicCamera::getClassTypeId();
|
||||
SbBool oldisperspective = getSoRenderManager()->getCamera()->getTypeId().isDerivedFrom(perspectivetype);
|
||||
SbBool newisperspective = type.isDerivedFrom(perspectivetype);
|
||||
|
||||
if((oldisperspective && newisperspective) ||
|
||||
(!oldisperspective && !newisperspective)) // Same old, same old..
|
||||
return;
|
||||
|
||||
|
||||
SoCamera* currentcam = getSoRenderManager()->getCamera();
|
||||
SoCamera* newcamera = (SoCamera*)type.createInstance();
|
||||
|
||||
// Transfer and convert values from one camera type to the other.
|
||||
if(newisperspective) {
|
||||
convertOrtho2Perspective((SoOrthographicCamera*)currentcam,
|
||||
(SoPerspectiveCamera*)newcamera);
|
||||
}
|
||||
else {
|
||||
convertPerspective2Ortho((SoPerspectiveCamera*)currentcam,
|
||||
(SoOrthographicCamera*)newcamera);
|
||||
}
|
||||
|
||||
getSoRenderManager()->setCamera(newcamera);
|
||||
getSoEventManager()->setCamera(newcamera);
|
||||
|
||||
//if the superscene has a camera we need to replace it too
|
||||
SoCamera* camera = NULL;
|
||||
SoSeparator* superscene = (SoSeparator*) getSoRenderManager()->getSceneGraph();
|
||||
SoSearchAction sa;
|
||||
sa.setInterest(SoSearchAction::FIRST);
|
||||
sa.setType(SoCamera::getClassTypeId());
|
||||
sa.apply(superscene);
|
||||
|
||||
if(sa.getPath()) {
|
||||
SoNode* node = sa.getPath()->getTail();
|
||||
SoGroup* parent = (SoGroup*) sa.getPath()->getNodeFromTail(1);
|
||||
|
||||
if(node && node->isOfType(SoCamera::getClassTypeId())) {
|
||||
parent->replaceChild(node, newcamera);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertOrtho2Perspective(const SoOrthographicCamera* in,
|
||||
SoPerspectiveCamera* out)
|
||||
{
|
||||
out->aspectRatio.setValue(in->aspectRatio.getValue());
|
||||
out->focalDistance.setValue(in->focalDistance.getValue());
|
||||
out->orientation.setValue(in->orientation.getValue());
|
||||
out->position.setValue(in->position.getValue());
|
||||
out->viewportMapping.setValue(in->viewportMapping.getValue());
|
||||
|
||||
SbRotation camrot = in->orientation.getValue();
|
||||
|
||||
float focaldist = in->height.getValue() / (2.0*tan(M_PI / 8.0));
|
||||
|
||||
SbVec3f offset(0,0,focaldist-in->focalDistance.getValue());
|
||||
|
||||
camrot.multVec(offset,offset);
|
||||
out->position.setValue(offset+in->position.getValue());
|
||||
|
||||
out->focalDistance.setValue(focaldist);
|
||||
|
||||
// 45° is the default value of this field in SoPerspectiveCamera.
|
||||
out->heightAngle = (float)(M_PI / 4.0);
|
||||
};
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertPerspective2Ortho(const SoPerspectiveCamera* in,
|
||||
SoOrthographicCamera* out)
|
||||
{
|
||||
out->aspectRatio.setValue(in->aspectRatio.getValue());
|
||||
out->focalDistance.setValue(in->focalDistance.getValue());
|
||||
out->orientation.setValue(in->orientation.getValue());
|
||||
out->position.setValue(in->position.getValue());
|
||||
out->viewportMapping.setValue(in->viewportMapping.getValue());
|
||||
|
||||
float focaldist = in->focalDistance.getValue();
|
||||
|
||||
out->height = 2.0f * focaldist * (float)tan(in->heightAngle.getValue() / 2.0);
|
||||
};
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setViewing(SbBool enable)
|
||||
{
|
||||
|
||||
m_viewingflag = enable;
|
||||
|
||||
// Turn off the selection indicators when we go back from picking
|
||||
// mode into viewing mode.
|
||||
if(m_viewingflag) {
|
||||
SoGLRenderAction* action = getSoRenderManager()->getGLRenderAction();
|
||||
|
||||
if(action != NULL)
|
||||
SoLocateHighlight::turnOffCurrentHighlight(action);
|
||||
}
|
||||
}
|
||||
|
||||
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isViewing(void) const
|
||||
{
|
||||
return m_viewingflag;
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountInc(void)
|
||||
{
|
||||
// Catch problems with missing interactiveCountDec() calls.
|
||||
assert(m_interactionnesting < 100);
|
||||
|
||||
if(++m_interactionnesting == 1) {
|
||||
m_interactionStartCallback.invokeCallbacks(this);
|
||||
}
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountDec(void)
|
||||
{
|
||||
if(--m_interactionnesting <= 0) {
|
||||
m_interactionEndCallback.invokeCallbacks(this);
|
||||
m_interactionnesting = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getInteractiveCount(void) const
|
||||
{
|
||||
return m_interactionnesting;
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::addStartCallback(SIM::Coin3D::Quarter::SoQTQuarterAdaptorCB* func, void* data)
|
||||
{
|
||||
m_interactionStartCallback.addCallback((SoCallbackListCB*)func, data);
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::removeStartCallback(SIM::Coin3D::Quarter::SoQTQuarterAdaptorCB* func, void* data)
|
||||
{
|
||||
m_interactionStartCallback.removeCallback((SoCallbackListCB*)func, data);
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::addFinishCallback(SIM::Coin3D::Quarter::SoQTQuarterAdaptorCB* func, void* data)
|
||||
{
|
||||
m_interactionEndCallback.addCallback((SoCallbackListCB*)func, data);
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::removeFinishCallback(SIM::Coin3D::Quarter::SoQTQuarterAdaptorCB* func, void* data)
|
||||
{
|
||||
m_interactionEndCallback.removeCallback((SoCallbackListCB*)func, data);
|
||||
}
|
||||
|
||||
|
||||
float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekDistance(void) const
|
||||
{
|
||||
return m_seekdistance;
|
||||
}
|
||||
|
||||
float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekTime(void) const
|
||||
{
|
||||
return m_seekperiod;
|
||||
}
|
||||
|
||||
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekMode(void) const
|
||||
{
|
||||
return m_inseekmode;
|
||||
}
|
||||
|
||||
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekValuePercentage(void) const
|
||||
{
|
||||
return m_seekdistanceabs ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::seekToPoint(const SbVec2s screenpos)
|
||||
{
|
||||
|
||||
SoRayPickAction rpaction(getSoRenderManager()->getViewportRegion());
|
||||
rpaction.setPoint(screenpos);
|
||||
rpaction.setRadius(2);
|
||||
rpaction.apply(getSoRenderManager()->getSceneGraph());
|
||||
|
||||
SoPickedPoint* picked = rpaction.getPickedPoint();
|
||||
|
||||
if(!picked) {
|
||||
this->interactiveCountInc(); // decremented in setSeekMode(FALSE)
|
||||
this->setSeekMode(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SbVec3f hitpoint;
|
||||
hitpoint = picked->getPoint();
|
||||
|
||||
this->seekToPoint(hitpoint);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::seekToPoint(const SbVec3f& scenepos)
|
||||
{
|
||||
SbVec3f hitpoint(scenepos);
|
||||
|
||||
m_camerastartposition = getSoRenderManager()->getCamera()->position.getValue();
|
||||
m_camerastartorient = getSoRenderManager()->getCamera()->orientation.getValue();
|
||||
|
||||
// move point to the camera coordinate system, consider
|
||||
// transformations before camera in the scene graph
|
||||
SbMatrix cameramatrix, camerainverse;
|
||||
getCameraCoordinateSystem(getSoRenderManager()->getCamera(),
|
||||
getSceneGraph(),
|
||||
cameramatrix,
|
||||
camerainverse);
|
||||
camerainverse.multVecMatrix(hitpoint, hitpoint);
|
||||
|
||||
float fd = m_seekdistance;
|
||||
|
||||
if(!m_seekdistanceabs)
|
||||
fd *= (hitpoint - getSoRenderManager()->getCamera()->position.getValue()).length()/100.0f;
|
||||
|
||||
getSoRenderManager()->getCamera()->focalDistance = fd;
|
||||
|
||||
SbVec3f dir = hitpoint - m_camerastartposition;
|
||||
dir.normalize();
|
||||
|
||||
// find a rotation that rotates current camera direction into new
|
||||
// camera direction.
|
||||
SbVec3f olddir;
|
||||
getSoRenderManager()->getCamera()->orientation.getValue().multVec(SbVec3f(0, 0, -1), olddir);
|
||||
SbRotation diffrot(olddir, dir);
|
||||
m_cameraendposition = hitpoint - fd * dir;
|
||||
m_cameraendorient = getSoRenderManager()->getCamera()->orientation.getValue() * diffrot;
|
||||
|
||||
if(m_seeksensor->isScheduled()) {
|
||||
m_seeksensor->unschedule();
|
||||
interactiveCountDec();
|
||||
}
|
||||
|
||||
m_seeksensor->setBaseTime(SbTime::getTimeOfDay());
|
||||
m_seeksensor->schedule();
|
||||
interactiveCountInc();
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setSeekDistance(const float distance)
|
||||
{
|
||||
m_seekdistance = distance;
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setSeekMode(SbBool enable)
|
||||
{
|
||||
if(!enable && m_seeksensor->isScheduled()) {
|
||||
m_seeksensor->unschedule();
|
||||
interactiveCountDec();
|
||||
}
|
||||
|
||||
m_inseekmode = enable;
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setSeekTime(const float seconds)
|
||||
{
|
||||
m_seekperiod = seconds;
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setSeekValueAsPercentage(const SbBool on)
|
||||
{
|
||||
m_seekdistanceabs = on ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getCameraCoordinateSystem(SoCamera* camera, SoNode* root, SbMatrix& matrix, SbMatrix& inverse)
|
||||
{
|
||||
searchaction.reset();
|
||||
searchaction.setSearchingAll(TRUE);
|
||||
searchaction.setInterest(SoSearchAction::FIRST);
|
||||
searchaction.setNode(camera);
|
||||
searchaction.apply(root);
|
||||
|
||||
matrix = inverse = SbMatrix::identity();
|
||||
|
||||
if(searchaction.getPath()) {
|
||||
matrixaction.apply(searchaction.getPath());
|
||||
matrix = matrixaction.getMatrix();
|
||||
inverse = matrixaction.getInverse();
|
||||
}
|
||||
|
||||
searchaction.reset();
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::seeksensorCB(void* data, SoSensor* s)
|
||||
{
|
||||
SoQTQuarterAdaptor* thisp = (SoQTQuarterAdaptor*) data;
|
||||
SbTime currenttime = SbTime::getTimeOfDay();
|
||||
|
||||
SoTimerSensor* sensor = (SoTimerSensor*)s;
|
||||
|
||||
float t =
|
||||
float((currenttime - sensor->getBaseTime()).getValue()) / thisp->m_seekperiod;
|
||||
|
||||
if((t > 1.0f) || (t + sensor->getInterval().getValue() > 1.0f)) t = 1.0f;
|
||||
|
||||
SbBool end = (t == 1.0f);
|
||||
|
||||
t = (float)((1.0 - cos(M_PI*t)) * 0.5);
|
||||
|
||||
thisp->getSoRenderManager()->getCamera()->position = thisp->m_camerastartposition +
|
||||
(thisp->m_cameraendposition - thisp->m_camerastartposition) * t;
|
||||
thisp->getSoRenderManager()->getCamera()->orientation =
|
||||
SbRotation::slerp(thisp->m_camerastartorient,
|
||||
thisp->m_cameraendorient,
|
||||
t);
|
||||
|
||||
if(end) thisp->setSeekMode(FALSE);
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition(void)
|
||||
{
|
||||
SoType t = getSoRenderManager()->getCamera()->getTypeId();
|
||||
assert(t.isDerivedFrom(SoNode::getClassTypeId()));
|
||||
assert(t.canCreateInstance());
|
||||
|
||||
if(m_storedcamera) {
|
||||
m_storedcamera->unref();
|
||||
}
|
||||
|
||||
m_storedcamera = (SoNode*)t.createInstance();
|
||||
m_storedcamera->ref();
|
||||
|
||||
m_storedcamera->copyFieldValues(getSoRenderManager()->getCamera());
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetToHomePosition(void)
|
||||
{
|
||||
if(!m_storedcamera) {
|
||||
return;
|
||||
}
|
||||
|
||||
SoType t = getSoRenderManager()->getCamera()->getTypeId();
|
||||
SoType s = m_storedcamera->getTypeId();
|
||||
|
||||
// most common case
|
||||
if(t == s) {
|
||||
// We copy the field data directly, instead of using
|
||||
// SoFieldContainer::copyContents(), for the reason described in
|
||||
// detail in So@Gui@Viewer::saveHomePosition().
|
||||
getSoRenderManager()->getCamera()->copyFieldValues(m_storedcamera);
|
||||
}
|
||||
// handle common case #1
|
||||
else if(t == SoOrthographicCamera::getClassTypeId() &&
|
||||
s == SoPerspectiveCamera::getClassTypeId()) {
|
||||
convertPerspective2Ortho((SoPerspectiveCamera*)m_storedcamera,
|
||||
(SoOrthographicCamera*)getSoRenderManager()->getCamera());
|
||||
}
|
||||
// handle common case #2
|
||||
else if(t == SoPerspectiveCamera::getClassTypeId() &&
|
||||
s == SoOrthographicCamera::getClassTypeId()) {
|
||||
convertOrtho2Perspective((SoOrthographicCamera*)m_storedcamera,
|
||||
(SoPerspectiveCamera*)getSoRenderManager()->getCamera());
|
||||
}
|
||||
|
||||
// otherwise, cameras have changed in ways we don't understand since
|
||||
// the last saveHomePosition() invokation, and so we're just going
|
||||
// to ignore the reset request
|
||||
}
|
130
src/Gui/Quarter/SoQTQuarterAdaptor.h
Normal file
130
src/Gui/Quarter/SoQTQuarterAdaptor.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Extends the QuarterWidget with all funcions the SoQtViewer has
|
||||
* Copyright (C) 2014 Stefan Tröger <stefantroeger@gmx.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SIM_COIN3D_SOQTQUARTERADAPTOR_H
|
||||
#define SIM_COIN3D_SOQTQUARTERADAPTOR_H
|
||||
|
||||
#include "Gui/Quarter/QuarterWidget.h"
|
||||
#include <Inventor/SoSceneManager.h>
|
||||
#include <Inventor/SbSphere.h>
|
||||
#include <Inventor/SoType.h>
|
||||
#include <Inventor/events/SoKeyboardEvent.h>
|
||||
#include <Inventor/Qt/SoQtCursor.h>
|
||||
#include <Inventor/lists/SoCallbackList.h>
|
||||
#include <Inventor/sensors/SoTimerSensor.h>
|
||||
#include <Inventor/actions/SoGetMatrixAction.h>
|
||||
#include <Inventor/actions/SoSearchAction.h>
|
||||
|
||||
class SbViewportRegion;
|
||||
class SoCamera;
|
||||
class SoOrthographicCamera;
|
||||
class SoPerspectiveCamera;
|
||||
|
||||
namespace SIM {
|
||||
namespace Coin3D {
|
||||
namespace Quarter {
|
||||
|
||||
class SoQTQuarterAdaptor;
|
||||
typedef void SoQTQuarterAdaptorCB(void* data, SoQTQuarterAdaptor* viewer);
|
||||
|
||||
class QUARTER_DLL_API SoQTQuarterAdaptor : public QuarterWidget {
|
||||
|
||||
public:
|
||||
explicit SoQTQuarterAdaptor(QWidget* parent = 0, const QGLWidget* sharewidget = 0, Qt::WindowFlags f = 0);
|
||||
explicit SoQTQuarterAdaptor(const QGLFormat& format, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
|
||||
explicit SoQTQuarterAdaptor(QGLContext* context, QWidget* parent = 0, const QGLWidget* sharewidget = 0, Qt::WindowFlags f = 0);
|
||||
virtual ~SoQTQuarterAdaptor();
|
||||
|
||||
//the functions available in soqtviewer but missing in quarter
|
||||
QWidget* getWidget();
|
||||
QWidget* getGLWidget();
|
||||
QWidget* getWidget() const;
|
||||
QWidget* getGLWidget() const;
|
||||
|
||||
virtual void setCameraType(SoType type);
|
||||
|
||||
virtual void setViewing(SbBool enable);
|
||||
SbBool isViewing(void) const;
|
||||
|
||||
void interactiveCountInc(void);
|
||||
void interactiveCountDec(void);
|
||||
int getInteractiveCount(void) const;
|
||||
|
||||
void addStartCallback(SoQTQuarterAdaptorCB* func, void* data = NULL);
|
||||
void addFinishCallback(SoQTQuarterAdaptorCB* func, void* data = NULL);
|
||||
void removeStartCallback(SoQTQuarterAdaptorCB* func, void* data = NULL);
|
||||
void removeFinishCallback(SoQTQuarterAdaptorCB* func, void* data = NULL);
|
||||
|
||||
virtual void setSeekMode(SbBool enable);
|
||||
SbBool isSeekMode(void) const;
|
||||
SbBool seekToPoint(const SbVec2s screenpos);
|
||||
void seekToPoint(const SbVec3f& scenepos);
|
||||
void setSeekTime(const float seconds);
|
||||
float getSeekTime(void) const;
|
||||
void setSeekDistance(const float distance);
|
||||
float getSeekDistance(void) const;
|
||||
void setSeekValueAsPercentage(const SbBool on);
|
||||
SbBool isSeekValuePercentage(void) const;
|
||||
|
||||
virtual void saveHomePosition(void);
|
||||
virtual void resetToHomePosition(void);
|
||||
|
||||
virtual void setSceneGraph(SoNode* root) {
|
||||
QuarterWidget::setSceneGraph(root);
|
||||
};
|
||||
|
||||
virtual bool processSoEvent(const SoEvent* event) {
|
||||
return QuarterWidget::processSoEvent(event);
|
||||
};
|
||||
|
||||
//this functions still need to be ported
|
||||
virtual void afterRealizeHook(void) {}; //enables spacenav and joystick in soqt, dunno if this is needed
|
||||
|
||||
private:
|
||||
void init();
|
||||
void convertPerspective2Ortho(const SoPerspectiveCamera* in, SoOrthographicCamera* out);
|
||||
void convertOrtho2Perspective(const SoOrthographicCamera* in, SoPerspectiveCamera* out);
|
||||
void getCameraCoordinateSystem(SoCamera * camera, SoNode * root, SbMatrix & matrix, SbMatrix & inverse);
|
||||
static void seeksensorCB(void * data, SoSensor * s);
|
||||
|
||||
bool m_viewingflag;
|
||||
int m_interactionnesting;
|
||||
SoCallbackList m_interactionStartCallback;
|
||||
SoCallbackList m_interactionEndCallback;
|
||||
|
||||
// Seek functionality
|
||||
SoTimerSensor* m_seeksensor;
|
||||
float m_seekperiod;
|
||||
SbBool m_inseekmode;
|
||||
SbVec3f m_camerastartposition, m_cameraendposition;
|
||||
SbRotation m_camerastartorient, m_cameraendorient;
|
||||
float m_seekdistance;
|
||||
SbBool m_seekdistanceabs;
|
||||
SoSearchAction searchaction;
|
||||
SoGetMatrixAction matrixaction;
|
||||
// Home position storage.
|
||||
SoNode * m_storedcamera;
|
||||
};
|
||||
|
||||
} //Quarter
|
||||
} //Coin3D
|
||||
} //
|
||||
|
||||
#endif // SIM_COIN3D_SOQTQUARTERADAPTOR_H
|
|
@ -62,6 +62,7 @@ SbBool Gui::SoFCDB::isInitialized(void)
|
|||
|
||||
void Gui::SoFCDB::init()
|
||||
{
|
||||
SoInteraction ::init();
|
||||
RotTransDragger ::initClass();
|
||||
SoGLRenderActionElement ::initClass();
|
||||
SoFCInteractiveElement ::initClass();
|
||||
|
@ -72,7 +73,6 @@ void Gui::SoFCDB::init()
|
|||
SoFCColorGradient ::initClass();
|
||||
SoFCBackgroundGradient ::initClass();
|
||||
SoFCBoundingBox ::initClass();
|
||||
SoInteraction ::init();
|
||||
SoFCSelection ::initClass();
|
||||
SoFCUnifiedSelection ::initClass();
|
||||
SoFCSelectionAction ::initClass();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define GUI_SOFCDB_H
|
||||
|
||||
#include <string>
|
||||
#include <Inventor/SbBasic.h>
|
||||
|
||||
class SoNode;
|
||||
namespace Gui {
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
# include <QTextStream>
|
||||
# include <QWaitCondition>
|
||||
# include <Inventor/C/basic.h>
|
||||
# include <Inventor/Qt/SoQtBasic.h>
|
||||
#endif
|
||||
|
||||
#include "Splashscreen.h"
|
||||
|
@ -507,7 +506,6 @@ void AboutDialog::on_copyButton_clicked()
|
|||
str << "Python version: " << PY_VERSION << endl;
|
||||
str << "Qt version: " << QT_VERSION_STR << endl;
|
||||
str << "Coin version: " << COIN_VERSION << endl;
|
||||
str << "SoQt version: " << SOQT_VERSION << endl;
|
||||
it = config.find("OCC_VERSION");
|
||||
if (it != config.end())
|
||||
str << "OCC version: " << it->second.c_str() << endl;
|
||||
|
|
|
@ -200,7 +200,7 @@ void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp
|
|||
}
|
||||
else if (strcmp(Reason,"EyeDistance") == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it)
|
||||
(*it)->setStereoOffset(rGrp.GetFloat("EyeDistance",5.0));
|
||||
(*it)->getSoRenderManager()->setStereoOffset(rGrp.GetFloat("EyeDistance",5.0));
|
||||
}
|
||||
else if (strcmp(Reason,"CornerCoordSystem") == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it)
|
||||
|
@ -216,7 +216,7 @@ void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp
|
|||
}
|
||||
else if (strcmp(Reason,"UseAntialiasing") == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it)
|
||||
(*it)->getGLRenderAction()->setSmoothing(rGrp.GetBool("UseAntialiasing",false));
|
||||
(*it)->getSoRenderManager()->getGLRenderAction()->setSmoothing(rGrp.GetBool("UseAntialiasing",false));
|
||||
}
|
||||
else if (strcmp(Reason,"ShowFPS") == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it)
|
||||
|
@ -244,7 +244,7 @@ void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp
|
|||
r3 = ((col3 >> 24) & 0xff) / 255.0; g3 = ((col3 >> 16) & 0xff) / 255.0; b3 = ((col3 >> 8) & 0xff) / 255.0;
|
||||
r4 = ((col4 >> 24) & 0xff) / 255.0; g4 = ((col4 >> 16) & 0xff) / 255.0; b4 = ((col4 >> 8) & 0xff) / 255.0;
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
(*it)->setBackgroundColor(SbColor(r1, g1, b1));
|
||||
(*it)->setBackgroundColor(QColor::fromRgbF(r1, g1, b1));
|
||||
if (rGrp.GetBool("UseBackgroundColorMid",false) == false)
|
||||
(*it)->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3));
|
||||
else
|
||||
|
@ -272,7 +272,7 @@ bool AbstractSplitView::onMsg(const char* pMsg, const char** ppReturn)
|
|||
}
|
||||
else if (strcmp("ViewBottom",pMsg) == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
SoCamera* cam = (*it)->getCamera();
|
||||
SoCamera* cam = (*it)->getSoRenderManager()->getCamera();
|
||||
cam->orientation.setValue(-1, 0, 0, 0);
|
||||
(*it)->viewAll();
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ bool AbstractSplitView::onMsg(const char* pMsg, const char** ppReturn)
|
|||
else if (strcmp("ViewFront",pMsg) == 0) {
|
||||
float root = (float)(sqrt(2.0)/2.0);
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
SoCamera* cam = (*it)->getCamera();
|
||||
SoCamera* cam = (*it)->getSoRenderManager()->getCamera();
|
||||
cam->orientation.setValue(-root, 0, 0, -root);
|
||||
(*it)->viewAll();
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ bool AbstractSplitView::onMsg(const char* pMsg, const char** ppReturn)
|
|||
}
|
||||
else if (strcmp("ViewLeft",pMsg) == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
SoCamera* cam = (*it)->getCamera();
|
||||
SoCamera* cam = (*it)->getSoRenderManager()->getCamera();
|
||||
cam->orientation.setValue(-0.5, 0.5, 0.5, -0.5);
|
||||
(*it)->viewAll();
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ bool AbstractSplitView::onMsg(const char* pMsg, const char** ppReturn)
|
|||
else if (strcmp("ViewRear",pMsg) == 0) {
|
||||
float root = (float)(sqrt(2.0)/2.0);
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
SoCamera* cam = (*it)->getCamera();
|
||||
SoCamera* cam = (*it)->getSoRenderManager()->getCamera();
|
||||
cam->orientation.setValue(0, root, root, 0);
|
||||
(*it)->viewAll();
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ bool AbstractSplitView::onMsg(const char* pMsg, const char** ppReturn)
|
|||
}
|
||||
else if (strcmp("ViewRight",pMsg) == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
SoCamera* cam = (*it)->getCamera();
|
||||
SoCamera* cam = (*it)->getSoRenderManager()->getCamera();
|
||||
cam->orientation.setValue(0.5, 0.5, 0.5, 0.5);
|
||||
(*it)->viewAll();
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ bool AbstractSplitView::onMsg(const char* pMsg, const char** ppReturn)
|
|||
}
|
||||
else if (strcmp("ViewTop",pMsg) == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
SoCamera* cam = (*it)->getCamera();
|
||||
SoCamera* cam = (*it)->getSoRenderManager()->getCamera();
|
||||
cam->orientation.setValue(0, 0, 0, 1);
|
||||
(*it)->viewAll();
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ bool AbstractSplitView::onMsg(const char* pMsg, const char** ppReturn)
|
|||
else if (strcmp("ViewAxo",pMsg) == 0) {
|
||||
float root = (float)(sqrt(3.0)/4.0);
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
SoCamera* cam = (*it)->getCamera();
|
||||
SoCamera* cam = (*it)->getSoRenderManager()->getCamera();
|
||||
cam->orientation.setValue(-0.333333f, -0.166666f, -0.333333f, -root);
|
||||
(*it)->viewAll();
|
||||
}
|
||||
|
|
|
@ -89,12 +89,12 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
|
||||
const SoType type(ev->getTypeId());
|
||||
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
const SbVec2s size(vp.getViewportSizePixels());
|
||||
const SbVec2f prevnormalized = this->lastmouseposition;
|
||||
const SbVec2s pos(ev->getPosition());
|
||||
const SbVec2f posn((float) pos[0] / (float) SoQtMax((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) SoQtMax((int)(size[1] - 1), 1));
|
||||
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
|
||||
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
|
||||
|
||||
this->lastmouseposition = posn;
|
||||
|
||||
|
@ -157,11 +157,11 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
this->setViewing(true);
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_UP:
|
||||
doZoom(viewer->getCamera(), TRUE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), TRUE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
case SoKeyboardEvent::PAGE_DOWN:
|
||||
doZoom(viewer->getCamera(), FALSE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), FALSE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -244,11 +244,11 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
this->button2down = press;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON4:
|
||||
doZoom(viewer->getCamera(), TRUE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), TRUE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
case SoMouseButtonEvent::BUTTON5:
|
||||
doZoom(viewer->getCamera(), FALSE, posn);
|
||||
doZoom(viewer->getSoRenderManager()->getCamera(), FALSE, posn);
|
||||
processed = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -266,7 +266,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
|||
}
|
||||
else if (this->currentmode == NavigationStyle::PANNING) {
|
||||
float ratio = vp.getViewportAspectRatio();
|
||||
panCamera(viewer->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, posn, prevnormalized);
|
||||
processed = TRUE;
|
||||
}
|
||||
else if (this->currentmode == NavigationStyle::DRAGGING) {
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
# include <Inventor/events/SoEvent.h>
|
||||
# include <Inventor/fields/SoSFString.h>
|
||||
# include <Inventor/fields/SoSFColor.h>
|
||||
# include <Inventor/Qt/SoQtBasic.h>
|
||||
#endif
|
||||
# include <QStackedWidget>
|
||||
|
||||
|
@ -74,7 +73,6 @@
|
|||
#include "SoFCVectorizeSVGAction.h"
|
||||
|
||||
// build in Inventor
|
||||
#include "Inventor/Qt/viewers/SoQtExaminerViewer.h"
|
||||
#include <Inventor/nodes/SoPerspectiveCamera.h>
|
||||
#include <Inventor/nodes/SoOrthographicCamera.h>
|
||||
|
||||
|
@ -112,15 +110,29 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent, Qt::W
|
|||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
hGrp->Attach(this);
|
||||
|
||||
//anti aliasing settings
|
||||
QGLFormat f;
|
||||
switch( hGrp->GetInt("AntiAliasing",0) ) {
|
||||
case View3DInventorViewer::MSAA2x:
|
||||
f.setSampleBuffers(true);
|
||||
f.setSamples(2);
|
||||
break;
|
||||
case View3DInventorViewer::MSAA4x:
|
||||
f.setSampleBuffers(true);
|
||||
f.setSamples(4);
|
||||
break;
|
||||
case View3DInventorViewer::MSAA8x:
|
||||
f.setSampleBuffers(true);
|
||||
f.setSamples(8);
|
||||
break;
|
||||
case View3DInventorViewer::None:
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
// create the inventor widget and set the defaults
|
||||
#if !defined (NO_USE_QT_MDI_AREA)
|
||||
#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5)
|
||||
// #0000282: Window gets smaller on loading files
|
||||
// #0001028: Main window resized when a document is opened
|
||||
_viewer = new View3DInventorViewer(this);
|
||||
#else
|
||||
_viewer = new View3DInventorViewer(0);
|
||||
#endif
|
||||
#if !defined (NO_USE_QT_MDI_AREA)
|
||||
_viewer = new View3DInventorViewer(f,this);
|
||||
_viewer->setDocument(this->_pcDocument);
|
||||
stack->addWidget(_viewer->getWidget());
|
||||
// http://forum.freecadweb.org/viewtopic.php?f=3&t=6055&sid=150ed90cbefba50f1e2ad4b4e6684eba
|
||||
|
@ -131,7 +143,7 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent, Qt::W
|
|||
//_viewer->getGLWidget()->setAttribute(Qt::WA_NoMousePropagation);
|
||||
setCentralWidget(stack);
|
||||
#else
|
||||
_viewer = new View3DInventorViewer(this);
|
||||
_viewer = new View3DInventorViewer(f,this);
|
||||
_viewer->setDocument(this->_pcDocument);
|
||||
#endif
|
||||
// apply the user settings
|
||||
|
@ -144,7 +156,6 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent, Qt::W
|
|||
OnChange(*hGrp,"BackgroundColor3");
|
||||
OnChange(*hGrp,"BackgroundColor4");
|
||||
OnChange(*hGrp,"UseBackgroundColorMid");
|
||||
OnChange(*hGrp,"AntiAliasing");
|
||||
OnChange(*hGrp,"ShowFPS");
|
||||
OnChange(*hGrp,"Orthographic");
|
||||
OnChange(*hGrp,"HeadlightColor");
|
||||
|
@ -322,7 +333,7 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
|
|||
_viewer->navigationStyle()->setZoomStep(val);
|
||||
}
|
||||
else if (strcmp(Reason,"EyeDistance") == 0) {
|
||||
_viewer->setStereoOffset(rGrp.GetFloat("EyeDistance",5.0));
|
||||
_viewer->getSoRenderManager()->setStereoOffset(rGrp.GetFloat("EyeDistance",5.0));
|
||||
}
|
||||
else if (strcmp(Reason,"CornerCoordSystem") == 0) {
|
||||
_viewer->setFeedbackVisibility(rGrp.GetBool("CornerCoordSystem",true));
|
||||
|
@ -333,9 +344,6 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
|
|||
else if (strcmp(Reason,"Gradient") == 0) {
|
||||
_viewer->setGradientBackground((rGrp.GetBool("Gradient",true)));
|
||||
}
|
||||
else if (strcmp(Reason,"AntiAliasing") == 0) {
|
||||
_viewer->setAntiAliasingMode(View3DInventorViewer::AntiAliasing(rGrp.GetInt("AntiAliasing",0)));
|
||||
}
|
||||
else if (strcmp(Reason,"ShowFPS") == 0) {
|
||||
_viewer->setEnabledFPSCounter(rGrp.GetBool("ShowFPS",false));
|
||||
}
|
||||
|
@ -377,7 +385,7 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
|
|||
r2 = ((col2 >> 24) & 0xff) / 255.0; g2 = ((col2 >> 16) & 0xff) / 255.0; b2 = ((col2 >> 8) & 0xff) / 255.0;
|
||||
r3 = ((col3 >> 24) & 0xff) / 255.0; g3 = ((col3 >> 16) & 0xff) / 255.0; b3 = ((col3 >> 8) & 0xff) / 255.0;
|
||||
r4 = ((col4 >> 24) & 0xff) / 255.0; g4 = ((col4 >> 16) & 0xff) / 255.0; b4 = ((col4 >> 8) & 0xff) / 255.0;
|
||||
_viewer->setBackgroundColor(SbColor(r1, g1, b1));
|
||||
_viewer->setBackgroundColor(QColor::fromRgbF(r1, g1, b1));
|
||||
if (rGrp.GetBool("UseBackgroundColorMid",false) == false)
|
||||
_viewer->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3));
|
||||
else
|
||||
|
@ -399,7 +407,7 @@ void View3DInventor::onUpdate(void)
|
|||
Base::Console().Log("Acti: Gui::View3DInventor::onUpdate()");
|
||||
#endif
|
||||
update();
|
||||
_viewer->render();
|
||||
_viewer->redraw();
|
||||
}
|
||||
|
||||
void View3DInventor::viewAll()
|
||||
|
@ -527,9 +535,9 @@ void View3DInventor::print(QPrinter* printer)
|
|||
void View3DInventor::previewFromFramebuffer(const QRect& rect, QImage& img)
|
||||
{
|
||||
QGLFramebufferObject fbo(rect.width(), rect.height(), QGLFramebufferObject::Depth);
|
||||
const SbColor col = _viewer->getBackgroundColor();
|
||||
const QColor col = _viewer->backgroundColor();
|
||||
bool on = _viewer->hasGradientBackground();
|
||||
_viewer->setBackgroundColor(SbColor(1.0f,1.0f,1.0f));
|
||||
_viewer->setBackgroundColor(QColor(255,255,255));
|
||||
_viewer->setGradientBackground(false);
|
||||
_viewer->renderToFramebuffer(&fbo);
|
||||
_viewer->setBackgroundColor(col);
|
||||
|
@ -553,51 +561,27 @@ bool View3DInventor::onMsg(const char* pMsg, const char** ppReturn)
|
|||
else if(strcmp("ViewSelection",pMsg) == 0) {
|
||||
_viewer->viewSelection();
|
||||
return true;
|
||||
// comment out on older Inventor
|
||||
#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 2)
|
||||
}
|
||||
else if(strcmp("SetStereoRedGreen",pMsg) == 0 ) {
|
||||
_viewer->setStereoType(SoQtViewer::STEREO_ANAGLYPH);
|
||||
_viewer->setProperty("StereoMode", Quarter::SoQTQuarterAdaptor::ANAGLYPH);
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("SetStereoQuadBuff",pMsg) == 0 ) {
|
||||
_viewer->setStereoType(SoQtViewer::STEREO_QUADBUFFER );
|
||||
_viewer->setProperty("StereoMode", Quarter::SoQTQuarterAdaptor::QUAD_BUFFER );
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("SetStereoInterleavedRows",pMsg) == 0 ) {
|
||||
_viewer->setStereoType(SoQtViewer::STEREO_INTERLEAVED_ROWS );
|
||||
_viewer->setProperty("StereoMode", Quarter::SoQTQuarterAdaptor::INTERLEAVED_ROWS );
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("SetStereoInterleavedColumns",pMsg) == 0 ) {
|
||||
_viewer->setStereoType(SoQtViewer::STEREO_INTERLEAVED_COLUMNS );
|
||||
_viewer->setProperty("StereoMode", Quarter::SoQTQuarterAdaptor::INTERLEAVED_COLUMNS );
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("SetStereoOff",pMsg) == 0 ) {
|
||||
_viewer->setStereoType(SoQtViewer::STEREO_NONE );
|
||||
_viewer->setProperty("StereoMode", Quarter::SoQTQuarterAdaptor::MONO );
|
||||
return true;
|
||||
#else
|
||||
}
|
||||
else if(strcmp("SetStereoRedGreen",pMsg) == 0 ) {
|
||||
Base::Console().Warning("Use SoQt 1.2.x or later!\n");
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("SetStereoQuadBuff",pMsg) == 0 ) {
|
||||
Base::Console().Warning("Use SoQt 1.2.x or later!\n");
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("SetStereoInterleavedRows",pMsg) == 0 ) {
|
||||
Base::Console().Warning("Use SoQt 1.2.x or later!\n");
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("SetStereoInterleavedColumns",pMsg) == 0 ) {
|
||||
Base::Console().Warning("Use SoQt 1.2.x or later!\n");
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("SetStereoOff",pMsg) == 0 ) {
|
||||
Base::Console().Warning("Use SoQt 1.2.x or later!\n");
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if(strcmp("Example1",pMsg) == 0 ) {
|
||||
SoSeparator * root = new SoSeparator;
|
||||
Texture3D(root);
|
||||
|
@ -617,7 +601,7 @@ bool View3DInventor::onMsg(const char* pMsg, const char** ppReturn)
|
|||
return true;
|
||||
}
|
||||
else if(strcmp("GetCamera",pMsg) == 0 ) {
|
||||
SoCamera * Cam = _viewer->getCamera();
|
||||
SoCamera * Cam = _viewer->getSoRenderManager()->getCamera();
|
||||
if (!Cam) return false;
|
||||
*ppReturn = SoFCDB::writeNodesToString(Cam).c_str();
|
||||
return true;
|
||||
|
@ -766,7 +750,7 @@ bool View3DInventor::onHasMsg(const char* pMsg) const
|
|||
|
||||
bool View3DInventor::setCamera(const char* pCamera)
|
||||
{
|
||||
SoCamera * CamViewer = _viewer->getCamera();
|
||||
SoCamera * CamViewer = _viewer->getSoRenderManager()->getCamera();
|
||||
if (!CamViewer) {
|
||||
throw Base::Exception("No camera set so far...");
|
||||
}
|
||||
|
@ -785,7 +769,7 @@ bool View3DInventor::setCamera(const char* pCamera)
|
|||
if (Cam->getTypeId() != CamViewer->getTypeId())
|
||||
{
|
||||
_viewer->setCameraType(Cam->getTypeId());
|
||||
CamViewer = _viewer->getCamera();
|
||||
CamViewer = _viewer->getSoRenderManager()->getCamera();
|
||||
}
|
||||
|
||||
SoPerspectiveCamera * CamViewerP = 0;
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
#include "View3DInventorExamples.h"
|
||||
|
||||
#include <Inventor/SbPlane.h>
|
||||
#include <Inventor/Qt/SoQt.h>
|
||||
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
|
||||
#include <Inventor/SoDB.h>
|
||||
#include <Inventor/actions/SoSearchAction.h>
|
||||
#include <Inventor/manips/SoPointLightManip.h>
|
||||
|
@ -266,24 +264,6 @@ void Texture3D(SoSeparator * root)
|
|||
root->addChild(planeTCoords);
|
||||
SoFaceSet * planeFS = new SoFaceSet;
|
||||
root->addChild(planeFS);
|
||||
|
||||
/*
|
||||
SoQtExaminerViewer * renderarea = new SoQtExaminerViewer( window );
|
||||
renderarea->setSceneGraph( root );
|
||||
renderarea->setBackgroundColor( SbColor( 0.0f, 0.2f, 0.3f ) );
|
||||
renderarea->setTitle(argv[0]);
|
||||
renderarea->setIconTitle(argv[0]);
|
||||
renderarea->viewAll();
|
||||
renderarea->show();
|
||||
|
||||
SoQt::show(window);
|
||||
SoQt::mainLoop();
|
||||
|
||||
delete renderarea;
|
||||
root->unref();
|
||||
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,7 +31,9 @@
|
|||
|
||||
#include <Base/Type.h>
|
||||
#include <Inventor/nodes/SoEventCallback.h>
|
||||
#include <Quarter/QuarterWidget.h>
|
||||
#include <Inventor/nodes/SoSwitch.h>
|
||||
#include <Inventor/SbRotation.h>
|
||||
#include "Gui/Quarter/SoQTQuarterAdaptor.h"
|
||||
#include <QCursor>
|
||||
|
||||
#include <Gui/Selection.h>
|
||||
|
@ -60,14 +62,15 @@ class Document;
|
|||
class SoFCUnifiedSelection;
|
||||
class GLGraphicsItem;
|
||||
class SoShapeScale;
|
||||
class ViewerEventFilter;
|
||||
|
||||
/** GUI view into a 3D scene provided by View3DInventor
|
||||
*
|
||||
*/
|
||||
class GuiExport View3DInventorViewer : public Quarter::QuarterWidget, public Gui::SelectionSingleton::ObserverType
|
||||
class GuiExport View3DInventorViewer : public Quarter::SoQTQuarterAdaptor, public Gui::SelectionSingleton::ObserverType
|
||||
{
|
||||
SOQT_OBJECT_ABSTRACT_HEADER(View3DInventorViewer, SoQtViewer);
|
||||
|
||||
typedef Quarter::SoQTQuarterAdaptor inherited;
|
||||
|
||||
public:
|
||||
/// Background modes for the savePicture() method
|
||||
enum eBackgroundType {
|
||||
|
@ -114,9 +117,11 @@ public:
|
|||
};
|
||||
//@}
|
||||
|
||||
View3DInventorViewer (QWidget *parent, const char *name=NULL, SbBool embed=true,
|
||||
Type type= SoQtViewer::BROWSER, SbBool build=true);
|
||||
View3DInventorViewer (QWidget *parent);
|
||||
View3DInventorViewer (const QGLFormat& format, QWidget *parent);
|
||||
virtual ~View3DInventorViewer();
|
||||
|
||||
void init();
|
||||
|
||||
/// Observer message from the Selection
|
||||
virtual void OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
|
||||
|
@ -212,13 +217,14 @@ public:
|
|||
//@{
|
||||
void setEditing(SbBool edit);
|
||||
SbBool isEditing() const { return this->editing; }
|
||||
void setEditingCursor (const SoQtCursor& cursor);
|
||||
void setEditingCursor (const QCursor& cursor);
|
||||
void setRedirectToSceneGraph(SbBool redirect) { this->redirected = redirect; }
|
||||
SbBool isRedirectedToSceneGraph() const { return this->redirected; }
|
||||
void setRedirectToSceneGraphEnabled(SbBool enable) { this->allowredir = enable; }
|
||||
SbBool isRedirectToSceneGraphEnabled(void) const { return this->allowredir; }
|
||||
//@}
|
||||
|
||||
void setComponentCursor(QCursor cursor);
|
||||
|
||||
/** @name Pick actions */
|
||||
//@{
|
||||
|
@ -345,8 +351,7 @@ protected:
|
|||
virtual void actualRedraw(void);
|
||||
virtual void setSeekMode(SbBool enable);
|
||||
virtual void afterRealizeHook(void);
|
||||
virtual void processEvent(QEvent * event);
|
||||
virtual SbBool processSoEvent(const SoEvent * const ev);
|
||||
virtual bool processSoEvent(const SoEvent * const ev);
|
||||
SbBool processSoEventBase(const SoEvent * const ev);
|
||||
void printDimension();
|
||||
void selectAll();
|
||||
|
@ -354,8 +359,8 @@ protected:
|
|||
static void clearBuffer(void * userdata, SoAction * action);
|
||||
static void setGLWidget(void * userdata, SoAction * action);
|
||||
static void handleEventCB(void * userdata, SoEventCallback * n);
|
||||
static void interactionStartCB(void * data, SoQtViewer * viewer);
|
||||
static void interactionFinishCB(void * data, SoQtViewer * viewer);
|
||||
static void interactionStartCB(void * data, Quarter::SoQTQuarterAdaptor * viewer);
|
||||
static void interactionFinishCB(void * data, Quarter::SoQTQuarterAdaptor * viewer);
|
||||
static void interactionLoggerCB(void * ud, SoAction* action);
|
||||
|
||||
private:
|
||||
|
@ -399,10 +404,13 @@ private:
|
|||
SbBool allowredir;
|
||||
|
||||
std::string overrideMode;
|
||||
|
||||
ViewerEventFilter* viewerEventFilter;
|
||||
|
||||
// friends
|
||||
friend class NavigationStyle;
|
||||
friend class GLPainter;
|
||||
friend class ViewerEventFilter;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
|
|
@ -441,7 +441,7 @@ Py::Object View3DInventorPy::viewRotateLeft(const Py::Tuple& args)
|
|||
throw Py::Exception();
|
||||
|
||||
try {
|
||||
SoCamera* cam = _view->getViewer()->getCamera();
|
||||
SoCamera* cam = _view->getViewer()->getSoRenderManager()->getCamera();
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
SbVec3f vdir(0, 0, -1);
|
||||
rot.multVec(vdir, vdir);
|
||||
|
@ -467,7 +467,7 @@ Py::Object View3DInventorPy::viewRotateRight(const Py::Tuple& args)
|
|||
throw Py::Exception();
|
||||
|
||||
try {
|
||||
SoCamera* cam = _view->getViewer()->getCamera();
|
||||
SoCamera* cam = _view->getViewer()->getSoRenderManager()->getCamera();
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
SbVec3f vdir(0, 0, -1);
|
||||
rot.multVec(vdir, vdir);
|
||||
|
@ -600,7 +600,7 @@ Py::Object View3DInventorPy::viewPosition(const Py::Tuple& args)
|
|||
SbVec3f((float)pos.x, (float)pos.y, (float)pos.z), steps, ms);
|
||||
}
|
||||
|
||||
SoCamera* cam = _view->getViewer()->getCamera();
|
||||
SoCamera* cam = _view->getViewer()->getSoRenderManager()->getCamera();
|
||||
if (!cam) return Py::None();
|
||||
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
|
@ -651,22 +651,22 @@ Py::Object View3DInventorPy::isAnimationEnabled(const Py::Tuple& args)
|
|||
void View3DInventorPy::createImageFromFramebuffer(int backgroundType, int width, int height, QImage& img)
|
||||
{
|
||||
QGLFramebufferObject fbo(width, height, QGLFramebufferObject::Depth);
|
||||
const SbColor col = _view->getViewer()->getBackgroundColor();
|
||||
const QColor col = _view->getViewer()->backgroundColor();
|
||||
bool on = _view->getViewer()->hasGradientBackground();
|
||||
|
||||
switch(backgroundType){
|
||||
case 0: // Current
|
||||
break;
|
||||
case 1: // Black
|
||||
_view->getViewer()->setBackgroundColor(SbColor(0.0f,0.0f,0.0f));
|
||||
_view->getViewer()->setBackgroundColor(QColor(0,0,0));
|
||||
_view->getViewer()->setGradientBackground(false);
|
||||
break;
|
||||
case 2: // White
|
||||
_view->getViewer()->setBackgroundColor(SbColor(1.0f,1.0f,1.0f));
|
||||
_view->getViewer()->setBackgroundColor(QColor(255,255,255));
|
||||
_view->getViewer()->setGradientBackground(false);
|
||||
break;
|
||||
case 3: // Transparent
|
||||
_view->getViewer()->setBackgroundColor(SbColor(1.0f,1.0f,1.0f));
|
||||
_view->getViewer()->setBackgroundColor(QColor(255,255,255));
|
||||
_view->getViewer()->setGradientBackground(false);
|
||||
break;
|
||||
default:
|
||||
|
@ -725,7 +725,7 @@ Py::Object View3DInventorPy::saveImage(const Py::Tuple& args)
|
|||
}
|
||||
|
||||
SoFCOffscreenRenderer& renderer = SoFCOffscreenRenderer::instance();
|
||||
SoCamera* cam = _view->getViewer()->getCamera();
|
||||
SoCamera* cam = _view->getViewer()->getSoRenderManager()->getCamera();
|
||||
renderer.writeToImageFile(cFileName, cComment, cam->getViewVolume().getMatrix(), img);
|
||||
|
||||
return Py::None();
|
||||
|
@ -773,7 +773,7 @@ Py::Object View3DInventorPy::getCameraNode(const Py::Tuple& args)
|
|||
throw Py::Exception();
|
||||
|
||||
try {
|
||||
SoNode* camera = _view->getViewer()->getCamera();
|
||||
SoNode* camera = _view->getViewer()->getSoRenderManager()->getCamera();
|
||||
PyObject* proxy = 0;
|
||||
std::string type;
|
||||
type = "So"; // seems that So prefix is missing in camera node
|
||||
|
@ -799,7 +799,7 @@ Py::Object View3DInventorPy::getCamera(const Py::Tuple& args)
|
|||
|
||||
try {
|
||||
SoWriteAction wa(&out);
|
||||
SoCamera * cam = _view->getViewer()->getCamera();
|
||||
SoCamera * cam = _view->getViewer()->getSoRenderManager()->getCamera();
|
||||
if (cam) wa.apply(cam);
|
||||
else buffer[0] = '\0';
|
||||
return Py::String(buffer);
|
||||
|
@ -864,7 +864,7 @@ Py::Object View3DInventorPy::getCameraType(const Py::Tuple& args)
|
|||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
|
||||
SoCamera* cam = _view->getViewer()->getCamera();
|
||||
SoCamera* cam = _view->getViewer()->getSoRenderManager()->getCamera();
|
||||
if (!cam) {
|
||||
throw Py::Exception("No camera set!");
|
||||
}
|
||||
|
@ -999,14 +999,10 @@ Py::Object View3DInventorPy::setStereoType(const Py::Tuple& args)
|
|||
}
|
||||
|
||||
try {
|
||||
#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 2)
|
||||
if (stereomode < 0 || stereomode > 4)
|
||||
throw Py::Exception("Out of range");
|
||||
SoQtViewer::StereoType mode = SoQtViewer::StereoType(stereomode);
|
||||
_view->getViewer()->setStereoType(mode);
|
||||
#else
|
||||
throw Py::Exception("Stereo types not supported. Use SoQt 1.2.x or later!");
|
||||
#endif
|
||||
Quarter::SoQTQuarterAdaptor::StereoMode mode = Quarter::SoQTQuarterAdaptor::StereoMode(stereomode);
|
||||
_view->getViewer()->setProperty("StereoMode",mode);
|
||||
return Py::None();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
|
@ -1026,13 +1022,8 @@ Py::Object View3DInventorPy::getStereoType(const Py::Tuple& args)
|
|||
throw Py::Exception();
|
||||
|
||||
try {
|
||||
#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 2)
|
||||
int mode = (int)(_view->getViewer()->getStereoType());
|
||||
int mode = (int)(_view->getViewer()->stereoMode());
|
||||
return Py::String(StereoTypeEnums[mode]);
|
||||
#else
|
||||
throw Py::Exception("Stereo types not supported. Use SoQt 1.2.x or later!");
|
||||
#endif
|
||||
return Py::None();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
throw Py::Exception(e.what());
|
||||
|
@ -1105,9 +1096,9 @@ Py::Object View3DInventorPy::getObjectInfo(const Py::Tuple& args)
|
|||
// graph traversal we must not use a second SoHandleEventAction as
|
||||
// we will get Coin warnings because of multiple scene graph traversals
|
||||
// which is regarded as error-prone.
|
||||
SoRayPickAction action(_view->getViewer()->getViewportRegion());
|
||||
SoRayPickAction action(_view->getViewer()->getSoRenderManager()->getViewportRegion());
|
||||
action.setPoint(SbVec2s((long)x,(long)y));
|
||||
action.apply(_view->getViewer()->getSceneManager()->getSceneGraph());
|
||||
action.apply(_view->getViewer()->getSoRenderManager()->getSceneGraph());
|
||||
SoPickedPoint *Point = action.getPickedPoint();
|
||||
|
||||
Py::Object ret = Py::None();
|
||||
|
@ -1174,10 +1165,10 @@ Py::Object View3DInventorPy::getObjectsInfo(const Py::Tuple& args)
|
|||
// graph traversal we must not use a second SoHandleEventAction as
|
||||
// we will get Coin warnings because of multiple scene graph traversals
|
||||
// which is regarded as error-prone.
|
||||
SoRayPickAction action(_view->getViewer()->getViewportRegion());
|
||||
SoRayPickAction action(_view->getViewer()->getSoRenderManager()->getViewportRegion());
|
||||
action.setPickAll(true);
|
||||
action.setPoint(SbVec2s((long)x,(long)y));
|
||||
action.apply(_view->getViewer()->getSceneManager()->getSceneGraph());
|
||||
action.apply(_view->getViewer()->getSoRenderManager()->getSceneGraph());
|
||||
const SoPickedPointList& pp = action.getPickedPointList();
|
||||
|
||||
Py::Object ret = Py::None();
|
||||
|
@ -1235,7 +1226,7 @@ Py::Object View3DInventorPy::getSize(const Py::Tuple& args)
|
|||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
try {
|
||||
SbVec2s size = _view->getViewer()->getSize();
|
||||
SbVec2s size = _view->getViewer()->getSoRenderManager()->getSize();
|
||||
Py::Tuple tuple(2);
|
||||
tuple.setItem(0, Py::Int(size[0]));
|
||||
tuple.setItem(1, Py::Int(size[1]));
|
||||
|
@ -1285,11 +1276,11 @@ Py::Object View3DInventorPy::getPointOnScreen(const Py::Tuple& args)
|
|||
}
|
||||
|
||||
try {
|
||||
const SbViewportRegion& vp = _view->getViewer()->getViewportRegion();
|
||||
const SbViewportRegion& vp = _view->getViewer()->getSoRenderManager()->getViewportRegion();
|
||||
float fRatio = vp.getViewportAspectRatio();
|
||||
const SbVec2s& sp = vp.getViewportSizePixels();
|
||||
//float dX, dY; vp.getViewportSize().getValue(dX, dY);
|
||||
SbViewVolume vv = _view->getViewer()->getCamera()->getViewVolume(fRatio);
|
||||
SbViewVolume vv = _view->getViewer()->getSoRenderManager()->getCamera()->getViewVolume(fRatio);
|
||||
|
||||
SbVec3f pt(vx,vy,vz);
|
||||
vv.projectToScreen(pt, pt);
|
||||
|
@ -1814,7 +1805,7 @@ Py::Object View3DInventorPy::getSceneGraph(const Py::Tuple& args)
|
|||
|
||||
static PyObject *
|
||||
wrap_SoQtViewer_setViewDirection(PyObject *proxy, PyObject *args)
|
||||
{
|
||||
{/*
|
||||
PyObject* object;
|
||||
if (!PyArg_ParseTuple(args, "O", &object)) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
|
@ -1845,12 +1836,12 @@ wrap_SoQtViewer_setViewDirection(PyObject *proxy, PyObject *args)
|
|||
}
|
||||
catch (Py::Exception&) {
|
||||
return NULL;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
wrap_SoQtViewer_getViewDirection(PyObject *proxy, PyObject *args)
|
||||
{
|
||||
{/*
|
||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
|
||||
|
@ -1882,12 +1873,12 @@ wrap_SoQtViewer_getViewDirection(PyObject *proxy, PyObject *args)
|
|||
}
|
||||
catch (Py::Exception&) {
|
||||
return NULL;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
wrap_SoQtViewer_setFocalDistance(PyObject *proxy, PyObject *args)
|
||||
{
|
||||
{/*
|
||||
float distance;
|
||||
if (!PyArg_ParseTuple(args, "f", &distance)) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
|
@ -1908,12 +1899,12 @@ wrap_SoQtViewer_setFocalDistance(PyObject *proxy, PyObject *args)
|
|||
cam->focalDistance.setValue(distance);
|
||||
} PY_CATCH;
|
||||
|
||||
Py_Return;
|
||||
Py_Return;*/
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
wrap_SoQtViewer_getFocalDistance(PyObject *proxy, PyObject *args)
|
||||
{
|
||||
{/*
|
||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
|
||||
|
@ -1930,12 +1921,12 @@ wrap_SoQtViewer_getFocalDistance(PyObject *proxy, PyObject *args)
|
|||
double dist = 0;
|
||||
SoCamera* cam = viewer->getCamera();
|
||||
if (cam) dist = cam->focalDistance.getValue();
|
||||
return PyFloat_FromDouble(dist);
|
||||
return PyFloat_FromDouble(dist);*/
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
wrap_SoQtViewer_seekToPoint(PyObject *proxy, PyObject *args)
|
||||
{
|
||||
{/*
|
||||
PyObject* object;
|
||||
if (!PyArg_ParseTuple(args, "O", &object)) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
|
@ -1974,7 +1965,7 @@ wrap_SoQtViewer_seekToPoint(PyObject *proxy, PyObject *args)
|
|||
}
|
||||
catch (const Py::Exception&) {
|
||||
return NULL;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
struct PyMethodDef wrap_SoQtViewer_methods[] = {
|
||||
|
@ -2006,7 +1997,7 @@ Py::Object View3DInventorPy::getViewer(const Py::Tuple& args)
|
|||
// the viewer.
|
||||
// Note: Once we have closed the viewer the Python object must not be used
|
||||
// anymore as it has a dangling pointer.
|
||||
SoQtViewer* view = _view->getViewer();
|
||||
Quarter::SoQTQuarterAdaptor* view = _view->getViewer();
|
||||
proxy = Base::Interpreter().createSWIGPointerObj("pivy.gui.soqt", "SoQtViewer *", (void*)view, 0);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
|
|
|
@ -366,10 +366,10 @@ SoPickedPoint* ViewProvider::getPointOnRay(const SbVec2s& pos, const View3DInven
|
|||
// for convenience make a pick ray action to get the (potentially) picked entity in the provider
|
||||
SoSeparator* root = new SoSeparator;
|
||||
root->ref();
|
||||
root->addChild(viewer->getCamera());
|
||||
root->addChild(viewer->getSoRenderManager()->getCamera());
|
||||
root->addChild(pcRoot);
|
||||
|
||||
SoRayPickAction rp(viewer->getViewportRegion());
|
||||
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
|
||||
rp.setPoint(pos);
|
||||
rp.apply(root);
|
||||
root->unref();
|
||||
|
@ -382,7 +382,7 @@ SoPickedPoint* ViewProvider::getPointOnRay(const SbVec3f& pos,const SbVec3f& dir
|
|||
{
|
||||
// Note: There seems to be a bug with setRay() which causes SoRayPickAction
|
||||
// to fail to get intersections between the ray and a line
|
||||
SoRayPickAction rp(viewer->getViewportRegion());
|
||||
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
|
||||
rp.setRay(pos,dir);
|
||||
rp.apply(pcRoot);
|
||||
|
||||
|
|
|
@ -515,10 +515,10 @@ SoPickedPointList ViewProviderGeometryObject::getPickedPoints(const SbVec2s& pos
|
|||
SoSeparator* root = new SoSeparator;
|
||||
root->ref();
|
||||
root->addChild(viewer.getHeadlight());
|
||||
root->addChild(viewer.getCamera());
|
||||
root->addChild(viewer.getSoRenderManager()->getCamera());
|
||||
root->addChild(this->pcHighlight);
|
||||
|
||||
SoRayPickAction rp(viewer.getViewportRegion());
|
||||
SoRayPickAction rp(viewer.getSoRenderManager()->getViewportRegion());
|
||||
rp.setPickAll(pickAll);
|
||||
rp.setPoint(pos);
|
||||
rp.apply(root);
|
||||
|
@ -533,10 +533,10 @@ SoPickedPoint* ViewProviderGeometryObject::getPickedPoint(const SbVec2s& pos, co
|
|||
SoSeparator* root = new SoSeparator;
|
||||
root->ref();
|
||||
root->addChild(viewer.getHeadlight());
|
||||
root->addChild(viewer.getCamera());
|
||||
root->addChild(viewer.getSoRenderManager()->getCamera());
|
||||
root->addChild(this->pcHighlight);
|
||||
|
||||
SoRayPickAction rp(viewer.getViewportRegion());
|
||||
SoRayPickAction rp(viewer.getSoRenderManager()->getViewportRegion());
|
||||
rp.setPoint(pos);
|
||||
rp.apply(root);
|
||||
root->unref();
|
||||
|
|
|
@ -6,7 +6,6 @@ if(BUILD_GUI)
|
|||
${Boost_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <QApplication>
|
||||
#include <QIcon>
|
||||
#include <QThread>
|
||||
#include <Inventor/Qt/SoQt.h>
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <windows.h>
|
||||
#elif defined(Q_WS_X11)
|
||||
|
@ -46,7 +45,8 @@
|
|||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/SoFCDB.h>
|
||||
|
||||
#include <Gui/Quarter/Quarter.h>
|
||||
#include <Inventor/SoDB.h>
|
||||
|
||||
static
|
||||
QWidget* setupMainWindow();
|
||||
|
@ -163,7 +163,7 @@ FreeCADGui_setupWithoutGUI(PyObject * /*self*/, PyObject *args)
|
|||
if (!SoDB::isInitialized()) {
|
||||
// init the Inventor subsystem
|
||||
SoDB::init();
|
||||
SoQt::init("FreeCAD");
|
||||
SIM::Coin3D::Quarter::Quarter::init();
|
||||
}
|
||||
if (!Gui::SoFCDB::isInitialized()) {
|
||||
Gui::SoFCDB::init();
|
||||
|
@ -260,7 +260,7 @@ QWidget* setupMainWindow()
|
|||
if (!SoDB::isInitialized()) {
|
||||
// init the Inventor subsystem
|
||||
SoDB::init();
|
||||
SoQt::init(mw);
|
||||
SIM::Coin3D::Quarter::Quarter::init();
|
||||
Gui::SoFCDB::init();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ include_directories(
|
|||
${COIN_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
#${ODE_INCLUDE_DIRS}
|
||||
|
|
|
@ -11,7 +11,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
|
|
|
@ -4,7 +4,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -14,7 +14,6 @@ include_directories(
|
|||
${QT_INCLUDE_DIR}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
|
|
@ -17,7 +17,6 @@ include_directories(
|
|||
${ZLIB_INCLUDE_DIR}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src/3rdParty/salomesmesh/inc
|
||||
|
|
|
@ -465,7 +465,7 @@ void DefineNodesCallback(void * ud, SoEventCallback * n)
|
|||
if (clPoly.front() != clPoly.back())
|
||||
clPoly.push_back(clPoly.front());
|
||||
|
||||
SoCamera* cam = view->getCamera();
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
|
|
|
@ -147,7 +147,7 @@ void TaskCreateNodeSet::DefineNodesCallback(void * ud, SoEventCallback * n)
|
|||
if (clPoly.front() != clPoly.back())
|
||||
clPoly.push_back(clPoly.front());
|
||||
|
||||
SoCamera* cam = view->getCamera();
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
|
|
|
@ -11,7 +11,6 @@ include_directories(
|
|||
${OPENCV2_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -13,7 +13,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -3,14 +3,13 @@ include_directories(
|
|||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
||||
set(InspectionGui_LIBS
|
||||
Inspection
|
||||
|
@ -18,23 +17,23 @@ set(InspectionGui_LIBS
|
|||
)
|
||||
|
||||
qt4_add_resources(Inspection_QRC_SRCS Resources/Inspection.qrc)
|
||||
|
||||
set(InspectionGui_MOC_HDRS
|
||||
|
||||
set(InspectionGui_MOC_HDRS
|
||||
VisualInspection.h
|
||||
)
|
||||
fc_wrap_cpp(InspectionGui_MOC_SRCS ${InspectionGui_MOC_HDRS})
|
||||
SOURCE_GROUP("Moc" FILES ${InspectionGui_MOC_SRCS})
|
||||
|
||||
set(Dialogs_UIC_SRCS
|
||||
)
|
||||
fc_wrap_cpp(InspectionGui_MOC_SRCS ${InspectionGui_MOC_HDRS})
|
||||
SOURCE_GROUP("Moc" FILES ${InspectionGui_MOC_SRCS})
|
||||
|
||||
set(Dialogs_UIC_SRCS
|
||||
VisualInspection.ui
|
||||
)
|
||||
qt4_wrap_ui(Dialogs_UIC_HDRS ${Dialogs_UIC_SRCS})
|
||||
SET(Dialogs_SRCS
|
||||
${Dialogs_UIC_HDRS}
|
||||
)
|
||||
qt4_wrap_ui(Dialogs_UIC_HDRS ${Dialogs_UIC_SRCS})
|
||||
SET(Dialogs_SRCS
|
||||
${Dialogs_UIC_HDRS}
|
||||
VisualInspection.cpp
|
||||
VisualInspection.h
|
||||
)
|
||||
SOURCE_GROUP("Dialogs" FILES ${Dialogs_SRCS})
|
||||
)
|
||||
SOURCE_GROUP("Dialogs" FILES ${Dialogs_SRCS})
|
||||
|
||||
SET(InspectionGui_SRCS
|
||||
${Inspection_QRC_SRCS}
|
||||
|
@ -47,12 +46,12 @@ SET(InspectionGui_SRCS
|
|||
ViewProviderInspection.cpp
|
||||
ViewProviderInspection.h
|
||||
Workbench.cpp
|
||||
Workbench.h
|
||||
)
|
||||
|
||||
add_library(InspectionGui SHARED ${InspectionGui_SRCS})
|
||||
target_link_libraries(InspectionGui ${InspectionGui_LIBS})
|
||||
|
||||
Workbench.h
|
||||
)
|
||||
|
||||
add_library(InspectionGui SHARED ${InspectionGui_SRCS})
|
||||
target_link_libraries(InspectionGui ${InspectionGui_LIBS})
|
||||
|
||||
|
||||
fc_target_copy_resource(InspectionGui
|
||||
${CMAKE_SOURCE_DIR}/src/Mod/Inspection
|
||||
|
@ -60,6 +59,6 @@ fc_target_copy_resource(InspectionGui
|
|||
InitGui.py)
|
||||
|
||||
SET_BIN_DIR(InspectionGui InspectionGui /Mod/Inspection)
|
||||
SET_PYTHON_PREFIX_SUFFIX(InspectionGui)
|
||||
|
||||
INSTALL(TARGETS InspectionGui DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
SET_PYTHON_PREFIX_SUFFIX(InspectionGui)
|
||||
|
||||
INSTALL(TARGETS InspectionGui DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
|
|
@ -472,10 +472,10 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
|||
}
|
||||
else {
|
||||
// the nearest picked point was not part of the view provider
|
||||
SoRayPickAction action(view->getViewportRegion());
|
||||
SoRayPickAction action(view->getSoRenderManager()->getViewportRegion());
|
||||
action.setPickAll(TRUE);
|
||||
action.setPoint(mbe->getPosition());
|
||||
action.apply(view->getSceneManager()->getSceneGraph());
|
||||
action.apply(view->getSoRenderManager()->getSceneGraph());
|
||||
|
||||
const SoPickedPointList& pps = action.getPickedPointList();
|
||||
for (int i=0; i<pps.getLength(); ++i) {
|
||||
|
|
|
@ -4,7 +4,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include <Gui/View3DInventorViewer.h>
|
||||
|
||||
using namespace MeshGui;
|
||||
using namespace Quarter;
|
||||
|
||||
PROPERTY_SOURCE(MeshGui::ViewProviderFace, Gui::ViewProviderDocumentObject)
|
||||
|
||||
|
@ -155,15 +156,15 @@ std::vector<std::string> ViewProviderFace::getDisplayModes(void) const
|
|||
return modes;
|
||||
}
|
||||
|
||||
SoPickedPoint* ViewProviderFace::getPickedPoint(const SbVec2s& pos, const SoQtViewer* viewer) const
|
||||
SoPickedPoint* ViewProviderFace::getPickedPoint(const SbVec2s& pos, const Gui::View3DInventorViewer* viewer) const
|
||||
{
|
||||
SoSeparator* root = new SoSeparator;
|
||||
root->ref();
|
||||
root->addChild(viewer->getHeadlight());
|
||||
root->addChild(viewer->getCamera());
|
||||
root->addChild(viewer->getSoRenderManager()->getCamera());
|
||||
root->addChild(this->pcMeshPick);
|
||||
|
||||
SoRayPickAction rp(viewer->getViewportRegion());
|
||||
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
|
||||
rp.setPoint(pos);
|
||||
rp.apply(root);
|
||||
root->unref();
|
||||
|
@ -455,11 +456,11 @@ void MeshFillHole::startEditing(MeshGui::ViewProviderMesh* vp)
|
|||
|
||||
myBoundariesRoot->removeAllChildren();
|
||||
myBoundariesRoot->addChild(viewer->getHeadlight());
|
||||
myBoundariesRoot->addChild(viewer->getCamera());
|
||||
myBoundariesRoot->addChild(viewer->getSoRenderManager()->getCamera());
|
||||
myBoundariesRoot->addChild(myBoundariesGroup);
|
||||
myBoundaryRoot->removeAllChildren();
|
||||
myBoundaryRoot->addChild(viewer->getHeadlight());
|
||||
myBoundaryRoot->addChild(viewer->getCamera());
|
||||
myBoundaryRoot->addChild(viewer->getSoRenderManager()->getCamera());
|
||||
createPolygons();
|
||||
static_cast<SoGroup*>(viewer->getSceneGraph())->addChild(myBridgeRoot);
|
||||
}
|
||||
|
@ -577,7 +578,7 @@ void MeshFillHole::createPolygons()
|
|||
}
|
||||
}
|
||||
|
||||
SoNode* MeshFillHole::getPickedPolygon(const SoRayPickAction& action/*SoNode* root, const SbVec2s& pos, const SoQtViewer* viewer*/) const
|
||||
SoNode* MeshFillHole::getPickedPolygon(const SoRayPickAction& action/*SoNode* root, const SbVec2s& pos*/) const
|
||||
{
|
||||
SoPolygon* poly = 0;
|
||||
const SoPickedPointList & points = action.getPickedPointList();
|
||||
|
@ -632,7 +633,7 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
|
|||
const SoEvent* ev = n->getEvent();
|
||||
if (ev->getTypeId() == SoLocation2Event::getClassTypeId()) {
|
||||
n->setHandled();
|
||||
SoRayPickAction rp(view->getViewportRegion());
|
||||
SoRayPickAction rp(view->getSoRenderManager()->getViewportRegion());
|
||||
rp.setPoint(ev->getPosition());
|
||||
rp.setPickAll(true);
|
||||
if (self->myNumPoints == 0)
|
||||
|
@ -664,7 +665,7 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
|
|||
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
|
||||
if (self->myNumPoints > 1)
|
||||
return;
|
||||
SoRayPickAction rp(view->getViewportRegion());
|
||||
SoRayPickAction rp(view->getSoRenderManager()->getViewportRegion());
|
||||
rp.setPoint(ev->getPosition());
|
||||
rp.setPickAll(true);
|
||||
if (self->myNumPoints == 0)
|
||||
|
@ -707,7 +708,7 @@ void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n)
|
|||
QTimer::singleShot(300, self, SLOT(finishEditing()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_MeshEditor.cpp"
|
||||
|
|
|
@ -31,14 +31,13 @@ class SoCoordinate3;
|
|||
class SoFaceSet;
|
||||
class SoEventCallback;
|
||||
class SoPickedPoint;
|
||||
class SoQtViewer;
|
||||
class SoGroup;
|
||||
class SoSeparator;
|
||||
class SoRayPickAction;
|
||||
class SbLine;
|
||||
class SbVec3f;
|
||||
|
||||
namespace Gui { class View3DInventor; }
|
||||
namespace Gui { class View3DInventor; class View3DInventorViewer;}
|
||||
namespace Mesh { class MeshObject; }
|
||||
namespace Mesh { class Feature; }
|
||||
namespace MeshGui {
|
||||
|
@ -60,7 +59,7 @@ public:
|
|||
void setDisplayMode(const char* ModeName);
|
||||
const char* getDefaultDisplayMode() const;
|
||||
std::vector<std::string> getDisplayModes(void) const;
|
||||
SoPickedPoint* getPickedPoint(const SbVec2s& pos, const SoQtViewer* viewer) const;
|
||||
SoPickedPoint* getPickedPoint(const SbVec2s& pos, const Gui::View3DInventorViewer* viewer) const;
|
||||
|
||||
ViewProviderMesh* mesh;
|
||||
std::vector<int> index;
|
||||
|
|
|
@ -175,12 +175,11 @@ void MeshSelection::prepareBrushSelection(bool add,SoEventCallbackCB *cb)
|
|||
brush->setColor(1.0f,0.0f,0.0f);
|
||||
brush->setLineWidth(3.0f);
|
||||
viewer->navigationStyle()->startSelection(brush);
|
||||
SoQtCursor::CustomCursor custom;
|
||||
custom.dim.setValue(CROSS_WIDTH, CROSS_HEIGHT);
|
||||
custom.hotspot.setValue(CROSS_HOT_X, CROSS_HOT_Y);
|
||||
custom.bitmap = cross_bitmap;
|
||||
custom.mask = cross_mask_bitmap;
|
||||
viewer->setComponentCursor(SoQtCursor(&custom));
|
||||
|
||||
QBitmap cursor = QBitmap::fromData(QSize(CROSS_WIDTH, CROSS_HEIGHT), cross_bitmap);
|
||||
QBitmap mask = QBitmap::fromData(QSize(CROSS_WIDTH, CROSS_HEIGHT), cross_mask_bitmap);
|
||||
QCursor custom(cursor, mask, CROSS_HOT_X, CROSS_HOT_Y);
|
||||
viewer->setComponentCursor(custom);
|
||||
this->addToSelection = add;
|
||||
}
|
||||
}
|
||||
|
@ -396,12 +395,12 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
|
|||
const MeshCore::MeshKernel& kernel = mesh.getKernel();
|
||||
|
||||
// simply get all triangles under the polygon
|
||||
SoCamera* cam = view->getCamera();
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
vp->getFacetsFromPolygon(polygon, proj, true, faces);
|
||||
if (self->onlyVisibleTriangles) {
|
||||
const SbVec2s& sz = view->getViewportRegion().getWindowSize();
|
||||
const SbVec2s& sz = view->getSoRenderManager()->getViewportRegion().getWindowSize();
|
||||
short width,height; sz.getValue(width,height);
|
||||
std::vector<SbVec2s> pixelPoly = view->getPolygon();
|
||||
SbBox2s rect;
|
||||
|
@ -411,7 +410,7 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
|
|||
}
|
||||
std::vector<unsigned long> rf; rf.swap(faces);
|
||||
std::vector<unsigned long> vf = vp->getVisibleFacetsAfterZoom
|
||||
(rect, view->getViewportRegion(), view->getCamera());
|
||||
(rect, view->getSoRenderManager()->getViewportRegion(), view->getSoRenderManager()->getCamera());
|
||||
|
||||
// get common facets of the viewport and the visible one
|
||||
std::sort(vf.begin(), vf.end());
|
||||
|
@ -441,7 +440,7 @@ void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n)
|
|||
vp->removeSelection(faces);
|
||||
}
|
||||
|
||||
view->render();
|
||||
view->redraw();
|
||||
}
|
||||
|
||||
void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n)
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
#include <Gui/SoFCOffscreenRenderer.h>
|
||||
#include <Gui/SoFCSelection.h>
|
||||
#include <Gui/SoFCSelectionAction.h>
|
||||
#include <Gui/SoFCDB.h>
|
||||
#include <Gui/SoFCDB.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Utilities.h>
|
||||
|
@ -677,7 +677,7 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n)
|
|||
ViewProviderMesh* self = static_cast<ViewProviderMesh*>(*it);
|
||||
if (self->getEditingMode() > -1) {
|
||||
self->finishEditing();
|
||||
SoCamera* cam = view->getCamera();
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
self->cutMesh(clPoly, proj, clip_inner);
|
||||
|
@ -686,7 +686,7 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n)
|
|||
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
|
||||
view->render();
|
||||
view->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,7 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n)
|
|||
ViewProviderMesh* self = static_cast<ViewProviderMesh*>(*it);
|
||||
if (self->getEditingMode() > -1) {
|
||||
self->finishEditing();
|
||||
SoCamera* cam = view->getCamera();
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
self->trimMesh(clPoly, proj, clip_inner);
|
||||
|
@ -724,7 +724,7 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n)
|
|||
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
|
||||
view->render();
|
||||
view->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,7 +750,7 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb)
|
|||
SbVec3f b,n;
|
||||
view->getNearPlane(b, n);
|
||||
Base::Vector3f cPoint(b[0],b[1],b[2]), cNormal(n[0],n[1],n[2]);
|
||||
SoCamera* pCam = view->getCamera();
|
||||
SoCamera* pCam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vol = pCam->getViewVolume();
|
||||
|
||||
// create a tool shape from these points
|
||||
|
@ -782,7 +782,7 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb)
|
|||
|
||||
// Close the transaction
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
view->render();
|
||||
view->redraw();
|
||||
}
|
||||
|
||||
void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb)
|
||||
|
@ -807,7 +807,7 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb)
|
|||
SbVec3f b,n;
|
||||
view->getNearPlane(b, n);
|
||||
Base::Vector3f cPoint(b[0],b[1],b[2]), cNormal(n[0],n[1],n[2]);
|
||||
SoCamera* pCam = view->getCamera();
|
||||
SoCamera* pCam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vol = pCam->getViewVolume();
|
||||
|
||||
// create a tool shape from these points
|
||||
|
@ -839,7 +839,7 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb)
|
|||
|
||||
// Close the transaction
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
view->render();
|
||||
view->redraw();
|
||||
}
|
||||
|
||||
void ViewProviderMesh::selectGLCallback(void * ud, SoEventCallback * n)
|
||||
|
@ -857,8 +857,8 @@ void ViewProviderMesh::selectGLCallback(void * ud, SoEventCallback * n)
|
|||
|
||||
SbVec2f pos = clPoly[0];
|
||||
float pX,pY; pos.getValue(pX,pY);
|
||||
const SbVec2s& sz = view->getViewportRegion().getViewportSizePixels();
|
||||
float fRatio = view->getViewportRegion().getViewportAspectRatio();
|
||||
const SbVec2s& sz = view->getSoRenderManager()->getViewportRegion().getViewportSizePixels();
|
||||
float fRatio = view->getSoRenderManager()->getViewportRegion().getViewportAspectRatio();
|
||||
if (fRatio > 1.0f) {
|
||||
pX = (pX - 0.5f) / fRatio + 0.5f;
|
||||
pos.setValue(pX,pY);
|
||||
|
@ -887,11 +887,11 @@ void ViewProviderMesh::selectGLCallback(void * ud, SoEventCallback * n)
|
|||
ViewProviderMesh* that = static_cast<ViewProviderMesh*>(*it);
|
||||
if (that->getEditingMode() > -1) {
|
||||
that->finishEditing();
|
||||
that->selectArea(x, y, w, h, view->getViewportRegion(), view->getCamera());
|
||||
that->selectArea(x, y, w, h, view->getSoRenderManager()->getViewportRegion(), view->getSoRenderManager()->getCamera());
|
||||
}
|
||||
}
|
||||
|
||||
view->render();
|
||||
view->redraw();
|
||||
}
|
||||
|
||||
void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
|
||||
|
@ -1004,8 +1004,8 @@ void ViewProviderMesh::boxZoom(const SbBox2s& box, const SbViewportRegion & vp,
|
|||
// Get the new center in normalized pixel coordinates
|
||||
short xmin,xmax,ymin,ymax;
|
||||
box.getBounds(xmin,ymin,xmax,ymax);
|
||||
const SbVec2f center((float) ((xmin+xmax)/2) / (float) SoQtMax((int)(size[0] - 1), 1),
|
||||
(float) (size[1]-(ymin+ymax)/2) / (float) SoQtMax((int)(size[1] - 1), 1));
|
||||
const SbVec2f center((float) ((xmin+xmax)/2) / (float) std::max((int)(size[0] - 1), 1),
|
||||
(float) (size[1]-(ymin+ymax)/2) / (float) std::max((int)(size[1] - 1), 1));
|
||||
|
||||
SbPlane plane = vv.getPlane(cam->focalDistance.getValue());
|
||||
panCamera(cam,vp.getViewportAspectRatio(),plane, SbVec2f(0.5,0.5), center);
|
||||
|
@ -1346,7 +1346,7 @@ void ViewProviderMesh::markPartCallback(void * ud, SoEventCallback * n)
|
|||
for (std::vector<ViewProvider*>::iterator it = views.begin(); it != views.end(); ++it) {
|
||||
static_cast<ViewProviderMesh*>(*it)->deleteSelection();
|
||||
}
|
||||
view->render();
|
||||
view->redraw();
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -13,7 +13,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
|
|
|
@ -88,10 +88,10 @@ namespace PartGui {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
class FaceColors::Private
|
||||
{
|
||||
public:
|
||||
|
||||
class FaceColors::Private
|
||||
{
|
||||
public:
|
||||
typedef boost::signals::connection Connection;
|
||||
Ui_TaskFaceColors* ui;
|
||||
Gui::View3DInventorViewer* view;
|
||||
|
@ -102,11 +102,11 @@ public:
|
|||
QSet<int> index;
|
||||
Connection connectDelDoc;
|
||||
Connection connectDelObj;
|
||||
|
||||
|
||||
Private(ViewProviderPartExt* vp) : ui(new Ui_TaskFaceColors()), view(0), vp(vp)
|
||||
{
|
||||
obj = vp->getObject();
|
||||
doc = Gui::Application::Instance->getDocument(obj->getDocument());
|
||||
{
|
||||
obj = vp->getObject();
|
||||
doc = Gui::Application::Instance->getDocument(obj->getDocument());
|
||||
|
||||
// build up map edge->face
|
||||
TopTools_IndexedMapOfShape mapOfShape;
|
||||
|
@ -121,16 +121,16 @@ public:
|
|||
current.push_back(vp->ShapeColor.getValue());
|
||||
perface = current;
|
||||
perface.resize(mapOfShape.Extent(), perface.front());
|
||||
}
|
||||
~Private()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
bool isVisibleFace(int faceIndex, const SbVec2f& pos, Gui::View3DInventorViewer* viewer)
|
||||
{
|
||||
}
|
||||
~Private()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
bool isVisibleFace(int faceIndex, const SbVec2f& pos, Gui::View3DInventorViewer* viewer)
|
||||
{
|
||||
SoSeparator* root = new SoSeparator;
|
||||
root->ref();
|
||||
root->addChild(viewer->getCamera());
|
||||
root->addChild(viewer->getSoRenderManager()->getCamera());
|
||||
root->addChild(vp->getRoot());
|
||||
|
||||
SoSearchAction searchAction;
|
||||
|
@ -139,7 +139,7 @@ public:
|
|||
searchAction.apply(root);
|
||||
SoPath* selectionPath = searchAction.getPath();
|
||||
|
||||
SoRayPickAction rp(viewer->getViewportRegion());
|
||||
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
|
||||
rp.setNormalizedPoint(pos);
|
||||
rp.apply(selectionPath);
|
||||
root->unref();
|
||||
|
@ -160,13 +160,13 @@ public:
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
void addFacesToSelection(Gui::View3DInventorViewer* viewer,
|
||||
const Gui::ViewVolumeProjection& proj,
|
||||
const Base::Polygon2D& polygon,
|
||||
const TopoDS_Shape& shape)
|
||||
{
|
||||
try {
|
||||
}
|
||||
void addFacesToSelection(Gui::View3DInventorViewer* viewer,
|
||||
const Gui::ViewVolumeProjection& proj,
|
||||
const Base::Polygon2D& polygon,
|
||||
const TopoDS_Shape& shape)
|
||||
{
|
||||
try {
|
||||
TopTools_IndexedMapOfShape M;
|
||||
|
||||
TopExp_Explorer xp_face(shape,TopAbs_FACE);
|
||||
|
@ -212,19 +212,19 @@ public:
|
|||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
static void selectionCallback(void * ud, SoEventCallback * cb)
|
||||
{
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
static void selectionCallback(void * ud, SoEventCallback * cb)
|
||||
{
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(cb->getUserData());
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, ud);
|
||||
SoNode* root = view->getSceneGraph();
|
||||
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(TRUE);
|
||||
|
||||
std::vector<SbVec2f> picked = view->getGLPolygon();
|
||||
SoCamera* cam = view->getCamera();
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
|
@ -247,10 +247,10 @@ public:
|
|||
cb->setHandled();
|
||||
const TopoDS_Shape& shape = static_cast<Part::Feature*>(self->d->obj)->Shape.getValue();
|
||||
self->d->addFacesToSelection(view, proj, polygon, shape);
|
||||
view->render();
|
||||
view->redraw();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/* TRANSLATOR PartGui::TaskFaceColors */
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -8,7 +8,6 @@ include_directories(
|
|||
${Boost_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
|
|
|
@ -379,7 +379,7 @@ void ViewProviderPoints::clipPointsCallback(void * ud, SoEventCallback * n)
|
|||
}
|
||||
}
|
||||
|
||||
view->render();
|
||||
view->getSoRenderManager()->render();
|
||||
}
|
||||
|
||||
void ViewProviderPoints::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
|
||||
|
@ -394,7 +394,7 @@ void ViewProviderPoints::cut(const std::vector<SbVec2f>& picked, Gui::View3DInve
|
|||
Points::Feature* fea = (Points::Feature*)pcObject;
|
||||
const Points::PointKernel& points = fea->Points.getValue();
|
||||
|
||||
SoCamera* pCam = Viewer.getCamera();
|
||||
SoCamera* pCam = Viewer.getSoRenderManager()->getCamera();
|
||||
SbViewVolume vol = pCam->getViewVolume();
|
||||
|
||||
// search for all points inside/outside the polygon
|
||||
|
|
|
@ -14,7 +14,6 @@ include_directories(
|
|||
${OCC_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -12,7 +12,6 @@ include_directories(
|
|||
${OCC_INCLUDE_DIR}
|
||||
${COIN3D_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
|
|
|
@ -16,7 +16,6 @@ include_directories(
|
|||
${OCC_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${EIGEN3_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -10,7 +10,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
|
|
|
@ -14,7 +14,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
${EIGEN3_INCLUDE_DIR}
|
||||
|
|
|
@ -67,7 +67,7 @@ float SoZoomTranslation::getScaleFactor()
|
|||
Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView();
|
||||
if (mdi && mdi->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
Gui::View3DInventorViewer *viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
|
||||
this->scale = viewer->getCamera()->getViewVolume(viewer->getCamera()->aspectRatio.getValue()).getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / 5;
|
||||
this->scale = viewer->getSoRenderManager()->getCamera()->getViewVolume(viewer->getSoRenderManager()->getCamera()->aspectRatio.getValue()).getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / 5;
|
||||
return this->scale;
|
||||
} else {
|
||||
return this->scale;
|
||||
|
|
|
@ -284,10 +284,14 @@ ViewProviderSketch::ViewProviderSketch()
|
|||
color = hGrp->GetUnsigned("SketchVertexColor", color);
|
||||
vertexColor.setPackedValue((uint32_t)color);
|
||||
PointColor.setValue(vertexColor);
|
||||
|
||||
//rubberband selection
|
||||
rubberband = new Gui::Rubberband();
|
||||
}
|
||||
|
||||
ViewProviderSketch::~ViewProviderSketch()
|
||||
{
|
||||
delete rubberband;
|
||||
}
|
||||
|
||||
// handler management ***************************************************************
|
||||
|
@ -429,7 +433,7 @@ void ViewProviderSketch::snapToGrid(double &x, double &y)
|
|||
|
||||
void ViewProviderSketch::getProjectingLine(const SbVec2s& pnt, const Gui::View3DInventorViewer *viewer, SbLine& line) const
|
||||
{
|
||||
const SbViewportRegion& vp = viewer->getViewportRegion();
|
||||
const SbViewportRegion& vp = viewer->getSoRenderManager()->getViewportRegion();
|
||||
|
||||
short x,y; pnt.getValue(x,y);
|
||||
SbVec2f siz = vp.getViewportSize();
|
||||
|
@ -448,7 +452,7 @@ void ViewProviderSketch::getProjectingLine(const SbVec2s& pnt, const Gui::View3D
|
|||
pY = (pY - 0.5f*dY) / fRatio + 0.5f*dY;
|
||||
}
|
||||
|
||||
SoCamera* pCam = viewer->getCamera();
|
||||
SoCamera* pCam = viewer->getSoRenderManager()->getCamera();
|
||||
if (!pCam) return;
|
||||
SbViewVolume vol = pCam->getViewVolume();
|
||||
|
||||
|
@ -741,6 +745,13 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
|||
return true;
|
||||
case STATUS_SKETCH_UseRubberBand:
|
||||
doBoxSelection(prvCursorPos, cursorPos, viewer);
|
||||
rubberband->setWorking(false);
|
||||
|
||||
//disable framebuffer drawing in viewer
|
||||
if(Gui::Application::Instance->activeDocument()->getActiveView()) {
|
||||
static_cast<Gui::View3DInventor *>(Gui::Application::Instance->activeDocument()->getActiveView())->getViewer()->setRenderFramebuffer(false);
|
||||
}
|
||||
|
||||
// a redraw is required in order to clear the rubberband
|
||||
draw(true);
|
||||
Mode = STATUS_NONE;
|
||||
|
@ -1064,27 +1075,17 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
|
|||
return true;
|
||||
case STATUS_SKETCH_StartRubberBand: {
|
||||
Mode = STATUS_SKETCH_UseRubberBand;
|
||||
rubberband->setWorking(true);
|
||||
viewer->setRenderFramebuffer(true);
|
||||
return true;
|
||||
}
|
||||
case STATUS_SKETCH_UseRubberBand: {
|
||||
Gui::GLPainter p;
|
||||
p.begin(viewer);
|
||||
p.setColor(1.0, 1.0, 0.0, 0.0);
|
||||
p.setLogicOp(GL_XOR);
|
||||
p.setLineWidth(3.0f);
|
||||
p.setLineStipple(2, 0x3F3F);
|
||||
// first redraw the old rectangle with XOR to restore the correct colors
|
||||
p.drawRect(prvCursorPos.getValue()[0],
|
||||
viewer->getGLWidget()->height() - prvCursorPos.getValue()[1],
|
||||
newCursorPos.getValue()[0],
|
||||
viewer->getGLWidget()->height() - newCursorPos.getValue()[1]);
|
||||
newCursorPos = cursorPos;
|
||||
// now draw the new rectangle
|
||||
p.drawRect(prvCursorPos.getValue()[0],
|
||||
rubberband->setCoords(prvCursorPos.getValue()[0],
|
||||
viewer->getGLWidget()->height() - prvCursorPos.getValue()[1],
|
||||
newCursorPos.getValue()[0],
|
||||
viewer->getGLWidget()->height() - newCursorPos.getValue()[1]);
|
||||
p.end();
|
||||
viewer->redraw();
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
|
@ -1241,7 +1242,7 @@ Base::Vector3d ViewProviderSketch::seekConstraintPosition(const Base::Vector3d &
|
|||
assert(edit);
|
||||
Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView();
|
||||
Gui::View3DInventorViewer *viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
|
||||
SoRayPickAction rp(viewer->getViewportRegion());
|
||||
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
|
||||
|
||||
float scaled_step = step * getScaleFactor();
|
||||
|
||||
|
@ -1739,7 +1740,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
polygon.Add(Base::Vector2D(corners[1].getValue()[0], corners[1].getValue()[1]));
|
||||
polygon.Add(Base::Vector2D(corners[1].getValue()[0], corners[0].getValue()[1]));
|
||||
|
||||
Gui::ViewVolumeProjection proj(viewer->getCamera()->getViewVolume());
|
||||
Gui::ViewVolumeProjection proj(viewer->getSoRenderManager()->getCamera()->getViewVolume());
|
||||
|
||||
Sketcher::SketchObject *sketchObject = getSketchObject();
|
||||
App::Document *doc = sketchObject->getDocument();
|
||||
|
@ -2644,7 +2645,7 @@ float ViewProviderSketch::getScaleFactor()
|
|||
Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView();
|
||||
if (mdi && mdi->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
Gui::View3DInventorViewer *viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
|
||||
return viewer->getCamera()->getViewVolume(viewer->getCamera()->aspectRatio.getValue()).getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / 3;
|
||||
return viewer->getSoRenderManager()->getCamera()->getViewVolume(viewer->getSoRenderManager()->getCamera()->aspectRatio.getValue()).getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / 3;
|
||||
} else {
|
||||
return 1.f;
|
||||
}
|
||||
|
@ -3414,8 +3415,8 @@ Restart:
|
|||
for (std::vector<Part::Geometry *>::iterator it=tempGeo.begin(); it != tempGeo.end(); ++it)
|
||||
if (*it) delete *it;
|
||||
|
||||
if (mdi && mdi->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
static_cast<Gui::View3DInventor *>(mdi)->getViewer()->render();
|
||||
if (mdi && mdi->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
static_cast<Gui::View3DInventor *>(mdi)->getViewer()->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4032,16 +4033,14 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo
|
|||
viewer->setEditing(TRUE);
|
||||
SoNode* root = viewer->getSceneGraph();
|
||||
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(FALSE);
|
||||
antiAliasing = (int)viewer->getAntiAliasingMode();
|
||||
if (antiAliasing != Gui::View3DInventorViewer::None)
|
||||
viewer->setAntiAliasingMode(Gui::View3DInventorViewer::None);
|
||||
|
||||
|
||||
viewer->addGraphicsItem(rubberband);
|
||||
rubberband->setViewer(viewer);
|
||||
}
|
||||
|
||||
void ViewProviderSketch::unsetEditViewer(Gui::View3DInventorViewer* viewer)
|
||||
{
|
||||
if (antiAliasing != Gui::View3DInventorViewer::None)
|
||||
viewer->setAntiAliasingMode(Gui::View3DInventorViewer::AntiAliasing(antiAliasing));
|
||||
viewer->removeGraphicsItem(rubberband);
|
||||
viewer->setEditing(FALSE);
|
||||
SoNode* root = viewer->getSceneGraph();
|
||||
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(TRUE);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <Inventor/SbColor.h>
|
||||
#include <Base/Tools2D.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/GLPainter.h>
|
||||
#include <boost/signals.hpp>
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
@ -203,8 +204,7 @@ public:
|
|||
/// is called when the Provider is in edit and a key event ocours. Only ESC ends edit.
|
||||
virtual bool keyPressed(bool pressed, int key);
|
||||
/// is called when the Provider is in edit and the mouse is clicked
|
||||
virtual bool mouseButtonPressed(int Button, bool pressed, const SbVec2s &pos,
|
||||
const Gui::View3DInventorViewer *viewer);
|
||||
virtual bool mouseButtonPressed(int Button, bool pressed, const SbVec2s& cursorPos, const Gui::View3DInventorViewer* viewer);
|
||||
//@}
|
||||
|
||||
friend class DrawSketchHandler;
|
||||
|
@ -371,7 +371,8 @@ protected:
|
|||
// reference coordinates for relative operations
|
||||
double xInit,yInit;
|
||||
bool relative;
|
||||
int antiAliasing;
|
||||
|
||||
Gui::Rubberband* rubberband;
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
|
|
@ -4,7 +4,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -4,7 +4,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -6,7 +6,6 @@ include_directories(
|
|||
${COIN3D_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${XERCESC_INCLUDE_DIR}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user