Sketcher: points defined as external geometry,

fix behavior of external geometry cursor,
          improve appearance of point creation cursor
This commit is contained in:
logari81 2012-07-10 15:25:27 +02:00
parent 47c44af453
commit e5953cedac
2 changed files with 50 additions and 37 deletions

View File

@ -32,6 +32,7 @@
# include <gp_Circ.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <BRepAdaptor_Curve.hxx>
# include <BRep_Tool.hxx>
# include <Geom_Plane.hxx>
# include <GeomAPI_ProjectPointOnSurf.hxx>
# include <BRepOffsetAPI_NormalProjection.hxx>
@ -1226,15 +1227,17 @@ void SketchObject::rebuildExternalGeometry(void)
invPlm.multVec(p2,p2);
if (Base::Distance(p1,p2) < Precision::Confusion()) {
std::string msg = SubElement + " perpendicular to the sketch plane cannot be used as external geometry";
throw Base::Exception(msg.c_str());
Base::Vector3d p = (p1 + p2) / 2;
Part::GeomPoint* point = new Part::GeomPoint(p);
point->Construction = true;
ExternalGeo.push_back(point);
}
else {
Part::GeomLineSegment* line = new Part::GeomLineSegment();
line->setPoints(p1,p2);
line->Construction = true;
ExternalGeo.push_back(line);
}
Part::GeomLineSegment* line = new Part::GeomLineSegment();
line->setPoints(p1,p2);
line->Construction = true;
ExternalGeo.push_back(line);
}
else {
try {
@ -1256,15 +1259,17 @@ void SketchObject::rebuildExternalGeometry(void)
Base::Vector3d p2(P2.X(),P2.Y(),P2.Z());
if (Base::Distance(p1,p2) < Precision::Confusion()) {
std::string msg = SubElement + " perpendicular to the sketch plane cannot be used as external geometry";
throw Base::Exception(msg.c_str());
Base::Vector3d p = (p1 + p2) / 2;
Part::GeomPoint* point = new Part::GeomPoint(p);
point->Construction = true;
ExternalGeo.push_back(point);
}
else {
Part::GeomLineSegment* line = new Part::GeomLineSegment();
line->setPoints(p1,p2);
line->Construction = true;
ExternalGeo.push_back(line);
}
Part::GeomLineSegment* line = new Part::GeomLineSegment();
line->setPoints(p1,p2);
line->Construction = true;
ExternalGeo.push_back(line);
}
else if (curve.GetType() == GeomAbs_Circle) {
gp_Circ c = curve.Circle();
@ -1304,7 +1309,12 @@ void SketchObject::rebuildExternalGeometry(void)
}
break;
case TopAbs_VERTEX:
throw Base::Exception("Vertices cannot be used as external geometry for sketches");
{
gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(refSubShape));
Part::GeomPoint* point = new Part::GeomPoint(Base::Vector3d(p.X(),p.Y(),p.Z()));
point->Construction = true;
ExternalGeo.push_back(point);
}
break;
default:
throw Base::Exception("Unknown type of geometry");

View File

@ -1269,22 +1269,22 @@ static const char *cursor_createpoint[]={
"......+.........................",
"......+.........................",
"......+.........................",
"...............+++++++..........",
"..............++.....++.........",
".............+.........+........",
"............++.........++.......",
"...........++...........++......",
"...........+.............+......",
"...........+.............+......",
"...........+.............+......",
"...........+.............+......",
"...........+.............+......",
"...........+.............+......",
"...........++...........++......",
"............++.........++.......",
".............+.........+........",
"..............++.....++.........",
"...............+++++++..........",
"................................",
"................................",
"................................",
".................++++...........",
"................++++++..........",
"...............++++++++.........",
"...............++++++++.........",
"...............++++++++.........",
"...............++++++++.........",
"................++++++..........",
".................++++...........",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................"};
@ -1843,8 +1843,9 @@ namespace SketcherGui {
if (!sSubName || sSubName[0] == '\0')
return false;
std::string element(sSubName);
// for the moment we allow only edges
if (element.substr(0,4) == "Edge") {
// for the moment we allow only edges and vertices
if ((element.size() > 4 && element.substr(0,4) == "Edge") ||
(element.size() > 6 && element.substr(0,6) == "Vertex")) {
return true;
}
return false;
@ -1917,7 +1918,8 @@ public:
virtual void mouseMove(Base::Vector2D onSketchPos)
{
applyCursor();
if (Gui::Selection().getPreselection().pObjectName)
applyCursor();
}
virtual bool pressButton(Base::Vector2D onSketchPos)
@ -1935,7 +1937,8 @@ public:
{
if (msg.Type == Gui::SelectionChanges::AddSelection) {
std::string subName(msg.pSubName);
if (subName.size() > 4 && subName.substr(0,4) == "Edge") {
if ((subName.size() > 4 && subName.substr(0,4) == "Edge") ||
(subName.size() > 6 && subName.substr(0,6) == "Vertex")) {
try {
Gui::Command::openCommand("Add external geometry");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addExternal(\"%s\",\"%s\")",