From 3f9dd8a9c36969fc150dcc3a80d0bfa92075983a Mon Sep 17 00:00:00 2001 From: jinyuan Date: Fri, 15 May 2026 09:45:44 +0800 Subject: [PATCH] =?UTF-8?q?OSGFramework=20=E9=80=82=E9=85=8D=20linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OSGFramework/include/OSGFramework.h | 80 +-- OSGFramework/include/VecCoordinate.h | 448 +++++++-------- OSGFramework/include/VecViewCommand.h | 404 +++++++------- OSGFramework/src/OSGFramework.pro | 162 +++--- OSGFramework/src/OSGFramework.pro.user | 227 ++++++++ OSGFramework/src/VecViewCommand.cpp | 724 ++++++++++++------------- 6 files changed, 1137 insertions(+), 908 deletions(-) create mode 100644 OSGFramework/src/OSGFramework.pro.user diff --git a/OSGFramework/include/OSGFramework.h b/OSGFramework/include/OSGFramework.h index a905bdb..33b46ac 100644 --- a/OSGFramework/include/OSGFramework.h +++ b/OSGFramework/include/OSGFramework.h @@ -1,40 +1,40 @@ -#ifdef _WINDOWS - #ifdef OSGFRAMEWORK_LIB - #define OSGFRAMEWORK_EXPORT __declspec(dllexport) - #else - #define OSGFRAMEWORK_EXPORT __declspec(dllimport) - #endif -#else - #define OSGFRAMEWORK_EXPORT -#endif - -#define BEGIN_OSGGRAPHICS_NAMESPACE \ -namespace pai {\ -namespace graphics{\ - - - -#define END_OSGGRAPHICS_NAMESPACE \ -};\ -};\ -using namespace pai::graphics; - - -#define DIGITIZER_ZVALUE 1 - -#define OSG_BACKGROUD_COLOR osg::Vec4f(1,1,1,1 ) -//#define OSG_BACKGROUD_COLOR osg::Vec4f(0.5,0.5,0.5,1 ) - -#define ZVALUE_ViewerLine -3 -#define ZVALUE_ViewerRuler -2 -#define ZVALUE_HUDFill -1 -#define ZVALUE_HUDGeometry -0.5 -#define ZVALUE_HUDRuler -0.0 - - -#pragma warning( disable: 4251 ) - - - - - +#ifdef WIN32 + #ifdef OSGFRAMEWORK_LIB + #define OSGFRAMEWORK_EXPORT __declspec(dllexport) + #else + #define OSGFRAMEWORK_EXPORT __declspec(dllimport) + #endif +#else + #define OSGFRAMEWORK_EXPORT +#endif + +#define BEGIN_OSGGRAPHICS_NAMESPACE \ +namespace pai {\ +namespace graphics{\ + + + +#define END_OSGGRAPHICS_NAMESPACE \ +};\ +};\ +using namespace pai::graphics; + + +#define DIGITIZER_ZVALUE 1 + +#define OSG_BACKGROUD_COLOR osg::Vec4f(1,1,1,1 ) +//#define OSG_BACKGROUD_COLOR osg::Vec4f(0.5,0.5,0.5,1 ) + +#define ZVALUE_ViewerLine -3 +#define ZVALUE_ViewerRuler -2 +#define ZVALUE_HUDFill -1 +#define ZVALUE_HUDGeometry -0.5 +#define ZVALUE_HUDRuler -0.0 + + +#pragma warning( disable: 4251 ) + + + + + diff --git a/OSGFramework/include/VecCoordinate.h b/OSGFramework/include/VecCoordinate.h index a2360b7..56d7052 100644 --- a/OSGFramework/include/VecCoordinate.h +++ b/OSGFramework/include/VecCoordinate.h @@ -1,224 +1,224 @@ -/** -* @file VecCoordinate.h -* @brief 通用的坐标转换:任意两种坐标之间的转换 -* @date 2014-5-26 -* @author: liyonggang -*/ -#ifndef PAI_FRAME_CVECCOORDINATE_H -#define PAI_FRAME_CVECCOORDINATE_H -#pragma warning( push ,0) -#include - -// #include -// #include -// #include - -#include "OSGFramework.h" -// #include "VecGeoToGeoNormalCoordinate.h" -// #include "VecWindowDocument.h" -// #include "2DWindowViewInfo.h" - -#pragma warning( pop ) -BEGIN_OSGGRAPHICS_NAMESPACE -class CVecSceneManager; -END_OSGGRAPHICS_NAMESPACE; - -BEGIN_OSGGRAPHICS_NAMESPACE; - -enum eCoordType -{ - //原始的用户业务坐标 - eCoord_GEO,//深度,工程值 - - //归一化的用户业务坐标:统一用户业务坐标到OSG的坐标系 - eCoord_GEONormal,//对数变换、倒置坐标轴 - - // OSG 物体局部坐标系. 就是平常渲染时给OSG::Geometry的顶点坐标 - eCoord_OSGLocal, //道内横向刻度 - - // OSG 全局模型坐标系,( transform by CVecSceneManager Global Model transform) - eCoord_OSGGlobal,//窗口中坐标 - - //相机坐标系,眼睛坐标系( 视图矩阵变化后) - eCoord_OSGCameraEye, - - // 投影矩阵变化后的归一化三维坐标(x,y,z的范围都是(-1,1) ) - eCoord_OSGNormal, - - // OSG的视口二维像素坐标( Y轴正方向是由下到上 ) - eCoord_OSGPixel, - - // QT Widget的窗口二维像素坐标( Y轴正方向是由上到下 ) - eCoord_GDIPixel, - - // 厘米单位坐标( Y轴正方向是由上到下 ) - eCoord_GDICM, -}; - -// /** -// * @class IVecCoordinate -// * @brief 通用的坐标转换:任意两种坐标之间的转换 -// */ -// class OSGFRAMEWORK_EXPORT IVecCoordinate -// { -// public: -// IVecCoordinate(); - -// virtual ~IVecCoordinate(); -// /** -// * @brief 把点从一个坐标系统转换另外一个坐标系统 -// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID -// * @param eInCoordType: 输入点的坐标系统 -// * @param inCoord: 输入的顶点 -// * @param eOutCoordType:输出的坐标系统类型 -// * @param outCoord: 输出的顶点 -// */ -// virtual void ConvertCoord( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3f inCoord, -// eCoordType eOutCoordType,osg::Vec3f& outCoord) = 0 ; - -// /** -// * @brief 把点从一个坐标系统转换另外一个坐标系统 -// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID -// * @param eInCoordType: 输入点的坐标系统 -// * @param inCoord: 输入的顶点 -// * @param eOutCoordType:输出的坐标系统类型 -// * @param outCoord: 输出的顶点 -// */ -// virtual void ConvertCoordDouble( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, -// eCoordType eOutCoordType,osg::Vec3d& outCoord ) = 0 ; - -// /** -// * @brief 把"长度"从一个坐标系统转换到另外一个坐标系统 -// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID -// * @param eInCoordType: 输入点的坐标系统 -// * @param inCoord: 输入的长度 -// * @param eOutCoordType:输出的坐标系统类型 -// * @param outCoord: 输出的长度 -// * @param bAbs: 输出的长度是否取绝对值 -// */ -// virtual void ConvertDeltaCoord( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, -// eCoordType eOutCoordType,osg::Vec3d& outCoord ,bool bAbs) = 0; -// }; - -// /** -// * @class IVecCoordinate -// * @brief 通用的坐标转换:任意两种坐标之间的转换 -// */ -// class OSGFRAMEWORK_EXPORT CVecCoordinate : public IVecCoordinate -// { -// public: - -// CVecCoordinate(); -// virtual void InitSceneManager(CVecSceneManager *ppSceneManager); - -// /** -// * @brief 把点从一个坐标系统转换另外一个坐标系统 -// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID -// * @param eInCoordType: 输入点的坐标系统 -// * @param inCoord: 输入的顶点 -// * @param eOutCoordType:输出的坐标系统类型 -// * @param outCoord: 输出的顶点 -// */ -// virtual void ConvertCoord( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3f inCoord, -// eCoordType eOutCoordType,osg::Vec3f& outCoord) ; -// virtual void ConvertCoordDoubleNoGEONormal( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, -// eCoordType eOutCoordType,osg::Vec3d& outCoord ); - -// /** -// * @brief 把点从一个坐标系统转换另外一个坐标系统 -// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID -// * @param eInCoordType: 输入点的坐标系统 -// * @param inCoord: 输入的顶点 -// * @param eOutCoordType:输出的坐标系统类型 -// * @param outCoord: 输出的顶点 -// */ -// virtual void ConvertCoordDouble( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, -// eCoordType eOutCoordType,osg::Vec3d& outCoord ) ; - -// /** -// * @brief 把"长度"从一个坐标系统转换到另外一个坐标系统 -// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID -// * @param eInCoordType: 输入点的坐标系统 -// * @param inCoord: 输入的长度 -// * @param eOutCoordType:输出的坐标系统类型 -// * @param outCoord: 输出的长度 -// * @param bAbs: 输出的长度是否取绝对值 -// */ -// void ConvertDeltaCoord( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, -// eCoordType eOutCoordType,osg::Vec3d& outCoord ,bool bAbs) ; - -// //同ConvertCoordDouble,只处理X坐标 -// virtual double ConvertX( const QUuid &ObjectID,eCoordType eInCoordType, double x, -// eCoordType eOutCoordType ); - -// //同ConvertCoordDouble,只处理Y坐标 -// virtual double ConvertY( const QUuid &ObjectID,eCoordType eInCoordType, double y, -// eCoordType eOutCoordType ); - -// //同ConvertDeltaCoord,只处理X方向长度 -// virtual double ConvertDeltaX( const QUuid &ObjectID,eCoordType eInCoordType, double x, -// eCoordType eOutCoordType,bool bAbs ) ; - -// //同ConvertDeltaCoord,只处理Y方向长度 -// virtual double ConvertDeltaY( const QUuid &ObjectID,eCoordType eInCoordType, double y, -// eCoordType eOutCoordType,bool bAbs) ; - -// /** -// * @brief 每厘米像素数 -// */ -// void SetPixelPerCm(QPrinter *pDC); -// void SetPixelPerCm(QPainter *pDC); -// void SetPixelPerCm(double PixelPerCm); -// double GetPixelPerCm(); -// /** -// * @brief 像素转为厘米 -// */ -// double PixelToCM( double fPixel ); -// /** -// * @breif 返回对于指定的坐标系而言每个像素对应的高度 -// * @param objectID 对象ID,通常为空 -// * @param eOutCoordType 结果坐标系的类型 -// */ -// double HeightPerPixel(const QUuid& objectID,eCoordType eOutCoordType); - -// /** -// * @breif 返回对于指定的坐标系而言每个像素对应的高度 -// * @param objectID 对象ID,通常为空 -// * @param eOutCoordType 结果坐标系的类型 -// */ -// double WidthPerPixel(const QUuid& objectID,eCoordType eOutCoordType); - -// virtual osg::Vec3d TransfromGeo_GeoNormal(const QUuid &ObjectID, osg::Vec3d in, bool bPositive); -// bool IsXYSwap( eCoordType eInCoordType,eCoordType eOutCoordType ); - -// private: -// typedef osg::Vec3d (*TransfromCoordinateFunc)(CVecCoordinate *pCoordinate, const QUuid &ObjectID,osg::Vec3d in, bool bPositive); - -// //坐标系统之间相互转换的函数。每个函数只负责相邻的两个坐标系之间的转换 -// static osg::Vec3d TransfromGeo_GeoNormal(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); -// static osg::Vec3d TransfromGeoNormal_OSGLocal(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); -// static osg::Vec3d TransfromOSGLocal_Global(CVecCoordinate *pCoordinate, const QUuid &ObjectID,osg::Vec3d in, bool bPositive); -// static osg::Vec3d TransfromOSGGlobal_EyePosition(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); -// static osg::Vec3d TransfromEye_NormalizedPosition(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); -// static osg::Vec3d TransfromOSGNormalizedPosition_Pixel(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); -// static osg::Vec3d TransfromOSGPixel_GDIPixel(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); -// static osg::Vec3d TransfromGDIPixel_GDICM(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); - -// protected: -// C2DWindowViewInfo *m_pWindowViewInfo; -// bool m_bInitWindowViewInfo; - -// protected: -// std::vector< TransfromCoordinateFunc > m_vTransfromCoordinateFunc;// 坐标转换的函数指针数组 -// public: -// CVecSceneManager *m_pSceneManager; -// CVecGeoToGeoNormalCoordinate m_GeoToGeoNormalCoordinate; -// double dPixelPerCm; -// osg::Matrixd m_WindowMatrix; -// osg::Matrixd m_ProjectMatrix; -// osg::Matrixd m_ViewMatrix; -// }; - -END_OSGGRAPHICS_NAMESPACE; -using namespace pai::graphics; -#endif +/** +* @file VecCoordinate.h +* @brief 通用的坐标转换:任意两种坐标之间的转换 +* @date 2014-5-26 +* @author: liyonggang +*/ +#ifndef PAI_FRAME_CVECCOORDINATE_H +#define PAI_FRAME_CVECCOORDINATE_H +#pragma warning( push ,0) +#include + +// #include +// #include +// #include + +#include "OSGFramework.h" +// #include "VecGeoToGeoNormalCoordinate.h" +// #include "VecWindowDocument.h" +// #include "2DWindowViewInfo.h" + +#pragma warning( pop ) +BEGIN_OSGGRAPHICS_NAMESPACE +class CVecSceneManager; +END_OSGGRAPHICS_NAMESPACE; + +BEGIN_OSGGRAPHICS_NAMESPACE; + +enum eCoordType +{ + //原始的用户业务坐标 + eCoord_GEO,//深度,工程值 + + //归一化的用户业务坐标:统一用户业务坐标到OSG的坐标系 + eCoord_GEONormal,//对数变换、倒置坐标轴 + + // OSG 物体局部坐标系. 就是平常渲染时给OSG::Geometry的顶点坐标 + eCoord_OSGLocal, //道内横向刻度 + + // OSG 全局模型坐标系,( transform by CVecSceneManager Global Model transform) + eCoord_OSGGlobal,//窗口中坐标 + + //相机坐标系,眼睛坐标系( 视图矩阵变化后) + eCoord_OSGCameraEye, + + // 投影矩阵变化后的归一化三维坐标(x,y,z的范围都是(-1,1) ) + eCoord_OSGNormal, + + // OSG的视口二维像素坐标( Y轴正方向是由下到上 ) + eCoord_OSGPixel, + + // QT Widget的窗口二维像素坐标( Y轴正方向是由上到下 ) + eCoord_GDIPixel, + + // 厘米单位坐标( Y轴正方向是由上到下 ) + eCoord_GDICM, +}; + +// /** +// * @class IVecCoordinate +// * @brief 通用的坐标转换:任意两种坐标之间的转换 +// */ +// class OSGFRAMEWORK_EXPORT IVecCoordinate +// { +// public: +// IVecCoordinate(); + +// virtual ~IVecCoordinate(); +// /** +// * @brief 把点从一个坐标系统转换另外一个坐标系统 +// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID +// * @param eInCoordType: 输入点的坐标系统 +// * @param inCoord: 输入的顶点 +// * @param eOutCoordType:输出的坐标系统类型 +// * @param outCoord: 输出的顶点 +// */ +// virtual void ConvertCoord( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3f inCoord, +// eCoordType eOutCoordType,osg::Vec3f& outCoord) = 0 ; + +// /** +// * @brief 把点从一个坐标系统转换另外一个坐标系统 +// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID +// * @param eInCoordType: 输入点的坐标系统 +// * @param inCoord: 输入的顶点 +// * @param eOutCoordType:输出的坐标系统类型 +// * @param outCoord: 输出的顶点 +// */ +// virtual void ConvertCoordDouble( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, +// eCoordType eOutCoordType,osg::Vec3d& outCoord ) = 0 ; + +// /** +// * @brief 把"长度"从一个坐标系统转换到另外一个坐标系统 +// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID +// * @param eInCoordType: 输入点的坐标系统 +// * @param inCoord: 输入的长度 +// * @param eOutCoordType:输出的坐标系统类型 +// * @param outCoord: 输出的长度 +// * @param bAbs: 输出的长度是否取绝对值 +// */ +// virtual void ConvertDeltaCoord( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, +// eCoordType eOutCoordType,osg::Vec3d& outCoord ,bool bAbs) = 0; +// }; + +// /** +// * @class IVecCoordinate +// * @brief 通用的坐标转换:任意两种坐标之间的转换 +// */ +// class OSGFRAMEWORK_EXPORT CVecCoordinate : public IVecCoordinate +// { +// public: + +// CVecCoordinate(); +// virtual void InitSceneManager(CVecSceneManager *ppSceneManager); + +// /** +// * @brief 把点从一个坐标系统转换另外一个坐标系统 +// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID +// * @param eInCoordType: 输入点的坐标系统 +// * @param inCoord: 输入的顶点 +// * @param eOutCoordType:输出的坐标系统类型 +// * @param outCoord: 输出的顶点 +// */ +// virtual void ConvertCoord( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3f inCoord, +// eCoordType eOutCoordType,osg::Vec3f& outCoord) ; +// virtual void ConvertCoordDoubleNoGEONormal( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, +// eCoordType eOutCoordType,osg::Vec3d& outCoord ); + +// /** +// * @brief 把点从一个坐标系统转换另外一个坐标系统 +// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID +// * @param eInCoordType: 输入点的坐标系统 +// * @param inCoord: 输入的顶点 +// * @param eOutCoordType:输出的坐标系统类型 +// * @param outCoord: 输出的顶点 +// */ +// virtual void ConvertCoordDouble( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, +// eCoordType eOutCoordType,osg::Vec3d& outCoord ) ; + +// /** +// * @brief 把"长度"从一个坐标系统转换到另外一个坐标系统 +// * @param ObjectID : Object ID,特别是在转为Well Section Geo坐标时有正确的Objecct ID +// * @param eInCoordType: 输入点的坐标系统 +// * @param inCoord: 输入的长度 +// * @param eOutCoordType:输出的坐标系统类型 +// * @param outCoord: 输出的长度 +// * @param bAbs: 输出的长度是否取绝对值 +// */ +// void ConvertDeltaCoord( const QUuid &ObjectID,eCoordType eInCoordType, osg::Vec3d inCoord, +// eCoordType eOutCoordType,osg::Vec3d& outCoord ,bool bAbs) ; + +// //同ConvertCoordDouble,只处理X坐标 +// virtual double ConvertX( const QUuid &ObjectID,eCoordType eInCoordType, double x, +// eCoordType eOutCoordType ); + +// //同ConvertCoordDouble,只处理Y坐标 +// virtual double ConvertY( const QUuid &ObjectID,eCoordType eInCoordType, double y, +// eCoordType eOutCoordType ); + +// //同ConvertDeltaCoord,只处理X方向长度 +// virtual double ConvertDeltaX( const QUuid &ObjectID,eCoordType eInCoordType, double x, +// eCoordType eOutCoordType,bool bAbs ) ; + +// //同ConvertDeltaCoord,只处理Y方向长度 +// virtual double ConvertDeltaY( const QUuid &ObjectID,eCoordType eInCoordType, double y, +// eCoordType eOutCoordType,bool bAbs) ; + +// /** +// * @brief 每厘米像素数 +// */ +// void SetPixelPerCm(QPrinter *pDC); +// void SetPixelPerCm(QPainter *pDC); +// void SetPixelPerCm(double PixelPerCm); +// double GetPixelPerCm(); +// /** +// * @brief 像素转为厘米 +// */ +// double PixelToCM( double fPixel ); +// /** +// * @breif 返回对于指定的坐标系而言每个像素对应的高度 +// * @param objectID 对象ID,通常为空 +// * @param eOutCoordType 结果坐标系的类型 +// */ +// double HeightPerPixel(const QUuid& objectID,eCoordType eOutCoordType); + +// /** +// * @breif 返回对于指定的坐标系而言每个像素对应的高度 +// * @param objectID 对象ID,通常为空 +// * @param eOutCoordType 结果坐标系的类型 +// */ +// double WidthPerPixel(const QUuid& objectID,eCoordType eOutCoordType); + +// virtual osg::Vec3d TransfromGeo_GeoNormal(const QUuid &ObjectID, osg::Vec3d in, bool bPositive); +// bool IsXYSwap( eCoordType eInCoordType,eCoordType eOutCoordType ); + +// private: +// typedef osg::Vec3d (*TransfromCoordinateFunc)(CVecCoordinate *pCoordinate, const QUuid &ObjectID,osg::Vec3d in, bool bPositive); + +// //坐标系统之间相互转换的函数。每个函数只负责相邻的两个坐标系之间的转换 +// static osg::Vec3d TransfromGeo_GeoNormal(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); +// static osg::Vec3d TransfromGeoNormal_OSGLocal(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); +// static osg::Vec3d TransfromOSGLocal_Global(CVecCoordinate *pCoordinate, const QUuid &ObjectID,osg::Vec3d in, bool bPositive); +// static osg::Vec3d TransfromOSGGlobal_EyePosition(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); +// static osg::Vec3d TransfromEye_NormalizedPosition(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); +// static osg::Vec3d TransfromOSGNormalizedPosition_Pixel(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); +// static osg::Vec3d TransfromOSGPixel_GDIPixel(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); +// static osg::Vec3d TransfromGDIPixel_GDICM(CVecCoordinate *pCoordinate,const QUuid &ObjectID, osg::Vec3d in, bool bPositive); + +// protected: +// C2DWindowViewInfo *m_pWindowViewInfo; +// bool m_bInitWindowViewInfo; + +// protected: +// std::vector< TransfromCoordinateFunc > m_vTransfromCoordinateFunc;// 坐标转换的函数指针数组 +// public: +// CVecSceneManager *m_pSceneManager; +// CVecGeoToGeoNormalCoordinate m_GeoToGeoNormalCoordinate; +// double dPixelPerCm; +// osg::Matrixd m_WindowMatrix; +// osg::Matrixd m_ProjectMatrix; +// osg::Matrixd m_ViewMatrix; +// }; + +END_OSGGRAPHICS_NAMESPACE; +using namespace pai::graphics; +#endif diff --git a/OSGFramework/include/VecViewCommand.h b/OSGFramework/include/VecViewCommand.h index 95c0dbc..4adf002 100644 --- a/OSGFramework/include/VecViewCommand.h +++ b/OSGFramework/include/VecViewCommand.h @@ -1,202 +1,202 @@ -/** -* @file VecViewCommand.h -* @brief 窗口工具栏上的Action插件集合管理类 -* @date 2014-5-26 -* @author: liyonggang -*/ -#ifndef PAI_FRAME_OSGVIEWCOMMAND_H -#define PAI_FRAME_OSGVIEWCOMMAND_H -#pragma warning( push ,0) - -#include -#include "OSGFramework.h" -#include "BaseObject.h" - -#pragma warning( pop ) -#pragma warning( disable: 4251 ) - - -BEGIN_OSGGRAPHICS_NAMESPACE; -class CVecSceneManager; - -/** -* @class Action的数据描述 -*/ -struct OSGFRAMEWORK_EXPORT sAction -{ -public: - sAction(); - - sAction( QString strIcon1,std::wstring strText1,bool bChecked1,bool bCheckAble1 ,QUuid DigitizerIDOrBuilderOjectID,QString slotFunctionName1,QKeySequence keyShortcut1 = QKeySequence () ); - -public: - QString strIcon; - std::wstring strText; - bool bChecked; - bool bCheckAble; - QUuid m_DigitizerIDOrBuilderOjectID;//(开关digitizer ID) 或 (显示隐藏UI builder的object ID) - QKeySequence keyShortcut; - QString slotFunctionName; -}; - -/** -* @class 窗口工具栏上的Action插件集合管理类 -*/ -class OSGFRAMEWORK_EXPORT CVecViewCommand : public QObject -{ - Q_OBJECT -public: - - /** - * @brief 初始化 - */ - CVecViewCommand( ); - void InitSceneManager( CVecSceneManager *pSceneManager ); - CVecSceneManager* GetSceneManager(); - - /** - * @brief 执行Action,模拟用户点击此Actioin - * @param viewCommandID : command ID - * @bChecked : 如果是Checkable的Action,是否Checked - */ - bool DoAction( QUuid viewCommandID,bool bChecked ); - - /** - * @brief 根据Command ID查找QAction - */ - QAction* GetAction( QUuid viewCommandID,bool bCreateIfNotExist = true ); - - /** - * @brief Action 是否checked and Enabled - */ - bool GetActionVisble( QUuid viewCommandID ); - - //返回当前视口安装的所有的Action - QMap& GetAllActions(); - - /** - * @brief 创建QAction - */ - static void BuildActionGeneral( CVecViewCommand &viewCommand,QUuid viewCommandID ); - - - /** - * @brief 根据view commandID查找Digitizer ID - */ - static QUuid GetDigitizerIDByViewCommandID( QUuid viewCommandID ); - // Action槽函数 -private slots: - void slotActionClicked(bool bChecked); - -private: - - //批量的根据插件注册的元数据创建QAction - void CreatActions( QList listviewCommandID ); - - // Cache Action - void AddUIElementToMap( QUuid viewCommandID,QObject *pAction ); - - // 根据插件注册的元数据创建QAction - QAction* _CreateAction( QUuid viewCommandID ); - -private: - CVecSceneManager *m_pSceneMgr; - QMapm_mapUIElement; //cache Action -}; - -typedef void (*BUILDUIELEMENT_FUNC )(CVecViewCommand &,QUuid); -typedef void (*UIELEMENTACTION_FUNC )(CVecViewCommand &,QUuid,bool); - -/** -* @class 创建Action函数指针,Action"槽"函数指针 -*/ -struct OSGFRAMEWORK_EXPORT sUIELEMENTFunction -{ -public: - sUIELEMENTFunction() - { - buildFunc = NULL; - ActionSlot = NULL; - } - sUIELEMENTFunction( BUILDUIELEMENT_FUNC buildFunc1,UIELEMENTACTION_FUNC ActionSlot1 ) - { - buildFunc = buildFunc1; - ActionSlot = ActionSlot1; - } - BUILDUIELEMENT_FUNC buildFunc; - UIELEMENTACTION_FUNC ActionSlot; -}; - -/** -* @brief ViewComand的创建和槽的函数指针 -*/ -OSGFRAMEWORK_EXPORT QMap< QUuid/*Action ID*/,sUIELEMENTFunction >& GetmapUIElementFunc(); - -/** -* @brief 注册View Command -* @param viewCommandID :Command ID -* @param s : Command 的元数据描述(文本,图标等) -* @param pSlotAction: Command对应的"槽"函数 -*/ -OSGFRAMEWORK_EXPORT void RegisterViewAction( QUuid viewCommandID,sAction s,UIELEMENTACTION_FUNC pSlotAction); - -/** -* @brief ViewComand的元数据:图标,文本等 -*/ -OSGFRAMEWORK_EXPORT QMap& _GetMapActionData(); - -OSGFRAMEWORK_EXPORT CVecViewCommand& GetGlobalCommand(); - -/** -* @class View Command注册的元数据 -*/ -struct OSGFRAMEWORK_EXPORT sRegisterViewAction -{ - QUuid actionID; - sAction s; - UIELEMENTACTION_FUNC pSlotAction; -}; - -/** -* @class 实现View Command自动注册的辅助类 -*/ -class OSGFRAMEWORK_EXPORT CRegisterViewActionAuto -{ -public: - CRegisterViewActionAuto( sRegisterViewAction *pRegisterViewAction ) - { - while( pRegisterViewAction ) - { - if( (*pRegisterViewAction).actionID.isNull() ) break; - - RegisterViewAction( pRegisterViewAction->actionID, pRegisterViewAction->s, pRegisterViewAction->pSlotAction ); - ++pRegisterViewAction; - } - } -}; - -//view Comand 插件注册宏 -#define BEGIN_REGISTER_VIEWCOMMAND()\ - sRegisterViewAction g_sRegisterViewActionData[]={\ - - -#define END_REGISTER_VIEWCOMMAND()\ - ,{QUuid(),sAction(),NULL } };\ - CRegisterViewActionAuto g_CRegisterViewActionAuto( g_sRegisterViewActionData ); - -//自动注册示例代码 -//BEGIN_REGISTER_VIEWCOMMAND() -//VIEW_COMMAND_ITEM( GetViewCmdID_ViewAll(),"viewall.png" , "View All",false,false,"",_SlotViewAll) -//END_REGISTER_VIEWCOMMAND() -#define VIEW_COMMAND_ITEM( viewCommandID,actionIcon,actionText, actionbChecked, actionbCheckAble,DigitizerIDOrBuilderOjectID,slotFunction )\ -{ viewCommandID,sAction( actionIcon,actionText,actionbChecked,actionbCheckAble,DigitizerIDOrBuilderOjectID,#slotFunction),slotFunction } - -#define VIEW_COMMAND_ITEM_SHORCUT( viewCommandID,actionIcon,actionText, actionbChecked, actionbCheckAble,DigitizerIDOrBuilderOjectID,slotFunction,actionshortcut )\ -{ viewCommandID,sAction( actionIcon,actionText,actionbChecked,actionbCheckAble,DigitizerIDOrBuilderOjectID,#slotFunction,actionshortcut),slotFunction } - - -END_OSGGRAPHICS_NAMESPACE; - -using namespace pai::graphics; - -#endif +/** +* @file VecViewCommand.h +* @brief 窗口工具栏上的Action插件集合管理类 +* @date 2014-5-26 +* @author: liyonggang +*/ +#ifndef PAI_FRAME_OSGVIEWCOMMAND_H +#define PAI_FRAME_OSGVIEWCOMMAND_H +#pragma warning( push ,0) + +#include +#include "OSGFramework.h" +#include "BaseObject.h" + +#pragma warning( pop ) +#pragma warning( disable: 4251 ) + + +BEGIN_OSGGRAPHICS_NAMESPACE; +class CVecSceneManager; + +/** +* @class Action的数据描述 +*/ +struct OSGFRAMEWORK_EXPORT sAction +{ +public: + sAction(); + + sAction( QString strIcon1,std::wstring strText1,bool bChecked1,bool bCheckAble1 ,QUuid DigitizerIDOrBuilderOjectID,QString slotFunctionName1,QKeySequence keyShortcut1 = QKeySequence () ); + +public: + QString strIcon; + std::wstring strText; + bool bChecked; + bool bCheckAble; + QUuid m_DigitizerIDOrBuilderOjectID;//(开关digitizer ID) 或 (显示隐藏UI builder的object ID) + QKeySequence keyShortcut; + QString slotFunctionName; +}; + +/** +* @class 窗口工具栏上的Action插件集合管理类 +*/ +class OSGFRAMEWORK_EXPORT CVecViewCommand : public QObject +{ + Q_OBJECT +public: + + /** + * @brief 初始化 + */ + CVecViewCommand( ); + void InitSceneManager( CVecSceneManager *pSceneManager ); + CVecSceneManager* GetSceneManager(); + + /** + * @brief 执行Action,模拟用户点击此Actioin + * @param viewCommandID : command ID + * @bChecked : 如果是Checkable的Action,是否Checked + */ + bool DoAction( QUuid viewCommandID,bool bChecked ); + + /** + * @brief 根据Command ID查找QAction + */ + QAction* GetAction( QUuid viewCommandID,bool bCreateIfNotExist = true ); + + /** + * @brief Action 是否checked and Enabled + */ + bool GetActionVisble( QUuid viewCommandID ); + + //返回当前视口安装的所有的Action + QMap& GetAllActions(); + + /** + * @brief 创建QAction + */ + static void BuildActionGeneral( CVecViewCommand &viewCommand,QUuid viewCommandID ); + + + /** + * @brief 根据view commandID查找Digitizer ID + */ + static QUuid GetDigitizerIDByViewCommandID( QUuid viewCommandID ); + // Action槽函数 +private slots: + void slotActionClicked(bool bChecked); + +private: + + //批量的根据插件注册的元数据创建QAction + void CreatActions( QList listviewCommandID ); + + // Cache Action + void AddUIElementToMap( QUuid viewCommandID,QObject *pAction ); + + // 根据插件注册的元数据创建QAction + QAction* _CreateAction( QUuid viewCommandID ); + +private: + CVecSceneManager *m_pSceneMgr; + QMapm_mapUIElement; //cache Action +}; + +typedef void (*BUILDUIELEMENT_FUNC )(CVecViewCommand &,QUuid); +typedef void (*UIELEMENTACTION_FUNC )(CVecViewCommand &,QUuid,bool); + +/** +* @class 创建Action函数指针,Action"槽"函数指针 +*/ +struct OSGFRAMEWORK_EXPORT sUIELEMENTFunction +{ +public: + sUIELEMENTFunction() + { + buildFunc = NULL; + ActionSlot = NULL; + } + sUIELEMENTFunction( BUILDUIELEMENT_FUNC buildFunc1,UIELEMENTACTION_FUNC ActionSlot1 ) + { + buildFunc = buildFunc1; + ActionSlot = ActionSlot1; + } + BUILDUIELEMENT_FUNC buildFunc; + UIELEMENTACTION_FUNC ActionSlot; +}; + +/** +* @brief ViewComand的创建和槽的函数指针 +*/ +OSGFRAMEWORK_EXPORT QMap< QUuid/*Action ID*/,sUIELEMENTFunction >& GetmapUIElementFunc(); + +/** +* @brief 注册View Command +* @param viewCommandID :Command ID +* @param s : Command 的元数据描述(文本,图标等) +* @param pSlotAction: Command对应的"槽"函数 +*/ +OSGFRAMEWORK_EXPORT void RegisterViewAction( QUuid viewCommandID,sAction s,UIELEMENTACTION_FUNC pSlotAction); + +/** +* @brief ViewComand的元数据:图标,文本等 +*/ +OSGFRAMEWORK_EXPORT QMap& _GetMapActionData(); + +OSGFRAMEWORK_EXPORT CVecViewCommand& GetGlobalCommand(); + +/** +* @class View Command注册的元数据 +*/ +struct OSGFRAMEWORK_EXPORT sRegisterViewAction +{ + QUuid actionID; + sAction s; + UIELEMENTACTION_FUNC pSlotAction; +}; + +/** +* @class 实现View Command自动注册的辅助类 +*/ +class OSGFRAMEWORK_EXPORT CRegisterViewActionAuto +{ +public: + CRegisterViewActionAuto( sRegisterViewAction *pRegisterViewAction ) + { + while( pRegisterViewAction ) + { + if( (*pRegisterViewAction).actionID.isNull() ) break; + + RegisterViewAction( pRegisterViewAction->actionID, pRegisterViewAction->s, pRegisterViewAction->pSlotAction ); + ++pRegisterViewAction; + } + } +}; + +//view Comand 插件注册宏 +#define BEGIN_REGISTER_VIEWCOMMAND()\ + sRegisterViewAction g_sRegisterViewActionData[]={\ + + +#define END_REGISTER_VIEWCOMMAND()\ + ,{QUuid(),sAction(),NULL } };\ + CRegisterViewActionAuto g_CRegisterViewActionAuto( g_sRegisterViewActionData ); + +//自动注册示例代码 +//BEGIN_REGISTER_VIEWCOMMAND() +//VIEW_COMMAND_ITEM( GetViewCmdID_ViewAll(),"viewall.png" , "View All",false,false,"",_SlotViewAll) +//END_REGISTER_VIEWCOMMAND() +#define VIEW_COMMAND_ITEM( viewCommandID,actionIcon,actionText, actionbChecked, actionbCheckAble,DigitizerIDOrBuilderOjectID,slotFunction )\ +{ viewCommandID,sAction( actionIcon,actionText,actionbChecked,actionbCheckAble,DigitizerIDOrBuilderOjectID,#slotFunction),slotFunction } + +#define VIEW_COMMAND_ITEM_SHORCUT( viewCommandID,actionIcon,actionText, actionbChecked, actionbCheckAble,DigitizerIDOrBuilderOjectID,slotFunction,actionshortcut )\ +{ viewCommandID,sAction( actionIcon,actionText,actionbChecked,actionbCheckAble,DigitizerIDOrBuilderOjectID,#slotFunction,actionshortcut),slotFunction } + + +END_OSGGRAPHICS_NAMESPACE; + +using namespace pai::graphics; + +#endif diff --git a/OSGFramework/src/OSGFramework.pro b/OSGFramework/src/OSGFramework.pro index fc73667..23bd3a0 100644 --- a/OSGFramework/src/OSGFramework.pro +++ b/OSGFramework/src/OSGFramework.pro @@ -1,80 +1,82 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2024-07-11T18:44:51 -# -#------------------------------------------------- - -QT += core gui widgets - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = OSGFramework -TEMPLATE = lib - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += OSGFRAMEWORK_LIB -DEFINES += _WINDOWS -DEFINES += _TIMESPEC_DEFINED - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += console \ - # static \ - c++11 \ - shared\ - dll - - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target - -CONFIG(debug, debug|release){ - DESTDIR = $$PWD/../../Bin - TARGET = $$join(TARGET,,,d) #为debug版本生成的文件增加d的后缀 -} else { - DESTDIR = $$PWD/../../BinR - TARGET = $$join(TARGET,,,) -} - - -FORMS += - -HEADERS += \ - ../include/VecViewCommand.h \ - -SOURCES += \ - VecViewCommand.cpp - -INCLUDEPATH += ../include -INCLUDEPATH += ../CallManage -INCLUDEPATH += ../../Slfio/include -INCLUDEPATH += ../../common -INCLUDEPATH += ../../BaseFun/include -INCLUDEPATH += ../../OSGDataModel/include -INCLUDEPATH += ../../DataMgr/include -INCLUDEPATH += ../../Workflow/include \ - ../../Workflow/WFEngine/IOService/include \ - ../../Workflow/WFEngine/Module/include \ - ../../Workflow/WFCrystal/SysUtility/utils/include \ - ../../Workflow/WFEngine/ObjectModel/ObjectModel/include \ - ../../Workflow/WFEngine/ObjectModel/ObjectModelBase/include - -CONFIG(debug, debug|release){ - LIBS += -L$$PWD/../../Bin -lslfiod - LIBS += -L$$PWD/../../Bin -lBaseFund - LIBS += -L$$PWD/../../Bin -lOSGDataModeld - LIBS += -L$$PWD/../../Bin -lDataMgrd -} else { - LIBS += -L$$PWD/../../BinR -lslfio - LIBS += -L$$PWD/../../BinR -lBaseFun - LIBS += -L$$PWD/../../BinR -lOSGDataModel - LIBS += -L$$PWD/../../BinR -lDataMgr -} +#------------------------------------------------- +# +# Project created by QtCreator 2024-07-11T18:44:51 +# +#------------------------------------------------- + +QT += core gui widgets + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = OSGFramework +TEMPLATE = lib + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += OSGFRAMEWORK_LIB +DEFINES += _WINDOWS +DEFINES += _TIMESPEC_DEFINED + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += console \ + # static \ + c++11 \ + shared\ + dll + + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +CONFIG(debug, debug|release){ + DESTDIR = $$PWD/../../Bin + TARGET = $$join(TARGET,,,d) #为debug版本生成的文件增加d的后缀 +} else { + DESTDIR = $$PWD/../../BinR + TARGET = $$join(TARGET,,,) +} + + +FORMS += + +HEADERS += \ + ../include/VecViewCommand.h \ + +SOURCES += \ + VecViewCommand.cpp + +INCLUDEPATH += ../include +INCLUDEPATH += ../CallManage +INCLUDEPATH += ../../Slfio/include +INCLUDEPATH += ../../common +INCLUDEPATH += ../../BaseFun/include +INCLUDEPATH += ../../OSGDataModel/include +INCLUDEPATH += ../../DataMgr/include +win32 { + INCLUDEPATH += ../../Workflow/include +} +INCLUDEPATH += ../../Workflow/WFEngine/IOService/include \ + ../../Workflow/WFEngine/Module/include \ + ../../Workflow/WFCrystal/SysUtility/utils/include \ + ../../Workflow/WFEngine/ObjectModel/ObjectModel/include \ + ../../Workflow/WFEngine/ObjectModel/ObjectModelBase/include + +CONFIG(debug, debug|release){ + LIBS += -L$$PWD/../../Bin -lslfiod + LIBS += -L$$PWD/../../Bin -lBaseFund + LIBS += -L$$PWD/../../Bin -lOSGDataModeld + LIBS += -L$$PWD/../../Bin -lDataMgrd +} else { + LIBS += -L$$PWD/../../BinR -lslfio + LIBS += -L$$PWD/../../BinR -lBaseFun + LIBS += -L$$PWD/../../BinR -lOSGDataModel + LIBS += -L$$PWD/../../BinR -lDataMgr +} diff --git a/OSGFramework/src/OSGFramework.pro.user b/OSGFramework/src/OSGFramework.pro.user new file mode 100644 index 0000000..c33bdaf --- /dev/null +++ b/OSGFramework/src/OSGFramework.pro.user @@ -0,0 +1,227 @@ + + + + + + EnvironmentId + {b6aced14-228a-4a04-b357-4d18ec1a3aad} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + true + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 0 + 80 + true + true + 1 + 0 + false + true + false + 2 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + false + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 10 + true + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 5.13.0 MSVC2017 64bit + Desktop Qt 5.13.0 MSVC2017 64bit + {b0d37dc0-4759-4799-8369-0bb44b3e17ec} + 1 + 0 + 0 + + 0 + E:\ALogplus\logplus\build\OSGFramework_Qt_5_13_0_msvc2017_64-Debug + E:/ALogplus/logplus/build/OSGFramework_Qt_5_13_0_msvc2017_64-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + E:\ALogplus\logplus\build\OSGFramework_Qt_5_13_0_msvc2017_64-Release + E:/ALogplus/logplus/build/OSGFramework_Qt_5_13_0_msvc2017_64-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + 2 + + + 0 + 部署 + 部署 + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph "dwarf,4096" -F 250 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/OSGFramework/src/VecViewCommand.cpp b/OSGFramework/src/VecViewCommand.cpp index e2149b1..df842af 100644 --- a/OSGFramework/src/VecViewCommand.cpp +++ b/OSGFramework/src/VecViewCommand.cpp @@ -1,362 +1,362 @@ -#pragma warning(push, 0) - -#include - -#include -#include - -#include "VecViewCommand.h" -// #include "VecSceneManager.h" -#include "geometryutils.h" -#include "ObjectID.h" -// #include "PaiAction.h" -#pragma warning(pop) - -BEGIN_OSGGRAPHICS_NAMESPACE; - -sAction::sAction() -{ - bChecked = false; - bCheckAble = false; -} - -sAction::sAction( QString strIcon1,std::wstring strText1,bool bChecked1,bool bCheckAble1 , - QUuid DigitizerIDOrBuilderOjectID,QString slotFunctionName1,QKeySequence keyShortcut1 ) -{ - strIcon = strIcon1; - strText = strText1; - bChecked = bChecked1; - bCheckAble = bCheckAble1; - keyShortcut = keyShortcut1; - m_DigitizerIDOrBuilderOjectID = DigitizerIDOrBuilderOjectID; - slotFunctionName = slotFunctionName1; -} - -QMap *g_pMapAction = NULL; -OSGFRAMEWORK_EXPORT QMap& _GetMapActionData() -{ - if( !g_pMapAction ) - { - g_pMapAction = new QMap(); - } - - return *g_pMapAction ; -} - -QUuid CVecViewCommand::GetDigitizerIDByViewCommandID( QUuid viewCommandID ) -{ - QMap& map = _GetMapActionData(); - if( !map.contains( viewCommandID ) ) - { - return QUuid(); - } - - //得到digitizer ID or Builder object ID - QUuid DigitizerID = map[viewCommandID].m_DigitizerIDOrBuilderOjectID; - if( DigitizerID.isNull( ) ) return DigitizerID; - - // //是否是digitizer ID - // if( !CVecDigitizer::GetFatory().IsSupport( DigitizerID ) ) - // { - // DigitizerID = QUuid(); - // } - return DigitizerID; -} - -bool _SlotDigitizerOrBuilder( CVecViewCommand &viewCommand,QUuid viewCommandID,bool bShow ) -{ - //无viewCommandID - QMap& map = _GetMapActionData(); - if( !map.contains( viewCommandID ) ) - { - return false; - } - - //得到digitizer ID or Builder object ID - QUuid id = map[viewCommandID].m_DigitizerIDOrBuilderOjectID; - if( id.isNull( ) ) return false ; - - bool bSucces(false); - - // //处理digitizer ID - // if( CVecDigitizer::GetFatory().IsSupport( id ) ) - // { - // //特殊处理Well Section window pick ID - // if( id == GetDigitizerID_Pick() ) - // { - // if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() ==GetWindowTypeID_QtWellSection()) id = GetDigitizerID_QtWellWindowPick(); - // else if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() == GetWindowTypeID_QtMultiWellSection()) id = GetDigitizerID_MultiWell(); - // else if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() == GetWindowTypeID_QtGeoGuideSection() ) id = GetDigitizerID_QtWellWindowPick() ; - // } - // bSucces = true; - // if( bShow) - // { - // viewCommand.GetSceneManager()->GetEventHander().SwitchDigitizer( id,QUuid() ); - // }else - // { - // ///此处特殊处理 单井窗口 - // if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() ==GetWindowTypeID_QtWellSection()) viewCommand.DoAction( GetDigitizerID_QtWellWindowPick(),true ); - // else if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() == GetWindowTypeID_QtMultiWellSection()) viewCommand.DoAction( GetDigitizerID_MultiWell(),true ); - // else if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() == GetWindowTypeID_QtGeoGuideSection() ) viewCommand.DoAction( GetDigitizerID_QtWellWindowPick(),true ); - // else - // { - // viewCommand.DoAction( GetDigitizerID_Pick(),true ); - // } - // } - // }else - // { - // //处理Builder Object ID - // CVecNodeBuilder *pBuilder = viewCommand.GetSceneManager()->GetBuilder( id ); - // if( pBuilder ) - // { - // bSucces = true; - // pBuilder->SetEnable( bShow ); - // } - // } - - return bSucces; -} - -void CVecViewCommand::BuildActionGeneral(CVecViewCommand &viewCommand,QUuid viewCommandID) -{ - viewCommand.AddUIElementToMap( viewCommandID,viewCommand._CreateAction(viewCommandID) ); -} - -CVecSceneManager* CVecViewCommand::GetSceneManager() -{ - return m_pSceneMgr; -} - -QMap< QUuid,sUIELEMENTFunction >* g_MapAction = NULL; - -OSGFRAMEWORK_EXPORT QMap< QUuid,sUIELEMENTFunction >& GetmapUIElementFunc() -{ - if( !g_MapAction ) - { - g_MapAction = new QMap< QUuid,sUIELEMENTFunction >(); - } - - return *g_MapAction; -} - -CVecViewCommand::CVecViewCommand() -{ - m_pSceneMgr = NULL; -} - -void CVecViewCommand::slotActionClicked(bool bChecked ) -{ - QAction *pAction = dynamic_cast( this->sender() ); - if( pAction ) - { - DoAction( (QUuid)( pAction->data().toString() ),bChecked ); - } -} - -bool CVecViewCommand::DoAction(QUuid viewCommandID,bool bChecked) -{ - QUuid currentid; - // if(m_pSceneMgr&&m_pSceneMgr->GetCurrentDigitzer()) currentid=m_pSceneMgr->GetCurrentDigitzer()->GetDigitizerID(); - //CWaitCursor waitCursor; - bool bSuccess(true); - - // set action state - QAction* pAction = GetAction( viewCommandID ); - if( pAction ) - { - pAction->setChecked( bChecked ); - } - - //执行槽函数 - UIELEMENTACTION_FUNC pActionSlot = GetmapUIElementFunc().value(viewCommandID).ActionSlot; - if( pActionSlot ) - { - bSuccess = true; - (*pActionSlot)(*this,viewCommandID,bChecked); - }else - { - bSuccess = _SlotDigitizerOrBuilder( *this,viewCommandID,bChecked ); - } - - // 收集Action互斥数据 - QList< QList< QUuid > > listMutexAll; - if( listMutexAll.empty() ) - { - QList listViewPostion; - listViewPostion << GetViewCmdID_ViewAbove() << GetViewCmdID_ViewBelow() << GetViewCmdID_ViewEast() - << GetViewCmdID_ViewWest()<< GetViewCmdID_ViewSouth()<< GetViewCmdID_ViewNorth(); - listMutexAll << listViewPostion; - - // digitizer Action互斥 - QList listDigitizerModel; - { - QMap&mapAction = _GetMapActionData(); - QMap::Iterator it = mapAction.begin(); - for( ; it!= mapAction.end() ; ++it ) - { - // if( CVecDigitizer::GetFatory().IsSupport( it.value().m_DigitizerIDOrBuilderOjectID ) ) - // { - // listDigitizerModel << it.key(); - // } - } - } - listMutexAll << listDigitizerModel; - } - - //执行Action互斥 - if( bChecked ) - { - foreach( QList< QUuid > listMutex,listMutexAll ) - { - if( !listMutex.contains(viewCommandID) ) continue; - - foreach( QUuid eOther,listMutex ) - { - if( eOther != viewCommandID ) - { - QAction *pActionOther = GetAction( eOther ); - if( pActionOther ) - { - pActionOther->setChecked( false ); - } - } - } - break; - } - } - return bSuccess ; -} - -QAction* CVecViewCommand::GetAction( QUuid viewCommandID,bool bCreateIfNotExist ) -{ - //创建Action - if( !m_mapUIElement.contains( viewCommandID ) ) - { - QList< QUuid > listTypes; - listTypes << viewCommandID; - if( bCreateIfNotExist ) - { - CreatActions( listTypes ); - } - } - if(m_mapUIElement.contains( viewCommandID ) ) - { - return dynamic_cast( m_mapUIElement.value( viewCommandID ) ); - } - return NULL; -} - -void CVecViewCommand::CreatActions( QList listUIElementType ) -{ - QMap&mapAction = _GetMapActionData(); - foreach( QUuid viewCommandID,listUIElementType ) - { - //已经有了 - if( m_mapUIElement.contains( viewCommandID ) ) - { - continue; - } - - // 如果是有ID,但Digitizer 或Builder都没有实现,那么就不创建此Action - if( mapAction.contains( viewCommandID ) ) - { - QUuid id = mapAction[viewCommandID].m_DigitizerIDOrBuilderOjectID; - // if( !id.isNull() ) - // { - // bool bDigitizerID = CVecDigitizer::GetFatory().IsSupport( id ) ; - // bool bBuilderID = false; - // if( m_pSceneMgr ) - // { - // bBuilderID = m_pSceneMgr->GetBuilder( id ) ? true : false; - // } - // if( (!bDigitizerID) && (!bBuilderID) ) - // { - // continue; - // } - // } - } - - //创建此Action - BUILDUIELEMENT_FUNC pCreateFunction = GetmapUIElementFunc().value( viewCommandID).buildFunc; - if( pCreateFunction ) - { - (*pCreateFunction)(*this,viewCommandID); - } - } -} - -QAction* CVecViewCommand::_CreateAction( QUuid viewCommandID ) -{ - QMap&mapAction = _GetMapActionData(); - if( !mapAction.contains(viewCommandID) ) return NULL; - - // 根据插件注册的元数据创建QAction - QAction *pAction( NULL ); - { - sAction &sAction = mapAction[viewCommandID]; - - // pAction = new gui::PaiAction( sAction.strIcon.isEmpty() ? QIcon() : QIcon( ::GetImagePath() + sAction.strIcon ), - // QStringFromWCharArray(sAction.strText.c_str(),-1 ),m_pSceneMgr ? dynamic_cast(m_pSceneMgr->GetVecViwer()) : (QObject*)this ); - - pAction->setData( viewCommandID.toString() ); - pAction->setCheckable( sAction.bCheckAble ); - pAction->setChecked( sAction.bChecked ); - if( !sAction.keyShortcut.isEmpty() ) - { - pAction->setShortcut( sAction.keyShortcut ); - } - - connect( pAction,SIGNAL(triggered ( bool )),SLOT(slotActionClicked(bool)) ); - } - return pAction ; -} - -void CVecViewCommand::AddUIElementToMap( QUuid viewCommandID,QObject *pUI ) -{ - m_mapUIElement[viewCommandID] = pUI; - - //Do action - QAction *pAction = dynamic_cast(pUI ); - if( pAction && pAction->isCheckable() ) - { - DoAction( viewCommandID,pAction->isChecked() ); - } -} - -bool CVecViewCommand::GetActionVisble( QUuid viewCommandID ) -{ - bool bVisble(false); - - QAction *pAction = GetAction( viewCommandID,false ); - if( pAction ) - { - bVisble = pAction->isChecked() && pAction->isEnabled(); - } - - return bVisble ; -} - -void CVecViewCommand::InitSceneManager(CVecSceneManager *pSceneManager) -{ - m_pSceneMgr = pSceneManager; -} - -QMap& CVecViewCommand::GetAllActions() -{ - return m_mapUIElement; -} - -OSGFRAMEWORK_EXPORT void RegisterViewAction( QUuid viewCommandID,sAction s,UIELEMENTACTION_FUNC pSlotAction) -{ - _GetMapActionData()[ viewCommandID ] = s; - GetmapUIElementFunc()[ viewCommandID ] = sUIELEMENTFunction( CVecViewCommand::BuildActionGeneral, - pSlotAction ); -} - -OSGFRAMEWORK_EXPORT CVecViewCommand& GetGlobalCommand() -{ - static CVecViewCommand s; - return s; -} - -END_OSGGRAPHICS_NAMESPACE; +#pragma warning(push, 0) + +#include + +#include +#include + +#include "VecViewCommand.h" +// #include "VecSceneManager.h" +#include "geometryutils.h" +#include "ObjectID.h" +// #include "PaiAction.h" +#pragma warning(pop) + +BEGIN_OSGGRAPHICS_NAMESPACE; + +sAction::sAction() +{ + bChecked = false; + bCheckAble = false; +} + +sAction::sAction( QString strIcon1,std::wstring strText1,bool bChecked1,bool bCheckAble1 , + QUuid DigitizerIDOrBuilderOjectID,QString slotFunctionName1,QKeySequence keyShortcut1 ) +{ + strIcon = strIcon1; + strText = strText1; + bChecked = bChecked1; + bCheckAble = bCheckAble1; + keyShortcut = keyShortcut1; + m_DigitizerIDOrBuilderOjectID = DigitizerIDOrBuilderOjectID; + slotFunctionName = slotFunctionName1; +} + +QMap *g_pMapAction = NULL; +OSGFRAMEWORK_EXPORT QMap& _GetMapActionData() +{ + if( !g_pMapAction ) + { + g_pMapAction = new QMap(); + } + + return *g_pMapAction ; +} + +QUuid CVecViewCommand::GetDigitizerIDByViewCommandID( QUuid viewCommandID ) +{ + QMap& map = _GetMapActionData(); + if( !map.contains( viewCommandID ) ) + { + return QUuid(); + } + + //得到digitizer ID or Builder object ID + QUuid DigitizerID = map[viewCommandID].m_DigitizerIDOrBuilderOjectID; + if( DigitizerID.isNull( ) ) return DigitizerID; + + // //是否是digitizer ID + // if( !CVecDigitizer::GetFatory().IsSupport( DigitizerID ) ) + // { + // DigitizerID = QUuid(); + // } + return DigitizerID; +} + +bool _SlotDigitizerOrBuilder( CVecViewCommand &viewCommand,QUuid viewCommandID,bool bShow ) +{ + //无viewCommandID + QMap& map = _GetMapActionData(); + if( !map.contains( viewCommandID ) ) + { + return false; + } + + //得到digitizer ID or Builder object ID + QUuid id = map[viewCommandID].m_DigitizerIDOrBuilderOjectID; + if( id.isNull( ) ) return false ; + + bool bSucces(false); + + // //处理digitizer ID + // if( CVecDigitizer::GetFatory().IsSupport( id ) ) + // { + // //特殊处理Well Section window pick ID + // if( id == GetDigitizerID_Pick() ) + // { + // if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() ==GetWindowTypeID_QtWellSection()) id = GetDigitizerID_QtWellWindowPick(); + // else if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() == GetWindowTypeID_QtMultiWellSection()) id = GetDigitizerID_MultiWell(); + // else if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() == GetWindowTypeID_QtGeoGuideSection() ) id = GetDigitizerID_QtWellWindowPick() ; + // } + // bSucces = true; + // if( bShow) + // { + // viewCommand.GetSceneManager()->GetEventHander().SwitchDigitizer( id,QUuid() ); + // }else + // { + // ///此处特殊处理 单井窗口 + // if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() ==GetWindowTypeID_QtWellSection()) viewCommand.DoAction( GetDigitizerID_QtWellWindowPick(),true ); + // else if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() == GetWindowTypeID_QtMultiWellSection()) viewCommand.DoAction( GetDigitizerID_MultiWell(),true ); + // else if(viewCommand.GetSceneManager()->GetVecWindow()->GetWindowType() == GetWindowTypeID_QtGeoGuideSection() ) viewCommand.DoAction( GetDigitizerID_QtWellWindowPick(),true ); + // else + // { + // viewCommand.DoAction( GetDigitizerID_Pick(),true ); + // } + // } + // }else + // { + // //处理Builder Object ID + // CVecNodeBuilder *pBuilder = viewCommand.GetSceneManager()->GetBuilder( id ); + // if( pBuilder ) + // { + // bSucces = true; + // pBuilder->SetEnable( bShow ); + // } + // } + + return bSucces; +} + +void CVecViewCommand::BuildActionGeneral(CVecViewCommand &viewCommand,QUuid viewCommandID) +{ + viewCommand.AddUIElementToMap( viewCommandID,viewCommand._CreateAction(viewCommandID) ); +} + +CVecSceneManager* CVecViewCommand::GetSceneManager() +{ + return m_pSceneMgr; +} + +QMap< QUuid,sUIELEMENTFunction >* g_MapAction = NULL; + +OSGFRAMEWORK_EXPORT QMap< QUuid,sUIELEMENTFunction >& GetmapUIElementFunc() +{ + if( !g_MapAction ) + { + g_MapAction = new QMap< QUuid,sUIELEMENTFunction >(); + } + + return *g_MapAction; +} + +CVecViewCommand::CVecViewCommand() +{ + m_pSceneMgr = NULL; +} + +void CVecViewCommand::slotActionClicked(bool bChecked ) +{ + QAction *pAction = dynamic_cast( this->sender() ); + if( pAction ) + { + DoAction( (QUuid)( pAction->data().toString() ),bChecked ); + } +} + +bool CVecViewCommand::DoAction(QUuid viewCommandID,bool bChecked) +{ + QUuid currentid; + // if(m_pSceneMgr&&m_pSceneMgr->GetCurrentDigitzer()) currentid=m_pSceneMgr->GetCurrentDigitzer()->GetDigitizerID(); + //CWaitCursor waitCursor; + bool bSuccess(true); + + // set action state + QAction* pAction = GetAction( viewCommandID ); + if( pAction ) + { + pAction->setChecked( bChecked ); + } + + //执行槽函数 + UIELEMENTACTION_FUNC pActionSlot = GetmapUIElementFunc().value(viewCommandID).ActionSlot; + if( pActionSlot ) + { + bSuccess = true; + (*pActionSlot)(*this,viewCommandID,bChecked); + }else + { + bSuccess = _SlotDigitizerOrBuilder( *this,viewCommandID,bChecked ); + } + + // 收集Action互斥数据 + QList< QList< QUuid > > listMutexAll; + if( listMutexAll.empty() ) + { + QList listViewPostion; + listViewPostion << GetViewCmdID_ViewAbove() << GetViewCmdID_ViewBelow() << GetViewCmdID_ViewEast() + << GetViewCmdID_ViewWest()<< GetViewCmdID_ViewSouth()<< GetViewCmdID_ViewNorth(); + listMutexAll << listViewPostion; + + // digitizer Action互斥 + QList listDigitizerModel; + { + QMap&mapAction = _GetMapActionData(); + QMap::Iterator it = mapAction.begin(); + for( ; it!= mapAction.end() ; ++it ) + { + // if( CVecDigitizer::GetFatory().IsSupport( it.value().m_DigitizerIDOrBuilderOjectID ) ) + // { + // listDigitizerModel << it.key(); + // } + } + } + listMutexAll << listDigitizerModel; + } + + //执行Action互斥 + if( bChecked ) + { + foreach( QList< QUuid > listMutex,listMutexAll ) + { + if( !listMutex.contains(viewCommandID) ) continue; + + foreach( QUuid eOther,listMutex ) + { + if( eOther != viewCommandID ) + { + QAction *pActionOther = GetAction( eOther ); + if( pActionOther ) + { + pActionOther->setChecked( false ); + } + } + } + break; + } + } + return bSuccess ; +} + +QAction* CVecViewCommand::GetAction( QUuid viewCommandID,bool bCreateIfNotExist ) +{ + //创建Action + if( !m_mapUIElement.contains( viewCommandID ) ) + { + QList< QUuid > listTypes; + listTypes << viewCommandID; + if( bCreateIfNotExist ) + { + CreatActions( listTypes ); + } + } + if(m_mapUIElement.contains( viewCommandID ) ) + { + return dynamic_cast( m_mapUIElement.value( viewCommandID ) ); + } + return NULL; +} + +void CVecViewCommand::CreatActions( QList listUIElementType ) +{ + QMap&mapAction = _GetMapActionData(); + foreach( QUuid viewCommandID,listUIElementType ) + { + //已经有了 + if( m_mapUIElement.contains( viewCommandID ) ) + { + continue; + } + + // 如果是有ID,但Digitizer 或Builder都没有实现,那么就不创建此Action + if( mapAction.contains( viewCommandID ) ) + { + QUuid id = mapAction[viewCommandID].m_DigitizerIDOrBuilderOjectID; + // if( !id.isNull() ) + // { + // bool bDigitizerID = CVecDigitizer::GetFatory().IsSupport( id ) ; + // bool bBuilderID = false; + // if( m_pSceneMgr ) + // { + // bBuilderID = m_pSceneMgr->GetBuilder( id ) ? true : false; + // } + // if( (!bDigitizerID) && (!bBuilderID) ) + // { + // continue; + // } + // } + } + + //创建此Action + BUILDUIELEMENT_FUNC pCreateFunction = GetmapUIElementFunc().value( viewCommandID).buildFunc; + if( pCreateFunction ) + { + (*pCreateFunction)(*this,viewCommandID); + } + } +} + +QAction* CVecViewCommand::_CreateAction( QUuid viewCommandID ) +{ + QMap&mapAction = _GetMapActionData(); + if( !mapAction.contains(viewCommandID) ) return NULL; + + // 根据插件注册的元数据创建QAction + QAction *pAction( NULL ); + { + sAction &sAction = mapAction[viewCommandID]; + + // pAction = new gui::PaiAction( sAction.strIcon.isEmpty() ? QIcon() : QIcon( ::GetImagePath() + sAction.strIcon ), + // QStringFromWCharArray(sAction.strText.c_str(),-1 ),m_pSceneMgr ? dynamic_cast(m_pSceneMgr->GetVecViwer()) : (QObject*)this ); + + pAction->setData( viewCommandID.toString() ); + pAction->setCheckable( sAction.bCheckAble ); + pAction->setChecked( sAction.bChecked ); + if( !sAction.keyShortcut.isEmpty() ) + { + pAction->setShortcut( sAction.keyShortcut ); + } + + connect( pAction,SIGNAL(triggered ( bool )),SLOT(slotActionClicked(bool)) ); + } + return pAction ; +} + +void CVecViewCommand::AddUIElementToMap( QUuid viewCommandID,QObject *pUI ) +{ + m_mapUIElement[viewCommandID] = pUI; + + //Do action + QAction *pAction = dynamic_cast(pUI ); + if( pAction && pAction->isCheckable() ) + { + DoAction( viewCommandID,pAction->isChecked() ); + } +} + +bool CVecViewCommand::GetActionVisble( QUuid viewCommandID ) +{ + bool bVisble(false); + + QAction *pAction = GetAction( viewCommandID,false ); + if( pAction ) + { + bVisble = pAction->isChecked() && pAction->isEnabled(); + } + + return bVisble ; +} + +void CVecViewCommand::InitSceneManager(CVecSceneManager *pSceneManager) +{ + m_pSceneMgr = pSceneManager; +} + +QMap& CVecViewCommand::GetAllActions() +{ + return m_mapUIElement; +} + +OSGFRAMEWORK_EXPORT void RegisterViewAction( QUuid viewCommandID,sAction s,UIELEMENTACTION_FUNC pSlotAction) +{ + _GetMapActionData()[ viewCommandID ] = s; + GetmapUIElementFunc()[ viewCommandID ] = sUIELEMENTFunction( CVecViewCommand::BuildActionGeneral, + pSlotAction ); +} + +OSGFRAMEWORK_EXPORT CVecViewCommand& GetGlobalCommand() +{ + static CVecViewCommand s; + return s; +} + +END_OSGGRAPHICS_NAMESPACE;