├── .gitignore ├── ExternShape ├── ExternShape.pro ├── MapArc.cpp ├── MapCircle.cpp ├── MapExternLine.cpp ├── MapPlaceNode.cpp └── MapRectange.cpp ├── ImplSceneVisualGroup.hpp ├── Inc ├── Ability │ ├── IFlashAbility.h │ └── IFlatAbility.h ├── ExternShape │ ├── ExternShape_Global.h │ ├── MapArc.h │ ├── MapCircle.h │ ├── MapExternLine.h │ ├── MapPlaceNode.h │ └── MapRectange.h ├── Hud │ ├── HudType.h │ ├── IHudNode.h │ └── IViewHud.h ├── ISceneCore.h ├── Inner │ ├── Common │ │ ├── ImplSceneAttitudeGroup.hpp │ │ ├── ImplSceneCameraGroup.hpp │ │ ├── ImplSceneFlashGroup.hpp │ │ ├── ImplSceneGroup.hpp │ │ ├── ImplSceneLodGroup.hpp │ │ ├── ImplSceneScaleGroup.hpp │ │ ├── ImplSceneScreenGroup.hpp │ │ └── ImplSceneVisualGroup.hpp │ ├── ILoadResource.h │ ├── IOsgSceneNode.h │ ├── IOsgViewPoint.h │ ├── IRender.h │ ├── ImplHudNode.hpp │ ├── ImplMapSceneGeometry.hpp │ ├── ImplMapSceneNode.hpp │ ├── ImplSceneGeometry.hpp │ ├── ImplSceneModel.hpp │ ├── ImplSceneNode.hpp │ ├── ImplSceneSensor.hpp │ ├── ImplSceneShape.hpp │ ├── OsgExtern │ │ ├── Grid2TriangleStrip.h │ │ ├── IOsgMapSceneNode.h │ │ ├── JudgeGeometry.h │ │ ├── LoadGLSL.h │ │ ├── MathCommon.h │ │ ├── MyMatrixTransform.h │ │ ├── MyPositionAttitudeTransform.h │ │ ├── NodeAbilityManager.h │ │ ├── OsgExtern.h │ │ ├── OsgExtern_Global.h │ │ └── SplitRectangle.h │ └── ThreadSafety │ │ ├── SafetyList.h │ │ ├── SafetyMap.h │ │ ├── SafetyQueue.h │ │ ├── SafetySet.h │ │ ├── SafetyStack.h │ │ ├── SafetyUniqueList.h │ │ └── SafetyVector.h ├── NoQt.h ├── Plot │ ├── Common │ │ ├── ISceneAttitudeGroup.h │ │ ├── ISceneCameraGroup.h │ │ ├── ISceneFlashGroup.h │ │ ├── ISceneLodGroup.h │ │ ├── ISceneModel.h │ │ ├── ISceneScaleGroup.h │ │ ├── ISceneScreenGroup.h │ │ └── ISceneVisualGroup.h │ ├── Hud │ │ ├── IHudButton.h │ │ ├── IHudImage.h │ │ ├── IHudLayout.h │ │ └── IHudText.h │ ├── IPlot.h │ ├── Map │ │ ├── IMap.h │ │ ├── IMapCoverImage.h │ │ ├── IMapLayer.h │ │ ├── IMapLine.h │ │ ├── IMapLocation.h │ │ ├── IMapObserver.h │ │ ├── IMapPoint.h │ │ ├── IMapPolygon.h │ │ ├── IMapPolygon3D.h │ │ ├── IMapSceneNode.h │ │ ├── MapType.h │ │ └── SpaceEnv │ │ │ ├── ISpaceBackGround.h │ │ │ └── ISpaceEnv.h │ ├── SatelliteShow │ │ ├── IOribit.h │ │ └── ISatellite.h │ └── SceneShape │ │ ├── IBeamSensor.h │ │ ├── IBoxSensor.h │ │ ├── IConeSensor.h │ │ ├── IEllipsoidSensor.h │ │ ├── IGeometry.h │ │ ├── IImage.h │ │ ├── ILabel.h │ │ ├── ILine.h │ │ ├── IPoint.h │ │ ├── IPolygon.h │ │ ├── IPolygon3D.h │ │ ├── IRadarSensor.h │ │ ├── ISConeSensor.h │ │ ├── ISceneDonut.h │ │ ├── ISensor.h │ │ └── IShape.h ├── Qml │ └── QtOsgItem.h ├── SceneCore_Global.h ├── SceneGraph │ ├── INodeAbility.h │ ├── ISceneGraph.h │ ├── ISceneGraphManager.h │ ├── ISceneGroup.h │ ├── ISceneNode.h │ ├── IViewPort.h │ ├── IWindow.h │ ├── SceneType.h │ └── ViewType.h └── Tool │ └── ITool.h ├── LICENSE ├── LoadMap ├── CSimpleLabel.cpp ├── CSimpleLabel.h ├── LoadMap.png ├── LoadMap.pro ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h └── mainwindow.ui ├── LoadQmlMap ├── AppGlobal.cpp ├── AppGlobal.h ├── DealWindowsMessage.cpp ├── DealWindowsMessage.h ├── LoadQmlMap.pro ├── LoadQmlMap_zh_CN.ts ├── PlotMap.cpp ├── PlotMap.h ├── img.qrc ├── main.cpp ├── main.qml ├── main6.qml ├── qml.qrc └── qml6.qrc ├── Map.pro ├── OsgExtern ├── FlashAbility.cpp ├── FlashAbility.h ├── FlatAbility.cpp ├── FlatAbility.h ├── Grid2TriangleStrip.cpp ├── ImplNodeAbility.hpp ├── JudgeGeometry.cpp ├── LoadGLSL.cpp ├── MathCommon.cpp ├── MyMatrixTransform.cpp ├── MyPositionAttitudeTransform.cpp ├── NodeAbilityManager.cpp ├── OsgExtern.pro └── SplitRectangle.cpp ├── Path.pri ├── Plot ├── Hud │ ├── Hud.pro │ ├── HudButton.cpp │ ├── HudButton.h │ ├── HudImage.cpp │ ├── HudImage.h │ ├── HudLayout.cpp │ ├── HudLayout.h │ ├── HudNode.cpp │ ├── HudNode.h │ ├── HudShape.cpp │ ├── HudShape.h │ ├── HudText.cpp │ └── HudText.h ├── Map │ ├── Atmosphere.cpp │ ├── Atmosphere.h │ ├── Map.cpp │ ├── Map.h │ ├── Map.pro │ ├── MapLayer.cpp │ ├── MapLayer.h │ ├── MapModelLayer.cpp │ ├── MapModelLayer.h │ ├── MapModifyLayer.cpp │ ├── MapModifyLayer.h │ ├── SpaceEnv.cpp │ └── SpaceEnv.h ├── MapShape │ ├── DrawShape │ │ ├── MapCoverImage.cpp │ │ ├── MapCoverImage.h │ │ ├── MapLine.cpp │ │ ├── MapLine.h │ │ ├── MapLocation.cpp │ │ ├── MapLocation.h │ │ ├── MapPoint.cpp │ │ ├── MapPoint.h │ │ ├── MapPolygon.cpp │ │ ├── MapPolygon.h │ │ ├── MapPolygon3D.cpp │ │ └── MapPolygon3D.h │ ├── MapShape.cpp │ ├── MapShape.h │ └── MapShape.pro ├── Plot.pro ├── PlotManager │ ├── MapNodeFactory.cpp │ ├── MapNodeFactory.h │ ├── PlotManager.cpp │ ├── PlotManager.h │ └── PlotManager.pro ├── SatelliteShow │ ├── SatelliteShow.cpp │ ├── SatelliteShow.h │ └── SatelliteShow.pro ├── SceneShape │ ├── DrawShape │ │ ├── BeamSensor.cpp │ │ ├── BeamSensor.h │ │ ├── RadarSensor.cpp │ │ ├── RadarSensor.h │ │ ├── SceneBox.cpp │ │ ├── SceneBox.h │ │ ├── SceneCone.cpp │ │ ├── SceneCone.h │ │ ├── SceneDonuts.cpp │ │ ├── SceneDonuts.h │ │ ├── SceneEllipsoid.cpp │ │ ├── SceneEllipsoid.h │ │ ├── SceneImage.cpp │ │ ├── SceneImage.h │ │ ├── SceneLabel.cpp │ │ ├── SceneLabel.h │ │ ├── SceneLine.cpp │ │ ├── SceneLine.h │ │ ├── ScenePoint.cpp │ │ ├── ScenePoint.h │ │ ├── ScenePolygon.cpp │ │ ├── ScenePolygon.h │ │ ├── ScenePolygon3D.cpp │ │ ├── ScenePolygon3D.h │ │ ├── SceneSCone.cpp │ │ └── SceneSCone.h │ ├── SceneShape.cpp │ ├── SceneShape.h │ └── SceneShape.pro ├── SpaceBackGround │ ├── SkyNode.cpp │ ├── SkyNode.h │ ├── Solar │ │ ├── PlanetModel.cpp │ │ ├── PlanetModel.h │ │ ├── SolarEnv.cpp │ │ ├── SolarEnv.h │ │ ├── SunModel.cpp │ │ └── SunModel.h │ ├── SpaceBackGround.cpp │ ├── SpaceBackGround.h │ ├── SpaceBackGround.pro │ └── Star │ │ ├── Boundary.cpp │ │ ├── Boundary.h │ │ ├── Frustum.cpp │ │ ├── Frustum.h │ │ ├── GeodesicGrid.cpp │ │ ├── GeodesicGrid.h │ │ ├── Milkyway.cpp │ │ ├── Milkyway.h │ │ ├── Star.cpp │ │ ├── Star.h │ │ ├── StarConstellation.cpp │ │ ├── StarConstellation.h │ │ ├── StarEnv.cpp │ │ ├── StarEnv.h │ │ ├── StarManager.cpp │ │ ├── StarManager.h │ │ ├── StarRender.cpp │ │ ├── StarRender.h │ │ ├── StarToneReproducer.cpp │ │ ├── StarToneReproducer.h │ │ ├── StarZoneArray.h │ │ ├── StarZoneArrayBase.h │ │ ├── StarZoneArrayRenderer.cpp │ │ ├── StarZoneArrayRenderer.h │ │ ├── StarZoneData.h │ │ └── StarZoneDataBase.h └── Trajectory │ ├── TrajectoryShow.cpp │ └── TrajectoryShow.h ├── README.md ├── SceneCore ├── MyNotify.cpp ├── MyNotify.h ├── SceneCore.cpp ├── SceneCore.h ├── SceneCore.pro ├── SceneGraph │ ├── DealViewPortChange.h │ ├── MyEarthManipulator.cpp │ ├── MyEarthManipulator.h │ ├── QtRender.cpp │ ├── QtRender.h │ ├── QtSceneGraph.cpp │ ├── QtSceneGraph.h │ ├── QtViewHud.cpp │ ├── QtViewHud.h │ ├── QtViewPort.cpp │ ├── QtViewPort.h │ ├── ResourceLoadExtern.cpp │ ├── ResourceLod.cpp │ ├── ResourceLod.h │ ├── SceneGraphManager.cpp │ ├── SceneGraphManager.h │ ├── ViewPortEventCallback.h │ └── VrCallBack.h └── Window │ ├── MyShader.h │ ├── Qml │ ├── QtOsgItem.cpp │ ├── QtOsgRenderer.cpp │ └── QtOsgRenderer.h │ ├── QtEventMap.cpp │ ├── QtEventMap.h │ ├── QtFBOWindow.cpp │ ├── QtFBOWindow.h │ ├── QtWindow.cpp │ ├── QtWindow.h │ └── Widget │ ├── QtOsgWindow.cpp │ └── QtOsgWindow.h ├── SoftSDK.pri └── Tool ├── Analysis ├── Analysis.pro ├── AnalysisTool.cpp ├── AnalysisTool.h ├── ViewAnalysis.cpp └── ViewAnalysis.h ├── IToolBase.h ├── IToolPub.h ├── Measure ├── Measure.pro ├── MeasureTool.cpp └── MeasureTool.h ├── Pick ├── IntersectionPick.cpp ├── IntersectionPick.h ├── Pick.pro ├── PickTool.cpp ├── PickTool.h ├── PointPick.cpp └── PointPick.h ├── Sound ├── Sound.pro ├── SoundTool.cpp └── SoundTool.h ├── Tool.pro └── ToolSelector ├── ToolSelector.cpp ├── ToolSelector.h └── ToolSelector.pro /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | *.slo 3 | *.lo 4 | *.o 5 | *.a 6 | *.la 7 | *.lai 8 | *.so 9 | *.so.* 10 | *.dll 11 | *.dylib 12 | *.idx 13 | /debug 14 | /release 15 | /build 16 | /Inc/Doc 17 | # Qt-es 18 | object_script.*.Release 19 | object_script.*.Debug 20 | *_plugin_import.cpp 21 | /.qmake.cache 22 | /.qmake.stash 23 | *.pro.user 24 | *.pro.user.* 25 | *.qbs.user 26 | *.qbs.user.* 27 | *.moc 28 | moc_*.cpp 29 | moc_*.h 30 | qrc_*.cpp 31 | ui_*.h 32 | *.qmlc 33 | *.jsc 34 | Makefile* 35 | *build-* 36 | *.qm 37 | *.prl 38 | 39 | # Qt unit tests 40 | target_wrapper.* 41 | 42 | # QtCreator 43 | *.autosave 44 | 45 | # QtCreator Qml 46 | *.qmlproject.user 47 | *.qmlproject.user.* 48 | 49 | # QtCreator CMake 50 | CMakeLists.txt.user* 51 | 52 | # QtCreator 4.8< compilation database 53 | compile_commands.json 54 | 55 | # QtCreator local machine specific files for imported projects 56 | *creator.user* 57 | /.vs 58 | *.pdb 59 | *.log 60 | *.tlog 61 | *.exp 62 | *.ilk 63 | *.lib 64 | *.db 65 | *.obj 66 | *.opendb 67 | *.props 68 | *.cbt 69 | *.user 70 | *.filters 71 | *.txt 72 | *.vcxproj 73 | *.recipe 74 | *.sln 75 | *.cd 76 | *.doc 77 | *.zip 78 | *.pri 79 | *.bat 80 | -------------------------------------------------------------------------------- /ExternShape/ExternShape.pro: -------------------------------------------------------------------------------- 1 | TARGET = ExternShape 2 | TEMPLATE = lib 3 | 4 | DEFINES *= EXTERNMAPSHAPE_LIBRARY 5 | 6 | SDK_CONFIG *= OSG OsgExtern SceneCore Satellite 7 | 8 | include($$PWD/../SoftSDK.pri) 9 | 10 | HEADERS += 11 | 12 | SOURCES += \ 13 | MapArc.cpp \ 14 | MapCircle.cpp \ 15 | MapExternLine.cpp \ 16 | MapPlaceNode.cpp \ 17 | MapRectange.cpp 18 | CONFIG *= ordered 19 | -------------------------------------------------------------------------------- /ExternShape/MapCircle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | CMapCircle::CMapCircle(ISceneGraph* pSceneGraph) 7 | { 8 | m_pSceneGraph = pSceneGraph; 9 | InitNode(); 10 | } 11 | void CMapCircle::SetCenter(const ScenePos &pos) 12 | { 13 | if(pos != m_stCenter) 14 | { 15 | m_stCenter = pos; 16 | UpdateNode(); 17 | } 18 | } 19 | void CMapCircle::SetRadius(const float& radius) 20 | { 21 | if(m_fRadius != radius) 22 | { 23 | m_fRadius = radius; 24 | UpdateNode(); 25 | } 26 | } 27 | void CMapCircle::SetColor(const SceneColor& color) 28 | { 29 | m_pPolygon->GetDrawPolygon()->SetColor(color); 30 | } 31 | void CMapCircle::SetFineness(int fineness) 32 | { 33 | if(m_nFineness != fineness) 34 | { 35 | m_nFineness = fineness; 36 | UpdateNode(); 37 | } 38 | } 39 | void CMapCircle::InitNode() 40 | { 41 | m_pPolygon = dynamic_cast(m_pSceneGraph->GetPlot()->CreateSceneNode("IMapPolygon")); 42 | } 43 | void CMapCircle::UpdateNode() 44 | { 45 | if(m_fRadius <0.01) 46 | { 47 | return; 48 | } 49 | double dTmpOffset = D2PI/m_nFineness; 50 | ScenePos Pos; 51 | std::vector GeoMuPos; 52 | for(int i =0 ; i<= m_nFineness;i++) 53 | { 54 | GisMath::GeoCalEndGeo(m_stCenter.dX*DD2R,m_stCenter.dY*DD2R,0,i*dTmpOffset, 0, 55 | m_fRadius,Pos.dX, Pos.dY,Pos.dZ); 56 | Pos.dX *= DR2D; 57 | Pos.dY *= DR2D; 58 | GeoMuPos.push_back(Pos); 59 | } 60 | m_pPolygon->GetDrawPolygon()->SetMultPos(GeoMuPos); 61 | } 62 | -------------------------------------------------------------------------------- /Inc/Ability/IFlashAbility.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_FLASH_ABILITY_HEARDER_H 2 | #define INTERFACE_FLASH_ABILITY_HEARDER_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 场景节点类 9 | */ 10 | class IFlashAbility:public INodeAbility 11 | { 12 | public: 13 | 14 | /** 15 | * @brief 转换成本类型 16 | * @return 17 | */ 18 | IFlashAbility* AsFlashAbility(){return(this);} 19 | 20 | /** 21 | * @brief 设置闪烁颜色 22 | * @param rColor 23 | */ 24 | void SetFlashColor(const SceneColor& rColor)JUDGE_EQUAL_CALL_FUNCTION(rColor,m_stFlahColor,FlashColorChanged) 25 | const SceneColor& GetFlashColor()const{return(m_stFlahColor);} 26 | 27 | /** 28 | * @brief 设置闪烁频率 29 | * @param nHZ > 60 将不再增加 nHZ <=0 将保持FlashColor不变即实现变色功能 30 | */ 31 | void SetFlashFreq(int nHZ)JUDGE_EQUAL_CALL_FUNCTION(nHZ,m_nFlashHZ,FlashStatusChanged) 32 | int GetFlashFreq(){return(m_nFlashHZ);} 33 | 34 | /** 35 | * @brief 是否开始闪烁 36 | */ 37 | void SetFlash(bool bFlash)JUDGE_EQUAL_CALL_FUNCTION(bFlash,m_bFlash,FlashFlashChanged) 38 | bool IsFlash(){return(m_bFlash);} 39 | protected: 40 | virtual ~IFlashAbility(){} 41 | 42 | virtual void FlashStatusChanged()=0; 43 | virtual void FlashColorChanged()=0; 44 | virtual void FlashFlashChanged()=0; 45 | protected: 46 | bool m_bFlash{true}; 47 | SceneColor m_stFlahColor; 48 | int m_nFlashHZ{1}; 49 | }; 50 | 51 | #endif //INTERFACE_FLASH_ABILITY_HEARDER_H 52 | -------------------------------------------------------------------------------- /Inc/Ability/IFlatAbility.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_FLAT_ABILITY_HEARDER_H 2 | #define INTERFACE_FLAT_ABILITY_HEARDER_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 平整的区域 9 | */ 10 | struct FlatArea 11 | { 12 | ScenePos stLeftUp; /// 左上角的位置 13 | ScenePos stRightUp; /// 右上角的位置 14 | ScenePos stRightDown; /// 右下角的位置 15 | ScenePos stLeftDown; /// 左下角的位置 16 | bool operator == (const FlatArea& rOther) const 17 | { 18 | if(&rOther == this) 19 | { 20 | return(true); 21 | } 22 | 23 | return(rOther.stLeftUp == stLeftUp 24 | && rOther.stRightUp == stRightUp 25 | && rOther.stRightDown == stRightDown 26 | && rOther.stLeftDown == stLeftDown); 27 | } 28 | }; 29 | 30 | /** 31 | * @brief 场景节点类 32 | */ 33 | class IFlatAbility:public INodeAbility 34 | { 35 | public: 36 | 37 | /** 38 | * @brief 转换成本类型 39 | * @return 40 | */ 41 | IFlatAbility* AsFlatAbility(){return(this);} 42 | 43 | /** 44 | * @brief 添加洞 45 | * @return 洞的索引 46 | */ 47 | virtual int AddHole(const FlatArea& flatArea)=0; 48 | 49 | /** 50 | * @brief 删除洞 51 | * @return 52 | */ 53 | virtual bool RemoveHole(int nIndex)=0; 54 | protected: 55 | virtual ~IFlatAbility(){} 56 | }; 57 | 58 | #endif //INTERFACE_FLAT_ABILITY_HEARDER_H 59 | -------------------------------------------------------------------------------- /Inc/ExternShape/ExternShape_Global.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTERNMAPSHAPE_GLOBAL_H 2 | #define EXTERNMAPSHAPE_GLOBAL_H 3 | #include 4 | 5 | #if defined(EXTERNMAPSHAPE_LIBRARY) 6 | # define OSGEXTERNSHARED_EXPORT Q_DECL_EXPORT 7 | #else 8 | # define OSGEXTERNSHARED_EXPORT Q_DECL_IMPORT 9 | #endif 10 | #endif // EXTERNMAPSHAPE_GLOBAL_H 11 | -------------------------------------------------------------------------------- /Inc/ExternShape/MapArc.h: -------------------------------------------------------------------------------- 1 | #ifndef MAPARC_H 2 | #define MAPARC_H 3 | 4 | #include 5 | #include 6 | 7 | class OSGEXTERNSHARED_EXPORT CMapArc 8 | { 9 | public: 10 | CMapArc(ISceneGraph* pSceneGraph); 11 | 12 | /** 13 | * @brief 设置圆心 14 | * @param rLeftUp 15 | */ 16 | void SetCenter(const ScenePos& pos); 17 | 18 | /** 19 | * @brief 设置半径 20 | */ 21 | void SetRadius(const float&); 22 | /** 23 | * @brief 设置颜色 24 | */ 25 | void SetColor(const SceneColor& color); 26 | 27 | /** 28 | * @brief 设置细度 29 | */ 30 | void SetFineness(int); 31 | 32 | /** 33 | * @brief 设置开始和结束角度 34 | */ 35 | void SetAngle(double dStartAngle, double dEndAngle); 36 | /** 37 | * @brief 获取地图节点 38 | * @return 39 | */ 40 | IMapLine* GetMapSceneNode(){return(m_pMapLine);} 41 | protected: 42 | /** 43 | * @brief 初始化节点 44 | */ 45 | void InitNode(); 46 | 47 | /** 48 | * @brief 更新节点 49 | */ 50 | void UpdateNode(); 51 | protected: 52 | ScenePos m_stCenter; 53 | ISceneGraph* m_pSceneGraph{}; 54 | IMapLine* m_pMapLine{}; 55 | 56 | float m_fRadius{}; 57 | double m_dStartAngle; 58 | double m_dEndAngle; 59 | int m_nFineness{72}; 60 | }; 61 | 62 | #endif // MAPARC_H 63 | -------------------------------------------------------------------------------- /Inc/ExternShape/MapCircle.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAPCIRCLE_H 2 | #define CMAPCIRCLE_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief 在地图上绘制矩形 8 | */ 9 | class OSGEXTERNSHARED_EXPORT CMapCircle 10 | { 11 | public: 12 | CMapCircle(ISceneGraph* pSceneGraph); 13 | 14 | /** 15 | * @brief 设置圆心 16 | * @param rLeftUp 17 | */ 18 | void SetCenter(const ScenePos& pos); 19 | 20 | /** 21 | * @brief 设置半径 22 | */ 23 | void SetRadius(const float&); 24 | /** 25 | * @brief 设置颜色 26 | */ 27 | void SetColor(const SceneColor& color); 28 | 29 | /** 30 | * @brief 设置细度 31 | */ 32 | void SetFineness(int); 33 | /** 34 | * @brief 获取地图节点 35 | * @return 36 | */ 37 | IMapPolygon* GetMapSceneNode(){return(m_pPolygon);} 38 | protected: 39 | /** 40 | * @brief 初始化节点 41 | */ 42 | void InitNode(); 43 | 44 | /** 45 | * @brief 更新节点 46 | */ 47 | void UpdateNode(); 48 | protected: 49 | ScenePos m_stCenter; 50 | ISceneGraph* m_pSceneGraph{}; 51 | IMapPolygon* m_pPolygon{}; 52 | 53 | float m_fRadius{}; 54 | int m_nFineness{36}; 55 | }; 56 | 57 | #endif // CMAPCIRCLE_H 58 | -------------------------------------------------------------------------------- /Inc/ExternShape/MapExternLine.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAP_EXTERN_LINE_H 2 | #define CMAP_EXTERN_LINE_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief 在地图上绘制矩形 8 | */ 9 | class OSGEXTERNSHARED_EXPORT CMapExternLine 10 | { 11 | public: 12 | CMapExternLine(ISceneGraph* pSceneGraph); 13 | IMapSceneNode* getNode(){return m_pMapLine;} 14 | bool AddPoint(int,const ScenePos&); 15 | bool UpdatePoint(int,const ScenePos&); 16 | bool DelPoint(int); 17 | ScenePos GetPoint(int); 18 | void SetMultPos(const std::vector&); 19 | void SetTerrainType(IMapSceneNode::MAP_TERRAIN); 20 | void SetColor(SceneColor color); 21 | void SetLineWidth(float); 22 | void SetVisible(bool); 23 | /** 24 | * @brief 设置细分参数 25 | * @param dTessellation [m] 26 | * @return 27 | */ 28 | void SetTessellation(double dTessellation)JUDGE_DOUBLE_CALL_FUNCTION(dTessellation,m_dTessellation,PointUpdate) 29 | double Tessellation(){return(m_dTessellation);} 30 | 31 | /** 32 | * @brief 强制更新 33 | */ 34 | void Update(); 35 | protected: 36 | /** 37 | * @brief 点更新 38 | */ 39 | void PointUpdate(); 40 | protected: 41 | ISceneGraph* m_pSceneGraph{}; 42 | IMapLine* m_pMapLine{}; 43 | double m_dTessellation{300.}; 44 | IMapSceneNode::MAP_TERRAIN mTerrainType; 45 | std::vector m_listAllPos; 46 | std::vector m_listVirtualPos; 47 | }; 48 | 49 | #endif // CMAP_EXTERN_LINE_H 50 | -------------------------------------------------------------------------------- /Inc/ExternShape/MapRectange.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAPRECTANGE_H 2 | #define CMAPRECTANGE_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief 在地图上绘制矩形 8 | */ 9 | class OSGEXTERNSHARED_EXPORT CMapRectange 10 | { 11 | public: 12 | CMapRectange(ISceneGraph* pSceneGraph); 13 | 14 | /** 15 | * @brief 设置点1 16 | * @param rLeftUp 17 | */ 18 | void SetPos1(const ScenePos& pos); 19 | 20 | /** 21 | * @brief 设置点2 22 | * 根据点1、点2的位置关系,自动计算其余两点位置 23 | */ 24 | void SetPos2(const ScenePos &pos); 25 | /** 26 | * @brief 设置颜色 27 | */ 28 | void SetColor(const SceneColor& color); 29 | /** 30 | * @brief 获取地图节点 31 | * @return 32 | */ 33 | IMapPolygon* GetMapSceneNode(){return(m_pPolygon);} 34 | protected: 35 | /** 36 | * @brief 初始化节点 37 | */ 38 | void InitNode(); 39 | 40 | /** 41 | * @brief 更新节点 42 | */ 43 | void UpdateNode(); 44 | protected: 45 | ScenePos m_stPos1; 46 | ScenePos m_stPos2; 47 | ISceneGraph* m_pSceneGraph{}; 48 | IMapPolygon* m_pPolygon{}; 49 | }; 50 | 51 | #endif // CMAPRECTANGE_H 52 | -------------------------------------------------------------------------------- /Inc/Hud/HudType.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_HUD_TYPE_HEARDER_H 2 | #define INTERFACE_HUD_TYPE_HEARDER_H 3 | 4 | enum HUD_POS_TYPE 5 | { 6 | HUD_FIXED, /// 固定位置 7 | HUD_UP_CENTER, /// 上部居中 8 | HUD_RIGHT_CENTER,///右边居中 9 | HUD_LEFT_CENTER,///左边居中 10 | HUD_UP_RIGHT, /// 右上角 11 | HUD_DOWN_LEFT, /// 左下角 12 | HUD_DOWN_RIGHT,/// 右下角 13 | HUD_UP_LEFT, /// 左上角 14 | HUD_DOWN_CENTER,/// 下部居中 15 | HUD_CENTER_CENTER/// 屏幕中间 16 | }; 17 | 18 | /** 19 | * @brief 屏幕坐标 20 | */ 21 | struct HudPos 22 | { 23 | unsigned short nX{}; /// 屏幕X轴坐标 24 | unsigned short nY{}; /// 屏幕Y轴坐标 25 | 26 | bool operator == (const HudPos& rOther)const 27 | { 28 | if(&rOther == this) 29 | { 30 | return(true); 31 | } 32 | 33 | return(nX == rOther.nX && nY == rOther.nY); 34 | } 35 | 36 | bool operator!=(const HudPos& rOther)const 37 | { 38 | return(!(this->operator==(rOther))); 39 | } 40 | }; 41 | 42 | #endif///INTERFACE_HUD_TYPE_HEARDER_H 43 | -------------------------------------------------------------------------------- /Inc/Hud/IHudNode.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_HUD_NODE_HEARDER_H 2 | #define INTERFACE_HUD_NODE_HEARDER_H 3 | #include 4 | #include 5 | /** 6 | * @brief 视口的屏显类 7 | */ 8 | class IHudNode:public ISceneNode 9 | { 10 | public: 11 | CONSTRUCTOR(IHudNode,ISceneNode) 12 | 13 | /** 14 | * @brief 设置节点在屏幕上的位置 15 | * @return 16 | */ 17 | void SetHudPos(const HudPos& rHudPos)JUDGE_EQUAL_CALL_FUNCTION(rHudPos,m_stHudPos,HudPosChanged) 18 | const HudPos& GetHudPos(){return(m_stHudPos);} 19 | 20 | /** 21 | * @brief 设置节点在屏幕位置的类型 22 | * @return 23 | */ 24 | void SetPosType(HUD_POS_TYPE type)JUDGE_EQUAL_CALL_FUNCTION(type,m_emHudPosType,HudTypeChanged) 25 | const HUD_POS_TYPE PosType()const{return(m_emHudPosType);} 26 | 27 | virtual void HudTypeChanged()=0; 28 | protected: 29 | virtual ~IHudNode(){} 30 | virtual void HudPosChanged()=0; 31 | 32 | protected: 33 | HudPos m_stHudPos; 34 | HUD_POS_TYPE m_emHudPosType{HUD_DOWN_LEFT}; 35 | }; 36 | 37 | #endif /// INTERFACE_HUD_NODE_HEARDER_H 38 | -------------------------------------------------------------------------------- /Inc/Hud/IViewHud.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_VIEW_HUD_HEARDER_H 2 | #define INTERFACE_VIEW_HUD_HEARDER_H 3 | 4 | #include 5 | /** 6 | * @brief 视口的屏显类 7 | */ 8 | class IViewHud:public ISceneNode 9 | { 10 | public: 11 | CONSTRUCTOR(IViewHud,ISceneNode) 12 | 13 | /** 14 | * @brief 添加屏显节点 15 | */ 16 | virtual bool AddHudNode(IHudNode* pHudNode)=0; 17 | 18 | /** 19 | * @brief 移除屏显节点 20 | */ 21 | virtual bool RemoveHudNode(IHudNode* pHudNode)=0; 22 | 23 | /** 24 | * @brief 清空所有的节点 25 | */ 26 | virtual void Clear()=0; 27 | /** 28 | * @brief 当前是否有选中hud节点 29 | */ 30 | virtual bool CurrentHaveSelect()=0; 31 | /** 32 | * @brief 当前是否有选中hud节点 33 | */ 34 | virtual void SetCurrentHaveSelect(bool valb)=0; 35 | protected: 36 | virtual ~IViewHud(){} 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Inc/ISceneCore.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_CORE_H 2 | #define INTERFACE_SCENE_CORE_H 3 | 4 | #include 5 | #include 6 | 7 | #ifdef Q_OS_WIN 8 | #ifdef QT_NO_DEBUG 9 | static const char s_sSuffix[]=".dll"; 10 | #else 11 | static const char s_sSuffix[]="d.dll"; 12 | #endif 13 | #else 14 | #ifdef QT_NO_DEBUG 15 | static const char s_sSuffix[]=".so"; 16 | #else 17 | static const char s_sSuffix[]="d.so"; 18 | #endif 19 | #endif 20 | 21 | struct ISceneCore 22 | { 23 | virtual ~ISceneCore(){} 24 | 25 | /** 26 | * @brief 获取窗口管理类 27 | * @return 28 | */ 29 | virtual ISceneGraphManager* GetSceneGraphManager()=0; 30 | 31 | }; 32 | 33 | extern "C" 34 | { 35 | /** 36 | * @brief 获取渲染场景核心库 37 | * @return 38 | */ 39 | SCENECORESHARED_EXPORT ISceneCore* GetSceneCore(); 40 | 41 | /** 42 | * @brief 移除渲染场景核心库 43 | */ 44 | SCENECORESHARED_EXPORT void CloseSceneCore(); 45 | 46 | /** 47 | * @brief 检查电脑配置是否支持 48 | * @param argv 为mian函数中第二个参数 49 | * @return 50 | */ 51 | SCENECORESHARED_EXPORT bool CheckPC(char *argv[]); 52 | 53 | /** 54 | * @brief 将路径转成utf-8编码的字符串 55 | * @param sPath 指定路径 56 | * @return 57 | */ 58 | SCENECORESHARED_EXPORT std::string Convert2Utf8(const std::string& sPath); 59 | 60 | /** 61 | * @brief 将路径统一成本地编码 62 | * @param sPath 指定路径 63 | * @return 64 | */ 65 | SCENECORESHARED_EXPORT std::string Convert2Local(const std::string& sPath); 66 | 67 | #ifdef NEED_VR 68 | /** 69 | * @brief 检查电脑是否连接VR设备 70 | * @return 71 | */ 72 | SCENECORESHARED_EXPORT bool CheckVR(); 73 | #endif 74 | 75 | 76 | /** 77 | * @brief 获取exe运行路径 78 | * @return 79 | */ 80 | SCENECORESHARED_EXPORT const std::string& GetExePath(); 81 | 82 | /** 83 | * @brief 获取资源所在路径 84 | * @return 85 | */ 86 | SCENECORESHARED_EXPORT const std::string& GetDataPath(); 87 | } 88 | #endif // ISCENCECORE_H 89 | -------------------------------------------------------------------------------- /Inc/Inner/Common/ImplSceneCameraGroup.hpp: -------------------------------------------------------------------------------- 1 | #ifndef IMPL_SCENE_CAMERA_GROUP_H 2 | #define IMPL_SCENE_CAMERA_GROUP_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * 实现ISceneCameraGroup的接口 9 | */ 10 | template 11 | class ImplSceneCameraGroup:public ImplSceneGroup 12 | { 13 | public: 14 | CONSTRUCTOR(ImplSceneCameraGroup,ImplSceneGroup) 15 | 16 | protected: 17 | void InitNode() 18 | { 19 | ImplSceneNode::InitNode(); 20 | m_pCamera = new osg::Camera; 21 | m_pCamera->setRenderOrder( osg::Camera::NESTED_RENDER ); 22 | m_pCamera->setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); 23 | ImplSceneGroup::SetGroupNode(m_pCamera.get()); 24 | } 25 | 26 | void FrameCall() 27 | { 28 | if(m_bIndexChanged) 29 | { 30 | m_pCamera->getOrCreateStateSet()->setRenderBinDetails(T::m_nIndex, "RenderBin" ); 31 | m_bIndexChanged=false; 32 | } 33 | 34 | ImplSceneGroup::FrameCall(); 35 | } 36 | 37 | void RenderIndexChanged()SET_TRUE_NODE_UPDATE(m_bIndexChanged) 38 | protected: 39 | osg::observer_ptr m_pCamera; 40 | bool m_bIndexChanged{false}; 41 | }; 42 | 43 | #endif // IMPL_SCENE_GROUP_H 44 | -------------------------------------------------------------------------------- /Inc/Inner/Common/ImplSceneScreenGroup.hpp: -------------------------------------------------------------------------------- 1 | #ifndef IMPL_SCENE_SCREEN_GROUP_H 2 | #define IMPL_SCENE_SCREEN_GROUP_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * 实现ISceneScreenGroup的接口 9 | */ 10 | template 11 | class ImplSceneScreenGroup:public ImplSceneGroup 12 | { 13 | public: 14 | CONSTRUCTOR(ImplSceneScreenGroup,ImplSceneGroup) 15 | 16 | protected: 17 | 18 | /** 19 | * @brief 初始化场景节点 20 | */ 21 | void InitNode() 22 | { 23 | if(!s_pStateSet.valid()) 24 | { 25 | s_pStateSet = new osg::StateSet; 26 | osgEarth::ScreenSpaceLayout::activate(s_pStateSet); 27 | } 28 | 29 | T::m_bOpenCull=false; 30 | ImplSceneGroup::InitNode(); 31 | ImplSceneGroup::m_pGroup->setStateSet(s_pStateSet); 32 | osgEarth::ScreenSpaceLayout::setDeclutteringEnabled(false); 33 | auto options = osgEarth::ScreenSpaceLayout::getOptions(); 34 | options.technique() = options.TECHNIQUE_CALLOUTS; 35 | osgEarth::ScreenSpaceLayout::setOptions(options); 36 | IOsgSceneNode::m_pRootNode->setCullingActive(false); 37 | } 38 | 39 | void AvoidChanged() 40 | { 41 | if(T::m_bAvoid) 42 | { 43 | osgEarth::ScreenSpaceLayout::setDeclutteringEnabled(true); 44 | } 45 | else 46 | { 47 | osgEarth::ScreenSpaceLayout::setDeclutteringEnabled(false); 48 | } 49 | } 50 | static osg::ref_ptr s_pStateSet; 51 | }; 52 | 53 | template 54 | osg::ref_ptr ImplSceneScreenGroup::s_pStateSet; 55 | #endif // IMPL_SCENE_FLASH_GROUP_H 56 | -------------------------------------------------------------------------------- /Inc/Inner/IOsgViewPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_OSG_VIEW_Point_H 2 | #define INTERFACE_OSG_VIEW_Point_H 3 | 4 | #include 5 | #include 6 | class IOsgViewPoint 7 | { 8 | public: 9 | /// 设置视点状态 10 | enum ViewPointType 11 | { 12 | View_2DMap, /// 二维查看 13 | View_3DMap, /// 三维查看 14 | View_Osg, /// 不使用地图的时候的操作器 15 | View_User, /// 用户查看 16 | View_Node /// 跟踪节点 17 | }; 18 | 19 | virtual ~IOsgViewPoint(){} 20 | 21 | /** 22 | * @brief 地图类型切换 23 | * @param emType 24 | */ 25 | virtual void ViewPointTypeChanged(ViewPointType emType){} 26 | 27 | /** 28 | * @brief 锁定视角 29 | */ 30 | virtual void SetLockView(bool){}; 31 | 32 | /** 33 | * @brief 获取osgView 34 | * @return 35 | */ 36 | virtual osgViewer::View* GetOsgView()=0; 37 | }; 38 | #endif 39 | -------------------------------------------------------------------------------- /Inc/Inner/IRender.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_HEADER_SCENERENDER_H 2 | #define INCLUDE_HEADER_SCENERENDER_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 每次渲染调用的回调 9 | */ 10 | struct RenderCall 11 | { 12 | bool m_bCallOne{true}; 13 | /** 14 | * @brief 每帧调用一次 15 | */ 16 | virtual void FrameCall(){} 17 | }; 18 | 19 | /** 20 | * @brief 仿真运行控制器 21 | */ 22 | class IRender 23 | { 24 | public: 25 | 26 | /** 27 | * @brief 添加更新操作 28 | * @param pUpdate 29 | */ 30 | virtual void AddUpdateOperation(osg::Operation*)=0; 31 | 32 | /** 33 | * @brief 重建线程 34 | * @attention 只有当增加删除视口的才需要调用此方法 35 | */ 36 | virtual void ResetupThread()=0; 37 | 38 | /** 39 | * @brief 订阅消息 40 | */ 41 | virtual void SubMessage(RenderCall*)=0; 42 | 43 | /** 44 | * @brief 更新所有的渲染消息 45 | */ 46 | virtual void UpdateRender()=0; 47 | protected: 48 | virtual ~IRender(){} 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Inc/Inner/OsgExtern/Grid2TriangleStrip.h: -------------------------------------------------------------------------------- 1 | #ifndef CGRID2TRIANGLESTRIP_H 2 | #define CGRID2TRIANGLESTRIP_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 本类的主要作用是将设定的网格 9 | * 化成 TRIANGLE_STRIP 的顶点索引 10 | */ 11 | class OSGEXTERNSHARED_EXPORT CGrid2TriangleStrip 12 | { 13 | public: 14 | /** 15 | * @brief 默认构造函数 16 | * @param unRow 行数 (左右 方向为行) 17 | * @param unLine 列数 (上下 方向为列) 18 | * @param bCloseure 行的最后是否闭合 19 | */ 20 | CGrid2TriangleStrip(unsigned int unRow=0, unsigned int unLine=0,bool bCloseure=false); 21 | 22 | /** 23 | * @brief 设置行的收尾是否闭合 24 | * @param bClosure 25 | */ 26 | void SetClosure(bool bClosure); 27 | bool GetClosure(){return(m_bClosure);} 28 | 29 | /** 30 | * @brief 设置行列 31 | * @param nRow 行数 32 | * @param nLine 列数 33 | */ 34 | void SetRowAndLine(unsigned int unRow, unsigned int unLine); 35 | 36 | /** 37 | * @brief 获取索引数组 38 | * @return 39 | */ 40 | const osg::MixinVector& GetIndex(){return(m_vIndex);} 41 | 42 | private: 43 | /** 44 | * @brief 生成索引 45 | */ 46 | void GenerateIndex(); 47 | private: 48 | unsigned int m_unRowCount{}; /// 行数 49 | unsigned int m_unLineCount{}; /// 列数 50 | bool m_bClosure{false}; /// 设置收尾是否闭合 51 | osg::MixinVector m_vIndex; /// 所有的顶点索引的集合 52 | }; 53 | 54 | #endif // CGRID2TRIANGLESTRIP_H 55 | -------------------------------------------------------------------------------- /Inc/Inner/OsgExtern/JudgeGeometry.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_JUDGE_GEOMETRY_H 2 | #define INCLUDE_JUDGE_GEOMETRY_H 3 | 4 | #include 5 | #include 6 | 7 | class OSGEXTERNSHARED_EXPORT CJudgeGeometry:public osg::Drawable::DrawCallback 8 | { 9 | public: 10 | CJudgeGeometry(std::string sName):m_sName(sName){} 11 | 12 | /** 13 | * @brief 重写父类的函数 14 | */ 15 | void drawImplementation(osg::RenderInfo& renderInfo,const osg::Drawable* drawable) const; 16 | private: 17 | std::string m_sName; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Inc/Inner/OsgExtern/MathCommon.h: -------------------------------------------------------------------------------- 1 | #ifndef H_HEADER_MATHCOMMON_H 2 | #define H_HEADER_MATHCOMMON_H 3 | 4 | #include 5 | 6 | class OSGEXTERNSHARED_EXPORT CMathCommon 7 | { 8 | public: 9 | 10 | static CMathCommon* GetInstance(); 11 | /** 12 | * @brief 获取sin值 13 | * @return 14 | */ 15 | const double* GetSin(); 16 | 17 | /** 18 | * @brief 获取cos值 19 | * @return 20 | */ 21 | const double* GetCos(); 22 | private: 23 | CMathCommon(); 24 | ~CMathCommon(); 25 | 26 | /** 27 | * @brief 初始化数据 28 | */ 29 | void Init(); 30 | 31 | private: 32 | double* m_pSin{}; /// sin值 33 | double* m_pCos{}; /// cos值 34 | bool m_bInit{false}; /// 是否初始化 35 | }; 36 | 37 | #endif // SNGEOMATHCOMMON_H 38 | -------------------------------------------------------------------------------- /Inc/Inner/OsgExtern/MyMatrixTransform.h: -------------------------------------------------------------------------------- 1 | #ifndef CMYMATRIXTRANSFORM_H 2 | #define CMYMATRIXTRANSFORM_H 3 | #include 4 | #include 5 | #include 6 | class OSGEXTERNSHARED_EXPORT CMyMatrixTransform:public osg::MatrixTransform 7 | { 8 | public: 9 | CMyMatrixTransform(); 10 | 11 | /** 12 | * @brief 设置姿态矩阵 13 | * @param rMatrix 14 | */ 15 | void SetMatrix(const Math::CMatrix& rMatrix); 16 | 17 | /** 18 | * @brief 重写虚函数 19 | */ 20 | virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const; 21 | virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix, osg::NodeVisitor*nv) const; 22 | }; 23 | 24 | #endif // CMYMATRIXTRANSFORM_H 25 | -------------------------------------------------------------------------------- /Inc/Inner/OsgExtern/MyPositionAttitudeTransform.h: -------------------------------------------------------------------------------- 1 | #ifndef H_MY_POSITION_ATTITUDE_TRANSFORM_HEADER_H 2 | #define H_MY_POSITION_ATTITUDE_TRANSFORM_HEADER_H 3 | #include 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 自定义平移旋转节点 9 | */ 10 | class OSGEXTERNSHARED_EXPORT CMyPositionAttitudeTransform:public osg::PositionAttitudeTransform 11 | { 12 | public: 13 | CMyPositionAttitudeTransform(); 14 | 15 | /** 16 | * @brief设置旋转矩阵 17 | */ 18 | void SetRotateMatrix(const osg::Matrix&); 19 | void SetRotateMatrix(const Math::CMatrix& rRotate); 20 | const osg::Matrix& RotateMatrix()const{return(m_matRotate);} 21 | 22 | /** 23 | * @brief 重写父类方法 24 | * @param matrix 25 | * @return 26 | */ 27 | bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const; 28 | bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const; 29 | 30 | protected: 31 | ~CMyPositionAttitudeTransform(){} 32 | 33 | /** 34 | * @brief 提前判断,减少矩阵运算 35 | * @return 36 | */ 37 | bool IsTransform() const; 38 | bool IsScale()const; 39 | bool IsPovi()const; 40 | private: 41 | osg::Matrix m_matRotate; 42 | }; 43 | 44 | #endif // MAP_GLOBAL_H 45 | -------------------------------------------------------------------------------- /Inc/Inner/OsgExtern/NodeAbilityManager.h: -------------------------------------------------------------------------------- 1 | #ifndef SPLITRECTANGLE_HEADER_H 2 | #define SPLITRECTANGLE_HEADER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /** 9 | * @brief将矩形划分成点序列 10 | */ 11 | class OSGEXTERNSHARED_EXPORT CNodeAbilityManager 12 | { 13 | public: 14 | static CNodeAbilityManager* GetInstance(); 15 | 16 | /** 17 | * @brief 根据类型创建能力 18 | * @param emType 能力类型 19 | * @return 能力值 20 | */ 21 | INodeAbility* CreateAbility(ABILITY_TYPE emType); 22 | 23 | /** 24 | * @brief 删除能力 25 | * @param 能力指针 26 | * @return 27 | */ 28 | bool RemoveAbility(INodeAbility*& pNodeAbility); 29 | protected: 30 | CNodeAbilityManager(){} 31 | }; 32 | 33 | #endif // SPLITRECTANGLE_HEADER_H 34 | -------------------------------------------------------------------------------- /Inc/Inner/OsgExtern/OsgExtern_Global.h: -------------------------------------------------------------------------------- 1 | #ifndef OSGEXTERN_GLOBAL_HEADER_H 2 | #define OSGEXTERN_GLOBAL_HEADER_H 3 | 4 | #include 5 | 6 | #if defined(OSGEXTERN_LIBRARY) 7 | # define OSGEXTERNSHARED_EXPORT Q_DECL_EXPORT 8 | #else 9 | # define OSGEXTERNSHARED_EXPORT Q_DECL_IMPORT 10 | #endif 11 | 12 | #endif // OSGEXTERN_GLOBAL_HEADER_H 13 | -------------------------------------------------------------------------------- /Inc/Inner/OsgExtern/SplitRectangle.h: -------------------------------------------------------------------------------- 1 | #ifndef SPLITRECTANGLE_HEADER_H 2 | #define SPLITRECTANGLE_HEADER_H 3 | 4 | #include 5 | 6 | struct RectanglePos 7 | { 8 | double dLon; 9 | double dLat; 10 | }; 11 | 12 | struct Rectangle 13 | { 14 | RectanglePos LeftUp; 15 | RectanglePos RightDown; 16 | }; 17 | 18 | /** 19 | * @brief将矩形划分成点序列 20 | */ 21 | class OSGEXTERNSHARED_EXPORT CSplitRectangle 22 | { 23 | public: 24 | CSplitRectangle(); 25 | 26 | /** 27 | * @brief 设置矩形 28 | * @param rRectangle 29 | */ 30 | void SetRectangle(const Rectangle& rRectangle); 31 | 32 | void SetGis(); 33 | protected: 34 | void ReCal(); 35 | protected: 36 | Rectangle m_stRectangle; 37 | }; 38 | 39 | #endif // SPLITRECTANGLE_HEADER_H 40 | -------------------------------------------------------------------------------- /Inc/Inner/ThreadSafety/SafetyMap.h: -------------------------------------------------------------------------------- 1 | #ifndef SAFETY_MAP_HEADER_H 2 | #define SAFETY_MAP_HEADER_H 3 | 4 | #endif SAFETY_MAP_HEADER_H 5 | -------------------------------------------------------------------------------- /Inc/Inner/ThreadSafety/SafetyQueue.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MJYCo-Ltd/Map/a95d6225cc08beffab6b609325610c3edfc129b6/Inc/Inner/ThreadSafety/SafetyQueue.h -------------------------------------------------------------------------------- /Inc/Inner/ThreadSafety/SafetyStack.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MJYCo-Ltd/Map/a95d6225cc08beffab6b609325610c3edfc129b6/Inc/Inner/ThreadSafety/SafetyStack.h -------------------------------------------------------------------------------- /Inc/Inner/ThreadSafety/SafetyUniqueList.h: -------------------------------------------------------------------------------- 1 | #ifndef SAFETY_LIST_HEADER_H 2 | #define SAFETY_LIST_HEADER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | template 11 | class CSafetyUniqueList 12 | { 13 | public: 14 | /** 15 | * @brief 放入数据 16 | * @param crT 17 | */ 18 | void Add(const T& crT) 19 | { 20 | OpenThreads::ScopedLock lock(m_listMutex); 21 | if(m_setUnique.end() == m_setUnique.find(crT)) 22 | { 23 | m_setUnique.insert(crT); 24 | m_listData.push_back(crT); 25 | } 26 | } 27 | 28 | /** 29 | * @brief 获取所有的值 30 | * @param rAll 31 | * @return 32 | */ 33 | void Get(std::vector& rAll) const 34 | { 35 | OpenThreads::ScopedLock lock(m_listMutex); 36 | rAll.reserve(m_listData.size()); 37 | 38 | for(auto one : m_listData) 39 | { 40 | rAll.push_back(one); 41 | } 42 | } 43 | 44 | /** 45 | * @brief 清空所有的 46 | */ 47 | void Clear() 48 | { 49 | OpenThreads::ScopedLock lock(m_listMutex); 50 | m_setUnique.clear(); 51 | m_listData.clear(); 52 | } 53 | private: 54 | std::list m_listData; 55 | std::unordered_set m_setUnique; 56 | mutable OpenThreads::Mutex m_listMutex; 57 | }; 58 | 59 | #endif //SAFETY_LIST_HEADER_H 60 | -------------------------------------------------------------------------------- /Inc/Inner/ThreadSafety/SafetyVector.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MJYCo-Ltd/Map/a95d6225cc08beffab6b609325610c3edfc129b6/Inc/Inner/ThreadSafety/SafetyVector.h -------------------------------------------------------------------------------- /Inc/NoQt.h: -------------------------------------------------------------------------------- 1 | #ifndef NO_QT_HEADER_INCLUDE_H 2 | #define NO_QT_HEADER_INCLUDE_H 3 | 4 | #if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 5 | # define Q_DECL_EXPORT __declspec(dllexport) 6 | # define Q_DECL_IMPORT __declspec(dllimport) 7 | #else 8 | # define Q_DECL_EXPORT __attribute__((visibility("default"))) 9 | # define Q_DECL_IMPORT __attribute__((visibility("default"))) 10 | #endif 11 | 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /Inc/Plot/Common/ISceneAttitudeGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_ATTITUDE_GROUP_HEARDER_H 2 | #define INTERFACE_SCENE_ATTITUDE_GROUP_HEARDER_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief 场景节点类 8 | */ 9 | class ISceneAttitudeGroup:public ISceneGroup 10 | { 11 | public: 12 | CONSTRUCTOR(ISceneAttitudeGroup,ISceneGroup) 13 | 14 | ISceneAttitudeGroup* AsSceneAttitudeGroup(){return(this);} 15 | 16 | /** 17 | * @brief 设置场景节点的位置 18 | */ 19 | void SetPos(const ScenePos& rPos)JUDGE_EQUAL_CALL_FUNCTION(rPos,m_stPos,PosChanged) 20 | const ScenePos& GetPos() const{return(m_stPos);} 21 | 22 | /** 23 | * @brief 设置姿态 24 | */ 25 | void SetAttitude(const SceneAttitude& rAttitude)JUDGE_EQUAL_CALL_FUNCTION(rAttitude,m_stAttitude,AttitudeChanged) 26 | void SetAttitude(const Math::CMatrix& rMatrix)JUDGE_EQUAL_CALL_FUNCTION(rMatrix,m_matAttitude,AttitudeMatrixChanged) 27 | const Math::CMatrix& Attitude()const{return(m_matAttitude);} 28 | 29 | /** 30 | * @brief 设置旋转依赖的中心点 31 | * @attention 例如人的手是相对于肘关节进行 32 | 旋转,而不是手腕 33 | */ 34 | void SetPivotPos(const ScenePos& rPivotPos)JUDGE_EQUAL_CALL_FUNCTION(rPivotPos,m_stPivot,PivotPosChanged) 35 | const ScenePos& PivotPos() const{return(m_stPivot);} 36 | protected: 37 | virtual ~ISceneAttitudeGroup(){} 38 | 39 | virtual void PosChanged()=0; 40 | virtual void AttitudeChanged()=0; 41 | virtual void AttitudeMatrixChanged()=0; 42 | virtual void PivotPosChanged()=0; 43 | protected: 44 | Math::CMatrix m_matAttitude; 45 | ScenePos m_stPos; 46 | ScenePos m_stPivot; 47 | SceneAttitude m_stAttitude; 48 | }; 49 | 50 | #endif // INTERFACE_SCENE_ATTITUDE_GROUP_HEARDER_H 51 | -------------------------------------------------------------------------------- /Inc/Plot/Common/ISceneCameraGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_CAMERA_GROUP_HEARDER_H 2 | #define INTERFACE_SCENE_CAMERA_GROUP_HEARDER_H 3 | 4 | #include 5 | /** 6 | * @brief 自动计算远近裁剪面的节点 7 | */ 8 | class ISceneCameraGroup:public ISceneGroup 9 | { 10 | public: 11 | CONSTRUCTOR(ISceneCameraGroup,ISceneGroup) 12 | 13 | void SetRenderIndex(int nIndex)JUDGE_EQUAL_CALL_FUNCTION(nIndex,m_nIndex,RenderIndexChanged) 14 | /** 15 | * @brief 转换成缩放节点 16 | * @return 17 | */ 18 | ISceneCameraGroup* AsSceneCameraGroup(){return(this);} 19 | 20 | protected: 21 | virtual ~ISceneCameraGroup(){} 22 | virtual void RenderIndexChanged()=0; 23 | 24 | protected: 25 | int m_nIndex{}; 26 | }; 27 | 28 | #endif//INTERFACE_SCENE_CAMERA_GROUP_HEARDER_H 29 | -------------------------------------------------------------------------------- /Inc/Plot/Common/ISceneFlashGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_FLASH_GROUP_HEARDER_H 2 | #define INTERFACE_SCENE_FLASH_GROUP_HEARDER_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief 场景节点类 8 | */ 9 | class ISceneFlashGroup:public ISceneGroup 10 | { 11 | public: 12 | CONSTRUCTOR(ISceneFlashGroup,ISceneGroup) 13 | 14 | /** 15 | * @brief 转换成本类型 16 | * @return 17 | */ 18 | ISceneFlashGroup* AsSceneFlashGroup(){return(this);} 19 | 20 | /** 21 | * @brief 设置闪烁颜色 22 | * @param rColor 23 | */ 24 | void SetFlashColor(const SceneColor& rColor)JUDGE_EQUAL_CALL_FUNCTION(rColor,m_stFlahColor,FlashColorChanged) 25 | const SceneColor& GetFlashColor()const{return(m_stFlahColor);} 26 | 27 | /** 28 | * @brief 设置闪烁频率 29 | * @param nHZ 30 | */ 31 | void SetFlashFreq(float fHZ){if(fHZ > 0 && fHZ < 30 && fabs(fHZ - m_fFlashHZ)>1e-7){m_fFlashHZ=fHZ;FlashStatusChanged();}} 32 | float GetFlashFreq(){return(m_fFlashHZ);} 33 | 34 | /** 35 | * @brief 是否开始闪烁 36 | */ 37 | void SetFlash(bool bFlash)JUDGE_EQUAL_CALL_FUNCTION(bFlash,m_bFlash,FlashFlashChanged) 38 | bool IsFlash(){return(m_bFlash);} 39 | protected: 40 | virtual ~ISceneFlashGroup(){} 41 | 42 | virtual void FlashStatusChanged()=0; 43 | virtual void FlashColorChanged()=0; 44 | virtual void FlashFlashChanged()=0; 45 | protected: 46 | bool m_bFlash{true}; 47 | SceneColor m_stFlahColor; 48 | float m_fFlashHZ{1.f}; 49 | }; 50 | 51 | #endif //INTERFACE_SCENE_FLASH_GROUP_HEARDER_H 52 | -------------------------------------------------------------------------------- /Inc/Plot/Common/ISceneLodGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_LOD_GROUP_HEARDER_H 2 | #define INTERFACE_SCENE_LOD_GROUP_HEARDER_H 3 | #include 4 | #include 5 | 6 | 7 | /** 8 | * @brief 场景切换节点,根据需要切换不同的显示 9 | */ 10 | class ISceneLodGroup:public ISceneGroup 11 | { 12 | public: 13 | enum SCENE_NODE_CHANGE_TYPE 14 | { 15 | NODE_EYE_DISTANCE, ///距离视点的距离 16 | NODE_SCREEN_PIXEL ///模型在屏幕上的像素大小(此方法对自动缩放的模型无效) 17 | }; 18 | 19 | CONSTRUCTOR(ISceneLodGroup,ISceneGroup) 20 | 21 | /** 22 | * @brief 转换成LodGroup 23 | * @return 24 | */ 25 | ISceneLodGroup* AsSceneLodGroup(){return(this);} 26 | 27 | /** 28 | * @brief设置模型切换类型 29 | * @param emType 30 | */ 31 | virtual void SetNodeChangeType(SCENE_NODE_CHANGE_TYPE emType)JUDGE_EQUAL_CALL_FUNCTION(emType,m_emType,ChangeTypeChanged) 32 | SCENE_NODE_CHANGE_TYPE NodeChangeType() const {return(m_emType);} 33 | 34 | /** 35 | * @brief 设置各级别的切换信息 36 | * @param rLevelInfos 37 | */ 38 | virtual void SetLevelsInfo(const std::vector& rLevelInfos)JUDGE_EQUAL_CALL_FUNCTION(rLevelInfos,m_vLevelInfos,LevelsChanged) 39 | virtual const std::vector& LevelsInfo() const{return(m_vLevelInfos);} 40 | protected: 41 | virtual ~ISceneLodGroup(){} 42 | 43 | virtual void ChangeTypeChanged()=0; 44 | virtual void LevelsChanged()=0; 45 | 46 | protected: 47 | SCENE_NODE_CHANGE_TYPE m_emType{NODE_EYE_DISTANCE}; 48 | std::vector m_vLevelInfos; 49 | }; 50 | 51 | #endif//INTERFACE_SCENE_AUTO_SCALE_GROUP_HEARDER_H 52 | -------------------------------------------------------------------------------- /Inc/Plot/Common/ISceneModel.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_MODEL_HEARDER_H 2 | #define INTERFACE_SCENE_MODEL_HEARDER_H 3 | 4 | #include 5 | #include 6 | /** 7 | * @brief 场景模型节点类 8 | */ 9 | class ISceneModel:public ISceneNode 10 | { 11 | public: 12 | CONSTRUCTOR(ISceneModel,ISceneNode) 13 | 14 | /** 15 | * @brief 转换成模型节点 16 | * @return 17 | */ 18 | ISceneModel* AsSceneModel(){return(this);} 19 | 20 | /** 21 | * @brief 设置模型初始化的姿态 22 | * @param rAttitude 23 | */ 24 | void InitAttitude(const SceneAttitude& rAttitude)JUDGE_EQUAL_CALL_FUNCTION(rAttitude,m_stInitAttitude,InitAttitudeChanged) 25 | const SceneAttitude& InitAttitude()const{return(m_stInitAttitude);} 26 | protected: 27 | virtual ~ISceneModel(){} 28 | virtual void InitAttitudeChanged()=0; 29 | 30 | protected: 31 | SceneAttitude m_stInitAttitude; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Inc/Plot/Common/ISceneScaleGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_SCALE_GROUP_HEARDER_H 2 | #define INTERFACE_SCENE_SCALE_GROUP_HEARDER_H 3 | 4 | #include 5 | /** 6 | * @brief 缩放节点类 7 | */ 8 | class ISceneScaleGroup:public ISceneGroup 9 | { 10 | public: 11 | CONSTRUCTOR(ISceneScaleGroup,ISceneGroup) 12 | 13 | /** 14 | * @brief 转换成缩放节点 15 | * @return 16 | */ 17 | ISceneScaleGroup* AsSceneScaleGroup(){return(this);} 18 | 19 | /** 20 | * @brief 设置缩放系数 21 | */ 22 | void SetScal(double dScalBit)JUDGE_POSITIVE_DOUBLE_CALL_FUNCTION(dScalBit,m_dScalBit,ScalChanged) 23 | double Scal()const{return(m_dScalBit);} 24 | 25 | /** 26 | * @brief 是否开启自动缩放 27 | * @param bAutoScal 28 | */ 29 | void SetAutoScal(bool bAutoScal)JUDGE_EQUAL_CALL_FUNCTION(bAutoScal,m_bAutoScal,AutoScalChanged) 30 | bool AutoScal(){return(m_bAutoScal);} 31 | 32 | /** 33 | * @brief 设置最小缩放倍数 34 | * @param dMinScal 35 | */ 36 | void SetMinScal(double dMinScal)JUDGE_POSITIVE_DOUBLE_CALL_FUNCTION(dMinScal,m_dMinScal,MinScalChanged) 37 | double MinScal(){return(m_dMinScal);} 38 | 39 | /** 40 | * @brief 设置最大缩放倍数 41 | * @param dMaxScal 42 | */ 43 | void SetMaxScal(double dMaxScal)JUDGE_POSITIVE_DOUBLE_CALL_FUNCTION(dMaxScal,m_dMaxScal,MaxScalChanged) 44 | double MaxScal(){return(m_dMaxScal);} 45 | protected: 46 | virtual ~ISceneScaleGroup(){} 47 | virtual void ScalChanged()=0; 48 | virtual void AutoScalChanged()=0; 49 | virtual void MinScalChanged()=0; 50 | virtual void MaxScalChanged()=0; 51 | 52 | protected: 53 | double m_dScalBit{1.}; 54 | double m_dMinScal{}; 55 | double m_dMaxScal{DBL_MAX}; 56 | bool m_bAutoScal{false}; 57 | }; 58 | 59 | #endif//INTERFACE_SCENE_AUTO_SCALE_GROUP_HEARDER_H 60 | -------------------------------------------------------------------------------- /Inc/Plot/Common/ISceneScreenGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_SCREEN_GROUP_HEARDER_H 2 | #define INTERFACE_SCENE_SCREEN_GROUP_HEARDER_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief 屏幕节点类 8 | */ 9 | class ISceneScreenGroup:public ISceneGroup 10 | { 11 | public: 12 | CONSTRUCTOR(ISceneScreenGroup,ISceneGroup) 13 | 14 | /** 15 | * @brief 转换成本类型 16 | * @return 17 | */ 18 | ISceneScreenGroup* AsSceneScreenGroup(){return(this);} 19 | 20 | /** 21 | * @brief 设置标牌是否避让 22 | * @return 23 | */ 24 | void SetAvoid(bool bAvoid)JUDGE_EQUAL_CALL_FUNCTION(bAvoid,m_bAvoid,AvoidChanged) 25 | bool IfAvoid() const {return(m_bAvoid);} 26 | protected: 27 | virtual ~ISceneScreenGroup(){} 28 | virtual void AvoidChanged()=0; 29 | protected: 30 | bool m_bAvoid{false}; 31 | }; 32 | 33 | #endif //INTERFACE_SCENE_FLASH_GROUP_HEARDER_H 34 | -------------------------------------------------------------------------------- /Inc/Plot/Common/ISceneVisualGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_VISUAL_GROUP_HEARDER_H 2 | #define INTERFACE_SCENE_VISUAL_GROUP_HEARDER_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 屏幕节点类 9 | */ 10 | class ISceneVisualGroup:public ISceneGroup 11 | { 12 | public: 13 | CONSTRUCTOR(ISceneVisualGroup,ISceneGroup) 14 | 15 | /** 16 | * @brief 转换成本类型 17 | * @return 18 | */ 19 | ISceneVisualGroup* AsSceneVisualGroup(){return(this);} 20 | 21 | /** 22 | * @brief 设置观察张角 23 | * @param dFovy [deg][0~180] 24 | */ 25 | void SetFovy(double dFovy)JUDGE_POSITIVE_DOUBLE_CALL_FUNCTION(dFovy,m_dFovy,ParameterChanged) 26 | double Fovy()const{return(m_dFovy);} 27 | 28 | /** 29 | * @brief 设置观察的纵横比 30 | */ 31 | void SetAspect(double dAspect)JUDGE_POSITIVE_DOUBLE_CALL_FUNCTION(dAspect,m_dAspect,ParameterChanged) 32 | double Aspect()const{return(m_dAspect);} 33 | 34 | /** 35 | * @brief 设置分析位置 36 | * @attention rViewPint.stPos 位置为具体的位置 37 | */ 38 | void SetViewPoint(const SceneViewPoint& rViewPoint)JUDGE_EQUAL_CALL_FUNCTION(rViewPoint,m_stViewPoint,ParameterChanged) 39 | const SceneViewPoint& ViewPoint()const{return(m_stViewPoint);} 40 | 41 | /** 42 | * @brief 设置视点是不是地理信息 43 | * @attention 44 | */ 45 | void SetPosIsGeo(bool bIsGeo)JUDGE_EQUAL_CALL_FUNCTION(bIsGeo,m_bIsGeoPos,ParameterChanged); 46 | bool PosIsGeo(){return(m_bIsGeoPos);} 47 | protected: 48 | virtual ~ISceneVisualGroup(){} 49 | virtual void ParameterChanged()=0; 50 | protected: 51 | double m_dFovy{45.}; /// 张角 52 | double m_dAspect{1.}; /// 纵横比 53 | bool m_bIsGeoPos{true};/// 位置是否是地理信息 54 | SceneViewPoint m_stViewPoint; ///视点位置 55 | }; 56 | 57 | #endif //INTERFACE_SCENE_FLASH_GROUP_HEARDER_H 58 | -------------------------------------------------------------------------------- /Inc/Plot/Hud/IHudImage.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_HUD_IMAGE_HEARDER_H 2 | #define INTERFACE_HUD_IMAGE_HEARDER_H 3 | 4 | #include 5 | #include 6 | #include 7 | /** 8 | * @brief 视口的屏显类 9 | */ 10 | class IHudImage:public IHudNode 11 | { 12 | public: 13 | CONSTRUCTOR(IHudImage,IHudNode) 14 | 15 | /** 16 | * @brief设置图片 17 | */ 18 | void SetImage(const std::string& sText)JUDGE_EQUAL_CALL_FUNCTION(sText,m_sImagePath,ImageChanged) 19 | const std::string& Image()const{return(m_sImagePath);} 20 | void SetRotation(double Angle)JUDGE_DOUBLE_CALL_FUNCTION(Angle,m_dAngle,AngleChanged); 21 | 22 | void SetImageSize(const SceneImageSize& stImageSize)JUDGE_EQUAL_CALL_FUNCTION(stImageSize,m_stImageSize,ImageSizeChanged); 23 | protected: 24 | virtual ~IHudImage(){} 25 | virtual void ImageChanged()=0; 26 | virtual void AngleChanged()=0; 27 | virtual void ImageSizeChanged()=0; 28 | protected: 29 | std::string m_sImagePath; 30 | double m_dAngle =0.0f; 31 | SceneImageSize m_stImageSize; 32 | }; 33 | 34 | #endif/// INTERFACE_HUD_IMAGE_HEARDER_H 35 | -------------------------------------------------------------------------------- /Inc/Plot/Hud/IHudText.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_HUD_TEXT_HEARDER_H 2 | #define INTERFACE_HUD_TEXT_HEARDER_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 视口的屏显类 9 | */ 10 | class IHudText:public IHudNode 11 | { 12 | public: 13 | CONSTRUCTOR(IHudText,IHudNode) 14 | 15 | /** 16 | * @brief 设置显示内容 17 | * @attention utf-8编码方式 18 | */ 19 | void SetText(const std::string& sText)JUDGE_EQUAL_CALL_FUNCTION(sText,m_sText,TextChanged) 20 | const std::string& Text()const{return(m_sText);} 21 | 22 | /** 23 | * @brief 设置字体 24 | */ 25 | void SetFont(const std::string& sFont)JUDGE_EQUAL_CALL_FUNCTION(sFont,m_sFont,FontChanged) 26 | const std::string& Font()const{return(m_sFont);} 27 | 28 | /** 29 | * @brief 设置字体填充颜色 30 | */ 31 | void SetColor(const SceneColor& rColor)JUDGE_EQUAL_CALL_FUNCTION(rColor,m_stColor,ColorChanged) 32 | const SceneColor& Color()const{return(m_stColor);} 33 | 34 | /** 35 | * @brief 设置字体边框颜色 36 | */ 37 | void SetOutColor(const SceneColor& rColor)JUDGE_EQUAL_CALL_FUNCTION(rColor,m_stOutLineColor,OutColorChanged) 38 | const SceneColor& OutLineColor()const{return(m_stOutLineColor);} 39 | 40 | /** 41 | * @brief 设置字体大小 42 | */ 43 | void SetFontSize(int nFontSize)JUDGE_EQUAL_CALL_FUNCTION(nFontSize,m_nFontSize,FontSizeChanged) 44 | int FontSize() const{return(m_nFontSize);} 45 | protected: 46 | virtual ~IHudText(){} 47 | 48 | virtual void FontSizeChanged()=0; 49 | virtual void TextChanged()=0; 50 | virtual void FontChanged()=0; 51 | virtual void ColorChanged()=0; 52 | virtual void OutColorChanged()=0; 53 | 54 | protected: 55 | int m_nFontSize{30}; 56 | std::string m_sText; 57 | std::string m_sFont; 58 | SceneColor m_stColor; 59 | SceneColor m_stOutLineColor; 60 | }; 61 | 62 | #endif// INTERFACE_HUD_TEXT_HEARDER_H 63 | -------------------------------------------------------------------------------- /Inc/Plot/IPlot.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_PLOT_HEADER_H 2 | #define INTERFACE_PLOT_HEADER_H 3 | 4 | #include 5 | #include 6 | 7 | enum SCENE_GROUP_TYPE 8 | { 9 | ATTITUDE_GROUP, /// 调整位置、姿态 10 | FLASH_GROUP, /// 闪烁 11 | LOD_GROUP, /// 分级显示 12 | SCALE_GROUP, /// 自动缩放 13 | SCREEN_GROUP, /// 将节点显示在屏幕上 14 | CAMERA_GROUP, /// 防止裁剪的节点 15 | VISUAL_GROUP, /// 视域分析 16 | STANDARD_GROUP /// 只是一个容器 17 | }; 18 | 19 | /** 20 | * @brief 标绘管理类 21 | */ 22 | class IPlot 23 | { 24 | friend class ISceneGraph; 25 | public: 26 | 27 | CONSTRUCTOR(IPlot,m_pSceneGraph) 28 | 29 | /** 30 | * @brief 注册标绘类型 31 | */ 32 | virtual void RegisterPlotType()=0; 33 | 34 | /** 35 | * @brief 根据不同的类型创建组节点 36 | * @return 37 | */ 38 | virtual ISceneGroup* CreateSceneGroup(SCENE_GROUP_TYPE)=0; 39 | 40 | /** 41 | * @brief 根据类型创建节点 42 | * @return 43 | */ 44 | virtual ISceneNode* CreateSceneNode(const std::string&)=0; 45 | 46 | /** 47 | * @brief 根据路径加载模型 48 | * @param1 相对路径或者绝对路径 49 | * @param2 bRef 是否是相对路径 50 | * @attention 相对路径对应的是exe所在目录中的Data目录 51 | * @return 52 | */ 53 | virtual ISceneNode* LoadSceneNode(const std::string&,bool bRef=true)=0; 54 | 55 | /** 56 | * @brief 根据模型ID获取模型 57 | * @return 58 | */ 59 | virtual ISceneNode* FindNodeByID(unsigned int unPickID)=0; 60 | 61 | /** 62 | * @brief 强制删除不再使用的地图节点 63 | */ 64 | virtual void FreeNoUseSceneNode()=0; 65 | protected: 66 | virtual ~IPlot(){} 67 | protected: 68 | ISceneGraph* m_pSceneGraph{}; 69 | }; 70 | 71 | #endif//INTERFACE_PLOT_HEADER_H 72 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapCoverImage.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_COVER_IMAGE_HEARDER_H 2 | #define INTERFACE_MAP_COVER_IMAGE_HEARDER_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /** 9 | * @brief 位置信息 10 | */ 11 | struct PosValue 12 | { 13 | double dX{}; 14 | double dY{}; 15 | double dValue{}; 16 | }; 17 | 18 | /** 19 | * @brief 覆盖信息 20 | */ 21 | struct CoverInfo 22 | { 23 | int nXNum{}; 24 | int nYNum{}; 25 | double dMin{}; 26 | double dMax{}; 27 | std::vectorvPosInfo; 28 | }; 29 | 30 | /** 31 | * @brief 测点信息 32 | */ 33 | struct CeDian 34 | { 35 | double dLon{}; 36 | double dLat{}; 37 | std::string sName; 38 | }; 39 | 40 | /** 41 | * @brief 绘制地面覆盖类 42 | */ 43 | class IMapCoverImage:public IMapSceneNode 44 | { 45 | public: 46 | CONSTRUCTOR(IMapCoverImage,IMapSceneNode) 47 | 48 | /** 49 | * @brief 获取覆盖范围 50 | * @return 51 | */ 52 | virtual void SetCoverInfo(const CoverInfo&)=0; 53 | 54 | /** 55 | * @brief 设置测点信息 56 | */ 57 | virtual void SetCeDian(const std::vector&)=0; 58 | 59 | /** 60 | * @brief 设置最小值的颜色 61 | */ 62 | virtual void SetMinValueColor(const SceneColor&)=0; 63 | 64 | /** 65 | * @brief 设置最大值的颜色 66 | */ 67 | virtual void SetMaxValueColor(const SceneColor&)=0; 68 | 69 | /** 70 | * @brief 设置范围和图片 71 | */ 72 | virtual void SetBound(const ScenePos&,const ScenePos&,const std::string&)=0; 73 | protected: 74 | virtual ~IMapCoverImage(){} 75 | }; 76 | 77 | #endif//INTERFACE_MAP_COVER_IMAGE_HEARDER_H 78 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_LAYER_HEADER_H 2 | #define INTERFACE_MAP_LAYER_HEADER_H 3 | #include 4 | #include "IMapSceneNode.h" 5 | 6 | class IMapLayer 7 | { 8 | public: 9 | /** 10 | * @brief 获取图层名字 11 | * @return 12 | */ 13 | virtual const std::string& GetLayerName()=0; 14 | 15 | /** 16 | * @brief 添加节点 17 | */ 18 | virtual unsigned int AddSceneNode(IMapSceneNode*)=0; 19 | 20 | /** 21 | * @brief 移除节点 22 | */ 23 | virtual void RemoveSceneNode(IMapSceneNode*)=0; 24 | 25 | /** 26 | * @brief 清空所有的节点 27 | */ 28 | virtual void Clear()=0; 29 | 30 | /** 31 | * @brief 控制图层显隐 32 | */ 33 | virtual void SetVisible(bool)=0; 34 | 35 | /** 36 | * @brief 图层是否可见 37 | * @return 38 | */ 39 | virtual bool IsVisible()=0; 40 | protected: 41 | virtual ~IMapLayer(){} 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapLine.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_LINE_HEARDER_H 2 | #define INTERFACE_MAP_LINE_HEARDER_H 3 | 4 | #include 5 | #include 6 | /** 7 | * @brief 场景节点类 8 | */ 9 | class IMapLine:public IMapSceneNode 10 | { 11 | public: 12 | CONSTRUCTOR(IMapLine,IMapSceneNode) 13 | 14 | /** 15 | * @brief 获取绘制信息 16 | * @return 17 | */ 18 | ILine* GetDrawLine(){return(m_pDrawLine);} 19 | virtual void Update() =0; 20 | protected: 21 | virtual ~IMapLine(){} 22 | protected: 23 | ILine* m_pDrawLine{}; 24 | }; 25 | 26 | #endif // INTERFACE_MAP_LINE_HEARDER_H 27 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapLocation.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_LOCATION_HEARDER_H 2 | #define INTERFACE_MAP_LOCATION_HEARDER_H 3 | 4 | #include 5 | /** 6 | * @brief 地图位置定位模型 7 | */ 8 | class IMapLocation:public IMapSceneNode 9 | { 10 | public: 11 | 12 | CONSTRUCTOR(IMapLocation,IMapSceneNode) 13 | 14 | /** 15 | * @brief 设置点的位置 16 | * @param rGeoPos 17 | */ 18 | void SetGeoPos(const ScenePos& rGeoPos)JUDGE_EQUAL_CALL_FUNCTION(rGeoPos,m_stGeoPos,PosChanged) 19 | const ScenePos& GeoPos(){return(m_stGeoPos);} 20 | 21 | /** 22 | * @brief 设置由SceneShpae创建的节点 23 | * @param pNode 24 | */ 25 | virtual void SetSceneNode(ISceneNode* pNode)=0; 26 | virtual ISceneNode* SceneNode(){return(m_pSceneNode);} 27 | protected: 28 | virtual ~IMapLocation(){} 29 | 30 | /** 31 | * @brief PosChanged 32 | */ 33 | virtual void PosChanged()=0; 34 | protected: 35 | ISceneNode* m_pSceneNode{}; 36 | ScenePos m_stGeoPos; 37 | }; 38 | 39 | #endif//INTERFACE_MAP_LOCATION_HEARDER_H 40 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapObserver.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_OBSERVER_HEARDER_H 2 | #define INTERFACE_MAP_OBSERVER_HEARDER_H 3 | 4 | #include 5 | #include 6 | #include 7 | /// 地图消息观察者 8 | struct IMapMessageObserver 9 | { 10 | /** 11 | * @brief 地图类型更改 12 | * @param 地图类型 13 | */ 14 | virtual void MapTypeChanged(MapType){} 15 | 16 | /** 17 | * @brief 图层增加消息 18 | * @param 增加的图层的名字 [utf-8编码] 19 | */ 20 | virtual void AddLayer(const std::string&){} 21 | 22 | /** 23 | * @brief 图层移除消息 24 | * @param 移除的图层的名字 [utf-8编码] 25 | */ 26 | virtual void RemoveLayer(const std::string&){} 27 | 28 | /** 29 | * @brief 鼠标所在的经纬度信息 30 | * @param 第1个参数 经度信息 [deg](-180,180) 31 | * @param 第2个参数 纬度信息 [deg][-90,90] 32 | * @param 第3个参数 高度信息 [m] 相对于wgs84椭球表面的高度 33 | */ 34 | virtual void MousePos(double,double,double){} 35 | 36 | virtual void MouseDown(MouseButtonMask type, double,double,double){}; 37 | 38 | virtual void MouseDblClick(MouseButtonMask type, double,double,double){}; 39 | }; 40 | 41 | #endif /// INTERFACE_MAP_OBSERVER_HEARDER_H 42 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_POINT_HEARDER_H 2 | #define INTERFACE_MAP_POINT_HEARDER_H 3 | 4 | #include 5 | #include 6 | /** 7 | * @brief 场景节点类 8 | */ 9 | class IMapPoint:public IMapSceneNode 10 | { 11 | public: 12 | CONSTRUCTOR(IMapPoint,IMapSceneNode) 13 | 14 | /** 15 | * @brief 获取真实的绘制体 16 | * @return 17 | */ 18 | IPoint* GetDrawPoint(){return(m_pDrawPoint);} 19 | protected: 20 | ~IMapPoint(){} 21 | protected: 22 | IPoint* m_pDrawPoint{}; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapPolygon.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_POLYGON_HEARDER_H 2 | #define INTERFACE_MAP_POLYGON_HEARDER_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief 场景节点类 8 | */ 9 | class IMapPolygon:public IMapSceneNode 10 | { 11 | public: 12 | CONSTRUCTOR(IMapPolygon,IMapSceneNode) 13 | 14 | /** 15 | * @brief 获取绘制信息 16 | * @return 17 | */ 18 | IPolygon* GetDrawPolygon(){return(m_pDrawPolygon);} 19 | protected: 20 | virtual ~IMapPolygon(){} 21 | protected: 22 | IPolygon* m_pDrawPolygon{}; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapPolygon3D.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_POLYGON_3D_HEARDER_H 2 | #define INTERFACE_MAP_POLYGON_3D_HEARDER_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief 场景节点类 8 | */ 9 | class IMapPolygon3D:public IMapSceneNode 10 | { 11 | public: 12 | CONSTRUCTOR(IMapPolygon3D,IMapSceneNode) 13 | 14 | /** 15 | * @brief 获取绘制信息 16 | * @return 17 | */ 18 | IPolygon3D* GetDrawPolygon(){return(m_pDrawPolygon);} 19 | protected: 20 | virtual ~IMapPolygon3D(){} 21 | protected: 22 | IPolygon3D* m_pDrawPolygon{}; 23 | }; 24 | 25 | #endif//INTERFACE_MAP_POLYGON_3D_HEARDER_H 26 | -------------------------------------------------------------------------------- /Inc/Plot/Map/IMapSceneNode.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAPSCENENODE_HEADER_H 2 | #define INTERFACE_MAPSCENENODE_HEADER_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief 地图节点 8 | */ 9 | class IMapSceneNode:public ISceneNode 10 | { 11 | public: 12 | CONSTRUCTOR(IMapSceneNode,ISceneNode) 13 | /** 14 | * @brief 地图节点高程格式 15 | */ 16 | enum MAP_TERRAIN 17 | { 18 | CLOSE_TERRAIN, /// 贴地 19 | RELATIVE_TERRAIN, /// 相对高程高度 20 | ABSOLUTE_TERRAIN /// 相对椭球表面高度 21 | }; 22 | 23 | /** 24 | * @brief 设置贴地模式 25 | */ 26 | void SetTerrainType(MAP_TERRAIN type)JUDGE_EQUAL_CALL_FUNCTION(type,m_emType,TerrainTypeChanged) 27 | MAP_TERRAIN TerrainType()const{return(m_emType);} 28 | 29 | IMapSceneNode* AsMapSceneNode(){return(this);} 30 | protected: 31 | virtual ~IMapSceneNode(){} 32 | 33 | /** 34 | * @brief 状态修改 35 | */ 36 | virtual void TerrainTypeChanged()=0; 37 | 38 | protected: 39 | MAP_TERRAIN m_emType{CLOSE_TERRAIN}; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Inc/Plot/Map/MapType.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_MAP_TYPE_HEADER_H 2 | #define INTERFACE_MAP_TYPE_HEADER_H 3 | #include 4 | #include 5 | #include 6 | 7 | enum MapType 8 | { 9 | MAP_3D, /// 三维地图 10 | MAP_2D, /// 二维地图 11 | MAP_USER /// 用户自定义地图 12 | }; 13 | #endif 14 | -------------------------------------------------------------------------------- /Inc/Plot/Map/SpaceEnv/ISpaceBackGround.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SPACE_BACKGROUBD_HEARDER_H 2 | #define INTERFACE_SPACE_BACKGROUBD_HEARDER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /** 9 | * @brief 场景节点类 10 | */ 11 | class ISpaceBackGround:public ISceneNode 12 | { 13 | public: 14 | CONSTRUCTOR(ISpaceBackGround,ISceneNode) 15 | 16 | /** 17 | * @brief 设置显示最大星等 默认为 6 最大星等为 20 18 | * @param nMax 19 | */ 20 | virtual void SetMaxVisibleMagnitude(int)=0; 21 | 22 | /** 23 | * @brief 设置银河是否可见 24 | * @param bShow 25 | */ 26 | virtual void SetMilkywayVisible(bool)=0; 27 | 28 | /** 29 | * @brief 设置星星名称是否可见 30 | * @param bShow 31 | */ 32 | virtual void SetStarNamesVisible(bool)=0; 33 | 34 | /** 35 | * @brief 设置边界是否可见 36 | * @param bShow 37 | */ 38 | virtual void SetBoundariesVisible(bool)=0; 39 | 40 | /** 41 | * @brief 设置星座连线是否可见 42 | * @param bShow 43 | */ 44 | virtual void SetConstellationLinesVisible(bool)=0; 45 | 46 | /** 47 | * @brief 设置星座名称是否可见 48 | * @param bShow 49 | */ 50 | virtual void SetConstellationNamesVisible(bool)=0; 51 | 52 | /** 53 | * @brief 不知道怎么用的情况下不要擅自调用 54 | */ 55 | virtual void UpdateMatrix(const Math::CMatrix&)=0; 56 | virtual void UpdatePos(const std::vector&)=0; 57 | protected: 58 | virtual ~ISpaceBackGround(){} 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Inc/Plot/Map/SpaceEnv/ISpaceEnv.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SPACE_ENV_HEARDER_H 2 | #define INTERFACE_SPACE_ENV_HEARDER_H 3 | #include 4 | #include 5 | class ISpaceBackGround; 6 | 7 | /** 8 | * @brief 场景节点类 9 | */ 10 | class ISpaceEnv:public ISceneGroup 11 | { 12 | public: 13 | 14 | CONSTRUCTOR(ISpaceEnv,ISceneGroup) 15 | /** 16 | * @brief 获取星空背景 17 | * @return 18 | */ 19 | virtual ISpaceBackGround* GetSpaceBackGround()=0; 20 | 21 | /** 22 | * @brief 获取地固系下太阳位置 23 | * @return 24 | */ 25 | virtual const Math::CVector& GetSunPos()=0; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Inc/Plot/SatelliteShow/IOribit.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_ORIBIT_HEARDER_H 2 | #define INTERFACE_ORIBIT_HEARDER_H 3 | #include 4 | #include 5 | #include 6 | 7 | class ISensor; 8 | 9 | /** 10 | * @brief 场景节点类 11 | */ 12 | class IOribit:public ISceneNode 13 | { 14 | public: 15 | 16 | /** 17 | * @brief 设置轨道颜色 18 | */ 19 | virtual void SetOribitColor(const SceneColor&)=0; 20 | 21 | /** 22 | * @brief 设置卫星J2000下的位置和速度 23 | * @param 第二个参数 卫星的 J2000下的位置和速度 [m,m,m,m/s,m/s,m/s] 24 | */ 25 | virtual void SetJ2000Oribit(const std::vector &)=0; 26 | 27 | /** 28 | * @brief 设置卫星的经纬度 29 | * @param 经纬信息 [deg,deg] 30 | */ 31 | virtual void SetGeoOribit(const std::vector&)=0; 32 | 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/IBeamSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_BEAM_SENSOR_HEARDER_H 2 | #define INTERFACE_BEAM_SENSOR_HEARDER_H 3 | #include 4 | 5 | /** 6 | * @brief 波瓣传感器 7 | */ 8 | class IBeamSensor:public ISensor 9 | { 10 | public: 11 | CONSTRUCTOR(IBeamSensor,ISensor) 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/IBoxSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_BOX_SENSOR_HEARDER_H 2 | #define INTERFACE_BOX_SENSOR_HEARDER_H 3 | #include "ISensor.h" 4 | 5 | /** 6 | * @brief 盒子传感器 7 | */ 8 | class IBoxSensor:public ISensor 9 | { 10 | public: 11 | CONSTRUCTOR(IBoxSensor,ISensor) 12 | 13 | /** 14 | * @brief 设置y/x轴的比率 15 | */ 16 | void SetYXRadio(double dYXRatio)JUDGE_POSITIVE_DOUBLE_CALL_FUNCTION(dYXRatio,m_dYXRatio,ShapeChanged) 17 | double YXRadio() const{return(m_dYXRatio);} 18 | 19 | /** 20 | * @brief 设置z/x轴的比率 21 | */ 22 | void SetZXRadio(double dZXRatio)JUDGE_POSITIVE_DOUBLE_CALL_FUNCTION(dZXRatio,m_dZXRatio,ShapeChanged) 23 | double ZXRadio() const{return(m_dZXRatio);} 24 | protected: 25 | virtual ~IBoxSensor(){} 26 | 27 | protected: 28 | double m_dYXRatio{1.}; 29 | double m_dZXRatio{1.}; 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/IConeSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_CONE_SENSOR_HEARDER_H 2 | #define INTERFACE_CONE_SENSOR_HEARDER_H 3 | #include 4 | 5 | /** 6 | * @brief 圆锥传感器 7 | */ 8 | class IConeSensor:public ISensor 9 | { 10 | public: 11 | CONSTRUCTOR(IConeSensor,ISensor) 12 | 13 | /** 14 | * @brief 设置圆锥半角 15 | */ 16 | void SetAngle(double dAngle)JUDGE_DOUBLE_CALL_FUNCTION(dAngle,m_dAngle,ShapeChanged) 17 | double Angle() const{return(m_dAngle);} 18 | protected: 19 | virtual ~IConeSensor(){} 20 | 21 | protected: 22 | double m_dAngle{5.0}; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/ILine.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_LINE_HEARDER_H 2 | #define INTERFACE_LINE_HEARDER_H 3 | #include 4 | #include 5 | /** 6 | * @brief 绘制线 7 | */ 8 | class ILine:public IGeometry 9 | { 10 | public: 11 | enum LINE_TYPE 12 | { 13 | SOLID_LINE, /// 实线 14 | DOTTED_LINE /// 虚线 15 | }; 16 | 17 | CONSTRUCTOR(ILine,IGeometry) 18 | 19 | /** 20 | * @brief 设置线宽度 21 | */ 22 | virtual void SetLineWidth(unsigned int nWidth)JUDGE_EQUAL_CALL_FUNCTION(nWidth,m_nLineWidth,LineWidthChanged) 23 | virtual unsigned int GetLineWidth(){return(m_nLineWidth);} 24 | 25 | /** 26 | * @brief 设置线型 27 | */ 28 | void SetLineType(LINE_TYPE lineType)JUDGE_EQUAL_CALL_FUNCTION(lineType,m_emLineType,LineTypeChanged) 29 | LINE_TYPE GetLineType()const {return(m_emLineType);} 30 | 31 | /** 32 | * @brief 是否开启荧光 33 | */ 34 | void OpenGlow(bool bOpen)JUDGE_EQUAL_CALL_FUNCTION(bOpen,m_bOpenGlow,GlowChanged) 35 | bool IsOpenGlow(){return(m_bOpenGlow);} 36 | 37 | protected: 38 | virtual void LineWidthChanged()=0; 39 | virtual void LineTypeChanged()=0; 40 | virtual void GlowChanged()=0; 41 | virtual ~ILine(){} 42 | protected: 43 | unsigned int m_nLineWidth{1u}; 44 | LINE_TYPE m_emLineType{SOLID_LINE}; 45 | bool m_bOpenGlow{false}; 46 | }; 47 | 48 | #endif // INTERFACE_LINE_HEARDER_H 49 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/IPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_POINT_HEARDER_H 2 | #define INTERFACE_POINT_HEARDER_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief 场景点节点 8 | */ 9 | class IPoint:public IGeometry 10 | { 11 | public: 12 | CONSTRUCTOR(IPoint,IGeometry) 13 | 14 | /** 15 | * @brief 设置点的大小 16 | */ 17 | void SetPointSize(float fPointSize)JUDGE_POSITIVE_FLOAT_CALL_FUNCTION(fPointSize,m_fPointSize,PointSizeChanged) 18 | float PointSize()const{return(m_fPointSize);} 19 | 20 | /** 21 | * @brief 设置点显示的图片 22 | */ 23 | void SetImage(const std::string& sImagePath)JUDGE_EQUAL_CALL_FUNCTION(sImagePath,m_sImagePath,ImagePathChanged) 24 | const std::string& Image()const{return(m_sImagePath);} 25 | protected: 26 | virtual ~IPoint(){} 27 | 28 | /// 状态更改 29 | virtual void PointSizeChanged()=0; 30 | virtual void ImagePathChanged()=0; 31 | 32 | protected: 33 | float m_fPointSize{1.f}; 34 | std::string m_sImagePath; 35 | }; 36 | 37 | #endif//INTERFACE_POINT_HEARDER_H 38 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/IPolygon.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_POLYGON_HEARDER_H 2 | #define INTERFACE_POLYGON_HEARDER_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief 多边形节点 8 | * @attention 多边形的边不能自相交 9 | */ 10 | class IPolygon:public IGeometry 11 | { 12 | public: 13 | CONSTRUCTOR(IPolygon,IGeometry) 14 | 15 | /** 16 | * @brief 是否显示边界线 17 | */ 18 | void ShowOutLine(bool bShowOutLine)JUDGE_EQUAL_CALL_FUNCTION(bShowOutLine,m_bShowOutLine,DrawChanged); 19 | bool IsShowOutLine(); 20 | 21 | /** 22 | * @brief 是否填充 23 | */ 24 | void Fill(bool bFille)JUDGE_EQUAL_CALL_FUNCTION(bFille,m_bFill,DrawChanged) 25 | bool IsFill(){return(m_bFill);} 26 | protected: 27 | virtual ~IPolygon(){} 28 | 29 | virtual void DrawChanged()=0; 30 | protected: 31 | bool m_bShowOutLine{false}; 32 | bool m_bFill{true}; 33 | }; 34 | 35 | #endif//INTERFACE_POLYGON_HEARDER_H 36 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/IPolygon3D.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_POLYGON_3D_HEARDER_H 2 | #define INTERFACE_POLYGON_3D_HEARDER_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief 多面体 8 | */ 9 | class IPolygon3D:public IGeometry 10 | { 11 | public: 12 | CONSTRUCTOR(IPolygon3D,IGeometry) 13 | 14 | /** 15 | * @brief 设置多边形的高度 16 | */ 17 | void SetHeight(double dHeight)JUDGE_POSITIVE_DOUBLE_CALL_FUNCTION(dHeight,m_dHeight,HeightChanged) 18 | double Height(){return(m_dHeight);} 19 | 20 | /** 21 | * @brief 设置是否显示底边 22 | */ 23 | void ShowBottom(bool bShow)JUDGE_EQUAL_CALL_FUNCTION(bShow,m_bShowBottom,ShapeChanged); 24 | bool IsBottomShow(){return(m_bShowBottom);} 25 | protected: 26 | virtual void HeightChanged()=0; 27 | virtual ~IPolygon3D(){} 28 | protected: 29 | double m_dHeight{1.}; /// 高度 30 | bool m_bShowBottom{true}; 31 | }; 32 | 33 | #endif//INTERFACE_POLYGON_3D_HEARDER_H 34 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/IRadarSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_RADAR_SENSOR_HEARDER_H 2 | #define INTERFACE_RADAR_SENSOR_HEARDER_H 3 | #include 4 | 5 | /** 6 | * @brief 雷达传感器 7 | */ 8 | class IRadarSensor:public ISensor 9 | { 10 | public: 11 | CONSTRUCTOR(IRadarSensor,ISensor) 12 | /** 13 | * @brief 设置雷达数据 14 | */ 15 | virtual void SetRadarData(const std::string& sFilePath,bool bIsRef=true)=0; 16 | protected: 17 | virtual ~IRadarSensor(){} 18 | protected: 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/ISConeSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCONE_SENSOR_HEARDER_H 2 | #define INTERFACE_SCONE_SENSOR_HEARDER_H 3 | #include "ISensor.h" 4 | 5 | /** 6 | * @brief 方锥传感器 7 | */ 8 | class ISConeSensor:public ISensor 9 | { 10 | public: 11 | ISConeSensor(ISceneGraph* pSceneGraph):ISensor(pSceneGraph){} 12 | /** 13 | * @brief 设置运动垂向半角 14 | */ 15 | void SetHAngle(double dHAngle)JUDGE_DOUBLE_CALL_FUNCTION(dHAngle,m_dHAngle,ShapeChanged) 16 | double HAngle() const {return(m_dHAngle);} 17 | 18 | /** 19 | * @brief 设置运动方向上半角 20 | */ 21 | void SetVAngle(double dVAngle)JUDGE_DOUBLE_CALL_FUNCTION(dVAngle,m_dVAngle,ShapeChanged) 22 | double VAngle()const{return(m_dVAngle);} 23 | protected: 24 | virtual ~ISConeSensor(){} 25 | protected: 26 | double m_dHAngle{5.}; 27 | double m_dVAngle{5.}; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/ISceneDonut.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_DONUT_HEARDER_H 2 | #define INTERFACE_SCENE_DONUT_HEARDER_H 3 | #include 4 | 5 | /** 6 | * @brief 甜甜圈 7 | */ 8 | class ISceneDonut:public ISensor 9 | { 10 | public: 11 | CONSTRUCTOR(ISceneDonut,ISensor) 12 | /** 13 | * @brief 设内半径 14 | */ 15 | void SetMinRadius(double dRadius)JUDGE_DOUBLE_CALL_FUNCTION(dRadius,m_dRMin,ShapeChanged) 16 | /** 17 | * @brief 设外半径 18 | */ 19 | void SetMaxRadius(double dRadius)JUDGE_DOUBLE_CALL_FUNCTION(dRadius,m_dRMax,ShapeChanged) 20 | 21 | protected: 22 | virtual ~ISceneDonut(){} 23 | protected: 24 | double m_dRMin{100000.0}; 25 | double m_dRMax{5.}; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Inc/Plot/SceneShape/IShape.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SHAPE_HEARDER_H 2 | #define INTERFACE_SHAPE_HEARDER_H 3 | #include 4 | 5 | /** 6 | * @brief 绘制模型的形状节点 7 | */ 8 | class IShape:public ISceneNode 9 | { 10 | public: 11 | CONSTRUCTOR(IShape,ISceneNode) 12 | 13 | /** 14 | * @brief 设置颜色 15 | */ 16 | void SetColor(const SceneColor& rColor)JUDGE_EQUAL_CALL_FUNCTION(rColor,m_stColor,ColorChanged) 17 | const SceneColor& Color() const{return(m_stColor);} 18 | 19 | protected: 20 | virtual ~IShape(){} 21 | /** 22 | * @brief 颜色更改消息 23 | */ 24 | virtual void ColorChanged()=0; 25 | virtual void ShapeChanged()=0; 26 | 27 | protected: 28 | SceneColor m_stColor; 29 | }; 30 | 31 | #endif//INTERFACE_SHAPE_HEARDER_H 32 | -------------------------------------------------------------------------------- /Inc/Qml/QtOsgItem.h: -------------------------------------------------------------------------------- 1 | #ifndef QT_OSG_ITEM_H 2 | #define QT_OSG_ITEM_H 3 | 4 | /** 5 | * @brief Qt Quick 的场景节点 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | class QtOsgRenderer; 13 | 14 | class SCENECORESHARED_EXPORT QtOsgItem:public QQuickFramebufferObject 15 | { 16 | friend QtOsgRenderer; 17 | Q_OBJECT 18 | Q_PROPERTY(ItemType type MEMBER m_emType WRITE setType) 19 | Q_PROPERTY(int frameRate MEMBER m_nFrameRate WRITE setFrameRate) 20 | 21 | public: 22 | enum ItemType 23 | { 24 | Item_2DMAP, 25 | Item_3DMAP, 26 | Item_User 27 | }; 28 | Q_ENUM(ItemType) 29 | 30 | QtOsgItem(QQuickItem *parent = nullptr); 31 | ~QtOsgItem(); 32 | 33 | /** 34 | * @brief 设置qml显示的类型 35 | * @param type 36 | */ 37 | void setType(ItemType type); 38 | 39 | /** 40 | * @brief 重写父类窗口 41 | * @return 42 | */ 43 | Renderer *createRenderer() const; 44 | 45 | /** 46 | * @brief 设置帧率 47 | */ 48 | void setFrameRate(int nFrameRate); 49 | 50 | protected slots: 51 | void Ready(); 52 | void EvnetCall(); 53 | 54 | protected: 55 | void keyPressEvent(QKeyEvent* event); 56 | void keyReleaseEvent(QKeyEvent* event); 57 | void mousePressEvent(QMouseEvent *event); 58 | void mouseReleaseEvent(QMouseEvent* event); 59 | void mouseMoveEvent(QMouseEvent* event); 60 | void mouseDoubleClickEvent(QMouseEvent *event); 61 | void wheelEvent(QWheelEvent *event); 62 | void touchEvent(QTouchEvent* event); 63 | void hoverMoveEvent(QHoverEvent* event); 64 | void dropEvent(QDropEvent *event); 65 | 66 | private: 67 | ItemType m_emType{Item_3DMAP}; /// 创建类型 68 | int m_nFrameRate{60}; /// 帧率 69 | qreal m_rScal{1.}; /// 缩放系数 70 | ISceneGraph* m_pSceneGraph{};/// 场景图 71 | QtOsgRenderer* m_pRenderer{}; /// 渲染器 72 | }; 73 | 74 | #endif // OSGITEM_H 75 | -------------------------------------------------------------------------------- /Inc/SceneCore_Global.h: -------------------------------------------------------------------------------- 1 | #ifndef SCENE_CORE_GLOBAL_H 2 | #define SCENE_CORE_GLOBAL_H 3 | #include 4 | 5 | #if defined(SCENECORE_LIBRARY) 6 | # define SCENECORESHARED_EXPORT Q_DECL_EXPORT 7 | #else 8 | # define SCENECORESHARED_EXPORT Q_DECL_IMPORT 9 | #endif 10 | 11 | #endif // SCENCECORE_GLOBAL_H 12 | -------------------------------------------------------------------------------- /Inc/SceneGraph/INodeAbility.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_NODE_ABILITY_HEARDER_H 2 | #define INTERFACE_NODE_ABILITY_HEARDER_H 3 | 4 | class IFlashAbility; 5 | class IFlatAbility; 6 | class ISceneNode; 7 | 8 | /** 9 | * @brief 场景节点类 10 | */ 11 | class INodeAbility 12 | { 13 | public: 14 | /** 15 | * @brief 更新能力 16 | */ 17 | virtual void UpdateAbility()=0; 18 | 19 | /** 20 | * @brief 绑定场景节点 21 | */ 22 | virtual void BoundNode(ISceneNode*)=0; 23 | 24 | /** 25 | * @brief 转换成闪烁能力 26 | * @return 27 | */ 28 | virtual IFlashAbility* AsFlashAbility(){return(nullptr);} 29 | virtual IFlatAbility* AsFlatAbility(){return(nullptr);} 30 | }; 31 | 32 | #endif //INTERFACE_NODE_ABILITY_HEARDER_H 33 | -------------------------------------------------------------------------------- /Inc/SceneGraph/ISceneGraphManager.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_MANAGER_HEARDER_H 2 | #define INTERFACE_SCENE_MANAGER_HEARDER_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief 场景类 8 | */ 9 | class ISceneGraphManager 10 | { 11 | public: 12 | virtual ~ISceneGraphManager(){} 13 | 14 | /** 15 | * @brief 创建场景图 16 | * @param 场景类型 17 | * @return 创建好的场景图 18 | */ 19 | virtual ISceneGraph* CreateSceneGraph(ISceneGraph::SceneGraphType)=0; 20 | 21 | /** 22 | * @brief 根据窗口查找关联的SceneGraph 23 | * @return 24 | */ 25 | virtual ISceneGraph* FindSceneGraph(IWindow*)=0; 26 | 27 | /** 28 | * @brief 根据quickitem 查找关联的SceneGraph 29 | * @return 30 | */ 31 | virtual ISceneGraph* FindSceneGraph(QQuickItem*)=0; 32 | 33 | /** 34 | * @brief 删除场景图 35 | * @return 36 | */ 37 | virtual bool DeleteSceneGraph(ISceneGraph*&)=0; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Inc/SceneGraph/ISceneGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_SCENE_GROUP_HEARDER_H 2 | #define INTERFACE_SCENE_GROUP_HEARDER_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief 场景组节点 8 | */ 9 | class ISceneGroup:public ISceneNode 10 | { 11 | public: 12 | CONSTRUCTOR(ISceneGroup,ISceneNode) 13 | 14 | /** 15 | * @brief 16 | * @return 17 | */ 18 | ISceneGroup* AsSceneGroup(){return(this);} 19 | 20 | /** 21 | * @brief 添加场景节点 22 | * @attention 只有一个线程下的节点才能相互添加 23 | */ 24 | virtual bool AddSceneNode(ISceneNode*)=0; 25 | 26 | /** 27 | * @brief 删除场景节点 28 | * @attention 移除场景节点 29 | */ 30 | virtual bool RemoveSceneNode(ISceneNode*)=0; 31 | protected: 32 | virtual ~ISceneGroup(){} 33 | }; 34 | 35 | #endif//INTERFACE_SCENE_GROUP_HEARDER_H 36 | -------------------------------------------------------------------------------- /Inc/SceneGraph/ViewType.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_VIEW_TYPE_HEARDER_H 2 | #define INTERFACE_VIEW_TYPE_HEARDER_H 3 | 4 | #include 5 | 6 | const int C_WINDOW_HEIGHT(100); 7 | const int C_WINDOW_WIDTH(100); 8 | 9 | /// 视点位置 10 | struct SceneViewPoint 11 | { 12 | ScenePos stPos; 13 | float fAzimuth{}; /// 方位角 [deg][0~360] 14 | float fElev{}; /// 俯仰角 [deg][0~90] 15 | float fDistance{10.f};/// 距视点位置的距离[m] 16 | 17 | ///重写判等操作符 18 | bool operator == (const SceneViewPoint& rOther) const 19 | { 20 | if(&rOther == this) 21 | { 22 | return(true); 23 | } 24 | 25 | return(rOther.stPos == stPos && 26 | JUDGE_FLOAT_EQUAL(fAzimuth,rOther.fAzimuth) && 27 | JUDGE_FLOAT_EQUAL(fElev,rOther.fElev) && 28 | JUDGE_FLOAT_EQUAL(fDistance,rOther.fDistance)); 29 | } 30 | 31 | bool operator !=(const SceneViewPoint& rOther) const 32 | { 33 | return(!(this->operator==(rOther))); 34 | } 35 | }; 36 | 37 | /// 视口位置 38 | struct CameraViewPort 39 | { 40 | int nX{}; /// 视口在屏幕X轴的位置 41 | int nY{}; /// 视口在屏幕Y轴的位置 42 | int nWidth{}; /// 视口的宽度 43 | int nHeight{}; /// 视口的高度 44 | 45 | /// 判断两个是否相等 46 | bool operator == (const CameraViewPort& rOther) const 47 | { 48 | if(&rOther == this) 49 | { 50 | return(true); 51 | } 52 | 53 | return(rOther.nX == nX && 54 | rOther.nY == nY && 55 | rOther.nWidth == nWidth && 56 | rOther.nHeight == nHeight); 57 | } 58 | 59 | /// 判断两者是否不相等 60 | bool operator != (const CameraViewPort& rOther) const 61 | { 62 | return(!this->operator==(rOther)); 63 | } 64 | 65 | bool IsValid()const 66 | { 67 | return(0 != nWidth && 0 != nHeight); 68 | } 69 | }; 70 | 71 | /// 视口类型 72 | enum ProjectType 73 | { 74 | Perspective, /// 透视投影 75 | Ortho /// 正视投影 76 | }; 77 | 78 | #endif /// INTERFACE_VIEW_TYPE_HEARDER_H 79 | -------------------------------------------------------------------------------- /Inc/Tool/ITool.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_TOOL_HEADER_H 2 | #define INTERFACE_TOOL_HEADER_H 3 | #include 4 | #include 5 | 6 | #include 7 | class ISceneGraph; 8 | struct PickMessage 9 | { 10 | virtual ~PickMessage(){} 11 | /** 12 | * @brief 鼠标选中目标信息 13 | * @param1 0 表示没有选中目标 非 0 表示选中目标ID 14 | * @param2 1 表述鼠标左键按下 2 表示鼠标右键双击 15 | */ 16 | virtual void PickID(unsigned int,unsigned int){} 17 | 18 | virtual void ToolChanged(const char* csOldTool,const char* csNewTool){} 19 | }; 20 | 21 | /** 22 | * @brief 工具类 23 | */ 24 | class ITool 25 | { 26 | friend class ISceneGraph; 27 | public: 28 | CONSTRUCTOR(ITool,m_pSceneGraph) 29 | 30 | /** 31 | * @brief 注册标绘类型 32 | */ 33 | virtual void RegisterTool()=0; 34 | 35 | /** 36 | * @brief 获取所有的工具 37 | */ 38 | virtual std::vector AllTool()const=0; 39 | 40 | /** 41 | * @brief 选择/取消工具 42 | */ 43 | virtual bool SelecteTool(const std::string& sToolID)=0; 44 | virtual void UnSelecteTool()=0; 45 | virtual const std::string& CurrentTool()=0; 46 | 47 | /** 48 | * @brief 注册消息 49 | */ 50 | virtual void SubPickMessage(PickMessage* pSub)=0; 51 | virtual void UnSubPickMessage(PickMessage* pSub)=0; 52 | protected: 53 | virtual ~ITool(){} 54 | protected: 55 | ISceneGraph* m_pSceneGraph{}; 56 | }; 57 | 58 | #endif//INTERFACE_TOOL_HEADER_H 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 MJYCo-Ltd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LoadMap/CSimpleLabel.h: -------------------------------------------------------------------------------- 1 | #ifndef CSIMPLELABEL_H 2 | #define CSIMPLELABEL_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | class IPlotBase; 8 | class ILabel; 9 | class ILine; 10 | class ISceneGraph; 11 | class ISceneGroup; 12 | class IMapLocation; 13 | class CSimpleLabel :public IWindowMessageObserver 14 | { 15 | public: 16 | CSimpleLabel(ISceneGraph*); 17 | ~CSimpleLabel(); 18 | // virtual void MouseDown(MouseButtonMask, int, int) override; 19 | virtual void MouseMove(MouseButtonMask, int, int) override; 20 | // virtual void MouseDblClick(MouseButtonMask, int, int) override; 21 | 22 | 23 | IMapLocation* getNode(); 24 | void setSimpleLabel(const char* ); 25 | void setComplexLabel(const char* ); 26 | void SetTarget(IPlotBase*); 27 | void setColor(long ); 28 | 29 | void update(); 30 | 31 | bool JudgeID(int unSelected,unsigned int); 32 | private: 33 | std::string simpleLabel; 34 | std::string fullLabel; 35 | IPlotBase* m_pTarget; 36 | ILabel* m_pLabel; 37 | ILine* m_pLine; 38 | ISceneGraph* m_pSceneGraph; 39 | 40 | bool m_bLabelChange; 41 | bool m_bSimpleLabelShow; 42 | std::string m_CurLabel; 43 | ISceneGroup* m_pSceneGroup; 44 | IMapLocation* m_pRoot; 45 | 46 | ScenePos m_TargetPos; 47 | 48 | long m_LabelColor; 49 | long m_LineColor; 50 | double m_TX; 51 | double m_TY; 52 | double m_TZ; 53 | 54 | SceneColor m_Color; 55 | bool m_bSelect; 56 | }; 57 | 58 | #endif // CSIMPLELABEL_H 59 | -------------------------------------------------------------------------------- /LoadMap/LoadMap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MJYCo-Ltd/Map/a95d6225cc08beffab6b609325610c3edfc129b6/LoadMap/LoadMap.png -------------------------------------------------------------------------------- /LoadMap/LoadMap.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-19T11:35:17 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 9 | 10 | TARGET = LoadMap 11 | TEMPLATE = app 12 | 13 | #DEFINES += NEED_VR 14 | SOURCES += \ 15 | CSimpleLabel.cpp \ 16 | main.cpp \ 17 | mainwindow.cpp 18 | 19 | HEADERS += \ 20 | CSimpleLabel.h \ 21 | mainwindow.h 22 | 23 | FORMS += \ 24 | mainwindow.ui \ 25 | mainwindow.ui 26 | 27 | SDK_CONFIG *= SceneCore Satellite OSG ExternShape 28 | unix:SDK_CONFIG *= Satellite OsgExtern ExternShape 29 | 30 | include(../SoftSDK.pri) 31 | -------------------------------------------------------------------------------- /LoadMap/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class MainWindow; 9 | } 10 | 11 | class ISceneGraph; 12 | class IMapSceneNode; 13 | class IPersonInfo; 14 | class IPoint; 15 | class IMapLine; 16 | class IModel; 17 | class ISceneNode; 18 | class IMapLayer; 19 | class CPlaceNode; 20 | 21 | class MainWindow : public QMainWindow 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | explicit MainWindow(QWidget *parent = nullptr); 27 | ~MainWindow(); 28 | 29 | void SetSecenGraph(ISceneGraph* pSceneGraph); 30 | protected: 31 | void timerEvent(QTimerEvent *event); 32 | private slots: 33 | void on_actionchange_triggered(); 34 | 35 | void on_action_triggered(); 36 | 37 | void on_action_2_triggered(); 38 | 39 | void on_action_3_triggered(); 40 | 41 | void on_action_4_triggered(); 42 | 43 | void on_action_5_triggered(); 44 | 45 | void on_action_6_triggered(); 46 | 47 | void on_action12_triggered(); 48 | 49 | void on_BeginCapture_triggered(); 50 | 51 | void on_endCapture_triggered(); 52 | 53 | void on_action_OpenVR_triggered(); 54 | 55 | void on_action_CloseVR_triggered(); 56 | 57 | protected: 58 | void PlotMap(); 59 | void LodPlot(); 60 | void TestGroup(); 61 | void LoadQingxie(); 62 | void TestHud(); 63 | 64 | private: 65 | Ui::MainWindow *ui; 66 | ISceneGraph* m_pSceneGraph; 67 | std::list m_listNode; 68 | int nTimerID=-1; 69 | int m_nTimes=0; 70 | double dL1; 71 | double dA1; 72 | double dL2; 73 | double dA2; 74 | double dL3; 75 | double dA3; 76 | IMapLayer* m_pLayer=nullptr; 77 | IPersonInfo* m_pPersonInfo=nullptr; 78 | IPoint* m_pPoint = nullptr; 79 | IMapLine* m_pLine = nullptr; 80 | IModel* m_pModel=nullptr; 81 | ISceneNode* m_pTrackNode=nullptr; 82 | CPlaceNode* m_pTestNode{}; 83 | CPlaceNode* m_pTestNode1{}; 84 | }; 85 | 86 | #endif // MAINWINDOW_H 87 | -------------------------------------------------------------------------------- /LoadQmlMap/AppGlobal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "AppGlobal.h" 6 | #include "PlotMap.h" 7 | 8 | QAppGlobal::QAppGlobal(QObject *parent) : QObject(parent) 9 | { 10 | m_pPlotMap = new CPlotMap; 11 | setObjectName("AppGlobal"); 12 | } 13 | 14 | QAppGlobal::~QAppGlobal() 15 | { 16 | delete m_pPlotMap; 17 | } 18 | 19 | /// 设置osgItem 20 | void QAppGlobal::setOsgItem(QQuickItem *pOsgItem) 21 | { 22 | m_pOsgItem = pOsgItem; 23 | auto pSeneGraph = GetSceneCore()->GetSceneGraphManager()->FindSceneGraph(pOsgItem); 24 | m_pPlotMap->SetSceneGraph(pSeneGraph); 25 | } 26 | 27 | void QAppGlobal::plotALine() 28 | { 29 | m_pPlotMap->PlotLine(); 30 | } 31 | 32 | void QAppGlobal::clearPlot() 33 | { 34 | m_pPlotMap->ClearLayer(); 35 | } 36 | -------------------------------------------------------------------------------- /LoadQmlMap/AppGlobal.h: -------------------------------------------------------------------------------- 1 | #ifndef APPGLOBAL_H 2 | #define APPGLOBAL_H 3 | 4 | #include 5 | 6 | class QQuickItem; 7 | class CPlotMap; 8 | //class ScenarioManager; 9 | class AreaPlanManager; 10 | //Q_DECLARE_METATYPE(ScenarioManager) 11 | //Q_DECLARE_METATYPE(Scenario) 12 | class QAppGlobal : public QObject 13 | { 14 | Q_OBJECT 15 | //Q_PROPERTY(ScenarioManager scenarioManager READ scenarioManager NOTIFY scenarioManagerChanged) 16 | public: 17 | explicit QAppGlobal(QObject *parent = nullptr); 18 | ~QAppGlobal(); 19 | 20 | /** 21 | * @brief 设置显示的osgquickItem 22 | * @param pOsgItem 23 | */ 24 | Q_INVOKABLE void setOsgItem(QQuickItem* pOsgItem); 25 | 26 | /** 27 | * @brief 标绘 28 | */ 29 | Q_INVOKABLE void plotALine(); 30 | 31 | /** 32 | * @brief 清空标绘 33 | */ 34 | Q_INVOKABLE void clearPlot(); 35 | private: 36 | CPlotMap* m_pPlotMap{}; /// 在map上绘制 37 | QQuickItem* m_pOsgItem{}; /// 设置绑定的osg显示 38 | }; 39 | 40 | 41 | #endif // APPGLOBAL_H 42 | -------------------------------------------------------------------------------- /LoadQmlMap/DealWindowsMessage.cpp: -------------------------------------------------------------------------------- 1 | #include "DealWindowsMessage.h" 2 | #include 3 | 4 | CDealWindowsMessage::CDealWindowsMessage() 5 | { 6 | 7 | } 8 | 9 | void CDealWindowsMessage::MouseDown(MouseButtonMask, int, int) 10 | { 11 | //qDebug()<<"hello Mouse Dow"; 12 | } 13 | -------------------------------------------------------------------------------- /LoadQmlMap/DealWindowsMessage.h: -------------------------------------------------------------------------------- 1 | #ifndef CDEALWINDOWSMESSAGE_H 2 | #define CDEALWINDOWSMESSAGE_H 3 | #include 4 | 5 | class CDealWindowsMessage:public IWindowMessageObserver 6 | { 7 | public: 8 | CDealWindowsMessage(); 9 | 10 | void MouseDown(MouseButtonMask, int, int); 11 | }; 12 | 13 | #endif // CDEALWINDOWSMESSAGE_H 14 | -------------------------------------------------------------------------------- /LoadQmlMap/LoadQmlMap.pro: -------------------------------------------------------------------------------- 1 | QT += quick 2 | 3 | HEADERS += \ 4 | AppGlobal.h \ 5 | DealWindowsMessage.h \ 6 | PlotMap.h 7 | 8 | SOURCES += \ 9 | AppGlobal.cpp \ 10 | DealWindowsMessage.cpp \ 11 | PlotMap.cpp \ 12 | main.cpp 13 | 14 | lessThan(QT_MAJOR_VERSION, 6):RESOURCES += qml.qrc 15 | greaterThan(QT_MAJOR_VERSION, 5):RESOURCES += qml6.qrc 16 | 17 | 18 | TRANSLATIONS += \ 19 | LoadQmlMap_zh_CN.ts 20 | 21 | SDK_CONFIG *= SceneCore Satellite 22 | unix:SDK_CONFIG *= Satellite OsgExtern 23 | 24 | include(../SoftSDK.pri) 25 | -------------------------------------------------------------------------------- /LoadQmlMap/LoadQmlMap_zh_CN.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /LoadQmlMap/PlotMap.h: -------------------------------------------------------------------------------- 1 | #ifndef CPLOTMAP_H 2 | #define CPLOTMAP_H 3 | 4 | class ISceneGraph; 5 | class CDealWindowsMessage; 6 | 7 | class CPlotMap 8 | { 9 | public: 10 | CPlotMap(); 11 | 12 | /** 13 | * @brief 设置场景图 14 | * @param pSceneGraph 15 | */ 16 | void SetSceneGraph(ISceneGraph* pSceneGraph); 17 | 18 | /** 19 | * @brief 绘制线 20 | */ 21 | void PlotLine(); 22 | 23 | /** 24 | * @brief 清空图层 25 | */ 26 | void ClearLayer(); 27 | private: 28 | ISceneGraph* m_pSceneGraph{}; 29 | CDealWindowsMessage* m_pDealWindowMessage{}; 30 | }; 31 | 32 | #endif // CPLOTMAP_H 33 | -------------------------------------------------------------------------------- /LoadQmlMap/img.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Image/Common/Menu_Button_Hilite.png 4 | Image/Common/Menu-TopLine-Emblem.png 5 | Image/Common/NormalShadow.png 6 | Image/Common/TalkboxBG.png 7 | 8 | 9 | -------------------------------------------------------------------------------- /LoadQmlMap/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "Qml/QtOsgItem.h" 8 | #include "ISceneCore.h" 9 | #include "AppGlobal.h" 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 14 | QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 15 | #endif 16 | 17 | QGuiApplication app(argc, argv); 18 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 19 | QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi); 20 | #endif 21 | 22 | bool bChecked = CheckPC(argv); 23 | if(!bChecked) 24 | { 25 | return(-1); 26 | } 27 | 28 | qmlRegisterType("MyItem",1,0,"AppGlobal"); 29 | qmlRegisterType("MyItem",1,0,"OsgItem"); 30 | 31 | QQmlApplicationEngine engine; 32 | 33 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 34 | const QUrl url(QStringLiteral("qrc:/main.qml")); 35 | #else 36 | const QUrl url(QStringLiteral("qrc:/main6.qml")); 37 | #endif 38 | QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 39 | &app, [url](QObject *obj, const QUrl &objUrl) { 40 | if (!obj && url == objUrl) 41 | QCoreApplication::exit(-1); 42 | }, Qt::QueuedConnection); 43 | engine.load(url); 44 | 45 | return app.exec(); 46 | } 47 | -------------------------------------------------------------------------------- /LoadQmlMap/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Window 2.12 3 | import MyItem 1.0 4 | 5 | Window 6 | { 7 | id: mainWindow 8 | visible: true 9 | x:0 10 | y:0 11 | flags: Qt.Window 12 | //width: 1920 13 | //height: 1080 14 | title: qsTr("Test") 15 | property var $app: AppGlobal{} 16 | 17 | OsgItem{ 18 | type: OsgItem.Item_3DMAP 19 | id:showOsg 20 | frameRate: 60 21 | focus: true 22 | anchors.fill: parent 23 | Component.onCompleted:{ 24 | $app.setOsgItem(showOsg) 25 | mainWindow.showMaximized(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LoadQmlMap/main6.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Window 2.12 3 | import MyItem 1.0 4 | import QtQml 2.0 5 | 6 | Window 7 | { 8 | id: mainWindow 9 | property var $app: AppGlobal{} 10 | 11 | visible: true 12 | width: 1024 13 | height: 768 14 | title: qsTr("Hello World") 15 | 16 | OsgItem 17 | { 18 | type: OsgItem.Item_2DMAP 19 | frameRate: 1000 20 | id:showOsg 21 | focus: true 22 | anchors.fill: parent 23 | } 24 | 25 | Component.onCompleted: 26 | { 27 | $app.setOsgItem(showOsg) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LoadQmlMap/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /LoadQmlMap/qml6.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main6.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /Map.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS =\ 4 | OsgExtern\ 5 | SceneCore\ 6 | Plot\ 7 | Tool\ 8 | ExternShape\ 9 | LoadMap 10 | CONFIG *= ordered 11 | -------------------------------------------------------------------------------- /OsgExtern/FlashAbility.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "FlashAbility.h" 4 | 5 | void CFlashAbility::InitAbility() 6 | { 7 | m_pSceneNode->MergeStateSet(FLASH_DRAW_STATE); 8 | 9 | m_pSceneNode->AsOsgSceneNode()->GetOsgNode()->getOrCreateStateSet() 10 | ->getOrCreateUniform("flashStartTime",osg::Uniform::FLOAT)->set((float)osg::Timer::instance()->time_s()); 11 | } 12 | 13 | void CFlashAbility::RemoveAbility() 14 | { 15 | m_pSceneNode->RemoveStateSet(FLASH_DRAW_STATE); 16 | } 17 | 18 | void CFlashAbility::UpdateAbility() 19 | { 20 | ImplNodeAbility::UpdateAbility(); 21 | 22 | /// 闪射状态更改 23 | if(m_bStatusChanged) 24 | { 25 | int nFlashHZ=m_nFlashHZ; 26 | 27 | if(nFlashHZ < 1) 28 | { 29 | nFlashHZ = -1; 30 | } 31 | 32 | if(nFlashHZ > 60) 33 | { 34 | nFlashHZ = 60; 35 | } 36 | 37 | /// 更新数据 38 | m_pSceneNode->AsOsgSceneNode()->GetOsgNode()->getOrCreateStateSet() 39 | ->getOrCreateUniform("flashDurTime",osg::Uniform::FLOAT)->set(.5f/nFlashHZ); 40 | m_pSceneNode->AsOsgSceneNode()->GetOsgNode()->getOrCreateStateSet() 41 | ->getOrCreateUniform("flashIntervalTime",osg::Uniform::FLOAT)->set(1.f/nFlashHZ); 42 | 43 | m_bStatusChanged=false; 44 | } 45 | 46 | /// 闪烁颜色更改 47 | if(m_bColorChanged) 48 | { 49 | m_pSceneNode->AsOsgSceneNode()->GetOsgNode()->getOrCreateStateSet() 50 | ->getOrCreateUniform("flashColor",osg::Uniform::FLOAT_VEC4) 51 | ->set(osg::Vec4(m_stFlahColor.fR,m_stFlahColor.fG,m_stFlahColor.fB,m_stFlahColor.fA)); 52 | 53 | m_bColorChanged=false; 54 | } 55 | 56 | ///闪烁状态更改 57 | if(m_bFlashChanged) 58 | { 59 | if(m_bFlash) 60 | { 61 | InitAbility(); 62 | } 63 | else 64 | { 65 | m_pSceneNode->RemoveStateSet(FLASH_DRAW_STATE); 66 | } 67 | m_bFlashChanged=false; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /OsgExtern/FlashAbility.h: -------------------------------------------------------------------------------- 1 | #ifndef CFLASHABILITY_H 2 | #define CFLASHABILITY_H 3 | #include 4 | #include 5 | #include 6 | #include "ImplNodeAbility.hpp" 7 | 8 | class CFlashAbility : public ImplNodeAbility 9 | { 10 | public: 11 | /** 12 | * @brief 初始化能力 13 | */ 14 | void InitAbility(); 15 | 16 | /** 17 | * @brief 移除能力 18 | */ 19 | void RemoveAbility(); 20 | 21 | /** 22 | * @brief 更新能力 23 | */ 24 | void UpdateAbility(); 25 | protected: 26 | void FlashStatusChanged()SET_TRUE_ABILITY_UPDATE(m_bStatusChanged) 27 | void FlashColorChanged()SET_TRUE_ABILITY_UPDATE(m_bColorChanged) 28 | void FlashFlashChanged()SET_TRUE_ABILITY_UPDATE(m_bFlashChanged) 29 | protected: 30 | osg::ref_ptr m_pFlashStartTime; 31 | osg::ref_ptr m_pFlashDurTime; 32 | osg::ref_ptr m_pFlashIntervalTime; 33 | osg::ref_ptr m_pFlashColor; 34 | osg::ref_ptr m_pOldStateSet; 35 | osg::observer_ptr m_pFlashStateSet; 36 | bool m_bStatusChanged{false}; 37 | bool m_bColorChanged{false}; 38 | bool m_bFlashChanged{false}; 39 | }; 40 | 41 | #endif // CFLASHABILITY_H 42 | -------------------------------------------------------------------------------- /OsgExtern/FlatAbility.h: -------------------------------------------------------------------------------- 1 | #ifndef CFLATABILITY_H 2 | #define CFLATABILITY_H 3 | #include 4 | #include "ImplNodeAbility.hpp" 5 | 6 | class CFlatAbility:public ImplNodeAbility 7 | { 8 | public: 9 | /** 10 | * @brief 初始化能力 11 | */ 12 | void InitAbility(); 13 | 14 | /** 15 | * @brief 移除能力 16 | */ 17 | void RemoveAbility(); 18 | 19 | /** 20 | * @brief 更新能力 21 | */ 22 | void UpdateAbility(); 23 | 24 | /** 25 | * @brief 添加洞 26 | */ 27 | int AddHole(const FlatArea& flatArea); 28 | 29 | /** 30 | * @brief 移除洞 31 | */ 32 | bool RemoveHole(int nIndex); 33 | protected: 34 | std::map m_mapId2Hole; 35 | osg::ref_ptr m_pHoleMatrix; 36 | osg::ref_ptr m_pHoleNum; 37 | }; 38 | 39 | #endif // CFLATABILITY_H 40 | -------------------------------------------------------------------------------- /OsgExtern/ImplNodeAbility.hpp: -------------------------------------------------------------------------------- 1 | #ifndef IMPLNODEABILITY_HPP 2 | #define IMPLNODEABILITY_HPP 3 | 4 | #include 5 | #include 6 | 7 | #define SET_TRUE_ABILITY_UPDATE(VA) {VA=true;m_pSceneNode->AbilityChanged();} 8 | 9 | template 10 | class ImplNodeAbility:public T 11 | { 12 | public: 13 | /** 14 | * @brief 初始化能力 15 | */ 16 | virtual void InitAbility()=0; 17 | 18 | /** 19 | * @brief 移除能力 20 | */ 21 | virtual void RemoveAbility()=0; 22 | 23 | /** 24 | * @brief 绑定场景节点 25 | * @param pNode 场景节点 26 | */ 27 | void BoundNode(ISceneNode* pNode) 28 | { 29 | if(nullptr != pNode && nullptr == m_pSceneNode) 30 | { 31 | m_pSceneNode = pNode; 32 | m_bNeedInit=true; 33 | m_pSceneNode->AbilityChanged(); 34 | } 35 | } 36 | 37 | /** 38 | * @brief 能力状态更改 39 | */ 40 | void AbilityStatusChanged() 41 | { 42 | m_pSceneNode->AbilityChanged(); 43 | } 44 | 45 | /** 46 | * @brief 更新节点的能力 47 | */ 48 | void UpdateAbility() 49 | { 50 | if(m_bNeedInit) 51 | { 52 | InitAbility(); 53 | m_bNeedInit = false; 54 | } 55 | } 56 | protected: 57 | ISceneNode* m_pSceneNode{}; 58 | bool m_bNeedInit{false}; 59 | }; 60 | 61 | #endif // IMPLNODEABILITY_HPP 62 | -------------------------------------------------------------------------------- /OsgExtern/LoadGLSL.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | CLoadGLSL::CLoadGLSL(const std::string &sGlslFileName, const std::string &sGlslConfigFileName) 4 | { 5 | LoadGlsl(sGlslFileName); 6 | LoadConfig(sGlslConfigFileName); 7 | } 8 | 9 | void CLoadGLSL::LoadGLSL(osg::State *pSateSet) 10 | { 11 | } 12 | 13 | osg::StateSet *CLoadGLSL::ChangeFieldValue(const std::string &sFieldName, const Field &fieldValue) 14 | { 15 | 16 | return(nullptr); 17 | } 18 | 19 | void CLoadGLSL::LoadGlsl(const std::string &sGlslFileName) 20 | { 21 | } 22 | 23 | void CLoadGLSL::LoadConfig(const std::string &sConfigFileName) 24 | { 25 | m_pDefaultStateset; 26 | } 27 | -------------------------------------------------------------------------------- /OsgExtern/MathCommon.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | std::map IOsgMapSceneNode::s_mapIs3D; 7 | std::map> IOsgMapSceneNode::s_mapMapNode; 8 | std::map> IOsgMapSceneNode::s_mapMapSRS; 9 | std::map> IOsgMapSceneNode::s_mapTerrain; 10 | std::map> IOsgMapSceneNode::s_mapHorizonCullBack; 11 | osg::ref_ptr IOsgMapSceneNode::s_pWGS84=osgEarth::SpatialReference::get("WGS84"); 12 | 13 | CMathCommon *CMathCommon::GetInstance() 14 | { 15 | static CMathCommon s_mathCommon; 16 | 17 | /// 如果没有初始化 则初始化 18 | if(!s_mathCommon.m_bInit) 19 | { 20 | s_mathCommon.Init(); 21 | } 22 | 23 | return(&s_mathCommon); 24 | } 25 | 26 | /// 获取sin值 27 | const double *CMathCommon::GetSin() 28 | { 29 | return(m_pSin); 30 | } 31 | 32 | /// 获取cos值 33 | const double* CMathCommon::GetCos() 34 | { 35 | return(m_pCos); 36 | } 37 | 38 | CMathCommon::CMathCommon(): 39 | m_bInit(false) 40 | { 41 | m_pSin = new double[360]; 42 | m_pCos = new double[360]; 43 | } 44 | 45 | /// 析构数据空间 46 | CMathCommon::~CMathCommon() 47 | { 48 | delete []m_pSin; 49 | delete []m_pCos; 50 | } 51 | 52 | /// 初始化 53 | void CMathCommon::Init() 54 | { 55 | for(int i=0; i<360; ++i) 56 | { 57 | m_pSin[i] = sin(i*DD2R); 58 | m_pCos[i] = cos(i*DD2R); 59 | } 60 | m_bInit = true; 61 | } 62 | -------------------------------------------------------------------------------- /OsgExtern/MyMatrixTransform.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | CMyMatrixTransform::CMyMatrixTransform() 4 | { 5 | } 6 | 7 | void CMyMatrixTransform::SetMatrix(const Math::CMatrix &rMatrix) 8 | { 9 | _matrix.set(rMatrix(0,0),rMatrix(0,1),rMatrix(0,2),0., 10 | rMatrix(1,0),rMatrix(1,1),rMatrix(1,2),0., 11 | rMatrix(2,0),rMatrix(2,1),rMatrix(2,2),0., 12 | 0.,0.,0.,1.); 13 | } 14 | 15 | bool CMyMatrixTransform::computeLocalToWorldMatrix(osg::Matrix &matrix, osg::NodeVisitor *nv) const 16 | { 17 | if(_matrix.isIdentity()) 18 | { 19 | return(true); 20 | } 21 | else 22 | { 23 | return(osg::MatrixTransform::computeLocalToWorldMatrix(matrix,nv)); 24 | } 25 | } 26 | 27 | bool CMyMatrixTransform::computeWorldToLocalMatrix(osg::Matrix &matrix, osg::NodeVisitor *nv) const 28 | { 29 | if(_matrix.isIdentity()) 30 | { 31 | return(true); 32 | } 33 | else 34 | { 35 | return(osg::MatrixTransform::computeWorldToLocalMatrix(matrix,nv)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /OsgExtern/NodeAbilityManager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "FlashAbility.h" 3 | #include "FlatAbility.h" 4 | 5 | CNodeAbilityManager *CNodeAbilityManager::GetInstance() 6 | { 7 | static CNodeAbilityManager s_gNodeAbilityManager; 8 | return(&s_gNodeAbilityManager); 9 | } 10 | 11 | INodeAbility *CNodeAbilityManager::CreateAbility(ABILITY_TYPE emType) 12 | { 13 | switch (emType) 14 | { 15 | case FLASH_ABILITY: 16 | return(new CFlashAbility); 17 | case AUTOSCAL_ABILITY: 18 | break; 19 | case MOTION_ABILITY: 20 | break; 21 | case FLAT_ABILITY: 22 | return(new CFlatAbility); 23 | break; 24 | case EDIT_ABILITY: 25 | break; 26 | default: 27 | break; 28 | } 29 | return(nullptr); 30 | } 31 | 32 | bool CNodeAbilityManager::RemoveAbility(INodeAbility *&pNodeAbility) 33 | { 34 | pNodeAbility = nullptr; 35 | return(true); 36 | } 37 | -------------------------------------------------------------------------------- /OsgExtern/OsgExtern.pro: -------------------------------------------------------------------------------- 1 | CONFIG -= qt 2 | 3 | TARGET = OsgExtern 4 | TEMPLATE = lib 5 | 6 | DEFINES += OSGEXTERN_LIBRARY 7 | 8 | SDK_CONFIG *= OSG Satellite 9 | 10 | include(../SoftSDK.pri) 11 | 12 | SOURCES += \ 13 | FlashAbility.cpp \ 14 | FlatAbility.cpp \ 15 | Grid2TriangleStrip.cpp \ 16 | JudgeGeometry.cpp \ 17 | LoadGLSL.cpp \ 18 | MathCommon.cpp \ 19 | MyMatrixTransform.cpp \ 20 | MyPositionAttitudeTransform.cpp \ 21 | NodeAbilityManager.cpp \ 22 | SplitRectangle.cpp 23 | 24 | HEADERS += \ 25 | FlashAbility.h \ 26 | FlatAbility.h \ 27 | ImplNodeAbility.hpp 28 | -------------------------------------------------------------------------------- /OsgExtern/SplitRectangle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | CSplitRectangle::CSplitRectangle() 4 | { 5 | } 6 | 7 | void CSplitRectangle::SetRectangle(const Rectangle &rRectangle) 8 | { 9 | m_stRectangle = rRectangle; 10 | ReCal(); 11 | } 12 | 13 | void CSplitRectangle::ReCal() 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /Path.pri: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MJYCo-Ltd/Map/a95d6225cc08beffab6b609325610c3edfc129b6/Path.pri -------------------------------------------------------------------------------- /Plot/Hud/Hud.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-19T11:02:02 4 | # 5 | #------------------------------------------------- 6 | 7 | CONFIG -= qt 8 | 9 | TARGET = Hud 10 | TEMPLATE = lib 11 | 12 | SDK_CONFIG *= OSG OsgExtern PLOT 13 | include($$PWD/../../SoftSDK.pri) 14 | 15 | HEADERS += \ 16 | HudImage.h \ 17 | HudLayout.h \ 18 | HudShape.h \ 19 | HudText.h \ 20 | HudButton.h 21 | 22 | SOURCES += \ 23 | HudImage.cpp \ 24 | HudLayout.cpp \ 25 | HudShape.cpp \ 26 | HudText.cpp \ 27 | HudButton.cpp 28 | -------------------------------------------------------------------------------- /Plot/Hud/HudButton.h: -------------------------------------------------------------------------------- 1 | #ifndef CHUDBUTTON_H 2 | #define CHUDBUTTON_H 3 | #include 4 | #include 5 | 6 | class CHudButton:public ImplHudNode 7 | { 8 | friend struct ClickViewpointHandler; 9 | public: 10 | CONSTRUCTOR(CHudButton,ImplHudNode) 11 | virtual bool SubObserver(IHudButtonObserver* pObserver); 12 | virtual bool UnSubObserver(IHudButtonObserver* pObserver); 13 | protected: 14 | void InitNode(); 15 | void FrameCall(); 16 | void FontSizeChanged()SET_TRUE_NODE_UPDATE(m_bFontSizeChanged) 17 | void TextChanged()SET_TRUE_NODE_UPDATE(m_bTextChanged) 18 | void FontChanged()SET_TRUE_NODE_UPDATE(m_bFontChanged) 19 | void ColorChanged()SET_TRUE_NODE_UPDATE(m_bColorChanged) 20 | void OutColorChanged()SET_TRUE_NODE_UPDATE(m_bOutColorChanged) 21 | protected: 22 | osg::observer_ptr m_pButtonControl; 23 | bool m_bFontSizeChanged{false}; 24 | bool m_bTextChanged{false}; 25 | bool m_bFontChanged{false}; 26 | bool m_bColorChanged{false}; 27 | bool m_bOutColorChanged{false}; 28 | std::list m_pAllButtonObserver; 29 | }; 30 | 31 | #endif // CHUDBUTTON_H 32 | -------------------------------------------------------------------------------- /Plot/Hud/HudImage.cpp: -------------------------------------------------------------------------------- 1 | #include "HudImage.h" 2 | #include 3 | void CHudImage::InitNode() 4 | { 5 | ImplHudNode::InitNode(); 6 | m_pImageControl = new osgEarth::Controls::ImageControl; 7 | m_pImageControl->setRotation(osgEarth::Angular(m_dAngle, osgEarth::Units::DEGREES)); 8 | m_pImageControl->setHorizAlign(osgEarth::Util::Controls::Control::ALIGN_RIGHT); 9 | m_pImageControl->setVertAlign(osgEarth::Util::Controls::Control::ALIGN_BOTTOM); 10 | m_pImageControl->setFixSizeForRotation(true); 11 | 12 | SetControlNode(m_pImageControl.get()); 13 | 14 | } 15 | 16 | void CHudImage::FrameCall() 17 | { 18 | if(m_bImageChanged) 19 | { 20 | auto pTexture = m_pSceneGraph->ResouceLoader()->LoadTexture(m_sImagePath); 21 | if(nullptr != pTexture) 22 | { 23 | m_pImageControl->setTexture(pTexture); 24 | 25 | m_pImageControl->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON); 26 | m_pImageControl->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); 27 | } 28 | m_bImageChanged=false; 29 | } 30 | if(m_bAngleChanged) 31 | { 32 | m_pImageControl->setRotation(osgEarth::Angular(m_dAngle, osgEarth::Units::DEGREES)); 33 | m_bAngleChanged=false; 34 | } 35 | 36 | if(m_bImageSizeChanged) 37 | { 38 | m_pImageControl->setSize(m_stImageSize.unWidth,m_stImageSize.unHeight); 39 | m_bImageSizeChanged = false; 40 | } 41 | ImplHudNode::FrameCall(); 42 | } 43 | -------------------------------------------------------------------------------- /Plot/Hud/HudImage.h: -------------------------------------------------------------------------------- 1 | #ifndef CHUDIMAGE_H 2 | #define CHUDIMAGE_H 3 | #include 4 | #include 5 | 6 | class CHudImage:public ImplHudNode 7 | { 8 | public: 9 | CONSTRUCTOR(CHudImage,ImplHudNode) 10 | 11 | protected: 12 | void ImageChanged()SET_TRUE_NODE_UPDATE(m_bImageChanged) 13 | void AngleChanged()SET_TRUE_NODE_UPDATE(m_bAngleChanged) 14 | void ImageSizeChanged()SET_TRUE_NODE_UPDATE(m_bImageSizeChanged) 15 | void InitNode(); 16 | void FrameCall(); 17 | protected: 18 | bool m_bImageChanged{false}; 19 | bool m_bAngleChanged{false}; 20 | bool m_bImageSizeChanged{false}; 21 | osg::observer_ptr m_pImageControl; 22 | }; 23 | 24 | #endif // CHUDIMAGE_H 25 | -------------------------------------------------------------------------------- /Plot/Hud/HudNode.cpp: -------------------------------------------------------------------------------- 1 | #include "HudNode.h" 2 | 3 | CHudNode::CHudNode() 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /Plot/Hud/HudNode.h: -------------------------------------------------------------------------------- 1 | #ifndef CHUDNODE_H 2 | #define CHUDNODE_H 3 | 4 | 5 | class CHudNode 6 | { 7 | public: 8 | CHudNode(); 9 | }; 10 | 11 | #endif // CHUDNODE_H 12 | -------------------------------------------------------------------------------- /Plot/Hud/HudShape.cpp: -------------------------------------------------------------------------------- 1 | #include "HudShape.h" 2 | #include "HudText.h" 3 | #include "HudImage.h" 4 | #include "HudLayout.h" 5 | #include "HudButton.h" 6 | 7 | static const char s_sHudImage[]="IHudImage"; 8 | static const char s_sHudText[]="IHudText"; 9 | static const char s_sHudLayout[]="IHudLayout"; 10 | static const char s_sHudVBox[]="IHudVBox"; 11 | static const char s_sHudButton[]="IHudButton"; 12 | 13 | ISceneNode* CreateNode(ISceneGraph*pSceneGraph,const std::string& sInterfaceName) 14 | { 15 | if(sInterfaceName == s_sHudText) 16 | { 17 | return(new CHudText(pSceneGraph)); 18 | } 19 | else if(sInterfaceName == s_sHudImage) 20 | { 21 | return(new CHudImage(pSceneGraph)); 22 | } 23 | else if(sInterfaceName == s_sHudLayout) 24 | { 25 | return(new CHudLayout(pSceneGraph)); 26 | } 27 | else if(sInterfaceName == s_sHudButton) 28 | { 29 | return(new CHudButton(pSceneGraph)); 30 | } 31 | else if(sInterfaceName == s_sHudVBox) 32 | { 33 | } 34 | return(nullptr); 35 | } 36 | 37 | bool QueryInterface(std::string& sInterfaceName) 38 | { 39 | sInterfaceName.clear(); 40 | 41 | sInterfaceName += s_sHudImage; 42 | sInterfaceName += " "; 43 | sInterfaceName += s_sHudText; 44 | sInterfaceName += " "; 45 | sInterfaceName += s_sHudLayout; 46 | sInterfaceName += " "; 47 | sInterfaceName += s_sHudButton; 48 | sInterfaceName += " "; 49 | sInterfaceName += s_sHudVBox; 50 | 51 | 52 | return(true); 53 | } 54 | -------------------------------------------------------------------------------- /Plot/Hud/HudShape.h: -------------------------------------------------------------------------------- 1 | #ifndef C_HUD_H 2 | #define C_HUD_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | extern "C" 10 | { 11 | Q_DECL_EXPORT ISceneNode* CreateNode(ISceneGraph*pSceneGraph,const std::string& sInterfaceName); 12 | Q_DECL_EXPORT bool QueryInterface(std::string& sInterfaceName); 13 | } 14 | 15 | #endif // C_HUD_H 16 | -------------------------------------------------------------------------------- /Plot/Hud/HudText.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HudText.h" 3 | 4 | ///初始化hud字体 5 | void CHudText::InitNode() 6 | { 7 | ImplHudNode::InitNode(); 8 | m_stColor.fR = 1.f; 9 | m_pLabelControl = new osgEarth::Controls::LabelControl; 10 | m_pLabelControl->setEncoding(osgText::String::ENCODING_UTF8); 11 | 12 | m_pLabelControl->setForeColor(m_stColor.fR,m_stColor.fG,m_stColor.fB,m_stColor.fA); 13 | m_pLabelControl->setFontSize(m_nFontSize); 14 | m_pLabelControl->setHaloColor(osg::Vec4(m_stOutLineColor.fR,m_stOutLineColor.fG,m_stOutLineColor.fB,m_stOutLineColor.fA)); 15 | 16 | SetControlNode(m_pLabelControl.get()); 17 | } 18 | 19 | /// 更新节点 20 | void CHudText::FrameCall() 21 | { 22 | if(m_bFontChanged) 23 | { 24 | m_pLabelControl->setFont(m_pSceneGraph->ResouceLoader()->LoadFont(m_sFont)); 25 | m_bFontChanged=false; 26 | } 27 | 28 | if(m_bFontSizeChanged) 29 | { 30 | m_pLabelControl->setFontSize(m_nFontSize); 31 | m_bFontSizeChanged=false; 32 | } 33 | 34 | if(m_bTextChanged) 35 | { 36 | m_pLabelControl->setText(m_sText); 37 | m_bTextChanged=false; 38 | } 39 | 40 | if(m_bColorChanged) 41 | { 42 | m_pLabelControl->setForeColor(osg::Vec4(m_stColor.fR,m_stColor.fG,m_stColor.fB,m_stColor.fA)); 43 | m_bColorChanged=false; 44 | } 45 | 46 | if(m_bOutColorChanged) 47 | { 48 | m_pLabelControl->setHaloColor(osg::Vec4(m_stOutLineColor.fR,m_stOutLineColor.fG,m_stOutLineColor.fB,m_stOutLineColor.fA)); 49 | m_bOutColorChanged=false; 50 | } 51 | 52 | ImplHudNode::FrameCall(); 53 | } 54 | -------------------------------------------------------------------------------- /Plot/Hud/HudText.h: -------------------------------------------------------------------------------- 1 | #ifndef CHUDTEXT_H 2 | #define CHUDTEXT_H 3 | #include 4 | #include 5 | 6 | class CHudText:public ImplHudNode 7 | { 8 | public: 9 | CONSTRUCTOR(CHudText,ImplHudNode) 10 | protected: 11 | void InitNode(); 12 | void FrameCall(); 13 | void FontSizeChanged()SET_TRUE_NODE_UPDATE(m_bFontSizeChanged) 14 | void TextChanged()SET_TRUE_NODE_UPDATE(m_bTextChanged) 15 | void FontChanged()SET_TRUE_NODE_UPDATE(m_bFontChanged) 16 | void ColorChanged()SET_TRUE_NODE_UPDATE(m_bColorChanged) 17 | void OutColorChanged()SET_TRUE_NODE_UPDATE(m_bOutColorChanged) 18 | protected: 19 | osg::observer_ptr m_pLabelControl; 20 | bool m_bFontSizeChanged{false}; 21 | bool m_bTextChanged{false}; 22 | bool m_bFontChanged{false}; 23 | bool m_bColorChanged{false}; 24 | bool m_bOutColorChanged{false}; 25 | }; 26 | 27 | #endif // CHUDTEXT_H 28 | -------------------------------------------------------------------------------- /Plot/Map/Atmosphere.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "Atmosphere.h" 8 | 9 | CAtmosphere::CAtmosphere(ISceneGraph* pSceneGraph) 10 | { 11 | IPlot* pPlot=pSceneGraph->GetPlot(); 12 | m_pEllipsoid=dynamic_cast(pPlot->CreateSceneNode("IEllipsoidSensor")); 13 | 14 | m_pEllipsoid->SetDrawType(IEllipsoidSensor::FULL_PART); 15 | m_pEllipsoid->SetEquator(R_Earth*1.025); 16 | m_pEllipsoid->SetPolar(R_Earth2*1.025); 17 | m_pEllipsoid->ShowLine(false); 18 | m_pEllipsoid->SetLatSegMents(100); 19 | 20 | m_pEllipsoid->MergeStateSet(ATMOSPHERE_DRAW_STATE|DONT_WRIT_DEPTH); 21 | } 22 | 23 | void CAtmosphere::MakeAtmosphere() 24 | { 25 | 26 | } 27 | 28 | osg::Node *CAtmosphere::GetNode() 29 | { 30 | return(m_pEllipsoid->AsOsgSceneNode()->GetRealNode()); 31 | } 32 | 33 | void CAtmosphere::SetVisible(bool bVisilbe) 34 | { 35 | m_pEllipsoid->SetVisible(bVisilbe); 36 | } 37 | -------------------------------------------------------------------------------- /Plot/Map/Atmosphere.h: -------------------------------------------------------------------------------- 1 | #ifndef CATMOSPHERE_H 2 | #define CATMOSPHERE_H 3 | #include 4 | #include 5 | 6 | class CAtmosphere 7 | { 8 | public: 9 | CAtmosphere(ISceneGraph* pSceneGraph); 10 | 11 | /** 12 | * @brief 构建太空盒子 13 | */ 14 | void MakeAtmosphere(); 15 | 16 | /** 17 | * @brief 获取节点 18 | * @return 19 | */ 20 | osg::Node* GetNode(); 21 | 22 | /** 23 | * @brief 设置是否可见 24 | * @param bVisilbe 25 | */ 26 | void SetVisible(bool bVisilbe); 27 | protected: 28 | IEllipsoidSensor* m_pEllipsoid{nullptr}; 29 | }; 30 | 31 | #endif // CATMOSPHERE_H 32 | -------------------------------------------------------------------------------- /Plot/Map/Map.pro: -------------------------------------------------------------------------------- 1 | CONFIG -= qt 2 | TARGET = Map 3 | TEMPLATE = lib 4 | 5 | DEFINES += MAP_LIBRARY 6 | 7 | SDK_CONFIG *= OSG OsgExtern SceneCore Satellite PLOT 8 | 9 | include($$PWD/../../SoftSDK.pri) 10 | 11 | HEADERS += \ 12 | Atmosphere.h \ 13 | Map.h \ 14 | MapLayer.h \ 15 | MapModelLayer.h \ 16 | MapModifyLayer.h \ 17 | SpaceEnv.h 18 | 19 | SOURCES += \ 20 | Atmosphere.cpp \ 21 | Map.cpp \ 22 | MapLayer.cpp \ 23 | MapModelLayer.cpp \ 24 | MapModifyLayer.cpp \ 25 | SpaceEnv.cpp 26 | -------------------------------------------------------------------------------- /Plot/Map/MapLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAP_LAYER_H 2 | #define CMAP_LAYER_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class ISceneGraph; 10 | class CMapModelLayer; 11 | 12 | class CMapLayer : public IMapLayer 13 | { 14 | public: 15 | CMapLayer(const std::string& sLayerName, ISceneGraph* pSceneGraph); 16 | ~CMapLayer(); 17 | 18 | /** 19 | * @brief 获取图层名字 20 | * @return 21 | */ 22 | const std::string& GetLayerName(){return(m_sLayerName);} 23 | 24 | /** 25 | * @brief 添加节点 26 | */ 27 | virtual unsigned int AddSceneNode(IMapSceneNode*pSceneNode); 28 | 29 | /** 30 | * @brief 移除节点 31 | */ 32 | virtual void RemoveSceneNode(IMapSceneNode* pSceneNode); 33 | 34 | /** 35 | * @brief 清空所有的节点 36 | */ 37 | virtual void Clear(); 38 | 39 | /** 40 | * @brief 控制图层显隐 41 | */ 42 | virtual void SetVisible(bool bVisible); 43 | 44 | /** 45 | * @brief 图层是否可见 46 | * @return 47 | */ 48 | virtual bool IsVisible(){return(m_bVisible);} 49 | 50 | /** 51 | * @brief 更新地图 52 | * @param pMapNode 53 | */ 54 | void UpdateMapNode(); 55 | 56 | /** 57 | * @brief 获取模型 58 | * @return 59 | */ 60 | CMapModelLayer* GetModelLayer(){return(m_pModelLayer.get());} 61 | 62 | /** 63 | * @brief 设置渲染顺序 64 | * @param nOrder 65 | */ 66 | void SetRenderOrder(int nOrder); 67 | protected: 68 | /** 69 | * @brief 移除节点 70 | */ 71 | void RemoveNode(IMapSceneNode*); 72 | private: 73 | ISceneGraph* m_pSceneGraph{}; 74 | osg::ref_ptr m_pModelLayer; 75 | std::string m_sLayerName; 76 | unsigned int m_unID{}; 77 | bool m_bVisible{true}; 78 | std::map m_mapID2Node; 79 | }; 80 | 81 | #endif // CPLOTLAYER_H 82 | -------------------------------------------------------------------------------- /Plot/Map/MapModelLayer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "MapModelLayer.h" 4 | 5 | using namespace osgEarth; 6 | 7 | CMapModelLayer::CMapModelLayer(ISceneGraph* pSceneGraph): 8 | ImplSceneGroup(pSceneGraph) 9 | { 10 | } 11 | 12 | void CMapModelLayer::init() 13 | { 14 | VisibleLayer::init(); 15 | #if OSGEARTH_VERSION_LESS_OR_EQUAL(3,2,0) 16 | installDefaultOpacityShader(); 17 | #endif 18 | } 19 | 20 | void CMapModelLayer::InitNode() 21 | { 22 | init(); 23 | ImplSceneGroup::InitNode(); 24 | } 25 | 26 | osg::Node* CMapModelLayer::getNode() const 27 | { 28 | return m_pGroup.get(); 29 | } 30 | 31 | osg::Group* CMapModelLayer::getGroup() const 32 | { 33 | return m_pGroup.get(); 34 | } 35 | -------------------------------------------------------------------------------- /Plot/Map/MapModelLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAP_MODEL_LAYER_H 2 | #define CMAP_MODEL_LAYER_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 由于AnnotationLayer使用起来有问题 9 | * 此处自己将AnnotationLayer的代码复制到此处 10 | */ 11 | class CMapModelLayer:public osgEarth::VisibleLayer,public ImplSceneGroup 12 | { 13 | public: 14 | /** 15 | * @brief 默认构造函数 16 | */ 17 | CMapModelLayer(ISceneGraph* pSceneGraph); 18 | 19 | /** 20 | * @brief 获取Layer的根节点 21 | * @return 22 | */ 23 | osg::Group* getGroup() const; 24 | 25 | public:/// 重写VisibleLayer的接口 26 | 27 | virtual osg::Node* getNode() const; 28 | 29 | /** 30 | * @brief 重写初始化 31 | */ 32 | virtual void init(); 33 | 34 | protected: 35 | void InitNode(); 36 | protected: 37 | /** 38 | * @brief 析构函数 39 | */ 40 | virtual ~CMapModelLayer(){} 41 | }; 42 | 43 | #endif // CMAP_MODEL_LAYER_H 44 | -------------------------------------------------------------------------------- /Plot/Map/MapModifyLayer.cpp: -------------------------------------------------------------------------------- 1 | #include "MapModifyLayer.h" 2 | 3 | CMapModifyLayer::CMapModifyLayer(osgEarth::MapNode *pMapNode, osgEarth::Layer *pLayer, bool bAdd): 4 | m_pMapNode(pMapNode), 5 | m_pLayer(pLayer), 6 | m_bAdd(bAdd) 7 | { 8 | } 9 | 10 | void CMapModifyLayer::operator()(osg::Object*) 11 | { 12 | if(m_bAdd) 13 | { 14 | m_pMapNode->getMap()->addLayer(m_pLayer); 15 | } 16 | else 17 | { 18 | m_pMapNode->getMap()->removeLayer(m_pLayer); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Plot/Map/MapModifyLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAPMODIFYLAYER_H 2 | #define CMAPMODIFYLAYER_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief 地图图层变化 9 | */ 10 | class CMapModifyLayer : public osg::Operation 11 | { 12 | public: 13 | CMapModifyLayer(osgEarth::MapNode*,osgEarth::Layer*,bool); 14 | void operator()(osg::Object*); 15 | private: 16 | osg::ref_ptr m_pMapNode; 17 | osg::ref_ptr m_pLayer; 18 | bool m_bAdd; 19 | }; 20 | 21 | #endif // CMAPMODIFYLAYER_H 22 | -------------------------------------------------------------------------------- /Plot/Map/SpaceEnv.h: -------------------------------------------------------------------------------- 1 | #ifndef CSPACEENV_H 2 | #define CSPACEENV_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class CSpaceEnv:public ImplSceneGroup 9 | { 10 | public: 11 | CSpaceEnv(ISceneGraph*); 12 | 13 | /** 14 | * @brief 设置视口主相机 15 | * @param pCamera 16 | */ 17 | void SetMainCamara(osg::Camera* pCamera); 18 | 19 | /** 20 | * @brief 获取空间背景 21 | * @return 22 | */ 23 | ISpaceBackGround* GetSpaceBackGround(); 24 | 25 | /** 26 | * @brief 初始化节点 27 | */ 28 | void InitNode(); 29 | 30 | /** 31 | * @brief 更新时间 32 | */ 33 | void UpdateDate(double, const Math::CMatrix &rBackGroundMatrix,const Math::CMatrix& rCaleRote); 34 | 35 | /** 36 | * @brief 获取太阳位置 37 | * @return 38 | */ 39 | const Math::CVector& GetSunPos(){return(m_vSun);} 40 | 41 | /** 42 | * @brief 重写子类显隐控制 43 | */ 44 | void VisibleChanged(); 45 | protected: 46 | ISpaceBackGround* m_pSpaceBackGround{}; 47 | bool m_bShowSpaceBackGround{true}; 48 | osg::observer_ptr m_pMainCamera; 49 | std::vector m_vAllPos; 50 | Math::CVector m_vSun; 51 | }; 52 | 53 | #endif // CSPACEENV_H 54 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapCoverImage.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENECOVER_H 2 | #define CSCENECOVER_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class CMapCoverImage:public ImplMapSceneNode 9 | { 10 | public: 11 | CONSTRUCTOR(CMapCoverImage,ImplMapSceneNode) 12 | 13 | /** 14 | * @brief 更新地图节点 15 | * @param pMapNode 16 | */ 17 | void UpdateMapNode(); 18 | 19 | /** 20 | * @brief 初始化节点 21 | */ 22 | void InitNode(); 23 | 24 | 25 | /** 26 | * @brief 获取覆盖范围 27 | * @return 28 | */ 29 | virtual void SetCoverInfo(const CoverInfo&); 30 | 31 | /** 32 | * @brief 设置测点信息 33 | */ 34 | void SetCeDian(const std::vector&); 35 | 36 | /** 37 | * @brief 初始化样式 38 | */ 39 | void InitStyle(); 40 | 41 | /** 42 | * @brief 设置最小颜色 43 | */ 44 | void SetMinValueColor(const SceneColor&); 45 | 46 | /** 47 | * @brief 设置最大值颜色 48 | */ 49 | void SetMaxValueColor(const SceneColor&); 50 | 51 | void SetBound(const ScenePos&,const ScenePos&,const std::string&); 52 | 53 | private: 54 | std::vector m_vCedian; //// 测点信息 55 | CoverInfo m_rCoverInfo; /// 覆盖信息 56 | SceneColor m_stMinColor; 57 | SceneColor m_stMaxColor; 58 | osg::ref_ptr m_pDrapeableNode; 59 | osg::ref_ptr m_pImage; 60 | osg::ref_ptr m_pCoverage; 61 | osg::observer_ptr m_pCoverRoot; 62 | }; 63 | 64 | #endif // CSCENECOVER_H 65 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapLine.cpp: -------------------------------------------------------------------------------- 1 | #include "MapLine.h" 2 | 3 | void CMapLine::InitNode() 4 | { 5 | ImplMapSceneGeometry::InitNode(); 6 | 7 | m_pDrawLine = dynamic_cast(m_pSceneGraph->GetPlot()->CreateSceneNode("ILine")); 8 | if(nullptr != m_pDrawLine) 9 | { 10 | SetGeometry(m_pDrawLine); 11 | } 12 | } 13 | void CMapLine::Update() 14 | { 15 | UpdateMapNode(); 16 | } 17 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapLine.h: -------------------------------------------------------------------------------- 1 | #ifndef H_HEADER_CSCENELINE_H 2 | #define H_HEADER_CSCENELINE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CMapLine:public ImplMapSceneGeometry 9 | { 10 | public: 11 | CONSTRUCTOR(CMapLine,ImplMapSceneGeometry) 12 | 13 | /** 14 | * @brief 初始化节点 15 | */ 16 | void InitNode() override; 17 | 18 | virtual void Update(); 19 | }; 20 | 21 | #endif // CSCENELINE_H 22 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapLocation.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAPLOCATION_H 2 | #define CMAPLOCATION_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | class CMapLocation:public ImplMapSceneNode 9 | { 10 | public: 11 | CONSTRUCTOR(CMapLocation,ImplMapSceneNode) 12 | 13 | /** 14 | * @brief 15 | * @param pNode 16 | */ 17 | void SetSceneNode(ISceneNode* pNode); 18 | /** 19 | * @brief 更新地图节点 20 | * @param pMapNode 21 | */ 22 | void UpdateMapNode(); 23 | 24 | protected: 25 | /** 26 | * @brief UpdateNode 27 | */ 28 | void FrameCall(); 29 | 30 | /** 31 | * @brief 初始化节点 32 | */ 33 | void InitNode(); 34 | 35 | /** 36 | * @brief 位置更改 37 | */ 38 | void PosChanged(); 39 | 40 | /** 41 | * @brief 贴地状态更改 42 | */ 43 | void TerrainTypeChanged(); 44 | 45 | /** 46 | * @brief 重新计算矩阵 47 | */ 48 | void ReCalculatMatrix(); 49 | 50 | protected: 51 | bool m_bPosChanged{false}; 52 | osgEarth::GeoPoint m_pGeoPoint; 53 | osg::observer_ptr m_pGeoTransform; 54 | }; 55 | 56 | #endif // CMAPLOCATION_H 57 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "MapPoint.h" 2 | 3 | void CMapPoint::InitNode() 4 | { 5 | ImplMapSceneGeometry::InitNode(); 6 | 7 | m_pDrawPoint = dynamic_cast(m_pSceneGraph->GetPlot()->CreateSceneNode("IPoint")); 8 | if(nullptr != m_pDrawPoint) 9 | { 10 | SetGeometry(m_pDrawPoint); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef H_HEADER_MAP_POINT_H 2 | #define H_HEADER_MAP_POINT_H 3 | 4 | #include 5 | #include 6 | 7 | class CMapPoint:public ImplMapSceneGeometry 8 | { 9 | public: 10 | CONSTRUCTOR(CMapPoint,ImplMapSceneGeometry) 11 | 12 | /** 13 | * @brief 初始化节点 14 | */ 15 | void InitNode() override; 16 | }; 17 | 18 | #endif // H_HEADER_MAP_POINT_H 19 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapPolygon.cpp: -------------------------------------------------------------------------------- 1 | #include "MapPolygon.h" 2 | 3 | void CMapPolygon::InitNode() 4 | { 5 | ImplMapSceneGeometry::InitNode(); 6 | 7 | m_pDrawPolygon = dynamic_cast(m_pSceneGraph->GetPlot()->CreateSceneNode("IPolygon")); 8 | if(nullptr != m_pDrawPolygon) 9 | { 10 | SetGeometry(m_pDrawPolygon); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapPolygon.h: -------------------------------------------------------------------------------- 1 | #ifndef CHEADER_SENEPOLYGON_H 2 | #define CHEADER_SENEPOLYGON_H 3 | 4 | #include 5 | #include 6 | 7 | class CMapPolygon:public ImplMapSceneGeometry 8 | { 9 | public: 10 | CONSTRUCTOR(CMapPolygon,ImplMapSceneGeometry) 11 | 12 | /** 13 | * @brief 初始化节点 14 | */ 15 | void InitNode() override; 16 | }; 17 | 18 | #endif // CSENEPOLYGON_H 19 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapPolygon3D.cpp: -------------------------------------------------------------------------------- 1 | #include "MapPolygon3D.h" 2 | 3 | void CMapPolygon3D::InitNode() 4 | { 5 | ImplMapSceneGeometry::InitNode(); 6 | 7 | m_pDrawPolygon = dynamic_cast(m_pSceneGraph->GetPlot()->CreateSceneNode("IPolygon3D")); 8 | if(nullptr != m_pDrawPolygon) 9 | { 10 | SetGeometry(m_pDrawPolygon); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Plot/MapShape/DrawShape/MapPolygon3D.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAPPOLYGON3D_H 2 | #define CMAPPOLYGON3D_H 3 | 4 | #include 5 | #include 6 | 7 | class CMapPolygon3D:public ImplMapSceneGeometry 8 | { 9 | public: 10 | CONSTRUCTOR(CMapPolygon3D,ImplMapSceneGeometry) 11 | 12 | /** 13 | * @brief 初始化节点 14 | */ 15 | void InitNode() override; 16 | }; 17 | 18 | #endif // CMAPPOLYGON3D_H 19 | -------------------------------------------------------------------------------- /Plot/MapShape/MapShape.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAP_SHAPE_H 2 | #define CMAP_SHAPE_H 3 | #include 4 | #include 5 | #include 6 | 7 | extern "C" 8 | { 9 | Q_DECL_EXPORT ISceneNode* CreateNode(ISceneGraph*pSceneGraph,const std::string& sInterfaceName); 10 | Q_DECL_EXPORT bool QueryInterface(std::string& sInterfaceName); 11 | } 12 | 13 | #endif // CMAP_SHAPE_H 14 | -------------------------------------------------------------------------------- /Plot/MapShape/MapShape.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-19T11:02:02 4 | # 5 | #------------------------------------------------- 6 | 7 | CONFIG -= qt 8 | 9 | TARGET = MapShape 10 | TEMPLATE = lib 11 | 12 | SDK_CONFIG *= OSG OsgExtern SceneCore Satellite PLOT 13 | 14 | include($$PWD/../../SoftSDK.pri) 15 | 16 | HEADERS += \ 17 | DrawShape/MapCoverImage.h \ 18 | DrawShape/MapLine.h \ 19 | DrawShape/MapLocation.h \ 20 | DrawShape/MapPoint.h \ 21 | DrawShape/MapPolygon.h \ 22 | DrawShape/MapPolygon3D.h \ 23 | MapShape.h 24 | 25 | SOURCES += \ 26 | DrawShape/MapCoverImage.cpp \ 27 | DrawShape/MapLine.cpp \ 28 | DrawShape/MapLocation.cpp \ 29 | DrawShape/MapPoint.cpp \ 30 | DrawShape/MapPolygon.cpp \ 31 | DrawShape/MapPolygon3D.cpp \ 32 | MapShape.cpp 33 | -------------------------------------------------------------------------------- /Plot/Plot.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS =\ 4 | SpaceBackGround\ 5 | SceneShape\ 6 | MapShape\ 7 | Hud\ 8 | SatelliteShow\ 9 | Map\ 10 | PlotManager 11 | 12 | 13 | CONFIG *= ordered 14 | -------------------------------------------------------------------------------- /Plot/PlotManager/MapNodeFactory.h: -------------------------------------------------------------------------------- 1 | #ifndef CMAPNODEFACTORY_H 2 | #define CMAPNODEFACTORY_H 3 | #include 4 | #include 5 | #include 6 | 7 | class ISceneNode; 8 | class ISceneGraph; 9 | 10 | /** 11 | * @brief 判断节点是否可以删除 12 | */ 13 | struct CanDeleteNode 14 | { 15 | int nTimes{}; 16 | ISceneNode* pSceneNode{}; 17 | }; 18 | 19 | class CMapNodeFactory:public QObject 20 | { 21 | Q_OBJECT 22 | public: 23 | CMapNodeFactory(ISceneGraph* pSceneGraph); 24 | ~CMapNodeFactory(); 25 | 26 | /** 27 | * @brief 根据类型创建节点 28 | * @param 接口名称 29 | * @return 30 | */ 31 | ISceneNode* CreateSceneNode(const std::string &sInterface); 32 | 33 | /** 34 | * @brief 删除不再使用的地图节点 35 | */ 36 | void DeleteNoUseSceneNode(); 37 | 38 | /** 39 | * @brief 初始化工厂 40 | */ 41 | void InitFactory(); 42 | 43 | /** 44 | * @brief 添加场景节点 45 | * @param pNode 46 | */ 47 | void InsertNode(ISceneNode* pNode); 48 | 49 | /** 50 | * @brief 根据模型ID获取模型 51 | * @param unPickID 52 | * @return 53 | */ 54 | ISceneNode* FindNodeByID(unsigned int unPickID); 55 | 56 | protected: 57 | 58 | /** 59 | * @brief 初始化类型 60 | */ 61 | void InitType(const std::string& sInterface); 62 | 63 | /** 64 | * @brief 定时处理 65 | */ 66 | void timerEvent(QTimerEvent *); 67 | private: 68 | int m_nTimerID{-1}; 69 | ISceneGraph* m_pSceneGraph{}; 70 | 71 | typedef ISceneNode* (*pCreateNodeFun)(ISceneGraph*,const std::string&); 72 | typedef bool (*pDeleteNodeFun)(ISceneNode*); 73 | typedef bool(*pQueryInterfaceFun)(std::string&); 74 | 75 | struct MapSceneFun 76 | { 77 | pCreateNodeFun pCrete{}; 78 | pDeleteNodeFun pDelete{}; 79 | }; 80 | 81 | std::map m_mapTypeFunc; 82 | 83 | std::map m_mapTypeDllName; /// 类型和dll的 84 | std::list m_allCreateNode; /// 所有的节点 85 | }; 86 | 87 | #endif // CMAPNODEFACTORY_H 88 | -------------------------------------------------------------------------------- /Plot/PlotManager/PlotManager.h: -------------------------------------------------------------------------------- 1 | #ifndef CPLOTMANAGER_H 2 | #define CPLOTMANAGER_H 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class CPlotLayer; 11 | class ISceneGraph; 12 | class CMapNodeFactory; 13 | 14 | 15 | class CPlotManager:public IPlot 16 | { 17 | friend class ChangeMapNode; 18 | 19 | public: 20 | CPlotManager(ISceneGraph* pSceneGraph); 21 | ~CPlotManager(); 22 | 23 | 24 | /** 25 | * @brief 根据不同的类型创建组节点 26 | */ 27 | ISceneGroup* CreateSceneGroup(SCENE_GROUP_TYPE emType); 28 | 29 | /** 30 | * @brief 根据接口类型创建节点 31 | * @param csInterfaceName 32 | * @return 33 | */ 34 | ISceneNode * CreateSceneNode(const std::string& csInterfaceName); 35 | 36 | /** 37 | * @brief LoadSceneNode 38 | * @param sPath 39 | * @return 40 | */ 41 | ISceneNode* LoadSceneNode(const std::string& sPath,bool bRef); 42 | 43 | /** 44 | * @brief 根据模型ID获取模型 45 | * @param unPickID 46 | * @return 47 | */ 48 | ISceneNode* FindNodeByID(unsigned int unPickID); 49 | 50 | /** 51 | * @brief 强制删除不再使用的地图节点 52 | */ 53 | void FreeNoUseSceneNode(); 54 | 55 | /** 56 | * @brief 57 | */ 58 | void RegisterPlotType(); 59 | private: 60 | CMapNodeFactory* m_pCreateFactory{};/// 创建节点 61 | }; 62 | 63 | extern "C" 64 | { 65 | Q_DECL_EXPORT IPlot* CreatePlot(ISceneGraph* pSceneGraph); 66 | }; 67 | #endif // CPLOTMANAGER_H 68 | -------------------------------------------------------------------------------- /Plot/PlotManager/PlotManager.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | TARGET = Plot 3 | TEMPLATE = lib 4 | 5 | SDK_CONFIG *= OSG SceneCore OsgExtern Satellite 6 | include($$PWD/../../SoftSDK.pri) 7 | 8 | HEADERS += \ 9 | MapNodeFactory.h \ 10 | PlotManager.h 11 | 12 | SOURCES += \ 13 | MapNodeFactory.cpp \ 14 | PlotManager.cpp 15 | -------------------------------------------------------------------------------- /Plot/SatelliteShow/SatelliteShow.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-19T11:02:02 4 | # 5 | #------------------------------------------------- 6 | 7 | CONFIG -= qt 8 | 9 | TARGET = SatelliteShow 10 | TEMPLATE = lib 11 | 12 | SDK_CONFIG *= OSG OsgExtern SceneCore Satellite PLOT 13 | 14 | include($$PWD/../../SoftSDK.pri) 15 | 16 | HEADERS += \ 17 | SatelliteShow.h 18 | 19 | SOURCES += \ 20 | SatelliteShow.cpp 21 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/BeamSensor.cpp: -------------------------------------------------------------------------------- 1 | #include "BeamSensor.h" 2 | 3 | void CBeamSensor::CreateShape() 4 | { 5 | } 6 | 7 | void CBeamSensor::UpdateShape() 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/BeamSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef CBEAMSENSOR_H 2 | #define CBEAMSENSOR_H 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief The CBeamSensor class 8 | */ 9 | class CBeamSensor:public ImplSceneSensor 10 | { 11 | public: 12 | CONSTRUCTOR(CBeamSensor,ImplSceneSensor) 13 | 14 | protected: 15 | void CreateShape(); 16 | void UpdateShape(); 17 | }; 18 | 19 | #endif // CBEAMSENSOR_H 20 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/RadarSensor.h: -------------------------------------------------------------------------------- 1 | #ifndef CRADARSENSOR_H 2 | #define CRADARSENSOR_H 3 | #include 4 | #include 5 | 6 | struct FlankPoint 7 | { 8 | double dX; /// 与中心点所成的角度 9 | double dZ; /// 到中心点的距离 10 | }; 11 | typedef std::vector Flank; 12 | 13 | class CRadarSensor:public ImplSceneSensor 14 | { 15 | public: 16 | CONSTRUCTOR(CRadarSensor,ImplSceneSensor) 17 | 18 | /** 19 | * @brief 设置雷达数据 20 | */ 21 | void SetRadarData(const std::string& sFilePath,bool bIsRef); 22 | protected: 23 | void CreateShape(); 24 | void UpdateShape(); 25 | 26 | void DealBuffer(const char *pBuffer); 27 | void CreateGeomery(double dRad, const Flank &vFlank); 28 | protected: 29 | double m_dMaxDis{}; 30 | }; 31 | 32 | #endif // CRADARSENSOR_H 33 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneBox.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENEBOX_H 2 | #define CSCENEBOX_H 3 | 4 | #include 5 | #include 6 | /** 7 | * @brief 绘制盒子 8 | */ 9 | class CSceneBox:public ImplSceneSensor 10 | { 11 | public: 12 | CONSTRUCTOR(CSceneBox,ImplSceneSensor); 13 | protected: 14 | void UpdateShape(); 15 | 16 | void CreateShape(); 17 | }; 18 | 19 | #endif // CSCENEBOX_H 20 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneCone.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "SceneCone.h" 4 | 5 | /// 更新图形 6 | void CSceneCone::UpdateShape() 7 | { 8 | double dR = tan(m_dAngle*DD2R); 9 | static const double * pCos = CMathCommon::GetInstance()->GetCos(); 10 | static const double* pSin = CMathCommon::GetInstance()->GetSin(); 11 | 12 | int j=1; 13 | for(int i=0; i<360; i += 3,++j) 14 | { 15 | m_pVertexArray->at(j).set(dR * pCos[i] ,dR*pSin[i],1.f); 16 | m_pNormals->at(j).set(pCos[i],pSin[i],0.f); 17 | } 18 | 19 | m_pVertexArray->at(j).set(dR ,0,1.f); 20 | } 21 | 22 | /// 创建图形 23 | void CSceneCone::CreateShape() 24 | { 25 | m_pVertexArray->resize(122); 26 | m_pNormals->resize(122); 27 | UpdateShape(); 28 | osg::DrawArrays* pDrawCone = new osg::DrawArrays(GL_TRIANGLE_FAN,0,m_pVertexArray->size()); 29 | m_pGeometry->addPrimitiveSet(pDrawCone); 30 | } 31 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneCone.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CSCENECONE_H 2 | #define HEADER_CSCENECONE_H 3 | #include 4 | #include 5 | 6 | class CSceneCone:public ImplSceneSensor 7 | { 8 | public: 9 | CONSTRUCTOR(CSceneCone,ImplSceneSensor) 10 | 11 | protected: 12 | /** 13 | * @brief 更新形状 14 | */ 15 | void UpdateShape(); 16 | 17 | /** 18 | * @brief 构造模型 19 | */ 20 | void CreateShape(); 21 | 22 | }; 23 | 24 | #endif // CSCENECONE_H 25 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneDonuts.cpp: -------------------------------------------------------------------------------- 1 | #include "SceneDonuts.h" 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | void CSceneDonuts::CreateShape() 8 | { 9 | m_pVertexArray->resizeArray(25*25); 10 | UpdateShape(); 11 | CGrid2TriangleStrip grid(25,25,true); 12 | const osg::MixinVector& rIndex = grid.GetIndex(); 13 | 14 | for(int nIndex=0; nIndexaddPrimitiveSet(new osg::DrawElementsUInt(GL_TRIANGLE_STRIP,rIndex[nIndex].size(),&rIndex[nIndex].front())); 17 | } 18 | m_bBuild = true; 19 | 20 | //m_pColorArray->push_back(m_vColor); 21 | } 22 | 23 | void CSceneDonuts::UpdateShape() 24 | { 25 | double dR = (m_dRMax - m_dRMin) / 2.0; 26 | CGrid2TriangleStrip grid(25,25,true); 27 | 28 | const osg::MixinVector& rIndex = grid.GetIndex(); 29 | // m_pGeometry->setVertexArray(m_pVertexArray); 30 | 31 | osg::Vec3 vLocal; 32 | for(int i=0,indexi=0; i<=360; i +=15,++indexi) 33 | { 34 | osg::Matrix tmpMatrix = osg::Matrix::rotate(osg::DegreesToRadians((float)i),osg::Z_AXIS); 35 | for(int j=0,indexj=0; j<=360; j +=15,++indexj) 36 | { 37 | vLocal.z() = CMathCommon::GetInstance()->GetCos()[j] * dR; 38 | vLocal.x() = m_dRMin+dR + CMathCommon::GetInstance()->GetSin()[j] * dR; 39 | vLocal.y() = 0; 40 | 41 | vLocal = tmpMatrix.preMult(vLocal); 42 | m_pVertexArray->at(indexj*25 + indexi) = vLocal; 43 | //pVetexArray->push_back(vLocal); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneDonuts.h: -------------------------------------------------------------------------------- 1 | #ifndef SCENEDONUTS_H 2 | #define SCENEDONUTS_H 3 | 4 | #include 5 | #include 6 | 7 | class CSceneDonuts:public ImplSceneSensor 8 | { 9 | public: 10 | CONSTRUCTOR(CSceneDonuts,ImplSceneSensor) 11 | protected: 12 | void CreateShape(); 13 | void UpdateShape(); 14 | private: 15 | bool m_bBuild;/// 是否构建完成 16 | osg::Vec4 m_vColor={1.0,0,0,1.0}; 17 | }; 18 | 19 | #endif // SCENEDONUTS_H 20 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneEllipsoid.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENEELLIPSOID_H 2 | #define CSCENEELLIPSOID_H 3 | 4 | #include 5 | #include 6 | class CSceneEllipsoid:public ImplSceneSensor 7 | { 8 | public: 9 | CONSTRUCTOR(CSceneEllipsoid,ImplSceneSensor) 10 | 11 | protected: 12 | /** 13 | * @brief 更新形状 14 | */ 15 | void UpdateShape(); 16 | 17 | /** 18 | * @brief 构造模型 19 | */ 20 | void CreateShape(); 21 | protected: 22 | osg::ref_ptr m_pEllipsoidModel; 23 | osg::ref_ptr m_pTexCoords; 24 | }; 25 | 26 | #endif // CSCENEELLIPSOID_H 27 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneImage.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENEIMAGE_H 2 | #define CSCENEIMAGE_H 3 | 4 | #include 5 | #include 6 | class CSceneImage:public ImplSceneNode 7 | { 8 | public: 9 | CONSTRUCTOR(CSceneImage,ImplSceneNode) 10 | protected: 11 | ~CSceneImage(); 12 | void ImageSizeChanged(){if(m_stImageSize) m_stImageSize.bOutSet=true;NodeChanged();} 13 | void ImagePathChanged()SET_TRUE_NODE_UPDATE(m_bPathChanged) 14 | void ImageDataChanged()SET_TRUE_NODE_UPDATE(m_bImageDataChanged) 15 | void SetQImage(const QImage& rImage); 16 | 17 | void InitNode(); 18 | /** 19 | * @brief 初始化节点 20 | */ 21 | void ColorChanged(){NodeChanged();} 22 | /** 23 | * @brief实现父类方法 24 | */ 25 | void ShapeChanged(){} 26 | /** 27 | * @brief 重写父类 28 | */ 29 | void FrameCall(); 30 | 31 | /** 32 | * @brief 获取影像节点 33 | * @return 34 | */ 35 | osg::Geometry* TryChangeToGeomerty(osg::Node *pNode); 36 | 37 | protected: 38 | bool m_bPathChanged{false}; 39 | bool m_bImageDataChanged{false}; 40 | bool m_bGeomertyChanged{false}; 41 | osg::ref_ptr m_pQImageDrawNode; 42 | static std::map>>s_mapID2ImageNode; 43 | }; 44 | 45 | #endif // CSCENEIMAGE_H 46 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneLabel.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENELABEL_H 2 | #define CSCENELABEL_H 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | class CSceneLabel:public ImplSceneNode,public ISceneNodeAttach 9 | { 10 | public: 11 | CONSTRUCTOR(CSceneLabel,ImplSceneNode) 12 | 13 | /** 14 | * @brief 设置依附节点 15 | */ 16 | bool SetAttachNode(ISceneNode* pSceneNode); 17 | bool DisAttachNode(ISceneNode* pSceneNode); 18 | 19 | void NodeVisibleChanged(bool); 20 | void AddIntoParent(osg::Group*); 21 | void DelFromParent(osg::Group*); 22 | 23 | protected: 24 | void InitNode(); 25 | void FrameCall(); 26 | 27 | void FontChanged()SET_TRUE_NODE_UPDATE(m_bFontChanged) 28 | void InfoChanged()SET_TRUE_NODE_UPDATE(m_bInfoChanged) 29 | void PosChanged()SET_TRUE_NODE_UPDATE(m_bPosChanged) 30 | void BoundingBoxVisibleChanged()SET_TRUE_NODE_UPDATE(m_bBoundingBoxVisibleChanged) 31 | void FontSizeChanged()SET_TRUE_NODE_UPDATE(m_bFontSizeChanged) 32 | void FillColorChanged()SET_TRUE_NODE_UPDATE(m_bFillColorChanged) 33 | void OutColorChanged()SET_TRUE_NODE_UPDATE(m_bOutColorChanged) 34 | void BoundingBoxColorChanged()SET_TRUE_NODE_UPDATE(m_bBoudingBoxColorChanged) 35 | void PixelOffChanged()SET_TRUE_NODE_UPDATE(m_bPixelOffChanged) 36 | protected: 37 | bool m_bInfoChanged{false}; 38 | bool m_bBoundingBoxVisibleChanged{false}; 39 | bool m_bFontSizeChanged{false}; 40 | bool m_bFillColorChanged{false}; 41 | bool m_bOutColorChanged{false}; 42 | bool m_bBoudingBoxColorChanged{false}; 43 | bool m_bPosChanged{false}; 44 | bool m_bFontChanged{false}; 45 | bool m_bPixelOffChanged{false}; 46 | osg::observer_ptr m_pText; 47 | }; 48 | 49 | #endif // CSCENELABEL_H 50 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneLine.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENELINE_H 2 | #define CSCENELINE_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | class CSceneLine:public ImplSceneGeometry 8 | { 9 | public: 10 | CONSTRUCTOR(CSceneLine,ImplSceneGeometry) 11 | 12 | protected: 13 | 14 | /** 15 | * @brief 线宽更改 16 | */ 17 | void LineWidthChanged()SET_TRUE_SHAPE_UPDATE(m_bWidthChanged) 18 | 19 | /** 20 | * @brief 线型更改 21 | */ 22 | void LineTypeChanged()SET_TRUE_NODE_UPDATE(m_bLineTypeChanged) 23 | 24 | /** 25 | * @brief 荧光状态更改 26 | */ 27 | void GlowChanged()SET_TRUE_NODE_UPDATE(m_bGlowChanged) 28 | 29 | /** 30 | * @brief 构造模型 31 | */ 32 | void CreateShape(); 33 | 34 | /** 35 | * @brief 更新形状 36 | */ 37 | void UpdateShape(); 38 | protected: 39 | osg::ref_ptr m_pPreviousPoints; 40 | osg::ref_ptr m_pNextPoints; 41 | bool m_bWidthChanged{false}; 42 | bool m_bLineTypeChanged{false}; 43 | bool m_bGlowChanged{false}; 44 | }; 45 | 46 | #endif // CSCENELINE_H 47 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/ScenePoint.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ScenePoint.h" 3 | 4 | /// 更新形状 5 | void CScenePoint::UpdateShape() 6 | { 7 | ImplSceneGeometry::UpdateShape(); 8 | 9 | /// 点大小更改 10 | if(m_bPointSizeChanged) 11 | { 12 | m_pGeometry->getOrCreateStateSet()->getOrCreateUniform("pointSize",osg::Uniform::FLOAT)->set(m_fPointSize); 13 | m_bPointSizeChanged = false; 14 | } 15 | 16 | /// 图片路径修改 17 | if(m_bImageChanged) 18 | { 19 | auto pPointTexture = m_pSceneGraph->ResouceLoader()->LoadTexture(m_sImagePath); 20 | if(nullptr != pPointTexture) 21 | { 22 | m_pGeometry->getOrCreateStateSet()->setTextureAttribute(0, pPointTexture); 23 | } 24 | else 25 | { 26 | m_pGeometry->getOrCreateStateSet()->removeTextureAttribute(0, pPointTexture); 27 | } 28 | m_bImageChanged= false; 29 | } 30 | } 31 | 32 | /// 创建形状 33 | void CScenePoint::CreateShape() 34 | { 35 | MergeStateSet(POINT_DRAW_STATE); 36 | OpenCull(false); 37 | 38 | m_pDrawArrays=new osg::DrawArrays(GL_POINTS,0,m_pVertexArray->size()); 39 | m_pGeometry->addPrimitiveSet(m_pDrawArrays); 40 | } 41 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/ScenePoint.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENEPOINT_H 2 | #define CSCENEPOINT_H 3 | #include 4 | #include 5 | class CScenePoint:public ImplSceneGeometry 6 | { 7 | public: 8 | CONSTRUCTOR(CScenePoint,ImplSceneGeometry) 9 | 10 | protected: 11 | /** 12 | * @brief 点大小更改 13 | */ 14 | void PointSizeChanged() override SET_TRUE_SHAPE_UPDATE(m_bPointSizeChanged) 15 | 16 | /** 17 | * @brief 图片路径更改 18 | */ 19 | void ImagePathChanged() override SET_TRUE_SHAPE_UPDATE(m_bImageChanged) 20 | 21 | /** 22 | * @brief 更新形状 23 | */ 24 | void UpdateShape() override; 25 | 26 | /** 27 | * @brief 构造模型 28 | */ 29 | void CreateShape() override; 30 | protected: 31 | bool m_bPointSizeChanged{false}; 32 | bool m_bImageChanged{false}; 33 | }; 34 | 35 | #endif // CSCENEPOINT_H 36 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/ScenePolygon.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ScenePolygon.h" 3 | 4 | /// 创建多边形 5 | void CScenePolygon::UpdateVetrix() 6 | { 7 | ImplSceneGeometry::UpdateVetrix(); 8 | 9 | if(m_pDrawLine.valid()) 10 | { 11 | m_pDrawLine->setCount(m_pVertexArray->size()); 12 | } 13 | } 14 | 15 | void CScenePolygon::CreateShape() 16 | { 17 | m_pDrawArrays = new osg::DrawArrays(GL_TRIANGLE_FAN,0,m_pVertexArray->size()); 18 | m_pDrawLine = new osg::DrawArrays(GL_LINE_LOOP,0,m_pVertexArray->size()); 19 | m_pGeometry->addPrimitiveSet(m_pDrawArrays); 20 | } 21 | 22 | /// 更新多边形 23 | void CScenePolygon::UpdateShape() 24 | { 25 | if(m_listAllPos.Size() > 2) 26 | { 27 | ImplSceneGeometry::UpdateShape(); 28 | /// 进行凹多边形裁剪 29 | 30 | m_pGeometry->removePrimitiveSet(0,m_pGeometry->getNumPrimitiveSets()); 31 | if(m_bFill) 32 | { 33 | m_pGeometry->addPrimitiveSet(m_pDrawArrays); 34 | 35 | /// 防止多边形为凹多边形 36 | { 37 | osgUtil::Tessellator tess; 38 | tess.setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY); 39 | tess.setWindingType(osgUtil::Tessellator::TESS_WINDING_ODD); 40 | tess.retessellatePolygons(*m_pGeometry); 41 | } 42 | } 43 | 44 | if(m_bShowOutLine) 45 | { 46 | m_pGeometry->addPrimitiveSet(m_pDrawLine); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/ScenePolygon.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENEPOLYGON_H 2 | #define CSCENEPOLYGON_H 3 | 4 | #include 5 | #include 6 | 7 | class CScenePolygon:public ImplSceneGeometry 8 | { 9 | public: 10 | CONSTRUCTOR(CScenePolygon,ImplSceneGeometry) 11 | 12 | protected: 13 | void UpdateVetrix(); 14 | void CreateShape(); 15 | void UpdateShape(); 16 | void DrawChanged()SET_TRUE_SHAPE_UPDATE(m_bNoUse) 17 | protected: 18 | osg::ref_ptr m_pDrawLine; 19 | bool m_bNoUse{}; 20 | }; 21 | 22 | #endif // CSCENEPOLYGON_H 23 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/ScenePolygon3D.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENEPOLYGON3D_H 2 | #define CSCENEPOLYGON3D_H 3 | 4 | #include 5 | #include 6 | 7 | class CScenePolygon3D:public ImplSceneGeometry 8 | { 9 | public: 10 | CONSTRUCTOR(CScenePolygon3D,ImplSceneGeometry); 11 | protected: 12 | void HeightChanged()SET_TRUE_SHAPE_UPDATE(m_bHeightChanged) 13 | 14 | /** 15 | * @brief 重写父类方法 16 | */ 17 | void CreateShape(); 18 | void UpdateShape(); 19 | 20 | /** 21 | * @brief 更新上面的点 22 | */ 23 | void UpdateTopFaceVertex(); 24 | protected: 25 | bool m_bHeightChanged{false}; 26 | }; 27 | 28 | #endif // CSCENEPOLYGON3D_H 29 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneSCone.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SceneSCone.h" 3 | 4 | /// 创建模型 5 | void CSceneSCone::CreateShape() 6 | { 7 | m_pVertexArray->resize(6); 8 | UpdateShape(); 9 | auto pDrawCone = new osg::DrawArrays(GL_TRIANGLE_FAN,0,m_pVertexArray->size()); 10 | 11 | m_pGeometry->addPrimitiveSet(pDrawCone); 12 | } 13 | 14 | /// 更新形状 15 | void CSceneSCone::UpdateShape() 16 | { 17 | double dH = tan(m_dHAngle*DD2R); 18 | double dV = tan(m_dVAngle*DD2R); 19 | 20 | m_pVertexArray->at(1).set(-dH ,-dV,1.f); 21 | m_pVertexArray->at(2).set(dH ,-dV,1.f); 22 | m_pVertexArray->at(3).set(dH ,dV,1.f); 23 | m_pVertexArray->at(4).set(-dH ,dV,1.f); 24 | m_pVertexArray->at(5).set(-dH ,-dV,1.f); 25 | } 26 | -------------------------------------------------------------------------------- /Plot/SceneShape/DrawShape/SceneSCone.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENESCONE_H 2 | #define CSCENESCONE_H 3 | #include 4 | #include 5 | 6 | class CSceneSCone:public ImplSceneSensor 7 | { 8 | public: 9 | CONSTRUCTOR(CSceneSCone,ImplSceneSensor) 10 | 11 | protected: 12 | void CreateShape(); 13 | void UpdateShape(); 14 | }; 15 | 16 | #endif // CSCENESCONE_H 17 | -------------------------------------------------------------------------------- /Plot/SceneShape/SceneShape.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENE_SHAPE_H 2 | #define CSCENE_SHAPE_H 3 | #include 4 | #include 5 | #include 6 | 7 | extern "C" 8 | { 9 | Q_DECL_EXPORT ISceneNode* CreateNode(ISceneGraph*pSceneGraph,const std::string& sInterfaceName); 10 | Q_DECL_EXPORT bool QueryInterface(std::string& sInterfaceName); 11 | } 12 | 13 | #endif // CSCENE_SHAPE_H 14 | -------------------------------------------------------------------------------- /Plot/SceneShape/SceneShape.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-19T11:02:02 4 | # 5 | #------------------------------------------------- 6 | 7 | CONFIG -= qt 8 | 9 | TARGET = SceneShape 10 | TEMPLATE = lib 11 | 12 | SDK_CONFIG *= OSG Satellite OsgExtern PLOT SceneCore 13 | 14 | include($$PWD/../../SoftSDK.pri) 15 | 16 | HEADERS += \ 17 | DrawShape/BeamSensor.h \ 18 | DrawShape/RadarSensor.h \ 19 | DrawShape/SceneBox.h \ 20 | DrawShape/SceneCone.h \ 21 | DrawShape/SceneDonuts.h \ 22 | DrawShape/SceneEllipsoid.h \ 23 | DrawShape/SceneImage.h \ 24 | DrawShape/SceneLabel.h \ 25 | DrawShape/SceneLine.h \ 26 | DrawShape/ScenePoint.h \ 27 | DrawShape/ScenePolygon.h \ 28 | DrawShape/ScenePolygon3D.h \ 29 | DrawShape/SceneSCone.h \ 30 | SceneShape.h 31 | 32 | SOURCES += \ 33 | DrawShape/BeamSensor.cpp \ 34 | DrawShape/RadarSensor.cpp \ 35 | DrawShape/SceneBox.cpp \ 36 | DrawShape/SceneCone.cpp \ 37 | DrawShape/SceneDonuts.cpp \ 38 | DrawShape/SceneEllipsoid.cpp \ 39 | DrawShape/SceneImage.cpp \ 40 | DrawShape/SceneLabel.cpp \ 41 | DrawShape/SceneLine.cpp \ 42 | DrawShape/ScenePoint.cpp \ 43 | DrawShape/ScenePolygon.cpp \ 44 | DrawShape/ScenePolygon3D.cpp \ 45 | DrawShape/SceneSCone.cpp \ 46 | SceneShape.cpp 47 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/SkyNode.h: -------------------------------------------------------------------------------- 1 | #ifndef CSKYNODE_H 2 | #define CSKYNODE_H 3 | #include 4 | #include "Solar/SolarEnv.h" 5 | #include "Star/StarEnv.h" 6 | 7 | class CSkyNode:public osg::Group 8 | { 9 | public: 10 | CSkyNode(ISceneGraph* pSceneGraph); 11 | 12 | /** 13 | * @brief 设置显示最大星等 默认为 6 最大星等为 20 14 | * @param nMax 15 | */ 16 | void SetMaxVisibleMagnitude(int nMax); 17 | 18 | /** 19 | * @brief 设置银河是否可见 20 | * @param bShow 21 | */ 22 | void SetMilkywayVisible(bool bShow); 23 | 24 | /** 25 | * @brief 设置星星名称是否可见 26 | * @param bShow 27 | */ 28 | void SetStarNamesVisible(bool bShow); 29 | 30 | /** 31 | * @brief 设置边界是否可见 32 | * @param bShow 33 | */ 34 | void SetBoundariesVisible(bool bShow); 35 | 36 | /** 37 | * @brief 设置星座连线是否可见 38 | * @param bShow 39 | */ 40 | void SetConstellationLinesVisible(bool bShow); 41 | 42 | /** 43 | * @brief 设置星座名称是否可见 44 | * @param bShow 45 | */ 46 | void SetConstellationNamesVisible(bool bShow); 47 | 48 | /** 49 | * @brief 设置行星名称是否可见 50 | * @param bShow 51 | */ 52 | void SetPlanetsNamesVisible(bool bShow); 53 | 54 | 55 | /** 56 | * @brief 更新矩阵 57 | */ 58 | void UpdateMatrix(const Math::CMatrix& rRotate); 59 | 60 | /** 61 | * @brief 更新位置 62 | */ 63 | void UpdatePos(const std::vector&); 64 | public: 65 | ///////////////// 重写父类方法 /////////////////// 66 | void traverse(osg::NodeVisitor&); 67 | osg::BoundingSphere computeBound() const; 68 | void releaseGLObjects(osg::State* state) const; 69 | void resizeGLObjectBuffers(unsigned maxSize); 70 | ///////////////// 重写父类方法 end/////////////////// 71 | private: 72 | osg::ref_ptr m_pSpaceBackGroundRoot; 73 | osg::ref_ptr m_pSolarEnv; /// 行星背景 74 | osg::ref_ptr m_pStarEnv; /// 星空背景 75 | }; 76 | 77 | #endif // CSKYNODE_H 78 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Solar/PlanetModel.h: -------------------------------------------------------------------------------- 1 | #ifndef PLANETMODEL_H 2 | #define PLANETMODEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | class ISceneGraph; 12 | 13 | class CPlanetModel 14 | { 15 | public: 16 | CPlanetModel(ISceneGraph* pSceneGraph,int nIndex); 17 | ~CPlanetModel(); 18 | 19 | /** 20 | * @brief 更新行星位置 21 | * @param rPos 22 | */ 23 | void UpdatePostion(const Math::CVector& rPos); 24 | 25 | /** 26 | * @brief 获取显示节点 27 | * @return 28 | */ 29 | osg::Node* GetNode(); 30 | 31 | protected: 32 | /** 33 | * @brief 构建行星 34 | */ 35 | void MakePlanet(); 36 | private: 37 | ISceneAttitudeGroup* m_pAttitudeNode; 38 | ISceneLodGroup* m_pLodNode; 39 | ISceneCameraGroup* m_pCameraNode; 40 | IPoint* m_pPointNode; 41 | IEllipsoidSensor* m_pEllipsoid; 42 | 43 | int m_nRenderBin; 44 | ISceneGraph* m_pSceneGraph; 45 | float m_fEquatorRadius; /// 赤道半径 46 | float m_fPolarRadius; /// 极半径 47 | osg::Vec4 m_rColor; /// 颜色 48 | std::string m_cnPlanetName; /// 行星显示名称 49 | std::string m_sPlanetImage; /// 行星图片名称 50 | }; 51 | 52 | #endif // PLANETMODEL_H 53 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Solar/SolarEnv.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "SolarEnv.h" 13 | 14 | extern void InitSolarName(); 15 | /// 太阳系构建函数 16 | CSolarEnv::CSolarEnv(ISceneGraph *pSceneGraph) 17 | :m_pSceneGraph(pSceneGraph) 18 | ,m_bNeedUpdate(false) 19 | { 20 | InitSolarName(); 21 | 22 | osg::StateSet *state = getOrCreateStateSet(); 23 | 24 | state->setMode(GL_BLEND,osg::StateAttribute::ON); 25 | } 26 | 27 | CSolarEnv::~CSolarEnv() 28 | { 29 | for(auto itor = m_mapPlanet.begin(); 30 | itor != m_mapPlanet.end(); 31 | ++itor) 32 | { 33 | delete itor->second; 34 | } 35 | m_mapPlanet.clear(); 36 | } 37 | 38 | /// 构建太阳系 39 | void CSolarEnv::CreateSolar() 40 | { 41 | 42 | for (int i=0;i<10; ++i) 43 | { 44 | /// 跳过地球 45 | if(2 == i) continue; 46 | 47 | CPlanetModel* pPlanet = new CPlanetModel(m_pSceneGraph,i); 48 | 49 | m_mapPlanet[i] = pPlanet; 50 | this->addChild(pPlanet->GetNode()); 51 | } 52 | 53 | m_pSun = new CSunModel; 54 | this->addChild(m_pSun); 55 | } 56 | 57 | void CSolarEnv::UpdatePos(const std::vector &vSolarPos) 58 | { 59 | for(auto itor = m_mapPlanet.begin(); 60 | itor != m_mapPlanet.end(); 61 | ++itor) 62 | { 63 | itor->second->UpdatePostion(vSolarPos[itor->first]); 64 | } 65 | 66 | m_pSun->UpdatePostion(vSolarPos[10]); 67 | } 68 | 69 | void CSolarEnv::SetPlanetNameShow(bool bVisible) 70 | { 71 | } 72 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Solar/SolarEnv.h: -------------------------------------------------------------------------------- 1 | #ifndef SOLARENV_H 2 | #define SOLARENV_H 3 | 4 | #include 5 | #include "PlanetModel.h" 6 | #include "SunModel.h" 7 | 8 | class ISceneGraph; 9 | 10 | class CSolarEnv:public osg::Group 11 | { 12 | public: 13 | CSolarEnv(ISceneGraph* pSceneGraph); 14 | ~CSolarEnv(); 15 | 16 | /** 17 | * @brief 创造整个太阳系 18 | */ 19 | void CreateSolar(); 20 | 21 | /** 22 | * @brief 是否需要更新 23 | * @return 24 | */ 25 | bool& IsNeedUpdate(){return(m_bNeedUpdate);} 26 | 27 | /** 28 | * @brief 更新行星位置 29 | * @param 行星位置 30 | */ 31 | void UpdatePos(const std::vector &vSolarPos); 32 | 33 | /** 34 | * @brief 设置行星名称显隐 35 | * @param bVisible 36 | */ 37 | void SetPlanetNameShow(bool bVisible); 38 | private: 39 | ISceneGraph* m_pSceneGraph; /// 场景 40 | bool m_bNeedUpdate; /// 是否需要更新 41 | std::map m_mapPlanet; /// 行星绘制类 42 | osg::ref_ptr m_pSun; /// 绘制的太阳 43 | }; 44 | 45 | #endif // SOLARENV_H 46 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Solar/SunModel.h: -------------------------------------------------------------------------------- 1 | #ifndef SUNMODEL_H 2 | #define SUNMODEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CSunModel:public osg::MatrixTransform 9 | { 10 | public: 11 | CSunModel(); 12 | 13 | /** 14 | * @brief 更新行星位置 15 | * @param rPos 16 | */ 17 | void UpdatePostion(const Math::CVector& rPos); 18 | 19 | void SetMatrix(const osg::Matrix& rMatrix); 20 | private: 21 | bool m_bNeedUpdate; /// 是否需要更新 22 | osg::Vec3 m_rECIPostion; /// 太阳的位置 23 | osg::ref_ptr m_pTrans; 24 | }; 25 | 26 | #endif // SUNMODEL_H 27 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/SpaceBackGround.h: -------------------------------------------------------------------------------- 1 | #ifndef SPACEENV_H 2 | #define SPACEENV_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "SkyNode.h" 8 | 9 | class CSpaceBackGround:public ImplSceneNode 10 | { 11 | public: 12 | CONSTRUCTOR(CSpaceBackGround,ImplSceneNode) 13 | ~CSpaceBackGround(); 14 | /** 15 | * @brief 设置显示最大星等 默认为 6 最大星等为 20 16 | * @param nMax 17 | */ 18 | void SetMaxVisibleMagnitude(int nMax); 19 | 20 | /** 21 | * @brief 设置银河是否可见 22 | * @param bShow 23 | */ 24 | void SetMilkywayVisible(bool bShow); 25 | 26 | /** 27 | * @brief 设置星星名称是否可见 28 | * @param bShow 29 | */ 30 | void SetStarNamesVisible(bool bShow); 31 | 32 | /** 33 | * @brief 设置边界是否可见 34 | * @param bShow 35 | */ 36 | void SetBoundariesVisible(bool bShow); 37 | 38 | /** 39 | * @brief 设置星座连线是否可见 40 | * @param bShow 41 | */ 42 | void SetConstellationLinesVisible(bool bShow); 43 | 44 | /** 45 | * @brief 设置星座名称是否可见 46 | * @param bShow 47 | */ 48 | void SetConstellationNamesVisible(bool bShow); 49 | 50 | /** 51 | * @brief 设置行星名称是否可见 52 | * @param bShow 53 | */ 54 | void SetPlanetsNamesVisible(bool bShow); 55 | 56 | /** 57 | * @brief 初始化节点 58 | */ 59 | void InitNode(); 60 | 61 | /** 62 | * @brief 更新位置 63 | */ 64 | void UpdatePos(const std::vector&); 65 | 66 | /** 67 | * @brief 更新矩阵 68 | */ 69 | void UpdateMatrix(const Math::CMatrix&); 70 | 71 | /** 72 | * @brief 重写子类显隐控制 73 | */ 74 | void VisibleChanged(); 75 | protected: 76 | osg::observer_ptr m_pSkyNode; 77 | }; 78 | 79 | 80 | extern "C" 81 | { 82 | Q_DECL_EXPORT ISceneNode* CreateNode(ISceneGraph*pSceneGraph,const std::string& sInterfaceName); 83 | Q_DECL_EXPORT bool QueryInterface(std::string& sInterfaceName); 84 | } 85 | #endif // SPACEENV_H 86 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/SpaceBackGround.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-19T11:02:02 4 | # 5 | #------------------------------------------------- 6 | 7 | QT -= gui 8 | 9 | TARGET = SpaceBackGround 10 | TEMPLATE = lib 11 | 12 | DEFINES += SPACEENV_LIBRARY 13 | 14 | SDK_CONFIG *= OSG Satellite OsgExtern SceneCore PLOT 15 | 16 | include($$PWD/../../SoftSDK.pri) 17 | 18 | HEADERS += \ 19 | SkyNode.h \ 20 | Solar/PlanetModel.h \ 21 | Solar/SolarEnv.h \ 22 | Solar/SunModel.h \ 23 | SpaceBackGround.h \ 24 | Star/Boundary.h \ 25 | Star/Frustum.h \ 26 | Star/GeodesicGrid.h \ 27 | Star/Milkyway.h \ 28 | Star/Star.h \ 29 | Star/StarConstellation.h \ 30 | Star/StarEnv.h \ 31 | Star/StarManager.h \ 32 | Star/StarRender.h \ 33 | Star/StarToneReproducer.h \ 34 | Star/StarZoneArray.h \ 35 | Star/StarZoneArrayBase.h \ 36 | Star/StarZoneArrayRenderer.h \ 37 | Star/StarZoneData.h \ 38 | Star/StarZoneDataBase.h 39 | 40 | SOURCES += \ 41 | SkyNode.cpp \ 42 | Solar/PlanetModel.cpp \ 43 | Solar/SolarEnv.cpp \ 44 | Solar/SunModel.cpp \ 45 | SpaceBackGround.cpp \ 46 | Star/Boundary.cpp \ 47 | Star/Frustum.cpp \ 48 | Star/GeodesicGrid.cpp \ 49 | Star/Milkyway.cpp \ 50 | Star/Star.cpp \ 51 | Star/StarConstellation.cpp \ 52 | Star/StarEnv.cpp \ 53 | Star/StarManager.cpp \ 54 | Star/StarRender.cpp \ 55 | Star/StarToneReproducer.cpp \ 56 | Star/StarZoneArrayRenderer.cpp 57 | 58 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/Boundary.h: -------------------------------------------------------------------------------- 1 | #ifndef BOUNDARY_H 2 | #define BOUNDARY_H 3 | 4 | #include 5 | class CBoundary:public osg::Referenced 6 | { 7 | public: 8 | CBoundary(); 9 | 10 | /** 11 | * @brief 设置是否可见 12 | * @param bVisible 13 | */ 14 | void SetVisible(bool bVisible); 15 | 16 | osg::Node* getNode(); 17 | protected: 18 | 19 | ~CBoundary(); 20 | private: 21 | void makeBoundray(); 22 | 23 | private: 24 | osg::ref_ptr m_pBoundray; 25 | bool m_bShowBoundary{true}; /// 是否显示天区 26 | }; 27 | 28 | #endif // BOUNDARY_H 29 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/Milkyway.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "Milkyway.h" 7 | 8 | CMilkyway::CMilkyway(ISceneGraph *pSceneGraph): 9 | m_pSceneGraph(pSceneGraph) 10 | { 11 | makeMilkyway(); 12 | } 13 | 14 | void CMilkyway::SetVisible(bool bVisible) 15 | { 16 | if(bVisible) 17 | { 18 | m_pMilkyway->setNodeMask(-1); 19 | } 20 | else 21 | { 22 | m_pMilkyway->setNodeMask(0); 23 | } 24 | } 25 | 26 | bool CMilkyway::Visible() 27 | { 28 | return(0 != m_pMilkyway->getNodeMask()); 29 | } 30 | 31 | osg::Node *CMilkyway::getNode() 32 | { 33 | return(m_pProgramNode.get()); 34 | } 35 | 36 | CMilkyway::~CMilkyway() 37 | { 38 | } 39 | 40 | /// 构建银河 41 | void CMilkyway::makeMilkyway() 42 | { 43 | osg::ref_ptr pHints = new osg::TessellationHints; 44 | 45 | /// 纹理坐标 46 | pHints->setCreateTextureCoords(true); 47 | pHints->setCreateFrontFace(false); 48 | pHints->setCreateBackFace(true); 49 | pHints->setCreateNormals(false); 50 | pHints->setCreateTop(false); 51 | pHints->setCreateBody(false); 52 | pHints->setCreateBottom(false); 53 | 54 | m_pProgramNode = new osg::Geode; 55 | osg::ref_ptr pShape = new osg::Sphere(osg::Vec3(),1.0999f); 56 | m_pMilkyway = new osg::ShapeDrawable(pShape,pHints); 57 | m_pProgramNode->addChild(m_pMilkyway); 58 | 59 | m_pMilkyway->setColor(osg::Vec4f(1.0f, 1.0f, 1.0f,1.0f)); 60 | 61 | 62 | m_pProgramNode->setStateSet(m_pSceneGraph->ResouceLoader()->GetOrCreateStateSet(GLOBAL_DRAW_STATE)); 63 | auto pNodeStateSet = m_pMilkyway->getOrCreateStateSet(); 64 | 65 | /// 添加纹理 66 | auto pTexture = m_pSceneGraph->ResouceLoader()->LoadTexture("Space/pixmaps/milkyway.png"); 67 | 68 | pNodeStateSet->setTextureAttribute(0, pTexture); 69 | } 70 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/Milkyway.h: -------------------------------------------------------------------------------- 1 | #ifndef MILKYWAY_H 2 | #define MILKYWAY_H 3 | 4 | #include 5 | #include 6 | #include 7 | class ISceneGraph; 8 | 9 | 10 | class CMilkyway:public osg::Referenced 11 | { 12 | public: 13 | CMilkyway(ISceneGraph* pSceneGraph); 14 | 15 | /** 16 | * @brief 设置显隐 17 | */ 18 | void SetVisible(bool); 19 | bool Visible(); 20 | 21 | osg::Node* getNode(); 22 | protected: 23 | ~CMilkyway(); 24 | 25 | private: 26 | void makeMilkyway(); 27 | 28 | private: 29 | ISceneGraph* m_pSceneGraph; 30 | osg::ref_ptr m_pProgramNode; 31 | osg::ref_ptr m_pMilkyway; 32 | }; 33 | 34 | #endif // MILKYWAY_H 35 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/Star.cpp: -------------------------------------------------------------------------------- 1 | #include "Star.h" 2 | static const double S_DINDEX2BV(4.0/127.); 3 | static const double S_DBV2INDEX(127.0/4.0); 4 | 5 | float IndexToBV(quint8 bV) 6 | { 7 | return static_cast(bV * S_DINDEX2BV - 0.50); 8 | } 9 | 10 | quint8 GetColorIndex(float bV) 11 | { 12 | quint8 ret = static_cast ((bV + 0.5) * S_DBV2INDEX); 13 | 14 | if (ret >= 128) 15 | { 16 | return 127; 17 | } 18 | else 19 | { 20 | return ret; 21 | } 22 | } 23 | 24 | void CBinStar1::getPosition(const IStarZoneData *z, float movementFactor, osg::Vec3f &pos) const 25 | { 26 | pos = z->getCenter() + z->getFirstAxis() * (x0 + movementFactor * dx0) 27 | + z->getSecondAxis() * (x1 + movementFactor * dx1); 28 | } 29 | 30 | float CBinStar1::getBV() const 31 | { 32 | return IndexToBV(bV); 33 | } 34 | 35 | void CBinStar2::getPosition(const IStarZoneData *z, float movementFactor, osg::Vec3f &pos) const 36 | { 37 | pos = z->getCenter() + z->getFirstAxis() * (x0 + movementFactor * dx0) 38 | + z->getSecondAxis() * (x1 + movementFactor * dx1); 39 | } 40 | 41 | float CBinStar2::getBV() const 42 | { 43 | return IndexToBV(bV); 44 | } 45 | 46 | void CBinStar3::getPosition(const IStarZoneData *z, float movementFactor, osg::Vec3f &pos) const 47 | { 48 | Q_UNUSED(movementFactor); 49 | 50 | pos = z->getCenter() + z->getFirstAxis() * float(x0) 51 | + z->getSecondAxis() * float(x1); 52 | } 53 | 54 | float CBinStar3::getBV() const 55 | { 56 | return IndexToBV(bV); 57 | } 58 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/StarConstellation.h: -------------------------------------------------------------------------------- 1 | #ifndef STARCONSTELLATION_H 2 | #define STARCONSTELLATION_H 3 | #include 4 | #include 5 | 6 | #include "StarZoneArrayRenderer.h" 7 | 8 | class ISceneGraph; 9 | 10 | class CStarConstellation 11 | { 12 | public: 13 | 14 | struct FindContext 15 | { 16 | ZoneArrayVector* vZoneArray; 17 | CStarConstellation *pBuilder; 18 | double dJD; 19 | }; 20 | 21 | static bool findPosition(int lev, unsigned int index, const osg::Vec3f &c0, 22 | const osg::Vec3f &c1, const osg::Vec3f &c2, void *context); 23 | 24 | CStarConstellation(ISceneGraph* pSceneGraph); 25 | 26 | /** 27 | * @brief 读取星座线 28 | * @return 29 | */ 30 | bool ReadConstellation(); 31 | 32 | /** 33 | * @brief 设置网格划分 34 | * @param nLevel 35 | * @param vZoneData 36 | * @param pGeodesicGrid 37 | * @param dJD 38 | */ 39 | void setGeodesicGrid(int nLevel, ZoneArrayVector& vZoneData, GeodesicGrid* pGeodesicGrid, osg::Group *pRoot, double dJD); 40 | 41 | protected: 42 | void BuildGeometry(osg::Group *pRoot); 43 | 44 | private: 45 | ISceneGraph* m_pSceneGraph; 46 | QMap > m_mapName2Hips; /// 星座连线 47 | QMap m_mapHip2Pos; /// 星星的位置 48 | }; 49 | 50 | #endif // STARCONSTELLATION_H 51 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/StarEnv.h: -------------------------------------------------------------------------------- 1 | #ifndef SA_STAR_ENV_H 2 | #define SA_STAR_ENV_H 3 | 4 | #include 5 | #include 6 | 7 | #include "Milkyway.h" 8 | #include "Boundary.h" 9 | #include "StarManager.h" 10 | 11 | class ISceneGraph; 12 | 13 | class CStarEnv : public osg::Camera 14 | { 15 | public: 16 | CStarEnv(ISceneGraph* pSceneGraph); 17 | 18 | /** 19 | * @brief 设置主view的camera 20 | * @param pMainCamera 21 | */ 22 | void SetMainView(osgViewer::View* pMainView); 23 | 24 | /** 25 | * @brief 重写父类方法 26 | * @param nv 27 | */ 28 | void traverse(osg::NodeVisitor& nv); 29 | 30 | /** 31 | * @brief 设置星区显示 32 | * @param bVisible 33 | */ 34 | void SetBoundaryVisible(bool bVisible); 35 | 36 | /** 37 | * @brief 设置名称显示 38 | * @param bVisible 39 | */ 40 | void SetStarNameVisible(bool bVisible); 41 | 42 | /** 43 | * @brief 设置星座显示 44 | * @param bVisible 45 | */ 46 | void SetConstellationVisible(bool bVisible); 47 | 48 | /** 49 | * @brief 设置银河的显隐 50 | */ 51 | void SetMilkwayVisible(bool); 52 | 53 | /** 54 | * @brief 更新矩阵 55 | * @param rRotate 56 | */ 57 | void UpdateMatrix(const Math::CMatrix &rRotate); 58 | 59 | protected: 60 | void InitProjMatrix(); 61 | ~CStarEnv(); 62 | private: 63 | bool m_bInit{false}; 64 | bool m_bRotate{true}; 65 | osg::Matrix m_rRoate; 66 | ISceneGraph* m_pSceneGraph; 67 | osg::ref_ptr m_pMilkyway; 68 | osg::ref_ptr m_pBoundary; 69 | osg::ref_ptr m_pStarManager; 70 | osg::observer_ptr m_pMainView; 71 | osg::observer_ptr m_pMainCamera; 72 | }; 73 | 74 | #endif // SA_STAR_ENV_H 75 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/StarToneReproducer.h: -------------------------------------------------------------------------------- 1 | #ifndef STARTONEREPRODUCER_H 2 | #define STARTONEREPRODUCER_H 3 | 4 | 5 | class CStarToneReproducer 6 | { 7 | public: 8 | CStarToneReproducer(); 9 | virtual ~CStarToneReproducer(); 10 | 11 | void setDisplayAdaptationLuminance(float displayAdaptationLuminance); 12 | 13 | void setWorldAdaptationLuminance(float worldAdaptationLuminance); 14 | float getWorldAdaptationLuminance() const; 15 | 16 | void setInputScale(float scale = 1.f); 17 | float getInputScale() const; 18 | 19 | void setMaxDisplayLuminance(float maxdL); 20 | 21 | float adaptLuminance(float worldLuminance) const; 22 | float reverseAdaptLuminance(float displayLuminance) const; 23 | 24 | void setDisplayGamma(float gamma); 25 | float getDisplayGamma() const; 26 | 27 | float adaptLuminanceScaled(float worldLuminance) const; 28 | float reverseAdaptLuminanceScaled(float displayLuminance) const; 29 | 30 | float adaptLuminanceScaledLn(float lnWorldLuminance,float pFact = 0.5f) const; 31 | 32 | void getShadersParams(float& a, float& b, float & c) const; 33 | public: 34 | // The global luminance scaling 35 | float inputScale; 36 | float lnInputScale; // std::log(inputScale) 37 | 38 | float Lda; // Display luminance adaptation (in cd/m^2) 39 | float Lwa; // World luminance adaptation (in cd/m^2) 40 | float oneOverMaxdL; // 1 / Display maximum luminance (in cd/m^2) 41 | float lnOneOverMaxdL; // log(oneOverMaxdL) 42 | float oneOverGamma; // 1 / Screen gamma value 43 | 44 | // Precomputed variables 45 | float alphaDa; 46 | float betaDa; 47 | float alphaWa; 48 | float betaWa; 49 | float alphaWaOverAlphaDa; 50 | float term2; 51 | float lnTerm2; // log(term2) 52 | 53 | float term2TimesOneOverMaxdLpOneOverGamma; 54 | }; 55 | 56 | #endif // STARTONEREPRODUCER_H 57 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/StarZoneArrayBase.h: -------------------------------------------------------------------------------- 1 | #ifndef STAR_ZONE_ARRAY_BASE_H 2 | #define STAR_ZONE_ARRAY_BASE_H 3 | #include 4 | #include 5 | 6 | #include "StarZoneDataBase.h" 7 | 8 | /** @interface IStarZoneArray 9 | * 包含多个星区数据. 10 | */ 11 | struct IStarZoneArray: public osg::Referenced 12 | { 13 | /** 14 | * Query count of zones in this array. 15 | */ 16 | virtual unsigned int getZonesCount() const = 0; 17 | 18 | /** 19 | * Query the specified zone in this array. 20 | * @param idx Zero based index of the zone wanted in this array. 21 | */ 22 | virtual IStarZoneData *getZone(unsigned int idx, const osg::Vec3f &c0, 23 | const osg::Vec3f &c1, const osg::Vec3f &c2) const = 0; 24 | 25 | /** 26 | * Query the level of this array. 27 | */ 28 | virtual int getLevel() const = 0; 29 | 30 | /** 31 | * Convert the original mag data to float one. 32 | */ 33 | virtual float convertMag(int mag) = 0; 34 | 35 | /** 36 | * Query the minimum mag value. 37 | */ 38 | virtual int getMagMin() const = 0; 39 | 40 | /** 41 | * Query the mag range value. 42 | */ 43 | virtual int getMagRange() const = 0; 44 | 45 | /** 46 | * Query the mag step. 47 | */ 48 | virtual int getMagStep() const = 0; 49 | 50 | /** 51 | * Query the movement factor. 52 | */ 53 | virtual float getMovementFactor(float JD) const = 0; 54 | 55 | /// Query the data type 56 | virtual int getType() const = 0; 57 | 58 | virtual void initTriangle(const osg::Vec3f &c0, const osg::Vec3f &c1, 59 | const osg::Vec3f &c2) = 0; 60 | virtual void scaleAxis() = 0; 61 | }; 62 | 63 | typedef std::vector > ZoneArrayVector; 64 | 65 | #endif // STAR_ZONE_ARRAY_BASE_H 66 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/StarZoneArrayRenderer.h: -------------------------------------------------------------------------------- 1 | #ifndef STARZONEARRAYRENDERER_H 2 | #define STARZONEARRAYRENDERER_H 3 | #include 4 | #include 5 | #include 6 | 7 | #include "StarZoneArrayBase.h" 8 | class GeodesicGrid; 9 | class ISceneGraph; 10 | 11 | class CStarZoneArrayRenderer : public osg::Referenced 12 | { 13 | struct ZoneInitContext 14 | { 15 | CStarZoneArrayRenderer *render; 16 | IStarZoneArray *za; 17 | }; 18 | 19 | public: 20 | CStarZoneArrayRenderer(ISceneGraph* pSceneGraph,IStarZoneArray *za, double JD 21 | , GeodesicGrid* pGrid, const QMap& hip2Names); 22 | 23 | /** 24 | * @brief 获取级别 25 | * @return 26 | */ 27 | int getLevel(){return(m_nLevel);} 28 | 29 | 30 | void readZones(IStarZoneArray *za, unsigned int idx, const osg::Vec3f &c0, 31 | const osg::Vec3f &c1, const osg::Vec3f &c2); 32 | osg::Geometry *getGeometry(float maxMag, unsigned int idx); 33 | const std::vector >& getStarNames(){return(m_vStarNames);} 34 | 35 | static bool initFunc(int lev, unsigned int index, const osg::Vec3f &c0, 36 | const osg::Vec3f &c1, const osg::Vec3f &c2, void *context); 37 | private: 38 | ISceneGraph* m_pSceneGraph; 39 | int m_nLevel; 40 | int m_nStartCount; 41 | float m_fMinMag; /// 最小视等; 42 | double m_dJD; 43 | const QMap& m_mapHip2Names; 44 | std::vector > m_vStarNames;/// 星星的名字 45 | std::vector > m_vStar; /// 星星的点 46 | }; 47 | 48 | typedef std::vector > ZoneArrayRenderVector; 49 | #endif // STARZONEARRAYRENDERER_H 50 | -------------------------------------------------------------------------------- /Plot/SpaceBackGround/Star/StarZoneDataBase.h: -------------------------------------------------------------------------------- 1 | #ifndef I_Star_ZoneBase_H 2 | #define I_Star_ZoneBase_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | /** @interface 星空区域基类 9 | * 将星空按照 Zone进行划分 10 | */ 11 | struct IStarZoneData: public osg::Referenced 12 | { 13 | /** 14 | * 获取该Zone中星星的数量 15 | */ 16 | virtual unsigned int getStarsCount() const = 0; 17 | 18 | /** 19 | * 获取该Zone的中心位置 20 | */ 21 | virtual const osg::Vec3f &getCenter() const = 0; 22 | 23 | /** 24 | * Query the first axis vector of this zone. 25 | */ 26 | virtual const osg::Vec3f &getFirstAxis() const = 0; 27 | 28 | /** 29 | * Query the second axis vector of this zone. 30 | */ 31 | virtual const osg::Vec3f &getSecondAxis() const = 0; 32 | 33 | /** 34 | * Query the normalized position of the star in J2000 coordinate system. 35 | * @param pos A vector to hold the position. 36 | */ 37 | virtual void getStarPosition(unsigned int idx, float movementFactor, 38 | osg::Vec3f &pos) const = 0; 39 | 40 | /** 41 | * 根据索引查询恒星的亮度 42 | * @return The visual magnitude of the star. 43 | */ 44 | virtual int getStarMag(unsigned int idx) const = 0; 45 | 46 | /** 47 | * 根据索引查找恒星的颜色 48 | * @return The BV magnitude. 49 | */ 50 | virtual float getStarBV(unsigned int idx) const = 0; 51 | 52 | /** 53 | * @brief 根据索引查找恒星的颜色索引 54 | * @param idx 55 | * @return 56 | */ 57 | virtual unsigned char getStarBVIndex(unsigned int idx) const=0; 58 | 59 | /** 60 | * 根据索引查找恒星的依巴谷编号 61 | */ 62 | virtual int getStarHip(unsigned int idx) const = 0; 63 | }; 64 | 65 | #endif // I_Star_ZoneBase_H 66 | -------------------------------------------------------------------------------- /Plot/Trajectory/TrajectoryShow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MJYCo-Ltd/Map/a95d6225cc08beffab6b609325610c3edfc129b6/Plot/Trajectory/TrajectoryShow.cpp -------------------------------------------------------------------------------- /Plot/Trajectory/TrajectoryShow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MJYCo-Ltd/Map/a95d6225cc08beffab6b609325610c3edfc129b6/Plot/Trajectory/TrajectoryShow.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Map 2 | 3 | 本项目使用QT5+基于osg和osgearth封装的渲染平台 4 | 5 | ![avatar](LoadMap/LoadMap.png) 6 | 7 | 主要工作: 8 | 9 | * 对Qt和OSG的OpenGL状态进行了分离 10 | * 分离渲染线程和Qt的界面主线程,使得渲染不影响主界面的流畅性 11 | * 真实的恒星位置、星座、星区,显示 12 | * 屏幕显示 13 | * 点、线、面、体的绘制 14 | * 灵活视点控制 15 | * 一键二、三维切换 16 | * 模型点选的统一控制 17 | * 统一状态,减少渲染时的状态切换 18 | 19 | 依赖库: 20 | 21 | * [window依赖的第三方库下载地址](https://github.com/MJYCo-Ltd/VersionMath_Map_Depend "依赖库和数据") 22 | * 本工程的矩阵运算、空间目标运算算法依赖于[VersionMath](https://github.com/MJYCo-Ltd/VersionMath "算法") 23 | 24 | 不足: 25 | 26 | * 没有对OSG的状态进行彻底的合并 27 | * 代码封装不彻底,暴露过多的OSG的机制 28 | -------------------------------------------------------------------------------- /SceneCore/MyNotify.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "MyNotify.h" 4 | 5 | CMyNotify::CMyNotify(const std::string &sLogPath,const char* pFileName) 6 | { 7 | std::string sFilePath = sLogPath; 8 | #ifdef Q_OS_WIN 9 | const char* pFindSubfix = strrchr(pFileName,'.'); 10 | sFilePath.append(pFileName,pFindSubfix-pFileName); 11 | #else 12 | sFilePath += pFileName; 13 | #endif 14 | sFilePath += ".log"; 15 | m_pFile = fopen(sFilePath.c_str(),"w"); 16 | 17 | m_bInit = m_pFile != nullptr; 18 | } 19 | 20 | void CMyNotify::notify(osg::NotifySeverity, const char *message) 21 | { 22 | if(m_bInit) 23 | { 24 | fwrite(message,strlen(message),1,m_pFile); 25 | } 26 | } 27 | 28 | CMyNotify::~CMyNotify() 29 | { 30 | if(m_bInit) 31 | { 32 | fflush(m_pFile); 33 | fclose(m_pFile); 34 | delete m_pFile; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SceneCore/MyNotify.h: -------------------------------------------------------------------------------- 1 | #ifndef MYNOTIFY_H 2 | #define MYNOTIFY_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief 用于接收osg和osgEarth打印的字符串 8 | */ 9 | class CMyNotify:public osg::NotifyHandler 10 | { 11 | public: 12 | CMyNotify(const std::string& sLogPath, const char *pFileName); 13 | 14 | /** 15 | * @brief 重写notify函数 16 | * @param message 将要打印的信息 17 | */ 18 | void notify(osg::NotifySeverity, const char *message); 19 | protected: 20 | ~CMyNotify(); 21 | private: 22 | FILE* m_pFile{}; 23 | bool m_bInit{false}; 24 | }; 25 | 26 | #endif // MYNOTIFY_H 27 | -------------------------------------------------------------------------------- /SceneCore/SceneCore.h: -------------------------------------------------------------------------------- 1 | #ifndef SCENCECORE_HEADER_H 2 | #define SCENCECORE_HEADER_H 3 | 4 | #include 5 | 6 | class CSceneGraphManager; 7 | /** 8 | * @brief 整个场景的核心库 9 | */ 10 | class CSceneCore:public ISceneCore 11 | { 12 | public: 13 | CSceneCore(); 14 | ~CSceneCore(); 15 | 16 | /** 17 | * @brief 获取窗口管理者 18 | * @return 19 | */ 20 | ISceneGraphManager* GetSceneGraphManager(); 21 | 22 | protected: 23 | CSceneGraphManager* m_pSceneGraphManger{}; 24 | }; 25 | #endif // SCENCECORE_H 26 | -------------------------------------------------------------------------------- /SceneCore/SceneCore.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-19T11:02:02 4 | # 5 | #------------------------------------------------- 6 | 7 | QT -= gui 8 | QT += widgets quick 9 | 10 | TARGET = SceneCore 11 | TEMPLATE = lib 12 | 13 | DEFINES += SCENECORE_LIBRARY 14 | 15 | SDK_CONFIG *= OSG OsgExtern Satellite 16 | 17 | include(../SoftSDK.pri) 18 | 19 | SOURCES += \ 20 | MyNotify.cpp \ 21 | SceneCore.cpp \ 22 | SceneGraph/MyEarthManipulator.cpp \ 23 | SceneGraph/QtRender.cpp \ 24 | SceneGraph/QtSceneGraph.cpp \ 25 | SceneGraph/QtViewHud.cpp \ 26 | SceneGraph/QtViewPort.cpp \ 27 | SceneGraph/ResourceLoadExtern.cpp \ 28 | SceneGraph/ResourceLod.cpp \ 29 | SceneGraph/SceneGraphManager.cpp \ 30 | Window/Qml/QtOsgItem.cpp \ 31 | Window/Qml/QtOsgRenderer.cpp \ 32 | Window/QtFBOWindow.cpp \ 33 | Window/QtWindow.cpp \ 34 | Window/QtEventMap.cpp \ 35 | Window/Widget/QtOsgWindow.cpp 36 | 37 | HEADERS += \ 38 | ../Inc/Qml/QtOsgItem.h \ 39 | MyNotify.h \ 40 | SceneCore.h \ 41 | SceneGraph/DealViewPortChange.h \ 42 | SceneGraph/MyEarthManipulator.h \ 43 | SceneGraph/QtRender.h \ 44 | SceneGraph/QtSceneGraph.h \ 45 | SceneGraph/QtViewHud.h \ 46 | SceneGraph/QtViewPort.h \ 47 | SceneGraph/ResourceLod.h \ 48 | SceneGraph/SceneGraphManager.h \ 49 | SceneGraph/ViewPortEventCallback.h \ 50 | Window/MyShader.h \ 51 | Window/Qml/QtOsgRenderer.h \ 52 | Window/QtFBOWindow.h \ 53 | Window/QtWindow.h \ 54 | Window/QtEventMap.h \ 55 | Window/Widget/QtOsgWindow.h 56 | -------------------------------------------------------------------------------- /SceneCore/SceneGraph/DealViewPortChange.h: -------------------------------------------------------------------------------- 1 | #ifndef DEALVIEWPORTCHANGE_H 2 | #define DEALVIEWPORTCHANGE_H 3 | 4 | #include 5 | #include "QtViewPort.h" 6 | 7 | /// 更改视点 8 | class HomeViewPointOperation:public osg::Operation 9 | { 10 | public: 11 | HomeViewPointOperation(osgGA::CameraManipulator* pManipulator):m_pManipulator(pManipulator){} 12 | 13 | void operator()(osg::Object*) 14 | { 15 | m_pManipulator->home(0); 16 | } 17 | private: 18 | osg::ref_ptr m_pManipulator; 19 | }; 20 | 21 | #endif // DEALVIEWPORTCHANGE_H 22 | -------------------------------------------------------------------------------- /SceneCore/SceneGraph/MyEarthManipulator.h: -------------------------------------------------------------------------------- 1 | #ifndef CFLATEARTHMANIPULATOR_H 2 | #define CFLATEARTHMANIPULATOR_H 3 | 4 | #include 5 | 6 | #if OSGEARTH_VERSION_GREATER_OR_EQUAL(3,0,0) 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | class CMyEarthManipulator : public osgEarth::Util::EarthManipulator 16 | { 17 | public: 18 | CMyEarthManipulator(MapType type); 19 | 20 | /** 21 | * @brief 切换地图类型 22 | * @param emType 23 | */ 24 | void ChangeMap(MapType emType); 25 | 26 | bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa); 27 | void pan(double dx, double dy); 28 | void rotate(double dx, double dy); 29 | void zoom(double dx, double dy, osg::View *view); 30 | 31 | /** 32 | * @brief 忽略拖拽 33 | * @param bAvoid 34 | */ 35 | void AvoidDrag(bool bAvoid){m_bAvoidDrag=bAvoid;} 36 | void AvoidDClick(bool bAvoid){m_bAvoidDClick=bAvoid;} 37 | 38 | /** 39 | * @brief 初始化视点 40 | */ 41 | void InitHomePoint(const SceneViewPoint& homePoint); 42 | 43 | /** 44 | * @brief 设置视点 45 | * @param viewPoint 46 | */ 47 | void SetViewPoint(const SceneViewPoint& viewPoint, double dTimes); 48 | 49 | /** 50 | * @锁定视角 51 | */ 52 | void SetLockView(bool bLock){m_bLockView = bLock;} 53 | 54 | protected: 55 | 56 | /** 57 | * @brief 调整视点 58 | */ 59 | bool AdjustViewPoint(osgEarth::Viewpoint &vp); 60 | 61 | private: 62 | MapType m_emType= MAP_USER; 63 | osgEarth::GeoExtent m_extent; 64 | double m_dHalfY{}; 65 | double m_dFactor{}; 66 | double m_dTanFvoy{DBL_MIN}; 67 | double m_dMaxDistance{360000000}; 68 | bool m_bCalFactor{false}; 69 | bool m_bInit{false}; 70 | bool m_bLockView{false}; 71 | bool m_bAvoidDrag{false}; 72 | bool m_bAvoidDClick{false}; 73 | }; 74 | 75 | #endif // CFLATEARTHMANIPULATOR_H 76 | -------------------------------------------------------------------------------- /SceneCore/SceneGraph/QtViewHud.h: -------------------------------------------------------------------------------- 1 | #ifndef QT_VIEWHUD_H 2 | #define QT_VIEWHUD_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class QtViewHud:public ImplSceneNode 10 | { 11 | public: 12 | QtViewHud(osg::View*,ISceneGraph*pSceneGraph); 13 | ~QtViewHud(); 14 | 15 | /** 16 | * @brief 添加屏显节点 17 | */ 18 | virtual bool AddHudNode(IHudNode* pHudNode); 19 | 20 | /** 21 | * @brief 移除屏显节点 22 | */ 23 | virtual bool RemoveHudNode(IHudNode* pHudNode); 24 | 25 | /** 26 | * @brief 清空所有的节点 27 | */ 28 | virtual void Clear(); 29 | /** 30 | * @brief 当前是否有选中hud节点 31 | */ 32 | virtual bool CurrentHaveSelect() 33 | { 34 | return m_CurrentHaveSlect; 35 | } 36 | /** 37 | * @brief 当前是否有选中hud节点 38 | */ 39 | virtual void SetCurrentHaveSelect(bool valb) 40 | { 41 | m_CurrentHaveSlect = valb; 42 | } 43 | 44 | protected: 45 | void InitNode(); 46 | void AddControl(osgEarth::Controls::ControlCanvas* pCanvas,osgEarth::Controls::Control* pControl); 47 | void DelControl(osgEarth::Controls::ControlCanvas* pCanvas,osgEarth::Controls::Control* pControl); 48 | private: 49 | osg::observer_ptr m_pView; 50 | osg::observer_ptr m_pControlCanvas; 51 | std::set m_setHudNode; 52 | bool m_CurrentHaveSlect = false; 53 | }; 54 | 55 | #endif // QTVIEWHUD_H 56 | -------------------------------------------------------------------------------- /SceneCore/SceneGraph/SceneGraphManager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "SceneGraphManager.h" 4 | #include "QtSceneGraph.h" 5 | 6 | CSceneGraphManager::CSceneGraphManager() 7 | { 8 | } 9 | 10 | /// 释放所有的 11 | CSceneGraphManager::~CSceneGraphManager() 12 | { 13 | for(auto one : m_vSceneGraph) 14 | { 15 | delete one; 16 | } 17 | } 18 | 19 | /// 初始化 20 | ISceneGraph *CSceneGraphManager::CreateSceneGraph(ISceneGraph::SceneGraphType typeScene) 21 | { 22 | auto pSceneGraph = new QtSceneGraph(typeScene); 23 | pSceneGraph->InitSceneGraph(); 24 | m_vSceneGraph.push_back(pSceneGraph); 25 | 26 | return(pSceneGraph); 27 | } 28 | 29 | /// 获取绑定的场景图 30 | ISceneGraph *CSceneGraphManager::FindSceneGraph(IWindow *pWindow) 31 | { 32 | for(auto one : m_vSceneGraph) 33 | { 34 | one->ContainWindow(pWindow); 35 | return(one); 36 | } 37 | 38 | return(nullptr); 39 | } 40 | 41 | ISceneGraph *CSceneGraphManager::FindSceneGraph(QQuickItem *pItem) 42 | { 43 | for(auto one : m_vSceneGraph) 44 | { 45 | if(one->IsQuickItem(pItem)) 46 | { 47 | return(one); 48 | } 49 | } 50 | 51 | return(nullptr); 52 | } 53 | 54 | /// 删除场景 55 | bool CSceneGraphManager::DeleteSceneGraph(ISceneGraph *& rForDelete) 56 | { 57 | auto itor = find(m_vSceneGraph.begin(),m_vSceneGraph.end(),rForDelete); 58 | 59 | if(itor != m_vSceneGraph.end()) 60 | { 61 | delete dynamic_cast(rForDelete); 62 | rForDelete = nullptr; 63 | m_vSceneGraph.erase(itor); 64 | return(true); 65 | } 66 | 67 | return(false); 68 | } 69 | -------------------------------------------------------------------------------- /SceneCore/SceneGraph/SceneGraphManager.h: -------------------------------------------------------------------------------- 1 | #ifndef CSCENEGRAPHMANAGER_H 2 | #define CSCENEGRAPHMANAGER_H 3 | #include 4 | #include "SceneGraph/ISceneGraphManager.h" 5 | 6 | class QtSceneGraph; 7 | class CSceneGraphManager:public ISceneGraphManager 8 | { 9 | public: 10 | CSceneGraphManager(); 11 | ~CSceneGraphManager(); 12 | 13 | /** 14 | * @brief 创建一个场景图 15 | * @return 16 | */ 17 | ISceneGraph* CreateSceneGraph(ISceneGraph::SceneGraphType typeScene); 18 | 19 | /** 20 | * @brief 查找绑定的场景图 21 | * @param pWindow 22 | * @return 23 | */ 24 | ISceneGraph* FindSceneGraph(IWindow* pWindow); 25 | 26 | /** 27 | * @brief 查找绑定的场景图 28 | * @param pItem 29 | * @return 30 | */ 31 | ISceneGraph* FindSceneGraph(QQuickItem* pItem); 32 | 33 | /** 34 | * @brief 删除一个 35 | * @return 36 | */ 37 | bool DeleteSceneGraph(ISceneGraph*& rForDelete); 38 | private: 39 | std::list m_vSceneGraph; /// 保存所有创建的地图 40 | }; 41 | 42 | #endif // CSCENEGRAPHMANAGER_H 43 | -------------------------------------------------------------------------------- /SceneCore/SceneGraph/ViewPortEventCallback.h: -------------------------------------------------------------------------------- 1 | #ifndef VIEWPORTEVENTCALLBACK_H 2 | #define VIEWPORTEVENTCALLBACK_H 3 | #include "QtViewPort.h" 4 | 5 | /** 6 | * @brief The ViewPortEventCallback class 7 | */ 8 | class ViewPortEventCallback:public osgGA::GUIEventHandler 9 | { 10 | public: 11 | ViewPortEventCallback(QtViewPort* pViewPort):m_pViewPort(pViewPort){} 12 | 13 | virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, 14 | osg::Object*, osg::NodeVisitor*) 15 | { 16 | if(ea.FRAME == ea.getEventType()) 17 | { 18 | /// 每一帧更新一次 19 | m_pViewPort->FrameEvent(); 20 | 21 | auto view = aa.asView(); 22 | if(nullptr != view) 23 | { 24 | 25 | view->getCamera()->getViewMatrixAsLookAt(m_vEye,m_vCenter,m_vUp); 26 | 27 | QMetaObject::invokeMethod(m_pViewPort,"EyePos",Q_ARG(double,m_vEye.x()), 28 | Q_ARG(double,m_vEye.y()),Q_ARG(double,m_vEye.z())); 29 | QMetaObject::invokeMethod(m_pViewPort,"LookDir",Q_ARG(double,m_vCenter.x()), 30 | Q_ARG(double,m_vCenter.y()),Q_ARG(double,m_vCenter.z())); 31 | } 32 | } 33 | 34 | return(osgGA::GUIEventHandler::handle(ea,aa)); 35 | } 36 | 37 | protected: 38 | QtViewPort* m_pViewPort{}; 39 | osg::Vec3d m_vEye; 40 | osg::Vec3d m_vCenter; 41 | osg::Vec3d m_vUp; 42 | }; 43 | 44 | #endif // VIEWPORTEVENTCALLBACK_H 45 | -------------------------------------------------------------------------------- /SceneCore/Window/MyShader.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSHADER_H 2 | #define MYSHADER_H 3 | 4 | static const char *vertexShaderSource= 5 | "#version 330\n" 6 | "out vec2 uv;\n" 7 | "void main(void)\n" 8 | "{\n" 9 | "vec2 pos[] = vec2[](vec2(-1.0, -1.0),\n" 10 | "vec2( 1.0, -1.0),\n" 11 | "vec2(-1.0, 1.0),\n" 12 | "vec2( 1.0, 1.0));\n" 13 | "vec2 uvpos[] = vec2[](vec2(0, 0.0),\n" 14 | "vec2( 1.0, 0.0),\n" 15 | "vec2(0.0, 1.0),\n" 16 | "vec2( 1.0, 1.0));\n" 17 | "gl_Position = vec4(pos[gl_VertexID], 0.0, 1.0);\n" 18 | "uv = uvpos[gl_VertexID];\n" 19 | "}\n"; 20 | 21 | static const char *fragmentShaderSource = 22 | "#version 330\n" 23 | "in vec2 uv;\n" 24 | "uniform sampler2D tex;\n" 25 | "out vec4 vFragColor;" 26 | "void main() {\n" 27 | " vFragColor = vec4(texture(tex, uv).rgb, 1.0);\n" 28 | "}\n"; 29 | 30 | #endif // MYSHADER_H 31 | -------------------------------------------------------------------------------- /SceneCore/Window/Qml/QtOsgRenderer.h: -------------------------------------------------------------------------------- 1 | #ifndef QTOSGRENDERER_H 2 | #define QTOSGRENDERER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../QtFBOWindow.h" 10 | 11 | class QtOsgRenderer : public QObject,public QQuickFramebufferObject::Renderer 12 | { 13 | Q_OBJECT 14 | public: 15 | QtOsgRenderer(ISceneGraph* pSceneGraph); 16 | ~QtOsgRenderer(); 17 | 18 | /** 19 | * @brief 初始化窗口 20 | */ 21 | void InitSurface(); 22 | 23 | /** 24 | * @brief 渲染函数 25 | */ 26 | void render(); 27 | 28 | /** 29 | * @brief 同步信息 30 | * @param pQuickFBO 31 | */ 32 | void synchronize(QQuickFramebufferObject *pQuickFBO); 33 | QtFBOWindow* GetFBOWindow(){return(m_pFBOWindow);} 34 | 35 | QOpenGLFramebufferObject *createFramebufferObject(const QSize &size); 36 | public slots: 37 | void UpdateTexture(); 38 | private: 39 | ISceneGraph* m_pSceneGraph{};/// 场景图 40 | QtOsgItem* m_pOsgItem{}; 41 | QtFBOWindow* m_pFBOWindow{}; /// 渲染窗口 42 | QOpenGLShaderProgram* m_pProgram{}; 43 | QOpenGLVertexArrayObject *m_pVao{}; 44 | QOpenGLFramebufferObject* m_pFBO{}; 45 | uint m_unTextureID{}; 46 | bool m_bInitOpengl{false}; 47 | bool m_bInitSys{false}; 48 | bool m_bUpdate{false}; 49 | }; 50 | 51 | #endif // QTOSGRENDERER_H 52 | -------------------------------------------------------------------------------- /SceneCore/Window/QtEventMap.h: -------------------------------------------------------------------------------- 1 | #ifndef QTEVENTMAP_H 2 | #define QTEVENTMAP_H 3 | 4 | #include 5 | #include 6 | 7 | class QKeyEvent; 8 | class QInputEvent; 9 | class QMouseEvent; 10 | class QWheelEvent; 11 | class QTouchEvent; 12 | 13 | /** 14 | * @brief Qt与osg的映射关系 15 | */ 16 | class QtEventdMap 17 | { 18 | public: 19 | /** 20 | * @brief 获取单例 21 | * @return 22 | */ 23 | static QtEventdMap* GetInstance(); 24 | 25 | /** 26 | * @brief 获取qt 对应的 osg的键值 27 | * @param event 28 | * @return 29 | */ 30 | int ChangeKeyEvent(QKeyEvent* event); 31 | 32 | /** 33 | * @brief 获取键盘的掩码 34 | * @param event 35 | * @return 36 | */ 37 | int ChangeKeyMask(QInputEvent* event); 38 | 39 | /** 40 | * @brief 获取鼠标对应的osg的键值 41 | * @param event 42 | * @return 43 | */ 44 | unsigned int ChangeMouseEvent(QMouseEvent* event); 45 | 46 | /** 47 | * @brief 获取滚轮对应的osg的值 48 | * @param event 49 | * @return 50 | */ 51 | osgGA::GUIEventAdapter::ScrollingMotion ChangeWheelEvent(QWheelEvent* event); 52 | 53 | protected: 54 | QtEventdMap(); 55 | 56 | protected: 57 | typedef std::map KeyMap; 58 | KeyMap mKeyMap; 59 | }; 60 | 61 | #endif // QTEVENTMAP_H 62 | -------------------------------------------------------------------------------- /SceneCore/Window/Widget/QtOsgWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef QT_OSG_WINDOW_H 2 | #define QT_OSG_WINDOW_H 3 | 4 | #include 5 | 6 | class QtFBOWindow; 7 | class QtRender; 8 | class QOpenGLShaderProgram; 9 | class QOpenGLVertexArrayObject; 10 | 11 | 12 | class QtOsgWindow : public QOpenGLWindow 13 | { 14 | Q_OBJECT 15 | public: 16 | QtOsgWindow(QThread* pThread,int nType); 17 | ~QtOsgWindow(); 18 | 19 | /** 20 | * @brief 关联渲染器 21 | * @param pRender 22 | */ 23 | void ConnectRender(QtRender* pRender); 24 | 25 | /** 26 | * @brief 设置FBO窗口 27 | * @param pFBOWindow 28 | */ 29 | void SetFBOWindow(QtFBOWindow* pFBOWindow); 30 | QtFBOWindow* GetFBOWindow(); 31 | 32 | /** 33 | * @brief 更改定时器间隔 34 | */ 35 | void ChangeTimer(int); 36 | 37 | 38 | public slots: 39 | void UpdateTexture(); 40 | 41 | /// 覆盖父类方法 42 | protected: 43 | void initializeGL() override; 44 | void paintUnderGL() override; 45 | void timerEvent(QTimerEvent *event) override; 46 | void keyPressEvent(QKeyEvent* event) override; 47 | void keyReleaseEvent(QKeyEvent* event) override; 48 | void resizeEvent(QResizeEvent *event) override; 49 | void mousePressEvent(QMouseEvent* event) override; 50 | void mouseReleaseEvent(QMouseEvent* event) override; 51 | void mouseDoubleClickEvent(QMouseEvent* event) override; 52 | void mouseMoveEvent(QMouseEvent* event) override; 53 | void wheelEvent(QWheelEvent* event) override; 54 | void touchEvent(QTouchEvent *event)override; 55 | private: 56 | void Init(); 57 | 58 | private: 59 | QThread* m_pOsgRenderThread{}; 60 | QtRender* m_pOsgRender{}; 61 | QtFBOWindow* m_pFBOWindow{}; 62 | QOpenGLShaderProgram* m_pProgram{}; 63 | QOpenGLVertexArrayObject *m_pVao{}; 64 | uint m_unTextureID{}; 65 | int m_nType{}; 66 | int m_nTimerID{}; 67 | bool m_bInit{false}; 68 | bool m_bUpdate{true}; 69 | }; 70 | 71 | #endif // GRAPHICSVIEW_H 72 | -------------------------------------------------------------------------------- /Tool/Analysis/Analysis.pro: -------------------------------------------------------------------------------- 1 | CONFIG -= qt 2 | TARGET = Analysis 3 | TEMPLATE = lib 4 | 5 | SDK_CONFIG *= TOOL 6 | include($$PWD/../../SoftSDK.pri) 7 | 8 | HEADERS += \ 9 | AnalysisTool.h \ 10 | ViewAnalysis.h 11 | 12 | SOURCES += \ 13 | AnalysisTool.cpp \ 14 | ViewAnalysis.cpp 15 | -------------------------------------------------------------------------------- /Tool/Analysis/AnalysisTool.cpp: -------------------------------------------------------------------------------- 1 | #include "AnalysisTool.h" 2 | 3 | CAnalysisTool::CAnalysisTool() 4 | { 5 | 6 | } 7 | 8 | ITool *CreateTool(ISceneGraph *pSceneGraph, const std::string &sInterfaceName) 9 | { 10 | return(nullptr); 11 | } 12 | 13 | bool QueryInterface(std::string& sInterfaceName) 14 | { 15 | sInterfaceName = "IViewAnalysis"; 16 | return(false); 17 | } 18 | -------------------------------------------------------------------------------- /Tool/Analysis/AnalysisTool.h: -------------------------------------------------------------------------------- 1 | #ifndef CANALYSISTOOL_H 2 | #define CANALYSISTOOL_H 3 | #include 4 | #include 5 | #include 6 | class CAnalysisTool 7 | { 8 | public: 9 | CAnalysisTool(); 10 | }; 11 | 12 | extern "C" 13 | { 14 | Q_DECL_EXPORT ITool* CreateTool(ISceneGraph* pSceneGraph,const std::string& sInterfaceName); 15 | Q_DECL_EXPORT bool QueryInterface(std::string& sInterfaceName); 16 | }; 17 | #endif // CANALYSISTOOL_H 18 | -------------------------------------------------------------------------------- /Tool/Analysis/ViewAnalysis.cpp: -------------------------------------------------------------------------------- 1 | #include "ViewAnalysis.h" 2 | 3 | bool CViewAnalysis::InitTool() 4 | { 5 | return(true); 6 | } 7 | 8 | void CViewAnalysis::ReleaseTool() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /Tool/Analysis/ViewAnalysis.h: -------------------------------------------------------------------------------- 1 | #ifndef CVIEWANALYSIS_H 2 | #define CVIEWANALYSIS_H 3 | 4 | #include "../IToolBase.h" 5 | class CViewAnalysis:public IToolBase 6 | { 7 | public: 8 | public: 9 | CViewAnalysis(ISceneGraph* pSceneGraph,CToolSelector*pToolSelector):IToolBase(pSceneGraph,pToolSelector){} 10 | 11 | /** 12 | * @brief 初始化工具 13 | */ 14 | bool InitTool(); 15 | void ReleaseTool(); 16 | }; 17 | 18 | #endif // CVIEWANALYSIS_H 19 | -------------------------------------------------------------------------------- /Tool/IToolBase.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_TOOL_BASE_HEADER_H 2 | #define INTERFACE_TOOL_BASE_HEADER_H 3 | 4 | class ISceneGraph; 5 | class CToolSelector; 6 | /** 7 | * @brief 工具类基类 8 | */ 9 | class IToolBase 10 | { 11 | public: 12 | IToolBase(ISceneGraph* pSceneGraph,CToolSelector*pToolSelector): 13 | m_pSceneGraph(pSceneGraph),m_pToolSelector(pToolSelector){} 14 | 15 | /** 16 | * @brief 初始化工具 17 | */ 18 | virtual bool InitTool()=0; 19 | 20 | /** 21 | * @brief 释放工具 22 | */ 23 | virtual void ReleaseTool()=0; 24 | 25 | virtual ~IToolBase(){} 26 | protected: 27 | ISceneGraph* m_pSceneGraph; 28 | CToolSelector* m_pToolSelector; 29 | }; 30 | 31 | #endif//INTERFACE_TOOL_HEADER_H 32 | -------------------------------------------------------------------------------- /Tool/IToolPub.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_TOOL_PUB_HEADER_H 2 | #define INTERFACE_TOOL_PUB_HEADER_H 3 | 4 | /** 5 | * @brief 工具发送消息 6 | */ 7 | class IToolPub 8 | { 9 | public: 10 | virtual ~IToolPub(){} 11 | /** 12 | * @brief 释放工具 13 | */ 14 | virtual void PickID(unsigned int,unsigned int)=0; 15 | }; 16 | 17 | #endif//INTERFACE_TOOL_HEADER_H 18 | -------------------------------------------------------------------------------- /Tool/Measure/Measure.pro: -------------------------------------------------------------------------------- 1 | CONFIG -= qt 2 | TARGET = Measure 3 | TEMPLATE = lib 4 | 5 | SDK_CONFIG *= TOOL 6 | include($$PWD/../../SoftSDK.pri) 7 | 8 | HEADERS += \ 9 | MeasureTool.h 10 | 11 | SOURCES += \ 12 | MeasureTool.cpp 13 | -------------------------------------------------------------------------------- /Tool/Measure/MeasureTool.cpp: -------------------------------------------------------------------------------- 1 | #include "MeasureTool.h" 2 | 3 | CMeasureTool::CMeasureTool() 4 | { 5 | 6 | } 7 | 8 | ITool *CreateTool(ISceneGraph *pSceneGraph, const std::string &sInterfaceName) 9 | { 10 | return(nullptr); 11 | } 12 | 13 | bool QueryInterface(std::string& sInterfaceName) 14 | { 15 | return(false); 16 | } 17 | -------------------------------------------------------------------------------- /Tool/Measure/MeasureTool.h: -------------------------------------------------------------------------------- 1 | #ifndef CMEASURETOOL_H 2 | #define CMEASURETOOL_H 3 | 4 | #include 5 | #include 6 | #include 7 | class CMeasureTool 8 | { 9 | public: 10 | CMeasureTool(); 11 | }; 12 | 13 | extern "C" 14 | { 15 | Q_DECL_EXPORT ITool* CreateTool(ISceneGraph* pSceneGraph,const std::string& sInterfaceName); 16 | Q_DECL_EXPORT bool QueryInterface(std::string& sInterfaceName); 17 | }; 18 | #endif // CMEASURETOOL_H 19 | -------------------------------------------------------------------------------- /Tool/Pick/IntersectionPick.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERSECTIONPICK_H 2 | #define INTERSECTIONPICK_H 3 | #include 4 | #include "PickTool.h" 5 | class CToolSelector; 6 | class ObjectIntersectionHandle; 7 | class IntersectionPick: public QObject,public IToolBase 8 | { 9 | Q_OBJECT 10 | public: 11 | IntersectionPick(ISceneGraph *pSceneGraph, CToolSelector *pToolSelector); 12 | /** 13 | * @brief 初始化工具 14 | */ 15 | bool InitTool(); 16 | void ReleaseTool(); 17 | public slots: 18 | void HitId(unsigned int,unsigned int); 19 | 20 | protected: 21 | ObjectIntersectionHandle* mIntersectionHandle; 22 | }; 23 | 24 | #endif // INTERSECTIONPICK_H 25 | -------------------------------------------------------------------------------- /Tool/Pick/Pick.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | TARGET = Pick 3 | TEMPLATE = lib 4 | 5 | SDK_CONFIG *= OSG TOOL 6 | include($$PWD/../../SoftSDK.pri) 7 | 8 | HEADERS += \ 9 | IntersectionPick.h \ 10 | PickTool.h \ 11 | PointPick.h 12 | 13 | SOURCES += \ 14 | IntersectionPick.cpp \ 15 | PickTool.cpp \ 16 | PointPick.cpp 17 | -------------------------------------------------------------------------------- /Tool/Pick/PickTool.cpp: -------------------------------------------------------------------------------- 1 | #include "PickTool.h" 2 | #include "PointPick.h" 3 | #include "IntersectionPick.h" 4 | 5 | static const char s_sPointPick[]="IPointPick"; 6 | static const char s_sIntersectionPick[]="IntersectionPick"; 7 | 8 | IToolBase *CreateTool(ISceneGraph *pSceneGraph, 9 | CToolSelector *pToolSelector, 10 | const std::string &sInterfaceName) 11 | { 12 | if(sInterfaceName == s_sPointPick) 13 | return(new CPointPick(pSceneGraph,pToolSelector)); 14 | else if(sInterfaceName == s_sIntersectionPick) 15 | return(new IntersectionPick(pSceneGraph,pToolSelector)); 16 | } 17 | 18 | bool QueryInterface(std::string& sInterfaceName) 19 | { 20 | sInterfaceName = s_sPointPick; 21 | sInterfaceName += " "; 22 | sInterfaceName += s_sIntersectionPick; 23 | return(false); 24 | } 25 | -------------------------------------------------------------------------------- /Tool/Pick/PickTool.h: -------------------------------------------------------------------------------- 1 | #ifndef CPICK_TOOL_H 2 | #define CPICK_TOOL_H 3 | 4 | #include 5 | #include 6 | #include "../IToolBase.h" 7 | 8 | extern "C" 9 | { 10 | Q_DECL_EXPORT IToolBase *CreateTool(ISceneGraph* pSceneGraph, 11 | CToolSelector* pToolSelector, 12 | const std::string& sInterfaceName); 13 | Q_DECL_EXPORT bool QueryInterface(std::string& sInterfaceName); 14 | }; 15 | #endif // CPICK_TOOL_H 16 | -------------------------------------------------------------------------------- /Tool/Pick/PointPick.h: -------------------------------------------------------------------------------- 1 | #ifndef CPOINTPICK_H 2 | #define CPOINTPICK_H 3 | #include 4 | #include 5 | #include "PickTool.h" 6 | 7 | class CToolSelector; 8 | class CPointPick:public QObject,public IToolBase 9 | { 10 | Q_OBJECT 11 | public: 12 | CPointPick(ISceneGraph* pSceneGraph,CToolSelector*pToolSelector); 13 | 14 | /** 15 | * @brief 初始化工具 16 | */ 17 | bool InitTool(); 18 | void ReleaseTool(); 19 | 20 | public slots: 21 | void HitId(unsigned int,unsigned int); 22 | protected: 23 | osg::ref_ptr m_pPicker; 24 | }; 25 | 26 | #endif // CPOINTPICK_H 27 | -------------------------------------------------------------------------------- /Tool/Sound/Sound.pro: -------------------------------------------------------------------------------- 1 | CONFIG -= qt 2 | TARGET = Sound 3 | TEMPLATE = lib 4 | 5 | SDK_CONFIG *= TOOL 6 | include($$PWD/../../SoftSDK.pri) 7 | 8 | HEADERS += \ 9 | SoundTool.h 10 | 11 | SOURCES += \ 12 | SoundTool.cpp 13 | -------------------------------------------------------------------------------- /Tool/Sound/SoundTool.cpp: -------------------------------------------------------------------------------- 1 | #include "SoundTool.h" 2 | 3 | CSoundTool::CSoundTool() 4 | { 5 | 6 | } 7 | 8 | ITool *CreateTool(ISceneGraph *pSceneGraph, const std::string &sInterfaceName) 9 | { 10 | return(nullptr); 11 | } 12 | 13 | bool QueryInterface(std::string& sInterfaceName) 14 | { 15 | sInterfaceName = "ISound"; 16 | return(false); 17 | } 18 | -------------------------------------------------------------------------------- /Tool/Sound/SoundTool.h: -------------------------------------------------------------------------------- 1 | #ifndef CMEASURETOOL_H 2 | #define CMEASURETOOL_H 3 | 4 | #include 5 | #include 6 | #include 7 | class CSoundTool 8 | { 9 | public: 10 | CSoundTool(); 11 | }; 12 | 13 | extern "C" 14 | { 15 | Q_DECL_EXPORT ITool* CreateTool(ISceneGraph* pSceneGraph,const std::string& sInterfaceName); 16 | Q_DECL_EXPORT bool QueryInterface(std::string& sInterfaceName); 17 | }; 18 | #endif // CMEASURETOOL_H 19 | -------------------------------------------------------------------------------- /Tool/Tool.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS =\ 4 | Analysis\ 5 | Measure\ 6 | Pick\ 7 | ToolSelector 8 | 9 | CONFIG *= ordered 10 | -------------------------------------------------------------------------------- /Tool/ToolSelector/ToolSelector.h: -------------------------------------------------------------------------------- 1 | #ifndef CTOOLSELECTOR_H 2 | #define CTOOLSELECTOR_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "../IToolPub.h" 8 | 9 | class IToolBase; 10 | class CToolSelector:public ITool,public IToolPub 11 | { 12 | public: 13 | CONSTRUCTOR(CToolSelector,ITool) 14 | 15 | /** 16 | * @brief 注册工具 17 | */ 18 | void RegisterTool(); 19 | 20 | /** 21 | * @brief 获取所有的工具 22 | * @return 23 | */ 24 | std::vector AllTool()const; 25 | 26 | /** 27 | * @brief 选择工具和取消工具 28 | */ 29 | bool SelecteTool(const std::string& sToolID); 30 | void UnSelecteTool(); 31 | const std::string& CurrentTool(){return(m_sCurrentToolID);} 32 | 33 | /** 34 | * @brief 订阅消息 35 | */ 36 | void SubPickMessage(PickMessage* pSub); 37 | void UnSubPickMessage(PickMessage* pSub); 38 | 39 | /** 40 | * @brief 点选消息 41 | */ 42 | void PickID(unsigned int,unsigned int); 43 | protected: 44 | void CreateTool(const std::string &sInterface); 45 | void InitType(const std::string &sInterface); 46 | 47 | private: 48 | typedef IToolBase* (*pCreateToolFun)(ISceneGraph*,CToolSelector*,const std::string&); 49 | typedef bool(*pQueryInterfaceFun)(std::string&); 50 | 51 | std::list m_listPickMessage; 52 | std::map m_mapTypeDllName; 53 | std::map m_mapTypeFunc; 54 | std::string m_sCurrentToolID; 55 | IToolBase * m_pCurrentTool=nullptr; 56 | }; 57 | 58 | extern "C" 59 | { 60 | Q_DECL_EXPORT ITool* CreateToolSelector(ISceneGraph* pSceneGraph); 61 | }; 62 | #endif // CTOOLSELECTOR_H 63 | -------------------------------------------------------------------------------- /Tool/ToolSelector/ToolSelector.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | TARGET = Tool 3 | TEMPLATE = lib 4 | 5 | SDK_CONFIG *= SceneCore OSG 6 | include($$PWD/../../SoftSDK.pri) 7 | 8 | HEADERS += \ 9 | ToolSelector.h 10 | 11 | SOURCES += \ 12 | ToolSelector.cpp 13 | --------------------------------------------------------------------------------