My Trihedron Code.

HI!. Last time, I met the trouble to make a ZbufferTrihedron. Of course, many people help me, But I can't solve. So I make my Trihedron code.

It work normally, But I think it's not as good as ZbufferTrihedron. Because, if you Zoom, Axis Change the it's length But Text same size.

If you want to use it. you got this coord and change the classname. If you develop in MFC base, you declare class object at Doc class. for example,

ASCENTOrigin Origin(anAxis); // anAxis class is Handle(Geom_Axis2Placement)
myAISContext->Display(&Origin); // myAISContext class is Handle(AIS_InteractiveContext)

///////////////////////////////////////////////////////////////////////////////////////////////

#ifndef _ASCENTORIGIN_H_
#define _ASCENTORIGIN_H_

#include "stdafx.h"
#include
#include
#include "AIS_InteractiveObject.hxx"
#include
#include
#include
#include

// for Selecting!!
#include

DEFINE_STANDARD_HANDLE(ASCENTOrigin, AIS_InteractiveObject)

class ASCENTOrigin : public AIS_InteractiveObject
{
private:
Handle(Geom_Axis2Placement) myAxis;
Handle(Prs3d_LineAspect) Xaxis;
Handle(Prs3d_LineAspect) Yaxis;
Handle(Prs3d_LineAspect) Zaxis;

Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& ,
const Standard_Integer);
void ComputeSelection(const Handle_SelectMgr_Selection &aSelection,
const Standard_Integer aMode);

public:
ASCENTOrigin(Handle(Geom_Axis2Placement)& anAxis);
virtual ~ASCENTOrigin();
DEFINE_STANDARD_RTTI(ASCENTOrigin)

};

#endif

IMPLEMENT_STANDARD_HANDLE(ASCENTOrigin,AIS_InteractiveObject)
IMPLEMENT_STANDARD_RTTIEXT(ASCENTOrigin, AIS_InteractiveObject)

ASCENTOrigin::ASCENTOrigin(Handle(Geom_Axis2Placement)& anAxis)
:AIS_InteractiveObject()
{
myAxis = anAxis;
Xaxis = new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID,1);
Yaxis = new Prs3d_LineAspect(Quantity_NOC_BLUE1, Aspect_TOL_SOLID,1);
Zaxis = new Prs3d_LineAspect(Quantity_NOC_GREEN, Aspect_TOL_SOLID,1);
}

ASCENTOrigin::~ASCENTOrigin()
{

}

void ASCENTOrigin::Compute(const Handle_PrsMgr_PresentationManager3d &aPresentationManager,
const Handle_Prs3d_Presentation &aPresentation,
const Standard_Integer aMode = 0)
{
Handle(AIS_Drawer) aDrawer = new AIS_Drawer();

Standard_CString Xtext = "X";
Standard_CString Ytext = "Y";
Standard_CString Ztext = "Z";

switch(aMode)
{
case 0:
DsgPrs_XYZAxisPresentation::Add(aPresentation, Xaxis, myAxis->XDirection() , 100 , Xtext, gp_Pnt(0,0,0), gp_Pnt(100,0,0));
DsgPrs_XYZAxisPresentation::Add(aPresentation, Yaxis, myAxis->YDirection() , 100 , Ytext, gp_Pnt(0,0,0), gp_Pnt(0,100,0));
DsgPrs_XYZAxisPresentation::Add(aPresentation, Zaxis, myAxis->Direction() , 100 , Ztext, gp_Pnt(0,0,0), gp_Pnt(0,0,100));

case 1:

break;
}
}

void ASCENTOrigin::ComputeSelection(const Handle_SelectMgr_Selection &aSelection,
const Standard_Integer aMode)
{
switch(aMode)
{
case 0:
{
gp_Pnt Origin(0,0,0);
TopoDS_Vertex OriginVertex;
OriginVertex = BRepBuilderAPI_MakeVertex(Origin);

//Handle(SelectMgr_EntityOwner) Owner = new SelectMgr_EntityOwner(

//aSelection->Add(new Select3D_SensitivePoint(Owner, Origin));
}
break;

case 1:
break;

case 2:
break;

case 3:
break;

default:
break;
}
}

//////////////////////////////////////////////////////////////////////////////////

You know that. It has not computeselection. So if you want to make a plane based on origin, you make a computeselection.

So i hope that if you have a algorithm of selection, share it please.

or please what i use the class to select XY-Plane and X Axis and Origin??

shudolf's picture

Hi . I add a computeSelection code. But It's not working! why does it happen?

my code is

switch(aMode)
{
case 0:
{
TopoDS_Shape XAxisLine;
TopoDS_Shape YAxisLine;
TopoDS_Shape ZAxisLine;

XAxisLine = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,0), gp_Pnt(100,0,0));
YAxisLine = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,0), gp_Pnt(0,100,0));
ZAxisLine = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,0), gp_Pnt(0,0,100));

Handle(StdSelect_BRepOwner) XAxisOwner = new stdSelect_BRepOwner(XAxisLine, 0, Standard_True);
Handle(StdSelect_BRepOwner) XAxisOwner = new stdSelect_BRepOwner(XAxisLine, 0, Standard_True);
Handle(StdSelect_BRepOwner) XAxisOwner = new stdSelect_BRepOwner(XAxisLine, 0, Standard_True);

aSelection->Add(new Select3D_SensitiveSegment(XAxisOwner, gp_Pnt(0,0,0) , gp_Pnt(100,0,0)));
aSelection->Add(new Select3D_SensitiveSegment(XAxisOwner, gp_Pnt(0,0,0) , gp_Pnt(0,100,0)));
aSelection->Add(new Select3D_SensitiveSegment(XAxisOwner, gp_Pnt(0,0,0) , gp_Pnt(0,0,100)));