├── .gitattributes ├── .gitignore ├── HViewer.sln ├── HViewer ├── .layers ├── ClipCallback.cpp ├── ClipCallback.h ├── GeneratedFiles │ ├── VSprojs - 快捷方式.lnk │ ├── qrc_MainWindow.cpp │ └── ui_MainWindow.h ├── HViewer.rc ├── HViewer.vcxproj ├── HViewer.vcxproj.filters ├── MainWindow.cpp ├── MainWindow.h ├── MainWindow.qrc ├── MainWindow.ui ├── PathPickHandler.h ├── PickPointHandler.cpp ├── PickPointHandler.h ├── Resources │ ├── clip_enable.ico │ ├── clip_remove.ico │ ├── line_mode.ico │ ├── logo.ico │ ├── path_add.ico │ ├── path_play.ico │ ├── path_remove.ico │ └── surface_mode.ico ├── SelectModelHandler.h ├── TreeWidget.cpp ├── TreeWidget.h ├── ViewerWidget.cpp ├── ViewerWidget.h ├── layers.txt ├── logo.ico ├── main.cpp ├── pickHandler.h └── resource.h ├── README.md └── imgs ├── UI.jpg ├── clip.gif ├── open.gif └── path.gif /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /HViewer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.168 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HViewer", "HViewer\HViewer.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {E9B9AB0A-D68C-4E30-ABAD-6B544CBCC1B6} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /HViewer/.layers: -------------------------------------------------------------------------------- 1 | 1,"box1.3dt" 2 | 2,"cylinder1.3dt" 3 | 3,"cylinder2.3dt" 4 | 4,"cylinder3.3dt" 5 | 5,"cylinder4.3dt" 6 | 6,"cylinder11.3dt" 7 | 7,"cylinder22.3dt" 8 | 8,"cylinder33.3dt" 9 | 9,"cylinder44.3dt" 10 | 10,"box2.3dt" 11 | 11,"box3.3dt" 12 | 12,"box4.3dt" 13 | 13,"box5.3dt" 14 | 14,"box6.3dt" 15 | -------------------------------------------------------------------------------- /HViewer/ClipCallback.cpp: -------------------------------------------------------------------------------- 1 | #include "ClipCallback.h" 2 | 3 | 4 | 5 | ClipCallback::ClipCallback() 6 | { 7 | } 8 | 9 | ClipCallback::ClipCallback(osg::Transform * _clipTransform, osg::Transform * _boxTransform) : clipTransform(_clipTransform), boxTransform(_boxTransform) 10 | { 11 | } 12 | 13 | ClipCallback::~ClipCallback() 14 | { 15 | } 16 | 17 | 18 | void ClipCallback::operator()(osg::Node * node, osg::NodeVisitor * nv) 19 | { 20 | clipTransform->removeChildren(0, clipTransform->getNumChildren()); 21 | 22 | osg::ref_ptr clipnode = new osg::ClipNode; 23 | 24 | osg::ComputeBoundsVisitor boundvisitor; 25 | boxTransform->accept(boundvisitor); 26 | osg::BoundingBox bb = boundvisitor.getBoundingBox(); 27 | 28 | 29 | clipnode->createClipBox(bb); 30 | clipnode->setCullingActive(false); 31 | 32 | 33 | clipTransform->addChild(clipnode); 34 | 35 | node->setStateSet(clipnode->getStateSet()); 36 | 37 | traverse(node, nv); 38 | } 39 | -------------------------------------------------------------------------------- /HViewer/ClipCallback.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class ClipCallback : public osg::NodeCallback 9 | { 10 | public: 11 | ClipCallback(); 12 | ClipCallback(osg::Transform* _clipTransform, osg::Transform* _boxTransform); 13 | 14 | 15 | virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); 16 | 17 | ~ClipCallback(); 18 | 19 | protected: 20 | osg::Transform* clipTransform; 21 | 22 | osg::Transform* boxTransform; 23 | 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /HViewer/GeneratedFiles/VSprojs - 快捷方式.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/GeneratedFiles/VSprojs - 快捷方式.lnk -------------------------------------------------------------------------------- /HViewer/GeneratedFiles/qrc_MainWindow.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Resource object code 3 | ** 4 | ** Created by: The Resource Compiler for Qt version 5.11.2 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #ifdef QT_NAMESPACE 10 | # define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name 11 | # define QT_RCC_MANGLE_NAMESPACE0(x) x 12 | # define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b 13 | # define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b) 14 | # define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \ 15 | QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) 16 | #else 17 | # define QT_RCC_PREPEND_NAMESPACE(name) name 18 | # define QT_RCC_MANGLE_NAMESPACE(name) name 19 | #endif 20 | 21 | #ifdef QT_NAMESPACE 22 | namespace QT_NAMESPACE { 23 | #endif 24 | 25 | #ifdef QT_NAMESPACE 26 | } 27 | #endif 28 | 29 | int QT_RCC_MANGLE_NAMESPACE(qInitResources_MainWindow)(); 30 | int QT_RCC_MANGLE_NAMESPACE(qInitResources_MainWindow)() 31 | { 32 | return 1; 33 | } 34 | 35 | int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_MainWindow)(); 36 | int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_MainWindow)() 37 | { 38 | return 1; 39 | } 40 | 41 | namespace { 42 | struct initializer { 43 | initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources_MainWindow)(); } 44 | ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources_MainWindow)(); } 45 | } dummy; 46 | } 47 | -------------------------------------------------------------------------------- /HViewer/GeneratedFiles/ui_MainWindow.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'MainWindow.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.11.2 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_MAINWINDOW_H 10 | #define UI_MAINWINDOW_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | QT_BEGIN_NAMESPACE 21 | 22 | class Ui_MainWindowClass 23 | { 24 | public: 25 | QMenuBar *menuBar; 26 | QToolBar *mainToolBar; 27 | QWidget *centralWidget; 28 | QStatusBar *statusBar; 29 | 30 | void setupUi(QMainWindow *MainWindowClass) 31 | { 32 | if (MainWindowClass->objectName().isEmpty()) 33 | MainWindowClass->setObjectName(QStringLiteral("MainWindowClass")); 34 | MainWindowClass->resize(600, 400); 35 | menuBar = new QMenuBar(MainWindowClass); 36 | menuBar->setObjectName(QStringLiteral("menuBar")); 37 | MainWindowClass->setMenuBar(menuBar); 38 | mainToolBar = new QToolBar(MainWindowClass); 39 | mainToolBar->setObjectName(QStringLiteral("mainToolBar")); 40 | MainWindowClass->addToolBar(mainToolBar); 41 | centralWidget = new QWidget(MainWindowClass); 42 | centralWidget->setObjectName(QStringLiteral("centralWidget")); 43 | MainWindowClass->setCentralWidget(centralWidget); 44 | statusBar = new QStatusBar(MainWindowClass); 45 | statusBar->setObjectName(QStringLiteral("statusBar")); 46 | MainWindowClass->setStatusBar(statusBar); 47 | 48 | retranslateUi(MainWindowClass); 49 | 50 | QMetaObject::connectSlotsByName(MainWindowClass); 51 | } // setupUi 52 | 53 | void retranslateUi(QMainWindow *MainWindowClass) 54 | { 55 | MainWindowClass->setWindowTitle(QApplication::translate("MainWindowClass", "MainWindow", nullptr)); 56 | } // retranslateUi 57 | 58 | }; 59 | 60 | namespace Ui { 61 | class MainWindowClass: public Ui_MainWindowClass {}; 62 | } // namespace Ui 63 | 64 | QT_END_NAMESPACE 65 | 66 | #endif // UI_MAINWINDOW_H 67 | -------------------------------------------------------------------------------- /HViewer/HViewer.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/HViewer.rc -------------------------------------------------------------------------------- /HViewer/HViewer.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | {B12702AD-ABFB-343A-A199-8E24837244A3} 15 | Qt4VSv1.0 16 | 10.0.17763.0 17 | 18 | 19 | 20 | Application 21 | v141 22 | 23 | 24 | Application 25 | v141 26 | 27 | 28 | 29 | $(MSBuildProjectDirectory)\QtMsBuild 30 | 31 | 32 | $(SolutionDir)$(Platform)\$(Configuration)\ 33 | $(VC_IncludePath);$(WindowsSDK_IncludePath);D:\OSG-3.6-x64\include 34 | $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;D:\OSG-3.6-x64\lib 35 | 36 | 37 | $(SolutionDir)$(Platform)\$(Configuration)\ 38 | $(VC_IncludePath);$(WindowsSDK_IncludePath);D:\OSG-3.6-x64\include 39 | $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;D:\OSG-3.6-x64\lib 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | true 60 | UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 61 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) 62 | Disabled 63 | ProgramDatabase 64 | MultiThreadedDebugDLL 65 | true 66 | 67 | 68 | Windows 69 | $(OutDir)\$(ProjectName).exe 70 | $(QTDIR)\lib;%(AdditionalLibraryDirectories) 71 | true 72 | qtmaind.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;OpenThreadsd.lib;osgAnimationd.lib;osgd.lib;osgDBd.lib;osgFXd.lib;osgGAd.lib;osgManipulatord.lib;osgParticled.lib;osgPresentationd.lib;osgQt5d.lib;osgShadowd.lib;osgSimd.lib;osgTerraind.lib;osgTextd.lib;osgUId.lib;osgUtild.lib;osgViewerd.lib;osgVolumed.lib;osgWidgetd.lib;Qt5OpenGLd.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 73 | 74 | 75 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 76 | Moc'ing %(Identity)... 77 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) 78 | UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 79 | 80 | 81 | Uic'ing %(Identity)... 82 | .\GeneratedFiles\ui_%(Filename).h 83 | 84 | 85 | Rcc'ing %(Identity)... 86 | .\GeneratedFiles\qrc_%(Filename).cpp 87 | 88 | 89 | 90 | 91 | true 92 | UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 93 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) 94 | 95 | MultiThreadedDLL 96 | true 97 | 98 | 99 | Windows 100 | $(OutDir)\$(ProjectName).exe 101 | $(QTDIR)\lib;%(AdditionalLibraryDirectories) 102 | true 103 | qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;OpenThreads.lib;osgAnimation.lib;osg.lib;osgDB.lib;osgFX.lib;osgGA.lib;osgManipulator.lib;osgParticle.lib;osgPresentation.lib;osgQt5.lib;osgShadow.lib;osgSim.lib;osgTerrain.lib;osgText.lib;osgUI.lib;osgUtil.lib;osgViewer.lib;osgVolume.lib;osgWidget.lib;Qt5OpenGL.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 104 | 105 | 106 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 107 | Moc'ing %(Identity)... 108 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) 109 | UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 110 | 111 | 112 | Uic'ing %(Identity)... 113 | .\GeneratedFiles\ui_%(Filename).h 114 | 115 | 116 | Rcc'ing %(Identity)... 117 | .\GeneratedFiles\qrc_%(Filename).cpp 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtWidgets 142 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtWidgets 143 | 144 | 145 | 146 | 147 | 148 | 149 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtWidgets 150 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtWidgets 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /HViewer/HViewer.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 14 | qrc;* 15 | false 16 | 17 | 18 | {99349809-55BA-4b9d-BF79-8FDBB0286EB3} 19 | ui 20 | 21 | 22 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 23 | qrc;* 24 | false 25 | 26 | 27 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 28 | moc;h;cpp 29 | False 30 | 31 | 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | 64 | 65 | Form Files 66 | 67 | 68 | 69 | 70 | Resource Files 71 | 72 | 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /HViewer/MainWindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/MainWindow.cpp -------------------------------------------------------------------------------- /HViewer/MainWindow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/MainWindow.h -------------------------------------------------------------------------------- /HViewer/MainWindow.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /HViewer/MainWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | MainWindowClass 3 | 4 | 5 | MainWindowClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | MainWindow 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /HViewer/PathPickHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/PathPickHandler.h -------------------------------------------------------------------------------- /HViewer/PickPointHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "PickPointHandler.h" 2 | 3 | osg::Geode * PickPointHandler::createPointSelector() 4 | { 5 | osg::ref_ptr colors = new osg::Vec4Array(1); 6 | (*colors)[0] = selectedColor; 7 | 8 | _selector = new osg::Geometry; 9 | _selector->setDataVariance(osg::Object::DYNAMIC); 10 | _selector->setUseDisplayList(false); 11 | _selector->setUseVertexBufferObjects(true); 12 | _selector->setVertexArray(new osg::Vec3Array(1)); 13 | _selector->setColorArray(colors.get()); 14 | _selector->setColorBinding(osg::Geometry::BIND_OVERALL); 15 | _selector->addPrimitiveSet(new osg::DrawArrays(GL_POINTS, 0, 1)); 16 | 17 | osg::ref_ptr geode = new osg::Geode; 18 | geode->addDrawable(_selector.get()); 19 | geode->getOrCreateStateSet()->setAttributeAndModes(new osg::Point(10.0f)); 20 | geode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); 21 | return geode.release(); 22 | } 23 | 24 | void PickPointHandler::doUserOperations(osgUtil::LineSegmentIntersector::Intersection & result) 25 | { 26 | osg::Geometry* geom = dynamic_cast(result.drawable.get()); 27 | if (!geom || !_selector || geom == _selector) return; 28 | 29 | osg::Vec3Array* vertices = dynamic_cast(geom->getVertexArray()); 30 | osg::Vec3Array* selVertices = dynamic_cast(_selector->getVertexArray()); 31 | if (!vertices || !selVertices) return; 32 | 33 | osg::Vec3 point = result.getWorldIntersectPoint(); 34 | osg::Matrix matrix = osg::computeLocalToWorld(result.nodePath); 35 | 36 | osg::Matrix vpMatrix; 37 | if (_camera.valid()) 38 | { 39 | vpMatrix = _camera->getViewMatrix() * _camera->getProjectionMatrix(); 40 | point = point * vpMatrix; 41 | } 42 | 43 | const std::vector& selIndices = result.indexList; 44 | for (unsigned int i = 0; i < 3 && i < selIndices.size(); ++i) 45 | { 46 | unsigned int pos = selIndices[i]; 47 | osg::Vec3 vertex = (*vertices)[pos] * matrix; 48 | float distance = (vertex * vpMatrix - point).length(); 49 | if (distance < 0.1f) 50 | { 51 | selVertices->front() = vertex; 52 | 53 | vertex = osg::Matrix::rotate(osg::Quat(-osg::PI_2, osg::X_AXIS)) * vertex; 54 | 55 | QString strVer = "X: "; 56 | strVer += QString::number(vertex.x(), 'f', 4); 57 | strVer += ", Y: "; 58 | strVer += QString::number(vertex.y(), 'f', 4); 59 | strVer += ", Z:"; 60 | strVer += QString::number(vertex.z(), 'f', 4); 61 | 62 | qDebug() << vertex.x() << " " << vertex.y() << " " << vertex.z() << endl; 63 | 64 | //_label->setText(strVer); 65 | //_mainWindow->setVerticeText(strVer); 66 | 67 | emit _viewerWidget->labelRReturn(strVer); 68 | 69 | } 70 | } 71 | selVertices->dirty(); 72 | _selector->dirtyBound(); 73 | } 74 | -------------------------------------------------------------------------------- /HViewer/PickPointHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | //#include "MainWindow.h" 18 | 19 | #include "ViewerWidget.h" 20 | 21 | #include "PickHandler.h" 22 | 23 | const osg::Vec4 normalColor(1.0f, 1.0f, 1.0f, 1.0f); 24 | const osg::Vec4 selectedColor(1.0f, 0.0f, 0.0f, 1.0f); 25 | 26 | class ViewerWidget; 27 | 28 | class PickPointHandler : public PickHandler 29 | { 30 | public: 31 | PickPointHandler(osg::Camera* camera, ViewerWidget* vw) : _selector(0), _camera(camera), _viewerWidget(vw) {} 32 | 33 | osg::Geode* createPointSelector(); 34 | 35 | virtual void doUserOperations(osgUtil::LineSegmentIntersector::Intersection& result); 36 | 37 | protected: 38 | osg::ref_ptr _selector; 39 | osg::observer_ptr _camera; 40 | 41 | ViewerWidget* _viewerWidget; 42 | }; -------------------------------------------------------------------------------- /HViewer/Resources/clip_enable.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/Resources/clip_enable.ico -------------------------------------------------------------------------------- /HViewer/Resources/clip_remove.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/Resources/clip_remove.ico -------------------------------------------------------------------------------- /HViewer/Resources/line_mode.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/Resources/line_mode.ico -------------------------------------------------------------------------------- /HViewer/Resources/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/Resources/logo.ico -------------------------------------------------------------------------------- /HViewer/Resources/path_add.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/Resources/path_add.ico -------------------------------------------------------------------------------- /HViewer/Resources/path_play.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/Resources/path_play.ico -------------------------------------------------------------------------------- /HViewer/Resources/path_remove.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/Resources/path_remove.ico -------------------------------------------------------------------------------- /HViewer/Resources/surface_mode.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/Resources/surface_mode.ico -------------------------------------------------------------------------------- /HViewer/SelectModelHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pickHandler.h" 4 | 5 | 6 | class SelectModelHandler : public PickHandler 7 | { 8 | public: 9 | SelectModelHandler() : _lastDrawable(0) 10 | { 11 | normalColor = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f); 12 | selectedColor = osg::Vec4(1.0f, 0.0f, 0.0f, 0.5f); 13 | } 14 | 15 | virtual void doUserOperations(osgUtil::LineSegmentIntersector::Intersection& result) 16 | { 17 | if (_lastDrawable.valid()) 18 | { 19 | setDrawableColor(_lastDrawable.get(), normalColor); 20 | _lastDrawable = NULL; 21 | } 22 | 23 | osg::Geometry* geom = dynamic_cast(result.drawable.get()); 24 | 25 | if (geom) 26 | { 27 | setDrawableColor(geom, selectedColor); 28 | _lastDrawable = geom; 29 | } 30 | 31 | } 32 | // 33 | void setDrawableColor(osg::Geometry* geom, const osg::Vec4& color) 34 | { 35 | // //osg::Vec4Array* colors = dynamic_cast(geom->getColorArray()); 36 | 37 | // //if (colors && colors->size() > 0) 38 | // //{ 39 | // // colors->front() = color; 40 | // // colors->dirty(); 41 | // //} 42 | 43 | osg::ref_ptr colors = new osg::Vec4Array(1); 44 | (*colors)[0] = selectedColor; 45 | 46 | geom->setColorArray(colors); 47 | } 48 | 49 | protected: 50 | osg::observer_ptr _lastDrawable; 51 | 52 | osg::Vec4 normalColor; 53 | osg::Vec4 selectedColor; 54 | }; -------------------------------------------------------------------------------- /HViewer/TreeWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "treeWidget.h" 2 | 3 | 4 | 5 | TreeWidget::TreeWidget() 6 | { 7 | _tree = new QTreeWidget; 8 | 9 | _tree->setHeaderLabel("LAYER LIST"); 10 | 11 | _root = new QTreeWidgetItem(); 12 | _root->setText(0, "root"); 13 | 14 | _tree->addTopLevelItem(_root); 15 | 16 | _root->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); 17 | _root->setCheckState(0, Qt::Checked); 18 | 19 | changeItem(0); 20 | 21 | connect(_tree, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(updateItem(QTreeWidgetItem*, int))); 22 | 23 | QHBoxLayout* layout = new QHBoxLayout; 24 | layout->addWidget(_tree); 25 | layout->setMargin(0); 26 | setLayout(layout); 27 | 28 | //connect(_tree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(highLightItem(QTreeWidgetItem*, int))); 29 | } 30 | 31 | 32 | TreeWidget::~TreeWidget() 33 | { 34 | } 35 | 36 | void TreeWidget::setScene(osg::Group* scene) 37 | { 38 | this->_scene = scene; 39 | } 40 | 41 | void TreeWidget::changeItem(int num) 42 | { 43 | //clear history items 44 | for (auto iter = _itemList.begin(); iter != _itemList.end(); iter++) 45 | { 46 | _root->removeChild(*iter); 47 | } 48 | _itemList.clear(); 49 | 50 | createItem(num); 51 | } 52 | 53 | 54 | void TreeWidget::createItem(int num) 55 | { 56 | if (num == 0) 57 | { 58 | _root->setHidden(true); 59 | } 60 | else 61 | { 62 | _root->setHidden(false); 63 | } 64 | 65 | // get layer name 66 | QVector names; 67 | QFile file("./.layers"); 68 | file.open(QIODevice::ReadOnly | QIODevice::Text); 69 | QTextStream in(&file); 70 | //in.setCodec("GBK"); 71 | for (size_t i = 0; i < num; i++) 72 | { 73 | QString curr_line = in.readLine(); 74 | names.push_back(curr_line); 75 | } 76 | file.close(); 77 | 78 | for (int i = 0; i < num; i++) 79 | { 80 | QTreeWidgetItem* subItem = new QTreeWidgetItem(_root); 81 | subItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); 82 | 83 | subItem->setText(0, names[i]); 84 | 85 | subItem->setCheckState(0, Qt::Checked); 86 | 87 | //connect(subItem, SIGNAL(itemChanged(QTreeWidgetItem*, int), ); 88 | 89 | _itemList.push_back(subItem); 90 | } 91 | 92 | _tree->expandAll(); 93 | } 94 | 95 | void TreeWidget::changeSwitchState(int index, bool targetState) 96 | { 97 | int count = _scene->getChild(index)->asSwitch()->getNumChildren(); 98 | for (size_t i = 0; i < count; i++) 99 | { 100 | _scene->getChild(index)->asSwitch()->setValue(i, targetState); 101 | } 102 | } 103 | 104 | 105 | void TreeWidget::updateItem(QTreeWidgetItem* item, int column) 106 | { 107 | if (Qt::Checked == item->checkState(0)) 108 | { 109 | int count = item->childCount(); 110 | if (count > 0) //root 111 | { 112 | for (int i = 0; i < count; i++) 113 | { 114 | item->child(i)->setCheckState(0, Qt::Checked); 115 | 116 | // show all layers 117 | changeSwitchState(i, true); 118 | } 119 | } 120 | else //subItem 121 | { 122 | updateRootItem(); 123 | int index = 0; 124 | for (auto iter = _itemList.begin(); iter != _itemList.end(); iter++) 125 | { 126 | if (*iter == item) 127 | { 128 | break; 129 | } 130 | index++; 131 | } 132 | changeSwitchState(index, true); 133 | } 134 | 135 | } 136 | 137 | if (Qt::Unchecked == item->checkState(0)) 138 | { 139 | int count = item->childCount(); 140 | if (count > 0) //root 141 | { 142 | for (int i = 0; i < count; i++) 143 | { 144 | item->child(i)->setCheckState(0, Qt::Unchecked); 145 | 146 | changeSwitchState(i, false); 147 | } 148 | } 149 | else //subItem 150 | { 151 | updateRootItem(); 152 | 153 | int index = 0; 154 | for (auto iter = _itemList.begin(); iter != _itemList.end(); iter++) 155 | { 156 | if (*iter == item) 157 | { 158 | break; 159 | } 160 | index++; 161 | } 162 | changeSwitchState(index, false); 163 | } 164 | } 165 | } 166 | 167 | void TreeWidget::updateRootItem() 168 | { 169 | int childCount = _root->childCount(); 170 | int checkedCount = 0; 171 | for (int i = 0; i < childCount; i++) 172 | { 173 | QTreeWidgetItem* childItem = _root->child(i); 174 | if (childItem->checkState(0) == Qt::Checked) 175 | { 176 | checkedCount++; 177 | } 178 | } 179 | 180 | if (checkedCount <= 0) 181 | { 182 | _root->setCheckState(0, Qt::Unchecked); 183 | } 184 | else if (checkedCount == childCount) 185 | { 186 | _root->setCheckState(0, Qt::Checked); 187 | } 188 | else 189 | { 190 | _root->setCheckState(0, Qt::PartiallyChecked); 191 | } 192 | } 193 | 194 | 195 | //void TreeWidget::highLightItem(QTreeWidgetItem * item, int column) 196 | //{ 197 | // 198 | //} -------------------------------------------------------------------------------- /HViewer/TreeWidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | class TreeWidget : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | TreeWidget(); 21 | ~TreeWidget(); 22 | 23 | void setScene(osg::Group*); 24 | void changeItem(int); 25 | 26 | private slots: 27 | void updateItem(QTreeWidgetItem* item, int column); 28 | //void highLightItem(QTreeWidgetItem* item, int column); 29 | 30 | private: 31 | QTreeWidgetItem* _root; 32 | QTreeWidget* _tree; 33 | QVector _itemList; 34 | 35 | osg::Group* _scene; 36 | 37 | void createItem(int); 38 | 39 | void changeSwitchState(int, bool); 40 | 41 | void updateRootItem(); 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /HViewer/ViewerWidget.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/ViewerWidget.cpp -------------------------------------------------------------------------------- /HViewer/ViewerWidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | 54 | #include "PathPickHandler.h" 55 | 56 | #include "PickPointHandler.h" 57 | 58 | #include "SelectModelHandler.h" 59 | 60 | #include "ClipCallback.h" 61 | 62 | 63 | 64 | class ViewerWidget : public QWidget 65 | { 66 | Q_OBJECT 67 | 68 | public: 69 | ViewerWidget(osgQt::GraphicsWindowQt* gw); 70 | ~ViewerWidget(); 71 | 72 | void setScene(osg::Node*); 73 | osg::Node* getScene(); 74 | 75 | void removeScene(); 76 | void removeOperation(); 77 | 78 | void changeToLineMode(); 79 | void changeToSurfaceMode(); 80 | 81 | void switchLayer(int index, bool targetStatus); 82 | void switchAllLayer(bool targetStatus); 83 | 84 | int getLayerCount(); 85 | 86 | void createClipDragger(); 87 | void removeClipDragger(); 88 | void clearClip(); 89 | 90 | void createPicker(); 91 | void removePicker(); 92 | 93 | void setBackColor(int r, int g, int b); 94 | 95 | void setLabelText(); 96 | 97 | protected: 98 | QTimer _timer; 99 | 100 | osg::ref_ptr _gw; 101 | 102 | osg::ref_ptr _viewer; 103 | 104 | osg::ref_ptr _scene; 105 | 106 | osg::ref_ptr _root; 107 | 108 | osg::ref_ptr _pathPickHandler; 109 | 110 | virtual void paintEvent(QPaintEvent* event) 111 | { 112 | _viewer->frame(); 113 | } 114 | 115 | public: 116 | osg::Node* addDraggerToBox(osg::Node* box); 117 | 118 | osg::Transform* createClipBoxToScene(osg::Node* scene); 119 | 120 | 121 | protected: 122 | // dragger for clipping 123 | osg::ref_ptr _boundingBox; 124 | osg::ref_ptr _shape; 125 | 126 | osg::ref_ptr _clipTransform; 127 | 128 | osg::ref_ptr _boxTransform; 129 | 130 | ClipCallback* _clipCallback; 131 | 132 | signals: 133 | void labelRReturn(QString); 134 | 135 | }; 136 | 137 | -------------------------------------------------------------------------------- /HViewer/layers.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/layers.txt -------------------------------------------------------------------------------- /HViewer/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/logo.ico -------------------------------------------------------------------------------- /HViewer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | a.setWindowIcon(QIcon("./Resources/logo.ico")); 8 | MainWindow w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /HViewer/pickHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class PickHandler : public osgGA::GUIEventHandler 7 | { 8 | public: 9 | virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) 10 | { 11 | if (ea.getEventType() != osgGA::GUIEventAdapter::RELEASE || 12 | ea.getButton() != osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON || 13 | !(ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL)) 14 | return false; 15 | 16 | osgViewer::View* viewer = dynamic_cast(&aa); 17 | if (viewer) 18 | { 19 | osg::ref_ptr intersector = 20 | new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY()); 21 | osgUtil::IntersectionVisitor iv(intersector.get()); 22 | viewer->getCamera()->accept(iv); 23 | 24 | if (intersector->containsIntersections()) 25 | { 26 | osgUtil::LineSegmentIntersector::Intersection result = *(intersector->getIntersections().begin()); 27 | doUserOperations(result); 28 | } 29 | } 30 | return false; 31 | } 32 | virtual void doUserOperations(osgUtil::LineSegmentIntersector::Intersection& result) = 0; 33 | }; 34 | -------------------------------------------------------------------------------- /HViewer/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/HViewer/resource.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A 3D model viewer based on OpenSceneGraph 3 and Qt 5 2 | OpenSceneGraph 3.6.3, QT 5.11.2, Visual Studio 2017 3 | 4 | ## example 5 | ![UI](https://github.com/Housz/HViewer/blob/master/imgs/UI.jpg) 6 | *UI* 7 | 8 | ![open](https://github.com/Housz/HViewer/blob/master/imgs/open.gif) 9 | *View* 10 | 11 | ![clip](https://github.com/Housz/HViewer/blob/master/imgs/clip.gif) 12 | *Clip* 13 | 14 | ![path](https://github.com/Housz/HViewer/blob/master/imgs/path.gif) 15 | *Path Animation* 16 | 17 | --------- 18 | ## to-do list: 19 | 20 | **function**: 21 | 22 | * ~~open/close model file(.obj .osg .3dt)~~ 23 | * ~~reset model~~ 24 | * ~~surface mode/line mode~~ 25 | * pick and highlight a model (connect to treeWidget) 26 | * ~~pick point and show its coord~~ 27 | * ~~section (dynamic)~~ 28 | * path animation(default/customize path) 29 | * capture 30 | * ~~light~~ 31 | * translation(with keyboard) 32 | * direct to front/back, lift/right, up/down 33 | 34 | **UI**: 35 | * ~~floatable toolbar(tree widget)~~ 36 | * ~~control toolBar to show/hide~~ 37 | * ~~toolbar~~ 38 | * shortcuts 39 | * ~~icon~~ 40 | * ~~background color~~ 41 | * language switch 42 | 43 | --------- 44 | ## bug 45 | * ~~low frame rate due to massive data~~ 46 | * ~~z-fighting~~ 47 | -------------------------------------------------------------------------------- /imgs/UI.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/imgs/UI.jpg -------------------------------------------------------------------------------- /imgs/clip.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/imgs/clip.gif -------------------------------------------------------------------------------- /imgs/open.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/imgs/open.gif -------------------------------------------------------------------------------- /imgs/path.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Housz/HViewer/5794f5d088b4a93c8a034d7cdb0f0fe01f6cc42f/imgs/path.gif --------------------------------------------------------------------------------