⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asdkemployee.cpp

📁 vs2003+arxobject2006相信不用说
💻 CPP
字号:
// (C) Copyright 2002-2005 by Autodesk, Inc. 
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted, 
// provided that the above copyright notice appears in all copies and 
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting 
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to 
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//

//-----------------------------------------------------------------------------
//----- AsdkEmployee.cpp : Implementation of AsdkEmployee
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include <TCHAR.H>

#include "AsdkEmployee.h"

//-----------------------------------------------------------------------------
Adesk::UInt32 AsdkEmployee::kCurrentVersionNumber =7;

//-----------------------------------------------------------------------------
ACRX_DXF_DEFINE_MEMBERS (
	AsdkEmployee, AcDbEllipse,
	AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 
	AcDbProxyEntity::kNoOperation, ASDKEMPLOYEE,
	"ASDKEMPLOYEEAPP"
	"|Product Desc:     A description for your object"
	"|Company:          Your company name"
	"|WEB Address:      Your company WEB site address"
)

//-----------------------------------------------------------------------------
AsdkEmployee::AsdkEmployee() : AcDbEllipse (AcGePoint3d (),
							   AcGeVector3d (0, 0, 1),
							   AcGeVector3d (1, 0, 0), 1) 
{ 
	// TODO: do your initialization. 
	m_firstName = m_lastName = NULL ;
}

AsdkEmployee::~AsdkEmployee () {
	delete [] m_lastName ;
	delete [] m_firstName ;
}

//-----------------------------------------------------------------------------
//----- AcDbObject protocols
//- Dwg Filing protocol
Acad::ErrorStatus AsdkEmployee::dwgOutFields (AcDbDwgFiler *pFiler) const {
	assertReadEnabled () ;
	//----- Save parent class information first.
	Acad::ErrorStatus es =AcDbEllipse::dwgOutFields (pFiler) ;
	if ( es != Acad::eOk )
		return (es) ;
	//----- Object version number needs to be saved first
	if ( (es =pFiler->writeUInt32 (AsdkEmployee::kCurrentVersionNumber)) != Acad::eOk )
		return (es) ;
	//----- Output params
	//.....

	pFiler->writeItem (m_ID) ;
	pFiler->writeItem (m_cube) ;
	pFiler->writeString (m_firstName) ;
	pFiler->writeItem (m_cube) ;
	pFiler->writeString (m_firstName) ;
	pFiler->writeString (m_lastName) ;
	return (pFiler->filerStatus ()) ;
}

Acad::ErrorStatus AsdkEmployee::dwgInFields (AcDbDwgFiler *pFiler) {
	assertWriteEnabled () ;
	//----- Read parent class information first.
	Acad::ErrorStatus es =AcDbEllipse::dwgInFields (pFiler) ;
	if ( es != Acad::eOk )
		return (es) ;
	//----- Object version number needs to be read first
	Adesk::UInt32 version =0 ;
	if ( (es =pFiler->readUInt32 (&version)) != Acad::eOk )
		return (es) ;
	if ( version > AsdkEmployee::kCurrentVersionNumber )
		return (Acad::eMakeMeProxy) ;
	//- Uncomment the 2 following lines if your current object implementation cannot
	//- support previous version of that object.
	//if ( version < AsdkEmployee::kCurrentVersionNumber )
	//	return (Acad::eMakeMeProxy) ;
	//----- Read params
	//.....

	if ( version >= 2 /*&& version <= endVersion*/ ) pFiler->readItem (&m_ID) ;
	if ( version >= 3 /*&& version <= endVersion*/ ) pFiler->readItem (&m_cube) ;
	if ( version >= 4 /*&& version <= endVersion*/ ) {
		delete [] m_firstName ; m_firstName =NULL ;
		pFiler->readString (&m_firstName) ;
	}
	if ( version >= 5 /*&& version <= endVersion*/ ) pFiler->readItem (&m_cube) ;
	if ( version >= 6 /*&& version <= endVersion*/ ) {
		delete [] m_firstName ; m_firstName =NULL ;
		pFiler->readString (&m_firstName) ;
	}
	if ( version >= 7 /*&& version <= endVersion*/ ) {
		delete [] m_lastName ; m_lastName =NULL ;
		pFiler->readString (&m_lastName) ;
	}
	return (pFiler->filerStatus ()) ;
}

//- Dxf Filing protocol
Acad::ErrorStatus AsdkEmployee::dxfOutFields (AcDbDxfFiler *pFiler) const {
	assertReadEnabled () ;
	//----- Save parent class information first.
	Acad::ErrorStatus es =AcDbEllipse::dxfOutFields (pFiler) ;
	if ( es != Acad::eOk )
		return (es) ;
	es =pFiler->writeItem (AcDb::kDxfSubclass, _RXST("AsdkEmployee")) ;
	if ( es != Acad::eOk )
		return (es) ;
	//----- Object version number needs to be saved first
	if ( (es =pFiler->writeUInt32 (kDxfInt32, AsdkEmployee::kCurrentVersionNumber)) != Acad::eOk )
		return (es) ;
	//----- Output params
	//.....

	return (pFiler->filerStatus ()) ;
}

Acad::ErrorStatus AsdkEmployee::dxfInFields (AcDbDxfFiler *pFiler) {
	assertWriteEnabled () ;
	//----- Read parent class information first.
	Acad::ErrorStatus es =AcDbEllipse::dxfInFields (pFiler) ;
	if ( es != Acad::eOk || !pFiler->atSubclassData (_RXST("AsdkEmployee")) )
		return (pFiler->filerStatus ()) ;
	//----- Object version number needs to be read first
	struct resbuf rb ;
	pFiler->readItem (&rb) ;
	if ( rb.restype != AcDb::kDxfInt32 ) {
		pFiler->pushBackItem () ;
		pFiler->setError (Acad::eInvalidDxfCode, _RXST("\nError: expected group code %d (version #)"), AcDb::kDxfInt32) ;
		return (pFiler->filerStatus ()) ;
	}
	Adesk::UInt32 version =(Adesk::UInt32)rb.resval.rlong ;
	if ( version > AsdkEmployee::kCurrentVersionNumber )
		return (Acad::eMakeMeProxy) ;
	//- Uncomment the 2 following lines if your current object implementation cannot
	//- support previous version of that object.
	//if ( version < AsdkEmployee::kCurrentVersionNumber )
	//	return (Acad::eMakeMeProxy) ;
	//----- Read params in non order dependant manner
	while ( es == Acad::eOk && (es =pFiler->readResBuf (&rb)) == Acad::eOk ) {
		switch ( rb.restype ) {
			//----- Read params by looking at their DXF code (example below)
			//case AcDb::kDxfXCoord:
			//	if ( version == 1 )
			//		cen3d =asPnt3d (rb.resval.rpoint) ;
			//	else 
			//		cen2d =asPnt2d (rb.resval.rpoint) ;
			//	break ;
			//.....

			default:
				//----- An unrecognized group. Push it back so that the subclass can read it again.
				pFiler->pushBackItem () ;
				es =Acad::eEndOfFile ;
				break ;
		}
	}
	//----- At this point the es variable must contain eEndOfFile
	//----- - either from readResBuf() or from pushback. If not,
	//----- it indicates that an error happened and we should
	//----- return immediately.
	if ( es != Acad::eEndOfFile )
		return (Acad::eInvalidResBuf) ;

	return (pFiler->filerStatus ()) ;
}

//-----------------------------------------------------------------------------
//----- AcDbEntity protocols
Adesk::Boolean AsdkEmployee::worldDraw (AcGiWorldDraw *mode) {
	assertReadEnabled () ;
	//----- Draw the AcDbEllipse entity
	AcDbEllipse::worldDraw (mode) ;
	//----- Write the Employee ID and Name
	char buffer [255] ;
	sprintf (buffer, "%d (cube#: %d)", m_ID, m_cube) ;
	mode->geometry ().text (center (), normal (), majorAxis (), minorAxis ().length () / 2, 1.0, 0.0, buffer) ;
	sprintf (buffer, "%s %s", m_firstName, m_lastName) ;
	mode->geometry ().text (center () - minorAxis () / 2, normal (), majorAxis (), minorAxis ().length () / 2, 1.0, 0.0, buffer) ;
	//----- Returns Adesk::kTrue to not call viewportDraw()
	return (Adesk::kTrue) ;
}


Acad::ErrorStatus AsdkEmployee::iD(Adesk::Int32& ID)
{
	assertReadEnabled () ;	ID = m_ID ;	return (Acad::eOk) ;}

Acad::ErrorStatus AsdkEmployee::setID(const Adesk::Int32 newVal)
{
	assertWriteEnabled () ;	m_ID = newVal ;	return (Acad::eOk) ;}

Acad::ErrorStatus AsdkEmployee::cube(Adesk::Int32& cube)
{
	assertReadEnabled () ;	cube = m_cube ;	return (Acad::eOk) ;}

Acad::ErrorStatus AsdkEmployee::setCube(const Adesk::Int32 newVal)
{
	assertWriteEnabled () ;	m_cube =newVal ;	return (Acad::eOk) ;}

Acad::ErrorStatus AsdkEmployee::firstName(char*& firstName)
{
	assertReadEnabled () ;	firstName = strdup(m_firstName) ;	return (Acad::eOk) ;}

Acad::ErrorStatus AsdkEmployee::setFirstName(const char* newVal)
{
	assertWriteEnabled () ;	delete [] m_firstName ;	m_firstName =_tcsdup (newVal) ;	return (Acad::eOk) ;}

Acad::ErrorStatus AsdkEmployee::lastName(char*& lastName)
{
	assertReadEnabled () ;	lastName = strdup(m_lastName) ;	return (Acad::eOk) ;}

Acad::ErrorStatus AsdkEmployee::setLastName(const char* newVal)
{
	assertWriteEnabled () ;	delete [] m_lastName ;	m_lastName =_tcsdup (newVal) ;	return (Acad::eOk) ;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -