|
|
|
|
|
#ifndef XJOBJECT_H //预编译,防止头文件被重复引用
|
|
|
#define XJOBJECT_H
|
|
|
|
|
|
#include "OMCommon.h"
|
|
|
#include "OMExport.h"
|
|
|
#include "XJPoint3D.h"
|
|
|
#include <iostream> //标准库头文件
|
|
|
#include <windows.h>
|
|
|
#include <fstream>
|
|
|
#include <iomanip> //引用输入输出流的控制符
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
static int objectBase;
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
#define NAME_LEN 128
|
|
|
|
|
|
class XJ_OM_EXPORT CXJObjectProperty
|
|
|
{
|
|
|
public:
|
|
|
CXJObjectProperty();
|
|
|
CXJObjectProperty(CXJObjectProperty* pobj);
|
|
|
virtual ~CXJObjectProperty();
|
|
|
|
|
|
public:
|
|
|
|
|
|
//************对象属性******************
|
|
|
char m_strName[NAME_LEN]; //对象的名称
|
|
|
|
|
|
/****显示相关属性*****/
|
|
|
bool m_wireframe; //渲染模式(线框)
|
|
|
EDisplayModel m_displayModel; //渲染模式(点、线、面)
|
|
|
COLORREF m_Color; //对象的颜色
|
|
|
COLORREF m_frontColor;
|
|
|
COLORREF m_backColor;
|
|
|
bool m_bVisible; //对象可见性
|
|
|
bool m_bTransparent; //是否透明性
|
|
|
float m_nTransparent; //透明度 0 - 1
|
|
|
bool m_bDepthTest; //深度检测
|
|
|
bool m_useBackFrontColor; //是否使用双面渲染
|
|
|
|
|
|
Point3D m_LocalCoordinate_X; //对象的局部坐标系X轴
|
|
|
Point3D m_LocalCoordinate_Y; //Y轴
|
|
|
Point3D m_LocalCoordinate_Z; //Z轴
|
|
|
|
|
|
Point3D m_ScreenCoordinate_X; //屏幕坐标系X轴
|
|
|
Point3D m_ScreenCoordinate_Y; //屏幕坐标系Y轴
|
|
|
Point3D m_ScreenCoordinate_Z; //屏幕坐标系Z轴
|
|
|
};
|
|
|
|
|
|
//宏定义,CXJObject的每个子类都需要声明此宏
|
|
|
#define MACRO_OBJECT(library, name)\
|
|
|
virtual const char* GetLibraryName() const {return #library;} \
|
|
|
virtual const char* GetClassName() const {return #name;} \
|
|
|
|
|
|
class XJ_OM_EXPORT CXJObject : protected CXJObjectProperty
|
|
|
{
|
|
|
public:
|
|
|
friend class CXJObjectManager;
|
|
|
friend class CXJObjectGroup;
|
|
|
friend class CXJObjectManagerLog;
|
|
|
|
|
|
//*************************对象操作虚函数************************
|
|
|
//对象平移(坐标轴向的距离)
|
|
|
virtual void Translate(double dx, double dy, double dz) {;}
|
|
|
|
|
|
//平移对象位置
|
|
|
virtual void TranslateByDir(Point3D dir, double distance);
|
|
|
|
|
|
//旋转对象
|
|
|
virtual void Rotate(Point3D basePt, Point3D axis, double angle) {;}
|
|
|
|
|
|
//更新对象在视图中的显示模式
|
|
|
//virtual void Update(CXJObject* pobject, EXJObjectUpdateType updateType);
|
|
|
|
|
|
//**************************对象属性管理************************
|
|
|
//获得对象的类型
|
|
|
EXJObjectType GetType() const;
|
|
|
|
|
|
//设置第几个Manager
|
|
|
void SetManagerIndex(int index){m_managerIndex = index;}
|
|
|
//获取第几个Manager
|
|
|
int GetManagerIndex() const{return m_managerIndex;}
|
|
|
|
|
|
//获得对象的OmKey
|
|
|
int GetOmKey() const;
|
|
|
|
|
|
//返回包含同类对象的组类型名称
|
|
|
virtual const char* GetLibraryName() const {return "CXJObject";}
|
|
|
|
|
|
//返回当前对象的类型名称
|
|
|
virtual const char* GetClassName() const {return "CXJObject";}
|
|
|
|
|
|
//获得对象的名字
|
|
|
const char* GetName() const;
|
|
|
//设置对象的名字
|
|
|
void SetName(const char* name);
|
|
|
|
|
|
//获得对象的名字前缀
|
|
|
const char* GetNameInternal() const;
|
|
|
//设置对象的名字前缀
|
|
|
void SetNameInternal(const char* namePrefix);
|
|
|
|
|
|
//获得对象的颜色
|
|
|
COLORREF GetColor() const;
|
|
|
//设置对象颜色
|
|
|
void SetColor(COLORREF color, bool useFrontBackColor = false);
|
|
|
|
|
|
void SetFrontColor(COLORREF color);
|
|
|
COLORREF GetFrontColor() const;
|
|
|
|
|
|
void SetBackColor(COLORREF color);
|
|
|
COLORREF GetBackColor() const;
|
|
|
|
|
|
//获得对象可见性
|
|
|
bool GetVisibility() const;
|
|
|
//设置对象是否可见
|
|
|
virtual void SetVisibility(bool visibile);
|
|
|
|
|
|
//获得对象透明标识
|
|
|
bool GetTransparent() const;
|
|
|
void SetTransparent(bool transparent);
|
|
|
|
|
|
//获得对象透明度等级
|
|
|
float GetTransparentDegree() const;
|
|
|
void SetTransparentDegree(float fTransparent);
|
|
|
|
|
|
//获得对象是否深度检测
|
|
|
bool GetDepthTest() const;
|
|
|
void SetDepthTest(bool val);
|
|
|
|
|
|
bool GetWireframe() const {return m_wireframe;}
|
|
|
void SetWireframe(bool wf) {m_wireframe = wf;}
|
|
|
|
|
|
//获得对象显示模式(点、线、面)
|
|
|
EDisplayModel GetDisplayModel() const {return m_displayModel;}
|
|
|
void SetDisplayModel(EDisplayModel eModel) {m_displayModel = eModel;}
|
|
|
|
|
|
//获取对象是否为零时对象的标识(临时对象就是不能保存和插入模型树的对象,只用于显示)
|
|
|
bool GetIsTempObject() const{return m_isTempObject;}
|
|
|
void SetIsTempObject(bool isTempObject) {m_isTempObject = isTempObject;}
|
|
|
|
|
|
//设置对象是否为Group的引用类型
|
|
|
void SetReference(bool reference){m_reference = reference;}
|
|
|
bool GetReference() const{return m_reference;}
|
|
|
|
|
|
//如果本对象是group内部的对象,设置和获得groupid,groupid默认为-1
|
|
|
void SetGroupID(int groupID){m_groupID = groupID;}
|
|
|
int GetGroupID() const {return m_groupID;}
|
|
|
|
|
|
//**************************对象局部坐标系******************
|
|
|
//获得对象局部坐标系X轴
|
|
|
Point3D GetLocalCoorX() const {return m_LocalCoordinate_X;}
|
|
|
|
|
|
//设置对象局部坐标系X轴
|
|
|
void SetLocalCoorX(Point3D xdir);
|
|
|
|
|
|
//获得对象局部坐标系Y轴
|
|
|
Point3D GetLocalCoorY() const {return m_LocalCoordinate_Y;}
|
|
|
//设置对象局部坐标系Y轴
|
|
|
void SetLocalCoorY(Point3D ydir) ;
|
|
|
|
|
|
//获得对象局部坐标系Z轴
|
|
|
Point3D GetLocalCoorZ() const {return m_LocalCoordinate_Z;}
|
|
|
//设置对象局部坐标系Z轴
|
|
|
void SetLocalCoorZ(Point3D zdir) ;
|
|
|
|
|
|
//获取当前对象是否使用双面渲染
|
|
|
void SetUseFrontBackColor(bool same) {m_useBackFrontColor = same;}
|
|
|
bool GetUseFrontBackColor() const {return m_useBackFrontColor;}
|
|
|
|
|
|
//深拷贝,拷贝对象的属性
|
|
|
CXJObjectProperty* CopyObjectProperty();
|
|
|
void CopyObjectProperty(CXJObjectProperty* pobjProp);
|
|
|
|
|
|
//对象开启裁剪平面操作
|
|
|
void SetClipPlaneFlag(bool clip) {m_bStartClipPlanes = clip;}
|
|
|
bool GetClipPlaneFlag() const {return m_bStartClipPlanes;}
|
|
|
|
|
|
virtual void CopyProperty(const CXJObject* pObj);
|
|
|
public:
|
|
|
//设置对象类型
|
|
|
void SetType(EXJObjectType type) ;
|
|
|
|
|
|
//设置对象的唯一标识符
|
|
|
void SetOmKey(int ID);
|
|
|
|
|
|
protected:
|
|
|
CXJObject(void);
|
|
|
CXJObject(const CXJObject* pobj);
|
|
|
virtual ~CXJObject();
|
|
|
|
|
|
//This method creates a copy of itself
|
|
|
virtual CXJObject* Copy() {return NULL;}
|
|
|
|
|
|
//This method copy all attributes of the object
|
|
|
void CopyGenericObjectProperties(const CXJObject* pobj);
|
|
|
|
|
|
protected:
|
|
|
|
|
|
int m_nOmKey; //对象的唯一标识
|
|
|
EXJObjectType m_ObjectType; //对象的类型
|
|
|
|
|
|
int m_managerIndex; //对应第几个ObjectManger
|
|
|
bool m_reference; //对象是否是Group中的引用对象的标记
|
|
|
char m_strNameInternal[NAME_LEN]; //对象的专有名称仅仅内部识别使用
|
|
|
|
|
|
int m_groupID; //对象的父节点Group的ID号,如果没有Group,则默认为-1
|
|
|
bool m_isTempObject; //临时对象不保存到文件,不插入到树上 默认为false
|
|
|
bool m_bStartClipPlanes; //开启裁剪标志
|
|
|
};
|
|
|
|
|
|
#endif
|