递归火山软件开发平台
标题:
研究了下虚函数子类重写都失败了如何解决
[打印本页]
作者:
沉默流星
时间:
前天 20:33
标题:
研究了下虚函数子类重写都失败了如何解决
在封装时遇到1.子类重写父类虚函数,并且子类当中还调用一个宏用来跟父类绑定
原生代码如下:
(, 下载次数: 8)
上传
点击文件名下载附件
(, 下载次数: 10)
上传
点击文件名下载附件
方式1 使用@接口 (失败)
因:接口实现的是子类调用。但无法让子类实现的这个函数体内写内容
(, 下载次数: 8)
上传
点击文件名下载附件
方式2 通过@视窗后缀文本 整成事件则报错
(, 下载次数: 8)
上传
点击文件名下载附件
要实现这种,应该怎么做。
1.@虚拟方法 可覆盖
如果使用虚拟方法 应该怎么实现
2.@视窗.后缀文本
如果使用这个 如何处理这个报错问题
3.使用变量
如果使用变量实现,应该如何实现
为了方便预览,源代码贴在2楼.
作者:
沉默流星
时间:
前天 20:35
请
// 自定义对象.h
复制代码
//自定义对象.cpp
#include "stdafx.h"
#include "自定义对象.h"
#define VERSION_ZFFDWGSCALE 1
ACRX_DXF_DEFINE_MEMBERS(自定义对象, AcDbObject,
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
AcDbProxyObject::kNoOperation,
ZFFDWGSCALE, ZffCustomObjectDB);
自定义对象::自定义对象()
{
//{{AFX_ARX_DATA_INIT(ZffDwgScale)
//}}AFX_ARX_DATA_INIT
m_infoScale = 0;
m_lableScale = 0;
}
自定义对象::~自定义对象()
{
// TODO: clean up.
}
Acad::ErrorStatus 自定义对象::dwgInFields(AcDbDwgFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es;
// Call dwgInFields from AcDbObject
if ((es = AcDbObject::dwgInFields(pFiler)) != Acad::eOk) {
return es;
}
// Read version number.
Adesk::UInt16 version;
pFiler->readItem(&version);
if (version > VERSION_ZFFDWGSCALE)
return Acad::eMakeMeProxy;
// Read the data members.
switch (version)
{
case (1):
// TODO: here you can file datamembers not
// created by the ObjectARX Add-In.
pFiler->readItem(&m_infoScale);
pFiler->readItem(&m_lableScale);
break;
}
return pFiler->filerStatus();
}
Acad::ErrorStatus 自定义对象::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
// Call dwgOutFields from AcDbObject
if ((es = AcDbObject::dwgOutFields(pFiler)) != Acad::eOk) {
return es;
}
// Write version number.
pFiler->writeItem((Adesk::UInt16)VERSION_ZFFDWGSCALE);
// Write the data members.
// TODO: here you can file datamembers not
// created by the ObjectARX Add-In.
pFiler->writeItem(m_infoScale);
pFiler->writeItem(m_lableScale);
return pFiler->filerStatus();
}
Acad::ErrorStatus 自定义对象::dxfInFields(AcDbDxfFiler* pFiler)
{
assertWriteEnabled();
struct resbuf rb;
if ((AcDbObject::dxfInFields(pFiler) != Acad::eOk) ||
!pFiler->atSubclassData(L"ZffDwgScale"))
return pFiler->filerStatus();
// Read version number.
pFiler->readItem(&rb);
if (rb.restype != AcDb::kDxfInt16) {
pFiler->pushBackItem();
pFiler->setError(Acad::eInvalidDxfCode,
L"nError: expected object version group code %d",
AcDb::kDxfInt16);
return pFiler->filerStatus();
}
else {
Adesk::UInt16 version = rb.resval.rint;
if (version > VERSION_ZFFDWGSCALE)
return Acad::eMakeMeProxy;
}
// 读取条件图比例
pFiler->readItem(&rb);
if (rb.restype != AcDb::kDxfInt32)
{
pFiler->pushBackItem();
pFiler->setError(Acad::eInvalidDxfCode,
L"nError: expected object version group code %d",
AcDb::kDxfInt32);
return pFiler->filerStatus();
}
else
{
m_infoScale = rb.resval.rlong;
}
// 读取出图比例
pFiler->readItem(&rb);
if (rb.restype != AcDb::kDxfInt32)
{
pFiler->pushBackItem();
pFiler->setError(Acad::eInvalidDxfCode,
L"nError: expected object version group code %d",
AcDb::kDxfInt32);
return pFiler->filerStatus();
}
else
{
m_lableScale = rb.resval.rlong;
}
return pFiler->filerStatus();
}
Acad::ErrorStatus 自定义对象::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es = AcDbObject::dxfOutFields(pFiler)) != Acad::eOk)
return es;
// Write subclass marker.
pFiler->writeItem(AcDb::kDxfSubclass, "ZffDwgScale");
// Write version number.
pFiler->writeItem(AcDb::kDxfInt16, (Adesk::UInt16)VERSION_ZFFDWGSCALE);
// 写入两个成员变量
pFiler->writeItem(AcDb::kDxfInt32, m_infoScale);
pFiler->writeItem(AcDb::kDxfInt32, m_lableScale);
return es;
}
void 自定义对象::Set(int infoScale, int lableScale)
{
assertWriteEnabled();
m_infoScale = infoScale;
m_lableScale = lableScale;
}
int 自定义对象::GetInfoScale() const
{
assertReadEnabled();
return m_infoScale;
}
int 自定义对象::GetLabelScale() const
{
AcDbObject* dx;
dx->dxfOutFields(a);
assertReadEnabled();
return m_lableScale;
}
复制代码
作者:
niuyanbo2021
时间:
昨天 07:17
顶贴,望大佬助力,谢谢!
欢迎光临 递归火山软件开发平台 (https://bbs.voldp.com/)
Powered by Discuz! X3.4