Hi
I have two questions regarding display conduits
-
How to draw shaded brep that is already added in the RhinoDoc with DrawShadedBrep ?
The ON_Brep* that is returned from CRhinoBrepObject::Brep is const, and DrawShadedBrep takes nonconst brep
object, so is it save here to const_cast ???class MyConduit :public CRhinoDisplayConduit
{
private:
CRhinoBrepObject* mBrepObj;
public:
MyConduit(CRhinoBrepObject* obj):
CRhinoDisplayConduit(CSupportChannels::SC_CALCBOUNDINGBOX |
CSupportChannels::SC_POSTDRAWOBJECTS | CSupportChannels::SC_DRAWOBJECT)
{
mBrepObj = obj;
}
bool ExecConduit( CRhinoDisplayPipeline& dp, UINT nChannel,bool& bTerminate)
{
if (nChannel == CSupportChannels::SC_DRAWOBJECT)
{
if( m_pChannelAttrs->m_pObject == mBrepObj)
m_pChannelAttrs->m_bDrawObject = false;
}
if (nChannel == CSupportChannels::SC_POSTDRAWOBJECTS)
{
const ON_Brep* brep = mBrepObj->Brep();// doesnot compile cause DrawShadedBrep takes nonconst Brep& dp.DrawShadedBrep(*brep,mymaterial); } }
};
ON_Brep* myBrep = GetBrepHere
CRhinoBrepObject* brep_obj = new CRhinoBrepObject();
brep_obj ->SetBrep( myBrep);
context.m_doc.AddObject(brep_obj);
MyConduit* conduit = new MyConduit(brep_obj);
conduit->Enable();
RhinoApp().ActiveDoc().Regen();
Why when drawing objects (that are added in rhino document ) with display conduit, when I select the rendered object it is not selection highlighted ?
Specifically, I was trying with CRhinoMeshObject , I want to draw the CRhinoMeshObject by myself. So i added the CRhinoMeshObject to the document, and set m_pChannelAttrs->m_bDrawObject = false in CSupportChannels::SC_DRAWOBJECT so Rhino can know that it will be custom drawed, and I drawed the mesh in SC_POSTDRAWOBJECTS. But when I try to select the rendered mesh, the mesh is selected, but it is not highlighted by the selection, so I guess I need to highlight the object through the conduit too, when it is selected, but do not know how to do that.
I guess the same behavior is seen for CRhinoBrepObject, but was not able to try because of problem 1).
.
Thank you