From 8805cab27c73593905f51c4e254d0b25d71fc9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Sun, 19 Apr 2015 16:09:52 +0200 Subject: [PATCH] FEM Post: Proof of concept --- CMakeLists.txt | 9 + src/Gui/CMakeLists.txt | 7 + src/Gui/CMakeLists.txt.orig | 1167 ++++++++++++++++++++++++++++++ src/Gui/SoFCDB.cpp | 1 + src/Gui/SoFCDB.cpp.orig | 312 ++++++++ src/Gui/SoVTKActor.cpp | 337 +++++++++ src/Gui/SoVTKActor.h | 97 +++ src/Gui/View3DInventorViewer.cpp | 253 +++++++ src/Gui/View3DInventorViewer.h | 9 + 9 files changed, 2192 insertions(+) create mode 100644 src/Gui/CMakeLists.txt.orig create mode 100644 src/Gui/SoFCDB.cpp.orig create mode 100644 src/Gui/SoVTKActor.cpp create mode 100644 src/Gui/SoVTKActor.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 150138900413..662d4d33746a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,6 +196,7 @@ OPTION(BUILD_START "Build the FreeCAD start module" ON) OPTION(BUILD_TEST "Build the FreeCAD test module" ON) OPTION(BUILD_WEB "Build the FreeCAD web module" ON) OPTION(BUILD_VR "Build the FreeCAD Oculus Rift support (need Oculus SDK 4.x or higher)" OFF) +OPTION(BUILD_VTK "Build the FreeCAD VTK support (need VTK 6 or higher)" OFF) if(MSVC) OPTION(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" ON) @@ -752,6 +753,14 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") #--------------------------------------------------- +# -------------------------------- VTK -------------------------------- + if(BUILD_VTK) + find_package(VTK REQUIRED) + add_definitions(-DFC_USE_VTK) + + include(${VTK_USE_FILE}) + endif(BUILD_VTK) + if(BUILD_GUI) # -------------------------------- OpenGL -------------------------------- diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 49bea4d1a32e..806ad00bb6eb 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -115,6 +115,13 @@ if(PYSIDE_INCLUDE_DIR) ) endif(PYSIDE_INCLUDE_DIR) +if(BUILD_VTK) + set(FreeCADGui_LIBS + ${FreeCADGui_LIBS} + ${VTK_LIBRARIES} + ) +endif(BUILD_VTK) + generate_from_xml(DocumentPy) generate_from_xml(PythonWorkbenchPy) generate_from_xml(ViewProviderPy) diff --git a/src/Gui/CMakeLists.txt.orig b/src/Gui/CMakeLists.txt.orig new file mode 100644 index 000000000000..0868ed817c6b --- /dev/null +++ b/src/Gui/CMakeLists.txt.orig @@ -0,0 +1,1167 @@ +#add_subdirectory(Icons) +add_subdirectory(Stylesheets) + +if(WIN32) +add_definitions(-DFCGui -DQIIS_MAKEDLL -DQSINT_MAKEDLL -DOVR_OS_WIN32 -DQUARTER_INTERNAL -DQUARTER_MAKE_DLL -DCOIN_DLL) +endif(WIN32) + +IF(CMAKE_BUILD_TYPE) + add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}") +ENDIF(CMAKE_BUILD_TYPE) + +if (FREECAD_USE_3DCONNEXION) + add_definitions(-D_USE_3DCONNEXION_SDK) + if(APPLE) + set(3DCONNEXION_LINKFLAGS "-F/Library/Frameworks -weak_framework 3DconnexionClient") + set(3DCONNEXION_INCLUDE_DIR ${3DCONNEXIONCLIENT_FRAMEWORK}/Headers + ${3DCONNEXIONCLIENT_FRAMEWORK}/Headers/3DconnexionClient ) + endif(APPLE) +endif(FREECAD_USE_3DCONNEXION) + +if (BUILD_VR) + add_definitions(-DBUILD_VR ) +endif(BUILD_VR) + +include_directories( + ${CMAKE_BINARY_DIR} + ${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 + ${CMAKE_CURRENT_BINARY_DIR}/DAGView + ${Boost_INCLUDE_DIRS} + ${COIN3D_INCLUDE_DIRS} + ${PYTHON_INCLUDE_DIRS} + ${XercesC_INCLUDE_DIRS} + ${QT_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIR} + ${3DCONNEXION_INCLUDE_DIR} +) + +if(MSVC) + set(FreeCADGui_LIBS + FreeCADApp + ${COIN3D_LIBRARIES} + ${QT_LIBRARIES} + ${QT_QTUITOOLS_LIBRARY} + ${OPENGL_gl_LIBRARY} + ) +else(MSVC) + set(FreeCADGui_LIBS + FreeCADApp + ${COIN3D_LIBRARIES} + ${QT_LIBRARIES} + ${Boost_LIBRARIES} + ${OPENGL_gl_LIBRARY} + ${3DCONNEXION_LINKFLAGS} + ) +endif(MSVC) + +IF(SPNAV_FOUND) + add_definitions(-DSPNAV_FOUND) + include_directories( + ${SPNAV_INCLUDE_DIR} + ) + set(FreeCADGui_LIBS + ${FreeCADGui_LIBS} + ${SPNAV_LIBRARIES} + ) + find_package(X11 QUIET) + if (X11_FOUND) + set(FreeCADGui_LIBS + ${FreeCADGui_LIBS} + ${X11_X11_LIB} + ) + endif(X11_FOUND) +ENDIF(SPNAV_FOUND) + +IF(OCULUS_FOUND) + add_definitions(-DOCULUS_FOUND) + include_directories( + ${OCULUS_INCLUDE_DIRS} + ) + set(FreeCADGui_LIBS + ${FreeCADGui_LIBS} + ${OCULUS_LIBRARIES} + ) +ENDIF(OCULUS_FOUND) + +if(SHIBOKEN_INCLUDE_DIR) + add_definitions(-DHAVE_SHIBOKEN) + include_directories( + ${SHIBOKEN_INCLUDE_DIR} + ) + set(FreeCADGui_LIBS + ${FreeCADGui_LIBS} + ${SHIBOKEN_LIBRARY} + ) +endif(SHIBOKEN_INCLUDE_DIR) + +if(PYSIDE_INCLUDE_DIR) + add_definitions(-DHAVE_PYSIDE) + include_directories( + ${PYSIDE_INCLUDE_DIR} + ${PYSIDE_INCLUDE_DIR}/QtCore + ${PYSIDE_INCLUDE_DIR}/QtGui + ) + set(FreeCADGui_LIBS + ${FreeCADGui_LIBS} + ${PYSIDE_LIBRARY} + ) +endif(PYSIDE_INCLUDE_DIR) + +if(BUILD_VTK) + set(FreeCADGui_LIBS + ${FreeCADGui_LIBS} + ${VTK_LIBRARIES} + ) +endif(BUILD_VTK) + +generate_from_xml(DocumentPy) +generate_from_xml(PythonWorkbenchPy) +generate_from_xml(ViewProviderPy) +generate_from_xml(ViewProviderDocumentObjectPy) +generate_from_xml(ViewProviderPythonFeaturePy) +generate_from_xml(WorkbenchPy) +generate_from_xml(SelectionObjectPy) + +generate_from_py(FreeCADGuiInit GuiInitScript.h) + +# The XML files +SET(FreeCADGui_XML_SRCS + ViewProviderDocumentObjectPy.xml + ViewProviderPythonFeaturePy.xml + ViewProviderPy.xml + PythonWorkbenchPy.xml + WorkbenchPy.xml + SelectionObjectPy.xml + DocumentPy.xml +) +SOURCE_GROUP("XML" FILES ${FreeCADApp_XML_SRCS}) + +# The 3D Connexion SDK files +if(FREECAD_USE_3DCONNEXION AND MSVC) +SET(FreeCADGui_SDK_SRCS + 3Dconnexion/I3dMouseParams.h + 3Dconnexion/MouseParameters.cpp + 3Dconnexion/MouseParameters.h + 3Dconnexion/GuiApplicationNativeEventAwareWin32.cpp +) +SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS}) +endif(FREECAD_USE_3DCONNEXION AND MSVC) + +if(FREECAD_USE_3DCONNEXION AND APPLE) +SET(FreeCADGui_SDK_SRCS + 3Dconnexion/GuiApplicationNativeEventAwareMac.cpp +) +SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS}) +endif(FREECAD_USE_3DCONNEXION AND APPLE) + +set(Gui_MOC_HDRS + Action.h + ActionFunction.h + Assistant.h + AutoSaver.h + CallTips.h + CombiView.h + Control.h + Clipping.h + DemoMode.h + DownloadDialog.h + DownloadItem.h + DownloadManager.h + DlgActionsImp.h + DlgActivateWindowImp.h + DlgUnitsCalculatorImp.h + DlgCommandsImp.h + DlgCustomizeImp.h + DlgCustomizeSpaceball.h + DlgCustomizeSpNavSettings.h + DlgDisplayPropertiesImp.h + DlgEditorImp.h + DlgGeneralImp.h + DlgInputDialogImp.h + DlgKeyboardImp.h + DlgMacroExecuteImp.h + DlgMacroRecordImp.h + DlgRunExternal.h + DlgEditFileIncludeProptertyExternal.h + DlgMaterialPropertiesImp.h + DlgOnlineHelpImp.h + DlgParameterImp.h + DlgPreferencesImp.h + DlgProjectInformationImp.h + DlgProjectUtility.h + DlgPropertyLink.h + DlgReportViewImp.h + DlgSettings3DViewImp.h + DlgSettingsViewColor.h + DlgSettingsColorGradientImp.h + DlgSettingsDocumentImp.h + DlgSettingsImageImp.h + DlgSettingsMacroImp.h + DlgSettingsUnitsImp.h + DlgTipOfTheDayImp.h + DlgCheckableMessageBox.h + DlgToolbarsImp.h + DlgWorkbenchesImp.h + TaskDlgRelocation.h + TaskCSysDragger.h + DlgUndoRedo.h + DockWindow.h + DockWindowManager.h + DocumentRecovery.h + EditorView.h + ExpressionCompleter.h + DlgExpressionInput.h + FileDialog.h + Flag.h + GraphicsViewZoom.h + GraphvizView.h + GuiApplication.h + GuiApplicationNativeEventAware.h + HelpView.h + InputVector.h + MainWindow.h + ManualAlignment.h + MDIView.h + NetworkRetriever.h + OnlineDocumentation.h + Placement.h + InputField.h + PrefWidgets.h + ProgressBar.h + PropertyPage.h + PropertyView.h + PythonConsole.h + PythonDebugger.h + PythonEditor.h + QuantitySpinBox.h + QListWidgetCustom.h + QuantitySpinBox_p.h + ReportView.h + SceneInspector.h + SelectionView.h + SpinBox.h + Splashscreen.h + TextEdit.h + TextureMapping.h + ToolBox.h + Transform.h + Tree.h + TreeView.h + ProjectView.h + View3DInventor.h + WidgetFactory.h + Widgets.h + Language/Translator.h + propertyeditor/PropertyEditor.h + propertyeditor/PropertyItem.h + propertyeditor/PropertyItemDelegate.h + propertyeditor/PropertyModel.h + TaskView/TaskAppearance.h + TaskView/TaskSelectLinkProperty.h + TaskView/TaskDialog.h + TaskView/TaskWatcher.h + TaskView/TaskEditControl.h + TaskView/TaskView.h + DAGView/DAGView.h + DAGView/DAGModel.h +) +#qt4_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS}) +fc_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS}) +#SOURCE_GROUP("Moc" FILES ${Gui_MOC_SRCS}) + +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp + COMMAND ${QT_MOC_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp ${CMAKE_CURRENT_SOURCE_DIR}/GraphvizView.cpp + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GraphvizView.cpp) + +set_property(SOURCE GraphvizView.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp) + +SET(Gui_UIC_SRCS + AboutApplication.ui + Clipping.ui + DemoMode.ui + DlgActions.ui + DlgActivateWindow.ui + DlgUnitsCalculator.ui + DlgAuthorization.ui + DlgChooseIcon.ui + DlgCommands.ui + DlgCustomizeSpNavSettings.ui + DlgDisplayProperties.ui + DlgEditor.ui + DlgGeneral.ui + DlgInputDialog.ui + DlgKeyboard.ui + DlgMacroExecute.ui + DlgRunExternal.ui + DlgMacroRecord.ui + DlgMaterialProperties.ui + DlgOnlineHelp.ui + DlgParameter.ui + DlgPreferences.ui + DlgProjectInformation.ui + DlgProjectUtility.ui + DlgPropertyLink.ui + DlgReportView.ui + DlgSettings3DView.ui + DlgSettingsUnits.ui + DlgSettingsViewColor.ui + DlgSettingsColorGradient.ui + DlgSettingsDocument.ui + DlgSettingsImage.ui + DlgSettingsMacro.ui + DlgCheckableMessageBox.ui + DlgTipOfTheDay.ui + DlgToolbars.ui + DlgWorkbenches.ui + DlgTreeWidget.ui + DlgLocationAngle.ui + DlgLocationPos.ui + DocumentRecovery.ui + DownloadManager.ui + DownloadItem.ui + DlgExpressionInput.ui + MouseButtons.ui + SceneInspector.ui + InputVector.ui + Placement.ui + TextureMapping.ui + TaskView/TaskAppearance.ui + TaskView/TaskSelectLinkProperty.ui +) + +SET(Gui_RES_SRCS + Icons/resource.qrc + Language/translation.qrc + iisTaskPanel/src/iisTaskPanel.qrc + QSint/actionpanel/schemes.qrc +) +QT4_ADD_RESOURCES(Gui_QRC_SRCS ${Gui_RES_SRCS}) + +QT4_WRAP_UI(Gui_UIC_HDRS ${Gui_UIC_SRCS}) +SOURCE_GROUP("Uic" FILES ${Gui_UIC_HDRS}) + +# The command sources +SET(Command_CPP_SRCS + Action.cpp + ActionFunction.cpp + Command.cpp + CommandDoc.cpp + CommandFeat.cpp + CommandMacro.cpp + CommandStd.cpp + CommandWindow.cpp + CommandTest.cpp + CommandView.cpp +) +SET(Command_SRCS + ${Command_CPP_SRCS} + Action.h + ActionFunction.h + Command.h +) +SOURCE_GROUP("Command" FILES ${Command_SRCS}) + +# The dialog sources +SET(Dialog_CPP_SRCS + Clipping.cpp + DemoMode.cpp + DlgActivateWindowImp.cpp + DlgUnitsCalculatorImp.cpp + DlgDisplayPropertiesImp.cpp + DlgInputDialogImp.cpp + DlgMacroExecuteImp.cpp + DlgRunExternal.cpp + DlgEditFileIncludeProptertyExternal.cpp + DlgMacroRecordImp.cpp + DlgMaterialPropertiesImp.cpp + DlgParameterImp.cpp + DlgProjectInformationImp.cpp + DlgProjectUtility.cpp + DlgPropertyLink.cpp + DlgTipOfTheDayImp.cpp + DlgExpressionInput.cpp + TaskDlgRelocation.cpp + DlgCheckableMessageBox.cpp + TaskCSysDragger.cpp + DlgUndoRedo.cpp + InputVector.cpp + Placement.cpp + PropertyPage.cpp + SceneInspector.cpp + TextureMapping.cpp + Transform.cpp + DownloadDialog.cpp + DownloadItem.cpp + DownloadManager.cpp + DocumentRecovery.cpp +) + +SET(Dialog_HPP_SRCS + Clipping.h + DemoMode.h + DlgActivateWindowImp.h + DlgUnitsCalculatorImp.h + DlgDisplayPropertiesImp.h + DlgInputDialogImp.h + DlgMacroExecuteImp.h + DlgRunExternal.h + DlgEditFileIncludeProptertyExternal.h + DlgMacroRecordImp.h + DlgMaterialPropertiesImp.h + DlgParameterImp.h + DlgProjectInformationImp.h + DlgProjectUtility.h + DlgPropertyLink.h + DlgCheckableMessageBox.h + DlgTipOfTheDayImp.h + DlgExpressionInput.h + TaskDlgRelocation.h + TaskCSysDragger.h + DlgUndoRedo.h + InputVector.h + Placement.h + PropertyPage.h + SceneInspector.h + TextureMapping.h + Transform.h + DownloadDialog.h + DownloadItem.h + DownloadManager.h + DocumentRecovery.h +) + +SET(Dialog_SRCS + ${Dialog_CPP_SRCS} + ${Dialog_HPP_SRCS} + AboutApplication.ui + Clipping.ui + DemoMode.ui + DlgActivateWindow.ui + DlgUnitsCalculator.ui + DlgAuthorization.ui + DlgDisplayProperties.ui + DlgInputDialog.ui + DlgLocationAngle.ui + DlgLocationPos.ui + DlgMacroExecute.ui + DlgRunExternal.ui + DlgMacroRecord.ui + DlgMaterialProperties.ui + DlgParameter.ui + DlgProjectInformation.ui + DlgProjectUtility.ui + DlgPropertyLink.ui + DlgTipOfTheDay.ui + DlgCheckableMessageBox.ui + DlgTreeWidget.ui + DlgExpressionInput.ui + DownloadManager.ui + DownloadItem.ui + DocumentRecovery.ui + MouseButtons.ui + InputVector.ui + Placement.ui + SceneInspector.ui + TextureMapping.ui +) +SOURCE_GROUP("Dialog" FILES ${Dialog_SRCS}) + +# The customize dialog sources +SET(Dialog_Customize_CPP_SRCS + DlgActionsImp.cpp + DlgCommandsImp.cpp + DlgCustomizeImp.cpp + DlgCustomizeSpaceball.cpp + DlgCustomizeSpNavSettings.cpp + DlgKeyboardImp.cpp + DlgToolbarsImp.cpp + DlgWorkbenchesImp.cpp + QListWidgetCustom.cpp +) +SET(Dialog_Customize_HPP_SRCS + DlgActionsImp.h + DlgCommandsImp.h + DlgCustomizeImp.h + DlgCustomizeSpaceball.h + DlgCustomizeSpNavSettings.h + DlgKeyboardImp.h + DlgToolbarsImp.h + DlgWorkbenchesImp.h + QListWidgetCustom.h +) +SET(Dialog_Customize_SRCS + ${Dialog_Customize_CPP_SRCS} + ${Dialog_Customize_HPP_SRCS} + DlgActions.ui + DlgChooseIcon.ui + DlgCommands.ui + DlgCustomizeSpNavSettings.ui + DlgKeyboard.ui + DlgToolbars.ui + DlgWorkbenches.ui +) +SOURCE_GROUP("Dialog\\Customize" FILES ${Dialog_Customize_SRCS}) + +# The settings dialog sources +SET(Dialog_Settings_CPP_SRCS + DlgEditorImp.cpp + DlgGeneralImp.cpp + DlgOnlineHelpImp.cpp + DlgPreferencesImp.cpp + DlgReportViewImp.cpp + DlgSettings3DViewImp.cpp + DlgSettingsUnitsImp.cpp + DlgSettingsViewColor.cpp + DlgSettingsColorGradientImp.cpp + DlgSettingsDocumentImp.cpp + DlgSettingsImageImp.cpp + DlgSettingsMacroImp.cpp +) +SET(Dialog_Settings_HPP_SRCS + DlgEditorImp.h + DlgGeneralImp.h + DlgOnlineHelpImp.h + DlgPreferencesImp.h + DlgReportViewImp.h + DlgSettings3DViewImp.h + DlgSettingsUnitsImp.h + DlgSettingsViewColor.h + DlgSettingsColorGradientImp.h + DlgSettingsDocumentImp.h + DlgSettingsImageImp.h + DlgSettingsMacroImp.h +) +SET(Dialog_Settings_SRCS + ${Dialog_Settings_CPP_SRCS} + ${Dialog_Settings_HPP_SRCS} + DlgEditor.ui + DlgGeneral.ui + DlgOnlineHelp.ui + DlgPreferences.ui + DlgReportView.ui + DlgSettings3DView.ui + DlgSettingsUnits.ui + DlgSettingsViewColor.ui + DlgSettingsColorGradient.ui + DlgSettingsDocument.ui + DlgSettingsImage.ui + DlgSettingsMacro.ui +) +SOURCE_GROUP("Dialog\\Settings" FILES ${Dialog_Settings_SRCS}) + +# The dock windows sources +SET(Dock_Windows_CPP_SRCS + CombiView.cpp + DockWindow.cpp + HelpView.cpp + PropertyView.cpp + ReportView.cpp + SelectionView.cpp + ToolBox.cpp + Tree.cpp + TreeView.cpp + ProjectView.cpp + DAGView/DAGView.cpp + DAGView/DAGModel.cpp + DAGView/DAGRectItem.cpp + DAGView/DAGModelGraph.cpp + DAGView/DAGFilter.cpp +) +SET(Dock_Windows_HPP_SRCS + CombiView.h + DockWindow.h + HelpView.h + PropertyView.h + ReportView.h + SelectionView.h + ToolBox.h + Tree.h + TreeView.h + ProjectView.h + DAGView/DAGView.h + DAGView/DAGModel.h + DAGView/DAGRectItem.h + DAGView/DAGModelGraph.h + DAGView/DAGFilter.h +) +SET(Dock_Windows_SRCS + ${Dock_Windows_CPP_SRCS} + ${Dock_Windows_HPP_SRCS} +) +SOURCE_GROUP("Dock Windows" FILES ${Dock_Windows_SRCS}) + +# The editor sources +SET(Editor_CPP_SRCS + CallTips.cpp + EditorView.cpp + PythonConsole.cpp + PythonConsolePy.cpp + PythonDebugger.cpp + PythonEditor.cpp + SyntaxHighlighter.cpp + TextEdit.cpp +) +SET(Editor_HPP_SRCS + CallTips.h + EditorView.h + PythonConsole.h + PythonConsolePy.h + PythonDebugger.h + PythonEditor.h + SyntaxHighlighter.h + TextEdit.h +) +SET(Editor_SRCS + ${Editor_CPP_SRCS} + ${Editor_HPP_SRCS} +) +SOURCE_GROUP("Editor" FILES ${Editor_SRCS}) + +# The help system +SET(Help_CPP_SRCS + Assistant.cpp + NetworkRetriever.cpp + OnlineDocumentation.cpp + WhatsThis.cpp +) +SET(Help_SRCS + ${Help_CPP_SRCS} + Assistant.h + NetworkRetriever.h + OnlineDocumentation.h + WhatsThis.h +) +SOURCE_GROUP("Help" FILES ${Help_SRCS}) + + +# The i18n sources +SET(Language_SRCS + Language/Translator.cpp + Language/Translator.h +) +SOURCE_GROUP("Language" FILES ${Language_SRCS}) + +# The property editor +SET(Propertyeditor_SRCS + propertyeditor/PropertyEditor.cpp + propertyeditor/PropertyEditor.h + propertyeditor/PropertyItem.cpp + propertyeditor/PropertyItem.h + propertyeditor/PropertyItemDelegate.cpp + propertyeditor/PropertyItemDelegate.h + propertyeditor/PropertyModel.cpp + propertyeditor/PropertyModel.h +) +SOURCE_GROUP("Propertyeditor" FILES ${Propertyeditor_SRCS}) + +# The task view +SET(Task_View_SRCS + TaskView/TaskAppearance.cpp + TaskView/TaskAppearance.h + TaskView/TaskAppearance.ui + TaskView/TaskSelectLinkProperty.cpp + TaskView/TaskSelectLinkProperty.h + TaskView/TaskSelectLinkProperty.ui + TaskView/TaskEditControl.cpp + TaskView/TaskEditControl.h + TaskView/TaskEditControl.ui + TaskView/TaskView.cpp + TaskView/TaskView.h + TaskView/TaskDialog.cpp + TaskView/TaskDialog.h + TaskView/TaskDialogPython.cpp + TaskView/TaskDialogPython.h + TaskView/TaskWatcher.cpp + TaskView/TaskWatcher.h +) +SOURCE_GROUP("Task View" FILES ${Task_View_SRCS}) + +SET(iisTaskPanel_SRCS + iisTaskPanel/src/iisfreecadscheme.cpp + iisTaskPanel/src/iisfreecadscheme.h + iisTaskPanel/src/iisiconlabel.cpp + iisTaskPanel/src/iisiconlabel.h + iisTaskPanel/src/iistaskbox.cpp + iisTaskPanel/src/iistaskbox.h + iisTaskPanel/src/iistaskgroup.cpp + iisTaskPanel/src/iistaskgroup.h + iisTaskPanel/src/iistaskheader.cpp + iisTaskPanel/src/iistaskheader.h + iisTaskPanel/src/iistaskpanel.cpp + iisTaskPanel/src/iistaskpanel.h + iisTaskPanel/src/iistaskpanelscheme.cpp + iisTaskPanel/src/iistaskpanelscheme.h + iisTaskPanel/src/iiswinxptaskpanelscheme.cpp + iisTaskPanel/src/iiswinxptaskpanelscheme.h + iisTaskPanel/src/iistaskpanel_global.h +) +SOURCE_GROUP("Widget\\iisTaskPanel" FILES ${iisTaskPanel_SRCS}) +set(iis_MOC_HDRS + iisTaskPanel/src/iisiconlabel.h + iisTaskPanel/src/iistaskbox.h + iisTaskPanel/src/iistaskgroup.h + iisTaskPanel/src/iistaskheader.h +) +qt4_wrap_cpp(iis_MOC_SRCS ${iis_MOC_HDRS}) +SOURCE_GROUP("Widget\\iisTaskPanel\\Mocs" FILES ${iis_MOC_SRCS}) + +SET(qsintActionPanel_SRCS + QSint/actionpanel/actionbox.cpp + QSint/actionpanel/actionbox.h + QSint/actionpanel/actionlabel.cpp + QSint/actionpanel/actionlabel.h + QSint/actionpanel/actiongroup.cpp + QSint/actionpanel/actiongroup.h + QSint/actionpanel/actionpanel.cpp + QSint/actionpanel/actionpanel.h + QSint/actionpanel/actionpanelscheme.cpp + QSint/actionpanel/actionpanelscheme.h + QSint/actionpanel/androidpanelscheme.cpp + QSint/actionpanel/androidpanelscheme.h + QSint/actionpanel/macpanelscheme.cpp + QSint/actionpanel/macpanelscheme.h + QSint/actionpanel/taskgroup_p.cpp + QSint/actionpanel/taskgroup_p.h + QSint/actionpanel/taskheader_p.cpp + QSint/actionpanel/taskheader_p.h + QSint/actionpanel/winvistapanelscheme.cpp + QSint/actionpanel/winvistapanelscheme.h + QSint/actionpanel/winxppanelscheme.cpp + QSint/actionpanel/winxppanelscheme.h + QSint/actionpanel/freecadscheme.cpp + QSint/actionpanel/freecadscheme.h +) +SOURCE_GROUP("Widget\\QSintActionPanel" FILES ${qsintActionPanel_SRCS}) +set(qsint_MOC_HDRS + QSint/actionpanel/actionbox.h + QSint/actionpanel/actionlabel.h + QSint/actionpanel/actiongroup.h + QSint/actionpanel/actionpanel.h + QSint/actionpanel/taskheader_p.h +) +qt4_wrap_cpp(qsint_MOC_SRCS ${qsint_MOC_HDRS}) +SOURCE_GROUP("Widget\\QSintActionPanel\\Mocs" FILES ${qsint_MOC_SRCS}) + +#SET(Resource_RCS +# Icons/resource.qrc +# Language/translation.qrc) +#qt4_add_resources(Resource_SRCS ${Resource_RCS}) +#SET(Resource_SRCS +# ${Resource_SRCS} +# Icons/resource.qrc +# Language/translation.qrc +#) +#SOURCE_GROUP("Resource" FILES ${Resource_SRCS}) + +# The 3d view +SET(View3D_CPP_SRCS + Flag.cpp + GLPainter.cpp + MouseSelection.cpp + NavigationStyle.cpp + InventorNavigationStyle.cpp + CADNavigationStyle.cpp + BlenderNavigationStyle.cpp + MayaGestureNavigationStyle.cpp + OpenCascadeNavigationStyle.cpp + TouchpadNavigationStyle.cpp + GestureNavigationStyle.cpp + SplitView3DInventor.cpp + View.cpp + View3DInventor.cpp + View3DInventorExamples.cpp + View3DInventorViewer.cpp + View3DInventorRiftViewer.cpp + CoinRiftWidget.cpp + View3DPy.cpp + View3DViewerPy.cpp +) +SET(View3D_SRCS + ${View3D_CPP_SRCS} + Flag.h + GLPainter.h + MouseSelection.h + NavigationStyle.h + SplitView3DInventor.h + View.h + View3DInventor.h + View3DInventorExamples.h + View3DInventorViewer.h + View3DPy.h + View3DInventorRiftViewer.h + CoinRiftWidget.h + View3DViewerPy.h +) +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) + +SET(Quarter_MOC_HDR + Quarter/SignalThread.h + Quarter/InteractionMode.h + Quarter/SensorManager.h + Quarter/ContextMenu.h + Quarter/eventhandlers/FocusHandler.h + Quarter/eventhandlers/DragDropHandler.h + Quarter/eventhandlers/EventFilter.h + Quarter/QuarterWidget.h +) +qt4_wrap_cpp(Quarter_MOC_SRCS ${Quarter_MOC_HDR}) + +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 + ViewProviderAnnotation.cpp + ViewProviderDocumentObject.cpp + ViewProviderDocumentObjectGroup.cpp + ViewProviderDocumentObjectPyImp.cpp + ViewProviderPythonFeaturePyImp.cpp + ViewProviderExtern.cpp + ViewProviderFeature.cpp + ViewProviderGeometryObject.cpp + ViewProviderInventorObject.cpp + ViewProviderMeasureDistance.cpp + ViewProviderPyImp.cpp + ViewProviderPythonFeature.cpp + ViewProviderVRMLObject.cpp + ViewProviderBuilder.cpp + ViewProviderPlacement.cpp + ViewProviderOriginFeature.cpp + ViewProviderPlane.cpp + ViewProviderLine.cpp + ViewProviderGeoFeatureGroup.cpp + ViewProviderOriginGroup.cpp + ViewProviderPart.cpp + ViewProviderOrigin.cpp + ViewProviderMaterialObject.cpp +) +SET(Viewprovider_SRCS + ${Viewprovider_CPP_SRCS} + ViewProvider.h + ViewProviderAnnotation.h + ViewProviderDocumentObject.h + ViewProviderDocumentObjectGroup.h + ViewProviderExtern.h + ViewProviderFeature.h + ViewProviderGeometryObject.h + ViewProviderInventorObject.h + ViewProviderMeasureDistance.h + ViewProviderPythonFeature.h + ViewProviderVRMLObject.h + ViewProviderBuilder.h + ViewProviderPlacement.h + ViewProviderOriginFeature.h + ViewProviderPlane.h + ViewProviderLine.h + ViewProviderGeoFeatureGroup.h + ViewProviderOriginGroup.h + ViewProviderPart.h + ViewProviderOrigin.h + ViewProviderMaterialObject.h +) +SOURCE_GROUP("View3D\\Viewprovider" FILES ${Viewprovider_SRCS}) + +# The Inventor sources +SET(Inventor_CPP_SRCS + Inventor/SoDrawingGrid.cpp + Inventor/SoAutoZoomTranslation.cpp + Inventor/MarkerBitmaps.cpp + SoFCBackgroundGradient.cpp + SoFCBoundingBox.cpp + SoFCColorBar.cpp + SoFCColorGradient.cpp + SoFCColorLegend.cpp + SoFCDB.cpp + SoFCInteractiveElement.cpp + SoFCOffscreenRenderer.cpp + SoFCSelection.cpp + SoFCUnifiedSelection.cpp + SoFCSelectionAction.cpp + SoFCVectorizeSVGAction.cpp + SoFCVectorizeU3DAction.cpp + SoNavigationDragger.cpp + SoAxisCrossKit.cpp + SoTextLabel.cpp + SoTouchEvents.cpp +<<<<<<< d7d347b2d62ec685840e7db1c35863e659148981 + SoFCCSysDragger.cpp +======= + SoVTKActor.cpp +>>>>>>> proof of concept +) +SET(Inventor_SRCS + ${Inventor_CPP_SRCS} + Inventor/SoDrawingGrid.h + Inventor/SoAutoZoomTranslation.h + Inventor/MarkerBitmaps.h + SoFCBackgroundGradient.h + SoFCBoundingBox.h + SoFCColorBar.h + SoFCColorGradient.h + SoFCColorLegend.h + SoFCDB.h + SoFCInteractiveElement.h + SoFCOffscreenRenderer.h + SoFCSelection.h + SoFCUnifiedSelection.h + SoFCSelectionAction.h + SoFCVectorizeSVGAction.h + SoFCVectorizeU3DAction.h + SoNavigationDragger.h + SoAxisCrossKit.h + SoTextLabel.h + SoTouchEvents.h +<<<<<<< d7d347b2d62ec685840e7db1c35863e659148981 + SoFCCSysDragger.h +======= + SoVTKActor.h +>>>>>>> proof of concept +) +SOURCE_GROUP("View3D\\Inventor" FILES ${Inventor_SRCS}) + +# The widget sources +SET(Widget_CPP_SRCS + FileDialog.cpp + MainWindow.cpp + PrefWidgets.cpp + InputField.cpp + ProgressBar.cpp + QuantitySpinBox.cpp + SpinBox.cpp + Splashscreen.cpp + WidgetFactory.cpp + Widgets.cpp + Window.cpp +) +SET(Widget_HPP_SRCS + FileDialog.h + MainWindow.h + PrefWidgets.h + InputField.h + ProgressBar.h + QuantitySpinBox.h + QuantitySpinBox_p.h + SpinBox.h + Splashscreen.h + WidgetFactory.h + Widgets.h + Window.h +) +SET(Widget_SRCS + ${Widget_CPP_SRCS} + ${Widget_HPP_SRCS} +) +SOURCE_GROUP("Widget" FILES ${Widget_SRCS}) + +# The view sources +SET(View_CPP_SRCS + MDIView.cpp + GraphvizView.cpp + ActiveObjectList.cpp +) +SET(View_HPP_SRCS + MDIView.h + GraphvizView.h + ActiveObjectList.h +) +SET(View_SRCS + ${View_CPP_SRCS} + ${View_HPP_SRCS} +) +SOURCE_GROUP("View" FILES ${View_SRCS}) + +# The workbench sources +SET(Workbench_CPP_SRCS + DockWindowManager.cpp + MenuManager.cpp + PythonWorkbenchPyImp.cpp + ToolBarManager.cpp + ToolBoxManager.cpp + Workbench.cpp + WorkbenchFactory.cpp + WorkbenchManager.cpp + WorkbenchPyImp.cpp +) +SET(Workbench_SRCS + ${Workbench_CPP_SRCS} + DockWindowManager.h + MenuManager.h + ToolBarManager.h + ToolBoxManager.h + Workbench.h + WorkbenchFactory.h + WorkbenchManager.h +) +SOURCE_GROUP("Workbench" FILES ${Workbench_SRCS}) + +SET(Selection_SRCS + SelectionObjectPyImp.cpp + SelectionObject.h + SelectionObject.cpp + Selection.h + Selection.cpp + SelectionFilter.h + SelectionFilter.cpp + SelectionFilter.y + SelectionFilter.l +) +SOURCE_GROUP("Selection" FILES ${Selection_SRCS}) + +# The FreeCADGui sources +SET(FreeCADGui_CPP_SRCS + Application.cpp + ApplicationPy.cpp + AutoSaver.cpp + BitmapFactory.cpp + Document.cpp + DocumentModel.cpp + DocumentPyImp.cpp + ExpressionBinding.cpp + GraphicsViewZoom.cpp + ExpressionCompleter.cpp + GuiApplication.cpp + GuiApplicationNativeEventAware.cpp + GuiConsole.cpp + Macro.cpp + MergeDocuments.cpp + resource.cpp + Control.cpp + SpaceballEvent.cpp + Thumbnail.cpp + Utilities.cpp + WaitCursor.cpp + ManualAlignment.cpp + WinNativeGestureRecognizers.cpp +) +SET(FreeCADGui_SRCS + Application.h + AutoSaver.h + BitmapFactory.h + Document.h + DocumentModel.h + ExpressionBinding.cpp + ExpressionCompleter.h + FreeCADGuiInit.py + GraphicsViewZoom.h + GuiApplication.h + GuiApplicationNativeEventAware.h + GuiConsole.h + InventorAll.h + Macro.h + MergeDocuments.h + PreCompiled.cpp + PreCompiled.h + Qt4All.h + Control.h + SpaceballEvent.h + Thumbnail.h + Utilities.h + WaitCursor.h + ManualAlignment.h + WinNativeGestureRecognizers.h +) + +SET(FreeCADGui_SRCS + ${FreeCADGui_SDK_SRCS} + ${FreeCADGui_CPP_SRCS} + ${FreeCADGui_XML_SRCS} + ${iis_MOC_SRCS} + ${qsint_MOC_SRCS} + ${Gui_QRC_SRCS} + ${Gui_UIC_HDRS} + ${Command_SRCS} + ${Dialog_SRCS} + ${Dialog_Customize_SRCS} + ${Dialog_Settings_SRCS} + ${Dock_Windows_SRCS} + ${Editor_SRCS} + ${Help_SRCS} + ${Inventor_SRCS} + ${Language_SRCS} + ${Propertyeditor_SRCS} + ${Task_View_SRCS} + ${iisTaskPanel_SRCS} + ${qsintActionPanel_SRCS} + ${Resource_SRCS} + ${Quarter_SRCS} + ${View3D_SRCS} + ${Viewprovider_SRCS} + ${Widget_SRCS} + ${View_SRCS} + ${Workbench_SRCS} + ${Selection_SRCS} + ${FreeCADGui_SRCS} +) + +if(MSVC) + add_definitions(-D_PreComp_) + SET(FreeCADGui_CPP_SRCS + Language/Translator.cpp + propertyeditor/PropertyEditor.cpp + propertyeditor/PropertyItem.cpp + propertyeditor/PropertyItemDelegate.cpp + propertyeditor/PropertyModel.cpp + TaskView/TaskAppearance.cpp + TaskView/TaskSelectLinkProperty.cpp + TaskView/TaskEditControl.cpp + TaskView/TaskView.cpp + ${Command_CPP_SRCS} + ${Dialog_CPP_SRCS} + ${Dialog_Customize_CPP_SRCS} + ${Dialog_Settings_CPP_SRCS} + ${Dock_Windows_CPP_SRCS} + ${Editor_CPP_SRCS} + ${Help_CPP_SRCS} + ${Inventor_CPP_SRCS} + ${View3D_CPP_SRCS} + ${Viewprovider_CPP_SRCS} + ${Widget_CPP_SRCS} + ${Workbench_CPP_SRCS} + ${FreeCADGui_CPP_SRCS} + ) + ADD_MSVC_PRECOMPILED_HEADER(FreeCADGui PreCompiled.h PreCompiled.cpp FreeCADGui_CPP_SRCS) +endif(MSVC) + +add_library(FreeCADGui SHARED ${FreeCADGui_SRCS}) + +target_link_libraries(FreeCADGui ${FreeCADGui_LIBS}) + +SET_BIN_DIR(FreeCADGui FreeCADGui) + +if(WIN32) + INSTALL(TARGETS FreeCADGui + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) +else(WIN32) + INSTALL(TARGETS FreeCADGui + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + INSTALL(FILES Icons/freecad.xpm + Icons/freecad-icon-16.png + Icons/freecad-icon-32.png + Icons/freecad-icon-48.png + Icons/freecad-icon-64.png + Icons/freecad.svg + Icons/freecad-doc.png + DESTINATION ${CMAKE_INSTALL_DATADIR} + ) +endif(WIN32) + diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 3df835c0b79d..f43ba85ccc61 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -35,6 +35,7 @@ #include #include "SoFCDB.h" +#include "SoVTKActor.h" #include "SoFCColorBar.h" #include "SoFCColorLegend.h" #include "SoFCColorGradient.h" diff --git a/src/Gui/SoFCDB.cpp.orig b/src/Gui/SoFCDB.cpp.orig new file mode 100644 index 000000000000..bca1c6737eaa --- /dev/null +++ b/src/Gui/SoFCDB.cpp.orig @@ -0,0 +1,312 @@ +/*************************************************************************** + * Copyright (c) 2005 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" +#ifndef _PreComp_ +# include +# include +# include +# include +# include +#endif + +#include +#include +#include + +#include "SoFCDB.h" +#include "SoVTKActor.h" +#include "SoFCColorBar.h" +#include "SoFCColorLegend.h" +#include "SoFCColorGradient.h" +#include "SoFCSelection.h" +#include "SoFCBackgroundGradient.h" +#include "SoFCBoundingBox.h" +#include "SoFCSelection.h" +#include "SoFCUnifiedSelection.h" +#include "SoFCSelectionAction.h" +#include "SoFCInteractiveElement.h" +#include "SoFCUnifiedSelection.h" +#include "SoFCVectorizeSVGAction.h" +#include "SoFCVectorizeU3DAction.h" +#include "SoAxisCrossKit.h" +#include "SoTextLabel.h" +#include "SoNavigationDragger.h" +#include "Inventor/SoDrawingGrid.h" +#include "Inventor/SoAutoZoomTranslation.h" +#include "Inventor/MarkerBitmaps.h" +#include "SoFCCSysDragger.h" + +#include "propertyeditor/PropertyItem.h" +#include "NavigationStyle.h" +#include "Flag.h" +#include "SelectionObject.h" + +using namespace Gui; +using namespace Gui::Inventor; +using namespace Gui::PropertyEditor; + +static SbBool init_done = false; +static SoGroup *storage = nullptr; + +SbBool Gui::SoFCDB::isInitialized(void) +{ + return init_done; +} + +void Gui::SoFCDB::init() +{ + SoInteraction ::init(); + RotTransDragger ::initClass(); + SoGLRenderActionElement ::initClass(); + SoFCInteractiveElement ::initClass(); + SoGLWidgetElement ::initClass(); + SoFCColorBarBase ::initClass(); + SoFCColorBar ::initClass(); + SoFCColorLegend ::initClass(); + SoFCColorGradient ::initClass(); + SoFCBackgroundGradient ::initClass(); + SoFCBoundingBox ::initClass(); + SoFCSelection ::initClass(); + SoFCUnifiedSelection ::initClass(); + SoFCSelectionAction ::initClass(); + SoFCDocumentAction ::initClass(); + SoGLWidgetNode ::initClass(); + SoFCEnableSelectionAction ::initClass(); + SoFCEnableHighlightAction ::initClass(); + SoFCSelectionColorAction ::initClass(); + SoFCHighlightColorAction ::initClass(); + SoFCDocumentObjectAction ::initClass(); + SoGLSelectAction ::initClass(); + SoVisibleFaceAction ::initClass(); + SoBoxSelectionRenderAction ::initClass(); + SoFCVectorizeSVGAction ::initClass(); + SoFCVectorizeU3DAction ::initClass(); + SoHighlightElementAction ::initClass(); + SoSelectionElementAction ::initClass(); + SoVRMLAction ::initClass(); + SoSkipBoundingGroup ::initClass(); + SoTextLabel ::initClass(); + SoStringLabel ::initClass(); + SoFrameLabel ::initClass(); + TranslateManip ::initClass(); + SoShapeScale ::initClass(); + SoAxisCrossKit ::initClass(); + SoRegPoint ::initClass(); + SoDrawingGrid ::initClass(); + SoAutoZoomTranslation ::initClass(); + MarkerBitmaps ::initClass(); +<<<<<<< d7d347b2d62ec685840e7db1c35863e659148981 + SoFCCSysDragger ::initClass(); +======= + SoVTKActor ::initClass(); +>>>>>>> proof of concept + + PropertyItem ::init(); + PropertySeparatorItem ::init(); + PropertyStringItem ::init(); + PropertyFontItem ::init(); + PropertyIntegerItem ::init(); + PropertyIntegerConstraintItem ::init(); + PropertyFloatItem ::init(); + PropertyUnitItem ::init(); + PropertyFloatConstraintItem ::init(); + PropertyUnitConstraintItem ::init(); + PropertyAngleItem ::init(); + PropertyBoolItem ::init(); + PropertyVectorItem ::init(); + PropertyVectorDistanceItem ::init(); + PropertyMatrixItem ::init(); + PropertyPlacementItem ::init(); + PropertyEnumItem ::init(); + PropertyStringListItem ::init(); + PropertyFloatListItem ::init(); + PropertyIntegerListItem ::init(); + PropertyColorItem ::init(); + PropertyMaterialItem ::init(); + PropertyMaterialListItem ::init(); + PropertyFileItem ::init(); + PropertyPathItem ::init(); + PropertyTransientFileItem ::init(); + PropertyLinkItem ::init(); + + NavigationStyle ::init(); + UserNavigationStyle ::init(); + InventorNavigationStyle ::init(); + CADNavigationStyle ::init(); + BlenderNavigationStyle ::init(); + MayaGestureNavigationStyle ::init(); + TouchpadNavigationStyle ::init(); + GestureNavigationStyle ::init(); + OpenCascadeNavigationStyle ::init(); + + GLGraphicsItem ::init(); + GLFlagWindow ::init(); + + SelectionObject ::init(); + + qRegisterMetaType("Base::Vector3f"); + qRegisterMetaType("Base::Vector3d"); + qRegisterMetaType("Base::Quantity"); + qRegisterMetaType >("Base::QuantityList"); + init_done = true; + + assert(!storage); + storage = new SoGroup(); + storage->ref(); +} + +void Gui::SoFCDB::finish() +{ + // Coin doesn't provide a mechanism to free static members of own data types. + // Hence, we need to define a static method e.g. 'finish()' for all new types + // to invoke the private member function 'atexit_cleanup()'. + SoFCColorBarBase ::finish(); + SoFCColorBar ::finish(); + SoFCColorLegend ::finish(); + SoFCColorGradient ::finish(); + SoFCBackgroundGradient ::finish(); + SoFCBoundingBox ::finish(); + SoFCSelection ::finish(); + SoFCSelectionAction ::finish(); + SoFCDocumentAction ::finish(); + SoFCDocumentObjectAction ::finish(); + SoFCEnableSelectionAction ::finish(); + SoFCEnableHighlightAction ::finish(); + SoFCSelectionColorAction ::finish(); + SoFCHighlightColorAction ::finish(); + + storage->unref(); + storage = nullptr; +} + +// buffer acrobatics for inventor **************************************************** +static char * buffer; +static size_t buffer_size = 0; +static std::string cReturnString; + +static void * +buffer_realloc(void * bufptr, size_t size) +{ + buffer = (char *)realloc(bufptr, size); + buffer_size = size; + return buffer; +} + +const std::string& Gui::SoFCDB::writeNodesToString(SoNode * root) +{ + SoOutput out; + buffer = (char *)malloc(1024); + buffer_size = 1024; + out.setBuffer(buffer, buffer_size, buffer_realloc); + if (root && root->getTypeId().isDerivedFrom(SoVRMLParent::getClassTypeId())) + out.setHeaderString("#VRML V2.0 utf8"); + + SoWriteAction wa(&out); + wa.apply(root); + + cReturnString = buffer; + free(buffer); + return cReturnString; +} + +bool Gui::SoFCDB::writeToVRML(SoNode* node, const char* filename, bool binary) +{ + SoVRMLAction vrml2; + vrml2.setOverrideMode(true); + vrml2.apply(node); + SoToVRML2Action tovrml2; + tovrml2.apply(node); + SoVRMLGroup* vrmlRoot = tovrml2.getVRML2SceneGraph(); + vrmlRoot->setInstancePrefix(SbString("o")); + vrmlRoot->ref(); + std::string buffer = SoFCDB::writeNodesToString(vrmlRoot); + vrmlRoot->unref(); // release the memory as soon as possible + + // restore old settings + vrml2.setOverrideMode(false); + vrml2.apply(node); + + Base::FileInfo fi(filename); + if (binary) { + // We want to write compressed VRML but Coin 2.4.3 doesn't do it even though + // SoOutput::getAvailableCompressionMethods() delivers a string list that + // contains 'GZIP'. setCompression() was called directly after opening the file, + // returned true and no error message appeared but anyway it didn't work. + // Strange is that reading GZIPped VRML files works. + // So, we do the compression on our own. + Base::ofstream str(fi, std::ios::out | std::ios::binary); + zipios::GZIPOutputStream gzip(str); + + if (gzip) { + gzip << buffer; + gzip.close(); + return true; + } + } + else { + Base::ofstream str(fi, std::ios::out); + + if (str) { + str << buffer; + str.close(); + return true; + } + } + + return false; +} + +bool Gui::SoFCDB::writeToFile(SoNode* node, const char* filename, bool binary) +{ + bool ret = false; + Base::FileInfo fi(filename); + + // Write VRML V2.0 + if (fi.hasExtension("wrl") || fi.hasExtension("vrml") || fi.hasExtension("wrz")) { + // If 'wrz' is set then force compression + if (fi.hasExtension("wrz")) + binary = true; + + ret = SoFCDB::writeToVRML(node, filename, binary); + } + else if (fi.hasExtension("iv")) { + // Write Inventor in ASCII + std::string buffer = SoFCDB::writeNodesToString(node); + Base::ofstream str(Base::FileInfo(filename), std::ios::out); + + if (str) { + str << buffer; + str.close(); + ret = true; + } + } + + return ret; +} + +SoGroup* Gui::SoFCDB::getStorage() +{ + assert(storage); //call init first. + return storage; +} diff --git a/src/Gui/SoVTKActor.cpp b/src/Gui/SoVTKActor.cpp new file mode 100644 index 000000000000..28d501e17acf --- /dev/null +++ b/src/Gui/SoVTKActor.cpp @@ -0,0 +1,337 @@ +/*************************************************************************** + * Copyright (c) 2015 Stefan Tröger * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" + +#ifdef FC_USE_VTK + +#include "SoVTKActor.h" +#include "InventorAll.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +using namespace Gui; + + +SO_NODE_SOURCE(SoVTKActor); + +void SoVTKActor::initClass() +{ + SO_NODE_INIT_CLASS(SoVTKActor, SoSeparator, "VTKActor"); +} + +SoVTKActor::SoVTKActor() : SoSeparator(), m_mapper(NULL) +{ + SO_NODE_CONSTRUCTOR(SoVTKActor); + + //create the subnodes which do the visualization work + m_shapeHints = new SoShapeHints(); + m_shapeHints->ref(); + m_shapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE; + m_coordinates = new SoCoordinate3(); + m_coordinates->ref(); + m_materialBinding = new SoMaterialBinding(); + m_materialBinding->ref(); + m_material = new SoMaterial(); + m_material->ref(); + m_normalBinding = new SoNormalBinding(); + m_normalBinding->ref(); + m_normals = new SoNormal(); + m_normals->ref(); + m_faces = new SoIndexedFaceSet(); + m_faces->ref(); + m_triangleStrips = new SoIndexedTriangleStripSet(); + m_triangleStrips->ref(); + m_markers = new SoIndexedMarkerSet(); + m_markers->ref(); + m_lines = new SoIndexedLineSet(); + m_lines->ref(); + + addChild(m_shapeHints); + addChild(m_materialBinding); + addChild(m_material); + addChild(m_normalBinding); + addChild(m_normals); + addChild(m_coordinates); + addChild(m_markers); + addChild(m_lines); + addChild(m_faces); + addChild(m_triangleStrips); +} + +SoVTKActor::~SoVTKActor() +{ + +} + +void SoVTKActor::doAction(SoAction* action) +{ + SoNode::doAction(action); +} + + +void SoVTKActor::setMapper(vtkMapper* m) +{ + m_mapper = m; + + + vtkDataSet *ds; + vtkPolyData *pd; + vtkGeometryFilter *gf = NULL; + vtkPointData *pntData; + vtkPoints *points; + vtkDataArray *normals = NULL; + vtkDataArray *tcoords = NULL; + int i; + vtkProperty *prop; + double *tempd; + vtkCellArray *cells; + vtkIdType npts = 0; + vtkIdType *indx = 0; + float tempf2; + vtkPolyDataMapper *pm; + vtkUnsignedCharArray *colors; + double *p; + unsigned char *c; + vtkTransform *trans; + + Base::Console().Message("render SoVTKActor\n"); + + // see if the actor has a mapper. it could be an assembly + if (m_mapper == NULL) + return; + + ds = m_mapper->GetInput(); + + vtkAlgorithmOutput* pdProducer = 0; + // we really want polydata + if ( ds->GetDataObjectType() != VTK_POLY_DATA ) { + gf = vtkGeometryFilter::New(); + gf->SetInputConnection( + m_mapper->GetInputConnection(0, 0)); + gf->Update(); + pd = gf->GetOutput(); + pdProducer = gf->GetOutputPort(); + } + else { + m_mapper->GetInputAlgorithm()->Update(); + pd = static_cast(ds); + pdProducer = m_mapper->GetInputConnection(0, 0); + } + + pm = vtkPolyDataMapper::New(); + pm->SetInputConnection(pdProducer); + pm->SetScalarRange(m_mapper->GetScalarRange()); + pm->SetScalarVisibility(m_mapper->GetScalarVisibility()); + pm->SetLookupTable(m_mapper->GetLookupTable()); + + points = pd->GetPoints(); + pntData = pd->GetPointData(); + normals = pntData->GetNormals(); + tcoords = pntData->GetTCoords(); + colors = pm->MapScalars(1.0); + + // write out point data if any + WritePointData(points, normals, tcoords, colors); + + // write out polys if any + if (pd->GetNumberOfPolys() > 0) { + + Base::Console().Message("render polys: %i\n", pd->GetNumberOfPolys()); + m_faces->coordIndex.startEditing(); + int soidx = 0; + cells = pd->GetPolys(); + for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) { + + for (i = 0; i < npts; i++) { + m_faces->coordIndex.set1Value(soidx, static_cast(indx[i])); + ++soidx; + } + m_faces->coordIndex.set1Value(soidx, -1); + ++soidx; + } + m_faces->coordIndex.finishEditing(); + } + + // write out tstrips if any + if (pd->GetNumberOfStrips() > 0) { + + Base::Console().Message("render strips\n"); + int soidx = 0; + cells = pd->GetStrips(); + m_triangleStrips->coordIndex.startEditing(); + for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) { + + for (i = 0; i < npts; i++) { + m_triangleStrips->coordIndex.set1Value(soidx, static_cast(indx[i])); + ++soidx; + } + m_triangleStrips->coordIndex.set1Value(soidx, -1); + ++soidx; + } + m_triangleStrips->coordIndex.finishEditing(); + } + + // write out lines if any + if (pd->GetNumberOfLines() > 0) { + + Base::Console().Message("render lines: %i\n", pd->GetNumberOfLines()); + int soidx = 0; + cells = pd->GetLines(); + m_lines->coordIndex.startEditing(); + for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) { + for (i = 0; i < npts; i++) { + m_lines->coordIndex.set1Value(soidx, static_cast(indx[i])); + ++soidx; + } + m_lines->coordIndex.set1Value(soidx, -1); + ++soidx; + } + m_lines->coordIndex.finishEditing(); + } + + // write out verts if any + // (more complex because there is no IndexedPointSet) + if (pd->GetNumberOfVerts() > 0){ + + Base::Console().Message("render verts\n"); + int soidx = 0; + cells = pd->GetVerts(); + m_markers->coordIndex.startEditing(); + for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) { + for (i = 0; i < npts; i++) { + m_markers->coordIndex.set1Value(soidx, static_cast(indx[i])); + ++soidx; + } + m_markers->coordIndex.set1Value(soidx, -1); + ++soidx; + } + m_markers->coordIndex.finishEditing(); + } + + if (gf) + gf->Delete(); + + pm->Delete(); +} + +vtkMapper* SoVTKActor::getMapper() +{ + return m_mapper; +} + +/* +void SoVTKActor::GLRender(SoGLRenderAction *action) +{ +}*/ + +void SoVTKActor::WritePointData(vtkPoints *points, vtkDataArray *normals, + vtkDataArray *tcoords, + vtkUnsignedCharArray *colors) +{ + double *p; + int i; + unsigned char *c; + + if(!points) + return; + + Base::Console().Message("render points: %i", points->GetNumberOfPoints()); + if(colors) + Base::Console().Message(", colors: %i", colors->GetNumberOfTuples()); + Base::Console().Message("\n"); + + m_coordinates->point.startEditing(); + for (i = 0; i < points->GetNumberOfPoints(); i++) { + p = points->GetPoint(i); + m_coordinates->point.set1Value(i, p[0], p[1], p[2]); + } + m_coordinates->point.finishEditing(); + + // write out the point nrmal data + if (normals) { + + Base::Console().Message("Write normals: %i\n", normals->GetNumberOfTuples()); + m_normals->vector.startEditing(); + for (i = 0; i < normals->GetNumberOfTuples(); i++) { + p = normals->GetTuple(i); + m_normals->vector.set1Value(i, SbVec3f(p[0], p[1], p[2])); + } + m_normals->vector.finishEditing(); + + m_normalBinding->value = SoNormalBinding::PER_VERTEX_INDEXED; + m_normalBinding->value.touch(); + } +/* + // write out the point data + if (tcoords) + { + fprintf(fp,"%sTextureCoordinateBinding {\n",indent); + VTK_INDENT_MORE; + fprintf(fp,"%svalue PER_VERTEX_INDEXED\n",indent); + VTK_INDENT_LESS; + fprintf(fp,"%s}\n",indent); + fprintf(fp,"%sTextureCoordinate2 {\n", indent); + VTK_INDENT_MORE; + fprintf(fp,"%spoint [\n", indent); + VTK_INDENT_MORE; + for (i = 0; i < tcoords->GetNumberOfTuples(); i++) + { + p = tcoords->GetTuple(i); + fprintf (fp,"%s%g %g,\n", indent, p[0], p[1]); + } + fprintf(fp,"%s]\n", indent); + VTK_INDENT_LESS; + fprintf(fp,"%s}\n", indent); + VTK_INDENT_LESS; + }*/ + + // write out the point data + if (colors) { + m_material->diffuseColor.startEditing(); + m_material->transparency.startEditing(); + for (i = 0; i < colors->GetNumberOfTuples(); i++) { + + c = colors->GetPointer(4*i); + m_material->diffuseColor.set1Value(i,static_cast(c[3]), + static_cast(c[2]), + static_cast(c[1])); + m_material->transparency.set1Value(i, static_cast(c[0])); + } + m_material->diffuseColor.finishEditing(); + m_material->transparency.finishEditing(); + m_materialBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED; + m_materialBinding->touch(); + } +} + +#endif //FC_USE_VTK diff --git a/src/Gui/SoVTKActor.h b/src/Gui/SoVTKActor.h new file mode 100644 index 000000000000..0982f5ca54d1 --- /dev/null +++ b/src/Gui/SoVTKActor.h @@ -0,0 +1,97 @@ +/*************************************************************************** + * Copyright (c) 2015 Stefan Tröger * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#ifndef GUI_SOVTKACTOR_H +#define GUI_SOVTKACTOR_H + +#ifdef FC_USE_VTK + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class vtkPoints; +class vtkDataArray; +class vtkUnsignedCharArray; +class vtkMapper; +class SoGLCoordinateElement; +class SoTextureCoordinateBundle; + +namespace Gui { + +class GuiExport SoVTKActor : public SoSeparator { + + SO_NODE_HEADER(SoVTKActor); + +public: + static void initClass(); + SoVTKActor(); + + //vtkActor functions + static SoVTKActor *New(); + + void setMapper(vtkMapper* m); + vtkMapper* getMapper(); + +protected: + virtual ~SoVTKActor(); + + //SoNode functions + /* + virtual void GLRender(SoGLRenderAction *action); + virtual void GLRenderBelowPath(SoGLRenderAction* action); + virtual void GLRenderInPath(SoGLRenderAction* action); + virtual void GLRenderOffPath(SoGLRenderAction* action);*/ + virtual void doAction(SoAction* action); + + void WritePointData(vtkPoints *points, vtkDataArray *normals, + vtkDataArray *tcoords, + vtkUnsignedCharArray *colors); + + vtkMapper* m_mapper; + SoCoordinate3* m_coordinates; + SoIndexedMarkerSet* m_markers; + SoIndexedLineSet* m_lines; + SoIndexedFaceSet* m_faces; + SoIndexedTriangleStripSet* m_triangleStrips; + SoMaterialBinding* m_materialBinding; + SoShapeHints* m_shapeHints; + SoMaterial* m_material; + SoNormalBinding* m_normalBinding; + SoNormal* m_normals; + +}; + +} // namespace PartGui + +#endif // FC_USE_VTK +#endif // GUI_SOVTKACTOR_H + diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 2634a936b9d5..a87297b006e5 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -129,6 +129,24 @@ #include "WinNativeGestureRecognizers.h" #include "Document.h" +#include "SoVTKActor.h" +#include "vtkDataSetSurfaceFilter.h" +#include "vtkGeometryFilter.h" +#include "vtkLookupTable.h" +#include "vtkPointData.h" +#include "vtkCellData.h" +#include "vtkContourFilter.h" +#include "vtkCubeSource.h" +#include "vtkPlane.h" +#include "vtkCutter.h" +#include "vtkHedgeHog.h" +#include "vtkGlyph3D.h" +#include "vtkArrowSource.h" +#include "vtkPointSource.h" +#include "vtkRungeKutta4.h" +#include "vtkStreamTracer.h" +#include "vtkPointLocator.h" + //#define FC_LOGGING_CB using namespace Gui; @@ -527,6 +545,241 @@ void View3DInventorViewer::init() cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap); mask = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_mask_bitmap); panCursor = QCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y); + + + //test vtk integration + vtkCubeSource* cube = vtkCubeSource::New(); + source = vtkSmartPointer::New(); + source->SetFileName("/home/stefan/Downloads/pressure.vtk"); + vtkGeometryFilter* f1 = vtkGeometryFilter::New(); + f1->SetInputConnection(source->GetOutputPort()); + f1->Update(); + + vtkPolyDataMapper* mapper_ = vtkPolyDataMapper::New(); + mapper_->SetInputConnection(f1->GetOutputPort()); + + mapper_->Update(); + vtkPolyData* data = mapper_->GetInput(); + + //try to color the data + vtkLookupTable* table = vtkLookupTable::New(); + + double range[2]; + data->GetPointData()->GetArray(0)->GetRange(range, 0); + table->SetTableRange(range[0], range[1]); + table->Build(); + + vtkUnsignedCharArray* colors = vtkUnsignedCharArray::New(); + colors->SetNumberOfComponents(3); + colors->SetName("Colors"); + + for(int i=0; iGetNumberOfPoints(); ++i) { + + //get the pressure at the point + double pressure = data->GetPointData()->GetArray(0)->GetComponent(i, 0); + double dcolor[3]; + table->GetColor(pressure, dcolor); + unsigned char color[3]; + for(unsigned int j=0; j<3; ++j) + color[j] = static_cast(255*dcolor[j]); + + colors->InsertNextTupleValue(color); + } + data->GetPointData()->SetScalars(colors); + + + SoVTKActor* actor = new SoVTKActor; + actor->ref(); + actor->setMapper(mapper_); + pcViewProviderRoot->addChild(actor); + + + //contour plot (isosurface) + SoTranslation* trans = new SoTranslation(); + trans->ref(); + trans->translation.setValue(SbVec3f(15,15,5)); + pcViewProviderRoot->addChild(trans); + + SoVTKActor* actor2 = new SoVTKActor; + actor2->ref(); + pcViewProviderRoot->addChild(actor2); + + vtkContourFilter* contour = vtkContourFilter::New(); + contour->SetValue(0, (range[0]+range[1])/2); + contour->SetInputConnection(source->GetOutputPort()); + vtkGeometryFilter* gf = vtkGeometryFilter::New(); + gf->SetInputConnection(contour->GetOutputPort()); + vtkPolyDataMapper* mapper2 = vtkPolyDataMapper::New(); + mapper2->SetInputConnection(gf->GetOutputPort()); + mapper2->Update(); + actor2->setMapper(mapper2); + + //slice + trans = new SoTranslation(); + trans->ref(); + trans->translation.setValue(SbVec3f(15,15,5)); + pcViewProviderRoot->addChild(trans); + + SoVTKActor* actor3 = new SoVTKActor; + actor3->ref(); + pcViewProviderRoot->addChild(actor3); + + vtkPlane* plane = vtkPlane::New(); + plane->SetOrigin(5,-4, 30); + plane->SetNormal(0.28, 0, 0.95); + vtkCutter* cutter = vtkCutter::New(); + cutter->SetInputConnection(source->GetOutputPort()); + cutter->SetCutFunction(plane); + cutter->Update(); + vtkPolyDataMapper* mapper3 = vtkPolyDataMapper::New(); + mapper3->SetInputConnection(cutter->GetOutputPort()); + mapper3->Update(); + + data = mapper3->GetInput(); + table = vtkLookupTable::New(); + data->GetPointData()->GetArray(0)->GetRange(range, 0); + table->SetTableRange(range[0], range[1]); + table->Build(); + colors = vtkUnsignedCharArray::New(); + colors->SetNumberOfComponents(3); + colors->SetName("Colors"); + for(int i=0; iGetNumberOfPoints(); ++i) { + //get the pressure at the point + double pressure = data->GetPointData()->GetArray(0)->GetComponent(i, 0); + double dcolor[3]; + table->GetColor(pressure, dcolor); + unsigned char color[3]; + for(unsigned int j=0; j<3; ++j) + color[j] = static_cast(255*dcolor[j]); + + colors->InsertNextTupleValue(color); + } + data->GetPointData()->SetScalars(colors); + actor3->setMapper(mapper3); + + + + //hedgehog + trans = new SoTranslation(); + trans->ref(); + trans->translation.setValue(SbVec3f(-30, -30, -30)); + pcViewProviderRoot->addChild(trans); + + SoVTKActor* actor4 = new SoVTKActor; + actor4->ref(); + pcViewProviderRoot->addChild(actor4); + + //vtkLookupTable* lut = vtkLookupTable::New(); + vtkHedgeHog* hedge = vtkHedgeHog::New(); + hedge->SetScaleFactor(0.001); + hedge->SetInputConnection(source->GetOutputPort()); + vtkPolyDataMapper* mapper4 = vtkPolyDataMapper::New(); + mapper4->SetInputConnection(hedge->GetOutputPort()); + mapper4->Update(); + data = mapper4->GetInput(); + colors = vtkUnsignedCharArray::New(); + colors->SetNumberOfComponents(3); + colors->SetName("Colors"); + for(int i=0; iGetNumberOfPoints(); ++i) { + unsigned char color[3]; + color[0] = 255; + color[1] = 50; + color[2] = 50; + + colors->InsertNextTupleValue(color); + } + data->GetPointData()->SetScalars(colors); + actor4->setMapper(mapper4); + + + //streamline + trans = new SoTranslation(); + trans->ref(); + trans->translation.setValue(SbVec3f(15, 15, 5)); + pcViewProviderRoot->addChild(trans); + + SoVTKActor* actor6 = new SoVTKActor; + actor6->ref(); + pcViewProviderRoot->addChild(actor6); + + vtkPointSource* point = vtkPointSource::New(); + point->SetRadius(3); + point->SetCenter(source->GetOutput()->GetCenter()); + point->SetNumberOfPoints(100); + vtkRungeKutta4* runge = vtkRungeKutta4::New(); + vtkStreamTracer* stream = vtkStreamTracer::New(); + stream->SetInputConnection(source->GetOutputPort()); + stream->SetSourceConnection(point->GetOutputPort()); + stream->SetMaximumPropagation(100); + stream->SetMaximumIntegrationStep(0.01); + stream->SetIntegrationDirection(vtkStreamTracer::BOTH); + stream->SetIntegrator(runge); + + vtkPolyDataMapper* mapper6 = vtkPolyDataMapper::New(); + mapper6->SetInputConnection(stream->GetOutputPort()); + mapper6->Update(); + + data = mapper6->GetInput(); + //see which cell data we got + for(int i=0; iGetPointData()->GetNumberOfArrays(); ++i) { + Base::Console().Message("Point data:\nArray %s (Type: %i)\n", data->GetPointData()->GetArrayName(i), + data->GetPointData()->GetArrayName(i)); + } + for(int i=0; iGetCellData()->GetNumberOfArrays(); ++i) { + Base::Console().Message("\nCell data:\nArray %s (Type: %i)", data->GetCellData()->GetArrayName(i), + data->GetCellData()->GetArrayName(i)); + + } + + table = vtkLookupTable::New(); + data->GetPointData()->GetArray(7)->GetRange(range, 0); + table->SetTableRange(range[0], range[1]); + Base::Console().Message("range: %d - %d\n", range[0], range[1]); + table->Build(); + colors = vtkUnsignedCharArray::New(); + colors->SetNumberOfComponents(3); + colors->SetName("Colors"); + for(int i=0; iGetNumberOfPoints(); ++i) { + //get the pressure at the point + double pressure = data->GetPointData()->GetArray(7)->GetComponent(i, 0); + //Base::Console().Message("angular velocity: %d\n", pressure); + double dcolor[3]; + table->GetColor(pressure, dcolor); + unsigned char color[3]; + for(unsigned int j=0; j<3; ++j) + color[j] = static_cast(255*dcolor[j]); + + colors->InsertNextTupleValue(color); + } + data->GetPointData()->SetScalars(colors); + actor6->setMapper(mapper6); + + + + //glyph + trans = new SoTranslation(); + trans->ref(); + trans->translation.setValue(SbVec3f(15, 15, 5)); + pcViewProviderRoot->addChild(trans); + + SoVTKActor* actor5 = new SoVTKActor; + actor5->ref(); + pcViewProviderRoot->addChild(actor5); + +// vtkArrowSource* arrow = vtkArrowSource::New(); +// arrow->SetTipRadius(0.1); +// arrow->SetTipLength(0.35); +// arrow->SetShaftRadius(0.03); +// arrow->SetTipResolution(4); +// arrow->SetShaftResolution(4); +// vtkGlyph3D* glyph = vtkGlyph3D::New(); +// glyph->SetInputConnection(source->GetOutputPort()); +// //glyph->SetSourceConnection(arrow->GetOutputPort()); +// vtkPolyDataMapper* mapper5 = vtkPolyDataMapper::New(); +// mapper5->SetInputConnection(glyph->GetOutputPort()); +// mapper5->Update(); +// actor5->setMapper(mapper5); + } View3DInventorViewer::~View3DInventorViewer() diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 02b0e6addb1d..b7c3b975bb13 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -39,6 +39,10 @@ #include +#include +#include +#include + class SoTranslation; class SoTransform; class SoText2; @@ -431,6 +435,11 @@ class GuiExport View3DInventorViewer : public Quarter::SoQTQuarterAdaptor, publi friend class NavigationStyle; friend class GLPainter; friend class ViewerEventFilter; + + + //vtk test + vtkSmartPointer source; + vtkSmartPointer mapper; }; } // namespace Gui