For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

How to drag end points of a segment

JRG's picture
Forums: 

How to drag a segment from one of it's end points using C++ code written by Peter Dolbey in QtOpenCascade Toolkit?

We need to rotate, enlarge or shrink the segment while one point keep fixed.

This is what we've done:

// -------------------------------------- My segment class
#include "_segment.h"

#include
#include
#include

// MACROS TO USE THE HANDLE
IMPLEMENT_STANDARD_HANDLE(_Segment, _Entity)
IMPLEMENT_STANDARD_RTTIEXT(_Segment, _Entity)
// MACRO FOR THE OCAF PERSISTENCE
IMPLEMENT_TOBJOCAF_PERSISTENCE(_Segment)

_Segment::_Segment(const TDF_Label& theLabel) : _Entity(theLabel) {
}

Handle(TObj_Partition) _Segment::Create(const TDF_Label &theLabel) {
Handle(TObj_Partition) partition = new _Segment(theLabel);
return partition;
}

void _Segment::initFields() {
TopoDS_Compound compound;

BRep_Builder builder;
builder.MakeCompound(compound);

BRepBuilderAPI_MakeVertex v1(gp_Pnt(210, -90, 59));
BRepBuilderAPI_MakeVertex v2(gp_Pnt(152, 248, 55));

BRepBuilderAPI_MakeEdge mkEdge(v1.Vertex(), v2.Vertex());

builder.Add(compound, mkEdge.Shape());

// Build a TNaming_NamedShape using built box
TNaming_Builder B(GetLabel());
B.Generated(compound);
}
// ----------------------------------- My segment class end

Thanks in advanced