#include <CigiViewCtrlV1.h>
Inheritance diagram for CigiViewCtrlV1:
Public Member Functions | |
CigiViewCtrlV1 () | |
virtual | ~CigiViewCtrlV1 () |
virtual int | Pack (CigiBasePacket *Base, Cigi_uint8 *Buff, void *Spec) const |
virtual int | Unpack (Cigi_uint8 *Buff, bool Swap, void *Spec) |
int | SetViewID (const Cigi_uint8 ViewIDIn, bool bndchk=true) |
Cigi_uint8 | GetViewID (void) const |
int | SetGroupID (const Cigi_uint8 GroupIDIn, bool bndchk=true) |
Cigi_uint8 | GetGroupID (void) const |
Definition at line 62 of file CigiViewCtrlV1.h.
CigiViewCtrlV1::CigiViewCtrlV1 | ( | ) |
General Constructor
Definition at line 85 of file CigiViewCtrlV1.cpp.
References CIGI_VIEW_CTRL_PACKET_ID_V1, CIGI_VIEW_CTRL_PACKET_SIZE_V1, CigiBaseViewCtrl::EntityID, CigiBaseViewCtrl::GroupID, CigiBasePacket::MinorVersion, CigiBasePacket::PacketID, CigiBasePacket::PacketSize, CigiBaseViewCtrl::Pitch, CigiBaseViewCtrl::PitchEn, CigiBaseViewCtrl::Roll, CigiBaseViewCtrl::RollEn, CigiBasePacket::Version, CigiBaseViewCtrl::ViewID, CigiBaseViewCtrl::XOff, CigiBaseViewCtrl::XOffEn, CigiBaseViewCtrl::Yaw, CigiBaseViewCtrl::YawEn, CigiBaseViewCtrl::YOff, CigiBaseViewCtrl::YOffEn, CigiBaseViewCtrl::ZOff, and CigiBaseViewCtrl::ZOffEn.
00086 { 00087 00088 PacketID = CIGI_VIEW_CTRL_PACKET_ID_V1; 00089 PacketSize = CIGI_VIEW_CTRL_PACKET_SIZE_V1; 00090 Version = 1; 00091 MinorVersion = 0; 00092 00093 EntityID = 0; 00094 ViewID = 0; 00095 GroupID = 0; 00096 XOffEn = true; 00097 YOffEn = true; 00098 ZOffEn = true; 00099 RollEn = true; 00100 PitchEn = true; 00101 YawEn = true; 00102 XOff = 0.0; 00103 YOff = 0.0; 00104 ZOff = 0.0; 00105 Roll = 0.0; 00106 Pitch = 0.0; 00107 Yaw = 0.0; 00108 00109 }
CigiViewCtrlV1::~CigiViewCtrlV1 | ( | ) | [virtual] |
Cigi_uint8 CigiViewCtrlV1::GetGroupID | ( | void | ) | const [inline] |
Gets the GroupID value.
Definition at line 149 of file CigiViewCtrlV1.h.
00150 { 00151 if(GroupID < 8) 00152 return(GroupID); 00153 else 00154 return((Cigi_uint8)0x07); 00155 }
Cigi_uint8 CigiViewCtrlV1::GetViewID | ( | void | ) | const [inline] |
Gets the ViewID value.
Definition at line 126 of file CigiViewCtrlV1.h.
00127 { 00128 if(ViewID < 31) 00129 return((Cigi_uint8)ViewID); 00130 else 00131 return((Cigi_uint8)0x1f); 00132 }
int CigiViewCtrlV1::Pack | ( | CigiBasePacket * | Base, | |
Cigi_uint8 * | Buff, | |||
void * | Spec | |||
) | const [virtual] |
The virtual Pack function for CIGI 1
Base | - A pointer to the instance of the packet to be packed. (Downcast to CigiBasePacket) | |
Buff | - A pointer to the current pack point. | |
Spec | - A pointer to special data - This is not used in this class. |
Implements CigiBaseViewCtrl.
Definition at line 126 of file CigiViewCtrlV1.cpp.
References PackPointerUnion::c, CIGI_SCOPY2, CIGI_SCOPY4, CIGI_VIEW_CTRL_PACKET_SIZE_V1, PackPointerUnion::d, CigiBaseViewCtrl::EntityID, PackPointerUnion::f, CigiBaseViewCtrl::GroupID, CigiBasePacket::PacketID, CigiBasePacket::PacketSize, CigiBaseViewCtrl::Pitch, CigiBaseViewCtrl::Roll, PackPointerUnion::s, CigiBaseViewCtrl::ViewID, CigiBaseViewCtrl::XOff, CigiBaseViewCtrl::Yaw, CigiBaseViewCtrl::YOff, and CigiBaseViewCtrl::ZOff.
00127 { 00128 double DBuf[6]; 00129 00130 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf; 00131 00132 PackPointer CDta; 00133 00134 CigiBaseViewCtrl * Data = ( CigiBaseViewCtrl *)Base; 00135 00136 CDta.d = DBuf; 00137 00138 *CDta.c++ = PacketID; 00139 *CDta.c++ = PacketSize; 00140 00141 CIGI_SCOPY2(CDta.s++, &Data->EntityID); 00142 00143 Cigi_uint8 HDta = 0; 00144 00145 if(Data->ViewID < 32) 00146 HDta = (Cigi_uint8)((Data->ViewID << 3) & 0xf8); 00147 else 00148 HDta = (Cigi_uint8)0xf8; 00149 00150 if(Data->GroupID < 8) 00151 HDta |= (Cigi_uint8)(Data->GroupID & 0x07); 00152 else 00153 HDta |= (Cigi_uint8)0x07; 00154 00155 *CDta.c++ = HDta; 00156 *CDta.c++ = 0; 00157 *CDta.c++ = 0; 00158 *CDta.c++ = 0; 00159 00160 CIGI_SCOPY4(CDta.f++, &Data->XOff); 00161 CIGI_SCOPY4(CDta.f++, &Data->YOff); 00162 CIGI_SCOPY4(CDta.f++, &Data->ZOff); 00163 CIGI_SCOPY4(CDta.f++, &Data->Roll); 00164 CIGI_SCOPY4(CDta.f++, &Data->Pitch); 00165 CIGI_SCOPY4(CDta.f++, &Data->Yaw); 00166 00167 memcpy(Buff,tBuf,CIGI_VIEW_CTRL_PACKET_SIZE_V1); 00168 00169 return(PacketSize); 00170 00171 00172 00173 }
int CigiViewCtrlV1::SetGroupID | ( | const Cigi_uint8 | GroupIDIn, | |
bool | bndchk = true | |||
) |
Sets the GroupID with bound checking control
GroupIDIn | - Specifies the view group that this packet controls. | |
bndchk | - Enables (true) or disables (false) bounds checking. |
Definition at line 244 of file CigiViewCtrlV1.cpp.
References CIGI_ERROR_VALUE_OUT_OF_RANGE, CIGI_SUCCESS, and CigiBaseViewCtrl::GroupID.
00245 { 00246 00247 #ifndef CIGI_NO_BND_CHK 00248 if(bndchk && ((GroupIDIn < 0)||(GroupIDIn > 7))) 00249 { 00250 #ifndef CIGI_NO_EXCEPT 00251 throw CigiValueOutOfRangeException("GroupID",(Cigi_uint8)GroupIDIn,0,7); 00252 #endif 00253 return(CIGI_ERROR_VALUE_OUT_OF_RANGE); 00254 } 00255 #endif 00256 00257 GroupID = GroupIDIn; 00258 return(CIGI_SUCCESS); 00259 00260 }
int CigiViewCtrlV1::SetViewID | ( | const Cigi_uint8 | ViewIDIn, | |
bool | bndchk = true | |||
) |
Sets the ViewID with bound checking control
ViewIDIn | - Specifies the view that this packet controls. If The Group ID is not 0, ViewID is ignored. | |
bndchk | - Enables (true) or disables (false) bounds checking. |
Definition at line 222 of file CigiViewCtrlV1.cpp.
References CIGI_ERROR_VALUE_OUT_OF_RANGE, CIGI_SUCCESS, and CigiBaseViewCtrl::ViewID.
00223 { 00224 00225 #ifndef CIGI_NO_BND_CHK 00226 if(bndchk && ((ViewIDIn < 0)||(ViewIDIn > 31))) 00227 { 00228 #ifndef CIGI_NO_EXCEPT 00229 throw CigiValueOutOfRangeException("ViewID",(Cigi_uint16)ViewIDIn,0,31); 00230 #endif 00231 return(CIGI_ERROR_VALUE_OUT_OF_RANGE); 00232 } 00233 #endif 00234 00235 ViewID = (Cigi_uint16)ViewIDIn; 00236 return(CIGI_SUCCESS); 00237 00238 }
int CigiViewCtrlV1::Unpack | ( | Cigi_uint8 * | Buff, | |
bool | Swap, | |||
void * | Spec | |||
) | [virtual] |
The virtual Unpack function for CIGI 1
Buff | - A pointer to the current pack point. | |
Swap | - N/A for V1 & V2 | |
Spec | - A pointer to special data - This is not used in this class. |
Implements CigiBaseViewCtrl.
Definition at line 178 of file CigiViewCtrlV1.cpp.
References PackPointerUnion::c, CIGI_SCOPY2, CIGI_SCOPY4, CIGI_VIEW_CTRL_PACKET_SIZE_V1, PackPointerUnion::d, CigiBaseViewCtrl::EntityID, PackPointerUnion::f, CigiBaseViewCtrl::GroupID, CigiBasePacket::PacketSize, CigiBaseViewCtrl::Pitch, CigiBaseViewCtrl::Roll, PackPointerUnion::s, CigiBaseViewCtrl::ViewID, CigiBaseViewCtrl::XOff, CigiBaseViewCtrl::Yaw, CigiBaseViewCtrl::YOff, and CigiBaseViewCtrl::ZOff.
00179 { 00180 double DBuf[6]; 00181 00182 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf; 00183 00184 PackPointer CDta; 00185 00186 memcpy(tBuf,Buff,CIGI_VIEW_CTRL_PACKET_SIZE_V1); 00187 00188 CDta.d = DBuf; 00189 00190 CDta.c += 2; // Step over packet id and size 00191 00192 CIGI_SCOPY2(&EntityID, CDta.s++); 00193 00194 Cigi_uint8 HDta = *CDta.c++; 00195 00196 ViewID = (Cigi_uint16)((HDta >> 3) & 0x1f); 00197 GroupID = (Cigi_uint8)(HDta & 0x07); 00198 00199 CDta.c += 3; 00200 00201 CIGI_SCOPY4(&XOff, CDta.f++); 00202 CIGI_SCOPY4(&YOff, CDta.f++); 00203 CIGI_SCOPY4(&ZOff, CDta.f++); 00204 CIGI_SCOPY4(&Roll, CDta.f++); 00205 CIGI_SCOPY4(&Pitch, CDta.f++); 00206 CIGI_SCOPY4(&Yaw, CDta.f++); 00207 00208 return(PacketSize); 00209 00210 }