Can someone provide a "mapping" between the parameters of AccuDraw.SetContext() and the AccuDrawFlags? The example only seems to use "ACCUDRAW_SetXAxis". For example, If I wish to use ACCUDRAW_UpdateRotation, which parameter(s) of AccuDraw.SetConext() should I use? The header file provides no clues.....
enum AccuDrawFlags { ACCUDRAW_SetModePolar = (1), ACCUDRAW_SetModeRect = (1<<1), ACCUDRAW_SetOrigin = (1<<2), ACCUDRAW_FixedOrigin = (1<<3), ACCUDRAW_SetRMatrix = (1<<4), ACCUDRAW_SetXAxis = (1<<5), ACCUDRAW_SetNormal = (1<<6), ACCUDRAW_SetDistance = (1<<7), ACCUDRAW_LockDistance = (1<<8), ACCUDRAW_Lock_X = (1<<9), ACCUDRAW_Lock_Y = (1<<10), ACCUDRAW_Lock_Z = (1<<11), ACCUDRAW_Disable = (1<<12), ACCUDRAW_Set3dMatrix = (1<<13), ACCUDRAW_OrientDefault = (1<<14), ACCUDRAW_SetFocus = (1<<15), ACCUDRAW_Delay = (1<<16), ACCUDRAW_OrientACS = (1<<17), ACCUDRAW_SetXAxis2 = (1<<18), ACCUDRAW_LockAngle = (1<<19), ACCUDRAW_AllowStartInLocate = (1<<20), ACCUDRAW_AlwaysSetOrigin = ((1<<21)|ACCUDRAW_SetOrigin), ACCUDRAW_RedrawCompass = (1<<22), ACCUDRAW_UpdateRotation = (1<<23), };
Here's an implementation for a helper class to avoid having to call SetContext directly. This class doesn't actually exist, it was adapted from imodeljs and I don't promise it compiles. I've posted it as it demonstrates how to properly call SetContext and what the useful AccuDrawFlags are. Usage:
AccuDrawHintBuilderPtr hints = AccuDrawHintBuilder::Create();
hints->SetOrigin(..);hints->SetRotation(..);
hints->SendHints();
/*=================================================================================**//** * AccuDrawHintBuilder is a DgnTool helper class that facilitates AccuDraw interaction. * The tool does not directly change the current AccuDraw state; the tool's job is merely * to supply "hints" to AccuDraw regarding it's preferred AccuDraw configuration for the * current tool state. User settings such as "Context Sensitivity" and "Floating Origin" * affect how/which hints get applied. * @bsiclass +===============+===============+===============+===============+===============+======*/ struct AccuDrawHintBuilder : RefCountedBase { private: bool m_setOrigin:1; bool m_setOriginFixed:1; bool m_setOriginAlways:1; bool m_setRotation:1; bool m_setXAxis:1; bool m_setNormal:1; bool m_setDistance:1; bool m_setAngle:1; bool m_setModePolar:1; bool m_setModeRectangular:1; bool m_setLockDistance:1; bool m_setLockAngle:1; bool m_setLockX:1; bool m_setLockY:1; bool m_setLockZ:1; DPoint3d m_origin; DVec3d m_axis; RotMatrix m_rMatrix; double m_distance; double m_angle; public: AccuDrawHintBuilder(); //! Create an instance of an AccuDrawHintBuilder for the purpose of tool interaction with AccuDraw. //! @return A reference counted pointer to an AccuDrawHintBuilder. static AccuDrawHintBuilderPtr Create(); void SetOrigin(DPoint3dCR); //!< Specify location for the compass origin. void SetRotation(RotMatrixCR); //!< Fully specify compass orientation. Tools should take care to not make AccuDraw's Z perpendicular to the view's Z. void SetXAxis(DVec3dCR); //!< Specify compass X axis direction taking the current AccuDraw rotation into account in computing Y and Z axes. void SetNormal(DVec3dCR); //!< Specify compass Z axis direction taking the current AccuDraw rotation into account in computing X and Y axes. void SetModePolar(); //!< Change compass to polar mode. void SetModeRectangular(); //!< Change compass to rectangular mode. void SetDistance(double); //!< Specify polar mode distance (in uors). void SetAngle(double); //!< Specify polar mode angle (in radians). void SetOriginFixed(); //!< Specify that compass remain at a fixed location for the current tool and not follow subsequent data points. void SetOriginAlways(); //!< Specify that "Floating Origin" setting not be honored which would normally cause the SetOrigin hint to be ignored. void SetLockDistance(); //!< Specify that polar mode distance is locked. Locks are cleared on next data button or by user interaction. void SetLockAngle(); //!< Specify that polar mode angle is locked. Locks are cleared on next data button or by user interaction. void SetLockX(); //!< Specify that rectangular mode X delta is locked. Locks are cleared on next data button or by user interaction. void SetLockY(); //!< Specify that rectangular mode Y delta is locked. Locks are cleared on next data button or by user interaction. void SetLockZ(); //!< Specify that rectangular mode Z delta is locked. Locks are cleared on next data button or by user interaction. BentleyStatus SendHints(bool activate = true); //!< Calls AccuDraw::SetContext using the current builder state. }; /*---------------------------------------------------------------------------------**//** * @bsimethod +---------------+---------------+---------------+---------------+---------------+------*/ AccuDrawHintBuilderPtr AccuDrawHintBuilder::Create() {return new AccuDrawHintBuilder();} /*---------------------------------------------------------------------------------**//** * @bsimethod +---------------+---------------+---------------+---------------+---------------+------*/ AccuDrawHintBuilder::AccuDrawHintBuilder() { m_setOrigin = m_setOriginFixed = m_setOriginAlways = m_setRotation = m_setXAxis = m_setNormal = m_setDistance = m_setAngle = m_setModePolar = m_setModeRectangular = m_setLockDistance = m_setLockAngle = m_setLockX = m_setLockY = m_setLockZ = false; } /*---------------------------------------------------------------------------------**//** * @bsimethod +---------------+---------------+---------------+---------------+---------------+------*/ void AccuDrawHintBuilder::SetOrigin(DPoint3dCR origin) {m_origin = origin; m_setOrigin = true;} void AccuDrawHintBuilder::SetRotation(RotMatrixCR rMatrix) {m_rMatrix = rMatrix; m_setRotation = true; m_setXAxis = m_setNormal = false;} void AccuDrawHintBuilder::SetXAxis(DVec3dCR xAxis) {m_axis = xAxis; m_setXAxis = true; m_setRotation = m_setNormal = false;} void AccuDrawHintBuilder::SetNormal(DVec3dCR normal) {m_axis = normal; m_setNormal = true; m_setRotation = m_setXAxis = false;} void AccuDrawHintBuilder::SetModePolar() {m_setModePolar = true; m_setModeRectangular = false;} void AccuDrawHintBuilder::SetModeRectangular() {m_setModeRectangular = true; m_setModePolar = false;} void AccuDrawHintBuilder::SetDistance(double distance) {m_distance = distance; m_setDistance = true;} void AccuDrawHintBuilder::SetAngle(double angle) {m_angle = angle; m_setAngle = true;} void AccuDrawHintBuilder::SetOriginFixed() {m_setOriginFixed = true;} void AccuDrawHintBuilder::SetOriginAlways() {m_setOriginAlways = true;} void AccuDrawHintBuilder::SetLockDistance() {m_setLockDistance = true;} void AccuDrawHintBuilder::SetLockAngle() {m_setLockAngle = true;} void AccuDrawHintBuilder::SetLockX() {m_setLockX = true;} void AccuDrawHintBuilder::SetLockY() {m_setLockY = true;} void AccuDrawHintBuilder::SetLockZ() {m_setLockZ = true;} /*---------------------------------------------------------------------------------**//** * @bsimethod +---------------+---------------+---------------+---------------+---------------+------*/ BentleyStatus AccuDrawHintBuilder::SendHints(bool activate) { uint32_t flags = 0; if (m_setOrigin) flags |= ACCUDRAW_SetOrigin; if (m_setOriginFixed) flags |= ACCUDRAW_FixedOrigin; if (m_setOriginAlways) flags |= ACCUDRAW_AlwaysSetOrigin; if (m_setRotation) flags |= ACCUDRAW_SetRMatrix; if (m_setXAxis) flags |= ACCUDRAW_SetXAxis; if (m_setNormal) flags |= ACCUDRAW_SetNormal; if (m_setModePolar) flags |= ACCUDRAW_SetModePolar; if (m_setModeRectangular) flags |= ACCUDRAW_SetModeRect; if (m_setLockDistance) flags |= ACCUDRAW_LockDistance; if (m_setLockAngle) flags |= ACCUDRAW_LockAngle; if (m_setLockX) flags |= ACCUDRAW_Lock_X; if (m_setLockY) flags |= ACCUDRAW_Lock_Y; if (m_setLockZ) flags |= ACCUDRAW_Lock_Z; if (SUCCESS != AccuDraw::GetInstance().SetContext((AccuDrawFlags) flags, &m_origin, m_setRotation ? (DVec3dCP) &m_rMatrix : &m_axis, NULL, m_setDistance ? &m_distance : nullptr, m_setAngle ? &m_angle : nullptr)) return ERROR; // Not enabed for this session... if (activate) AccuDraw::GetInstance().Activate(); // If not already enabled (ex. dynamics not started) most/all callers would want to enable it now (optional activate arg provided just in case)... return SUCCESS; }
Thanks !!
I'll take a look at this soon!