diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index 0d726d333..9b92e6449 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -399,7 +399,6 @@ void DrawProjGroup::setViewOrientation(DrawProjGroupItem *v, const char *projTyp //xDir = viewOrientationMatrix.getValue() * xDir; v->Direction.setValue(dir); - //v->XAxisDirection.setValue(xDir); } void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index 9375d4bb8..7b43144d7 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -57,7 +57,6 @@ DrawProjGroupItem::DrawProjGroupItem(void) //projection group controls these Direction.setStatus(App::Property::ReadOnly,true); - XAxisDirection.setStatus(App::Property::ReadOnly,true); Scale.setStatus(App::Property::ReadOnly,true); ScaleType.setStatus(App::Property::ReadOnly,true); } diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index 1c404d10b..e0acc9c0b 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -83,6 +83,7 @@ DrawView::~DrawView() App::DocumentObjectExecReturn *DrawView::execute(void) { + //Base::Console().Message("TRACE - DV::execute - %s\n",Label.getValue()); TechDraw::DrawPage *page = findParentPage(); if(page) { if (ScaleType.isValue("Document")) { @@ -105,6 +106,7 @@ App::DocumentObjectExecReturn *DrawView::execute(void) void DrawView::onChanged(const App::Property* prop) { if (!isRestoring()) { + //Base::Console().Message("TRACE - DV::onChanged(%s) - %s\n",prop->getName(),Label.getValue()); if (prop == &ScaleType) { if (ScaleType.isValue("Document")) { Scale.setStatus(App::Property::ReadOnly,true); diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 7a474f0aa..5214f6afd 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -103,13 +103,12 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0) { static const char *group = "Projection"; static const char *fgroup = "Format"; - static const char *lgroup = "SectionLine"; static const char *sgroup = "Show"; //properties that affect Geometry ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"3D Shape to view"); ADD_PROPERTY_TYPE(Direction ,(0,0,1.0) ,group,App::Prop_None,"Projection direction. The direction you are looking from."); - ADD_PROPERTY_TYPE(XAxisDirection ,(1,0,0) ,group,App::Prop_None,"Where to place projection's XAxis (rotation)"); +// ADD_PROPERTY_TYPE(XAxisDirection ,(1,0,0) ,group,App::Prop_None,"Where to place projection's XAxis (rotation)"); ADD_PROPERTY_TYPE(Tolerance,(0.05f),group,App::Prop_None,"Internal tolerance for calculations"); Tolerance.setConstraints(&floatRange); @@ -135,9 +134,6 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0) //properties that affect Section Line ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,sgroup,App::Prop_None,"Show/hide section line if applicable"); - ADD_PROPERTY_TYPE(HorizSectionLine ,(true) ,lgroup,App::Prop_None,"Section line is horizontal"); - ADD_PROPERTY_TYPE(ArrowUpSection ,(false) ,lgroup,App::Prop_None,"Section line arrows point up"); - ADD_PROPERTY_TYPE(SymbolSection,("A") ,lgroup,App::Prop_None,"Section identifier"); geometryObject = new TechDrawGeometry::GeometryObject(this); getRunControl(); @@ -166,6 +162,8 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void) return new App::DocumentObjectExecReturn("FVP - Linked shape object is empty"); } + //Base::Console().Message("TRACE - DVP::execute - %s \n",Label.getValue()); + (void) DrawView::execute(); //make sure Scale is up to date geometryObject->setTolerance(Tolerance.getValue()); @@ -175,8 +173,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void) gp_Pnt inputCenter; try { inputCenter = TechDrawGeometry::findCentroid(shape, - Direction.getValue(), - getValidXDir()); + Direction.getValue()); shapeCentroid = Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()); } catch (Standard_Failure) { @@ -228,7 +225,6 @@ short DrawViewPart::mustExecute() const short result = 0; if (!isRestoring()) { result = (Direction.isTouched() || - XAxisDirection.isTouched() || Source.isTouched() || Scale.isTouched() ); } @@ -241,6 +237,8 @@ short DrawViewPart::mustExecute() const void DrawViewPart::onChanged(const App::Property* prop) { + //Base::Console().Message("TRACE - DVP::onChanged(%s) - %s\n",prop->getName(),Label.getValue()); + DrawView::onChanged(prop); //TODO: when scale changes, any Dimensions for this View sb recalculated. DVD should pick this up subject to topological naming issues. @@ -249,15 +247,12 @@ void DrawViewPart::onChanged(const App::Property* prop) void DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Pnt& inputCenter) { Base::Vector3d baseProjDir = Direction.getValue(); - Base::Vector3d validXDir = getValidXDir(); - saveParamSpace(baseProjDir, - validXDir); + saveParamSpace(baseProjDir); geometryObject->projectShape(shape, inputCenter, - Direction.getValue(), - validXDir); + Direction.getValue()); geometryObject->extractGeometry(TechDrawGeometry::ecHARD, //always show the hard&outline visible lines true); geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE, @@ -749,11 +744,7 @@ Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt) const { Base::Vector3d centeredPoint = pt - shapeCentroid; Base::Vector3d direction = Direction.getValue(); - Base::Vector3d xAxis = getValidXDir(); - gp_Ax2 viewAxis; - viewAxis = gp_Ax2(gp_Pnt(0.0,0.0,0.0), - gp_Dir(direction.x, direction.y, direction.z), - gp_Dir(xAxis.x, xAxis.y, xAxis.z)); + gp_Ax2 viewAxis = TechDrawGeometry::getViewAxis(centeredPoint,direction); HLRAlgo_Projector projector( viewAxis ); gp_Pnt2d prjPnt; projector.Project(gp_Pnt(centeredPoint.x,centeredPoint.y,centeredPoint.z), prjPnt); @@ -774,64 +765,27 @@ bool DrawViewPart::hasGeometry(void) const return result; } -Base::Vector3d DrawViewPart::getValidXDir() const +void DrawViewPart::saveParamSpace(const Base::Vector3d& direction) { - Base::Vector3d X(1.0,0.0,0.0); - Base::Vector3d Y(0.0,1.0,0.0); - Base::Vector3d Z(0.0,0.0,1.0); - Base::Vector3d xDir = XAxisDirection.getValue(); - if (xDir.Length() < Precision::Confusion()) { - Base::Console().Warning("XAxisDirection has zero length - using (1,0,0)\n"); - xDir = X; - } - double xLength = xDir.Length(); - xDir.Normalize(); - Base::Vector3d viewDir = Direction.getValue(); - viewDir.Normalize(); - Base::Vector3d randomDir(0.0,0.0,0.0); - if (xDir == viewDir) { - randomDir = Y; - if (randomDir == xDir) { - randomDir = X; - } - xDir = randomDir; - Base::Console().Warning("XAxisDirection cannot equal +/- Direction - using (%.3f,%.3f%.3f)\n", - xDir.x,xDir.y,xDir.z); - } else if (xDir == (-1.0 * viewDir)) { - randomDir = Y; - if ((xDir == randomDir) || - (xDir == (-1.0 * randomDir))) { - randomDir = X; - } - xDir = randomDir; - Base::Console().Warning("XAxisDirection cannot equal +/- Direction - using (%.3f,%.3f%.3f)\n", - xDir.x,xDir.y,xDir.z); - } - return xLength * xDir; -} + Base::Vector3d origin(0.0,0.0,0.0); + gp_Ax2 viewAxis = TechDrawGeometry::getViewAxis(origin,direction); -void DrawViewPart::saveParamSpace(const Base::Vector3d& direction, - const Base::Vector3d& xAxis) -{ - gp_Ax2 viewAxis; - viewAxis = gp_Ax2(gp_Pnt(0, 0, 0), - gp_Dir(direction.x, -direction.y, direction.z), - gp_Dir(xAxis.x, -xAxis.y, xAxis.z)); // Y invert warning! // - - uDir = Base::Vector3d(xAxis.x, -xAxis.y, xAxis.z); + gp_Dir xdir = viewAxis.XDirection(); + uDir = Base::Vector3d(xdir.X(),xdir.Y(),xdir.Z()); gp_Dir ydir = viewAxis.YDirection(); vDir = Base::Vector3d(ydir.X(),ydir.Y(),ydir.Z()); wDir = Base::Vector3d(direction.x, -direction.y, direction.z); + wDir.Normalize(); } -DrawViewSection* DrawViewPart::getSectionRef(void) const +std::vector DrawViewPart::getSectionRefs(void) const { - DrawViewSection* result = nullptr; + std::vector result; std::vector inObjs = getInList(); for (auto& o:inObjs) { if (o->getTypeId().isDerivedFrom(DrawViewSection::getClassTypeId())) { - result = static_cast(o); + result.push_back(static_cast(o)); } } return result; diff --git a/src/Mod/TechDraw/App/DrawViewPart.h b/src/Mod/TechDraw/App/DrawViewPart.h index 92c3efb9b..93330b235 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.h +++ b/src/Mod/TechDraw/App/DrawViewPart.h @@ -72,7 +72,7 @@ public: App::PropertyLink Source; //Part Feature App::PropertyVector Direction; //TODO: Rename to YAxisDirection or whatever this actually is (ProjectionDirection) - App::PropertyVector XAxisDirection; + //App::PropertyVector XAxisDirection; App::PropertyBool SeamVisible; App::PropertyBool SmoothVisible; //App::PropertyBool OutlinesVisible; @@ -93,11 +93,7 @@ public: App::PropertyFloatConstraint Tolerance; App::PropertyBool HorizCenterLine; App::PropertyBool VertCenterLine; - App::PropertyBool ShowSectionLine; - App::PropertyBool HorizSectionLine; //true(horiz)/false(vert) - App::PropertyBool ArrowUpSection; //true(up/right)/false(down/left) - App::PropertyString SymbolSection; std::vector getHatches(void) const; @@ -118,12 +114,11 @@ public: double getBoxX(void) const; double getBoxY(void) const; virtual QRectF getRect() const; - virtual DrawViewSection* getSectionRef() const; //is there a ViewSection based on this ViewPart? + virtual std::vector getSectionRefs() const; //are there ViewSections based on this ViewPart? const Base::Vector3d& getUDir(void) const {return uDir;} //paperspace X const Base::Vector3d& getVDir(void) const {return vDir;} //paperspace Y const Base::Vector3d& getWDir(void) const {return wDir;} //paperspace Z const Base::Vector3d& getCentroid(void) const {return shapeCentroid;} - Base::Vector3d getValidXDir() const; Base::Vector3d projectPoint(const Base::Vector3d& pt) const; virtual short mustExecute() const; @@ -158,8 +153,7 @@ protected: double simpleMinDist(TopoDS_Shape s1, TopoDS_Shape s2); //const; //probably sb static or DrawUtil //Projection parameter space - void saveParamSpace(const Base::Vector3d& direction, - const Base::Vector3d& xAxis); + void saveParamSpace(const Base::Vector3d& direction); Base::Vector3d uDir; //paperspace X Base::Vector3d vDir; //paperspace Y Base::Vector3d wDir; //paperspace Z diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index e2765d00f..1fff54d41 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -30,13 +30,15 @@ #include #include -#include +//#include #include #include #include #include #include +# include #include +#include #include #include #include @@ -49,6 +51,7 @@ #include #include #include +#include #include #include @@ -76,6 +79,14 @@ using namespace TechDraw; using namespace std; +const char* DrawViewSection::SectionDirEnums[]= {"Right", + "Left", + "Up", + "Down", + NULL}; + + + //=========================================================================== // DrawViewSection //=========================================================================== @@ -89,12 +100,14 @@ DrawViewSection::DrawViewSection() //static const char *lgroup = "Line"; - ADD_PROPERTY_TYPE(BaseView ,(0),sgroup,App::Prop_None,"2D View with SectionLine"); + ADD_PROPERTY_TYPE(SectionSymbol ,("A"),sgroup,App::Prop_None,"The identifier for this section"); + ADD_PROPERTY_TYPE(BaseView ,(0),sgroup,App::Prop_None,"2D View source for this Section"); ADD_PROPERTY_TYPE(SectionNormal ,(0,0,1.0) ,sgroup,App::Prop_None,"Section Plane normal direction"); //direction of extrusion of cutting prism ADD_PROPERTY_TYPE(SectionOrigin ,(0,0,0) ,sgroup,App::Prop_None,"Section Plane Origin"); + SectionDirection.setEnums(SectionDirEnums); + ADD_PROPERTY_TYPE(SectionDirection,((long)0),sgroup, App::Prop_None, "Direction in Base View for this Section"); ADD_PROPERTY_TYPE(ShowCutSurface ,(true),fgroup,App::Prop_None,"Shade the cut surface"); - ADD_PROPERTY_TYPE(CutSurfaceColor,(0.0,0.0,0.0),fgroup,App::Prop_None,"The color to shade the cut surface"); ADD_PROPERTY_TYPE(HatchCutSurface ,(false),fgroup,App::Prop_None,"Hatch the cut surface"); ADD_PROPERTY_TYPE(HatchPattern ,(""),fgroup,App::Prop_None,"The hatch pattern file for the cut surface"); @@ -114,7 +127,6 @@ short DrawViewSection::mustExecute() const if (!isRestoring()) { result = (Scale.isTouched() || Direction.isTouched() || - XAxisDirection.isTouched() || BaseView.isTouched() || SectionNormal.isTouched() || SectionOrigin.isTouched() ); @@ -127,8 +139,23 @@ short DrawViewSection::mustExecute() const void DrawViewSection::onChanged(const App::Property* prop) { + if (!isRestoring()) { + //Base::Console().Message("TRACE - DVS::onChanged(%s) - %s\n",prop->getName(),Label.getValue()); + if (prop == &SectionSymbol) { + std::string lblText = "Section " + + std::string(SectionSymbol.getValue()) + + " - " + + std::string(SectionSymbol.getValue()); + Label.setValue(lblText); + } + if (prop == &SectionOrigin) { + App::DocumentObject* base = BaseView.getValue(); + base->touch(); + } + } DrawView::onChanged(prop); } + App::DocumentObjectExecReturn *DrawViewSection::execute(void) { App::DocumentObject* link = Source.getValue(); @@ -143,8 +170,9 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) if (!base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) return new App::DocumentObjectExecReturn("BaseView object is not a DrawViewPart object"); + //Base::Console().Message("TRACE - DVS::execute() - %s/%s\n",getNameInDocument(),Label.getValue()); + const Part::TopoShape &partTopo = static_cast(link)->Shape.getShape(); - //const TechDraw::DrawViewPart* dvp = static_cast(base); if (partTopo.getShape().IsNull()) return new App::DocumentObjectExecReturn("Linked shape object is empty"); @@ -152,47 +180,25 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) (void) DrawView::execute(); //make sure Scale is up to date gp_Pln pln = getSectionPlane(); - // Get the Axis Directions for the Plane to transform UV components again - gp_XYZ xAxis = pln.XAxis().Direction().XYZ(); - gp_XYZ yAxis = pln.YAxis().Direction().XYZ(); - gp_XYZ origin = pln.Location().XYZ(); - gp_Dir plnNormal = pln.Axis().Direction().XYZ(); + gp_Dir gpNormal = pln.Axis().Direction(); + Base::Vector3d orgPnt = SectionOrigin.getValue(); Base::BoundBox3d bb = partTopo.getBoundBox(); - - Base::Vector3d tmp1 = SectionOrigin.getValue(); - Base::Vector3d plnPnt(tmp1.x, tmp1.y, tmp1.z); - Base::Vector3d plnNorm(plnNormal.X(), plnNormal.Y(), plnNormal.Z()); - -// if(!bb.IsCutPlane(plnPnt, plnNorm)) { //this test doesn't work if plane is coincident with bb! - if(!isReallyInBox(plnPnt, bb)) { + if(!isReallyInBox(orgPnt, bb)) { Base::Console().Warning("DVS: Section Plane doesn't intersect part in %s\n",getNameInDocument()); Base::Console().Warning("DVS: Using center of bounding box.\n"); - plnPnt = bb.GetCenter(); - //SectionOrigin.setValue(plnPnt); + orgPnt = bb.GetCenter(); + SectionOrigin.setValue(orgPnt); } - double dMax = bb.CalcDiagonalLength(); - - double maxParm = dMax; - BRepBuilderAPI_MakePolygon mkPoly; - gp_Pnt pn1(origin + xAxis * maxParm + yAxis * maxParm); - gp_Pnt pn2(origin + xAxis * maxParm + yAxis * -maxParm); - gp_Pnt pn3(origin + xAxis * -maxParm + yAxis * -maxParm); - gp_Pnt pn4(origin + xAxis * -maxParm + yAxis * +maxParm); - - mkPoly.Add(pn1); - mkPoly.Add(pn2); - mkPoly.Add(pn3); - mkPoly.Add(pn4); - mkPoly.Close(); - // Make the extrusion face - BRepBuilderAPI_MakeFace mkFace(mkPoly.Wire()); + double dMax = bb.CalcDiagonalLength(); + BRepBuilderAPI_MakeFace mkFace(pln, -dMax,dMax,-dMax,dMax); TopoDS_Face aProjFace = mkFace.Face(); if(aProjFace.IsNull()) return new App::DocumentObjectExecReturn("DrawViewSection - Projected face is NULL"); - TopoDS_Shape prism = BRepPrimAPI_MakePrism(aProjFace, dMax * gp_Vec(pln.Axis().Direction()), false, true).Shape(); + gp_Vec extrudeDir = dMax * gp_Vec(gpNormal); + TopoDS_Shape prism = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape(); // We need to copy the shape to not modify the BRepstructure BRepBuilderAPI_Copy BuilderCopy(partTopo.getShape()); @@ -207,18 +213,17 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) BRepBndLib::Add(rawShape, testBox); testBox.SetGap(0.0); if (testBox.IsVoid()) { //prism & input don't intersect. rawShape is garbage, don't bother. + Base::Console().Log("INFO - DVS::execute - prism & input don't intersect\n"); return DrawView::execute(); } geometryObject->setTolerance(Tolerance.getValue()); geometryObject->setScale(Scale.getValue()); - Base::Vector3d validXDir = getValidXDir(); gp_Pnt inputCenter; try { inputCenter = TechDrawGeometry::findCentroid(rawShape, - Direction.getValue(), - validXDir); + Direction.getValue()); TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(rawShape, inputCenter, Scale.getValue()); @@ -248,8 +253,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) const TopoDS_Face& face = TopoDS::Face(expl.Current()); TopoDS_Face pFace = projectFace(face, inputCenter, - Direction.getValue(), - validXDir); + Direction.getValue()); if (!pFace.IsNull()) { builder.Add(newFaces,pFace); } @@ -270,10 +274,13 @@ gp_Pln DrawViewSection::getSectionPlane() const { Base::Vector3d plnPnt = SectionOrigin.getValue(); Base::Vector3d plnNorm = SectionNormal.getValue(); + gp_Ax2 viewAxis = TechDrawGeometry::getViewAxis(plnPnt,plnNorm,false); + gp_Ax3 viewAxis3(viewAxis); - return gp_Pln(gp_Pnt(plnPnt.x, plnPnt.y, plnPnt.z), gp_Dir(plnNorm.x, plnNorm.y, plnNorm.z)); + return gp_Pln(viewAxis3); } + //! tries to find the intersection of the section plane with the shape giving a collection of planar faces TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shape& shape) { @@ -336,22 +343,18 @@ std::vector DrawViewSection::getFaceGeometry() //! project a single face using HLR - used for section faces TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face, gp_Pnt faceCenter, - const Base::Vector3d &direction, - const Base::Vector3d &xaxis) + const Base::Vector3d &direction) { if(face.IsNull()) { throw Base::Exception("DrawViewSection::projectFace - input Face is NULL"); } - gp_Ax2 transform; - transform = gp_Ax2(faceCenter, - gp_Dir(direction.x, direction.y, direction.z), - gp_Dir(xaxis.x, xaxis.y, xaxis.z)); + Base::Vector3d origin(faceCenter.X(),faceCenter.Y(),faceCenter.Z()); + gp_Ax2 viewAxis = TechDrawGeometry::getViewAxis(origin,direction); HLRBRep_Algo *brep_hlr = new HLRBRep_Algo(); brep_hlr->Add(face); - - HLRAlgo_Projector projector( transform ); + HLRAlgo_Projector projector( viewAxis ); brep_hlr->Projector(projector); brep_hlr->Update(); brep_hlr->Hide(); diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 0a95596af..9f60ba1ec 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -60,12 +60,13 @@ public: App::PropertyLink BaseView; App::PropertyVector SectionNormal; App::PropertyVector SectionOrigin; + App::PropertyEnumeration SectionDirection; App::PropertyBool ShowCutSurface; App::PropertyColor CutSurfaceColor; App::PropertyBool HatchCutSurface; App::PropertyFile HatchPattern; App::PropertyColor HatchColor; - + App::PropertyString SectionSymbol; virtual short mustExecute() const; bool isReallyInBox (const Base::Vector3d v, const Base::BoundBox3d bb) const; @@ -83,6 +84,7 @@ public: public: std::vector getFaceGeometry(); + static const char* SectionDirEnums[]; protected: TopoDS_Compound sectionFaces; @@ -91,14 +93,12 @@ protected: TopoDS_Compound findSectionPlaneIntersections(const TopoDS_Shape& shape); TopoDS_Face projectFace(const TopoDS_Shape &face, gp_Pnt faceCenter, - const Base::Vector3d &direction, - const Base::Vector3d &xaxis); + const Base::Vector3d &direction); void getParameters(void); }; typedef App::FeaturePythonT DrawViewSectionPython; - } //namespace TechDraw #endif diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index 752dcd650..2b0c92b4f 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -38,10 +38,10 @@ #include #include #include -#include +//#include #include #include -#include +//#include #include #include #include @@ -161,36 +161,18 @@ void GeometryObject::clear() //!set up a hidden line remover and project a shape with it void GeometryObject::projectShape(const TopoDS_Shape& input, const gp_Pnt& inputCenter, - const Base::Vector3d& direction, - const Base::Vector3d& xAxis) + const Base::Vector3d& direction) { - Base::Vector3d stdZ(0.0,0.0,1.0); - Base::Vector3d flipDirection(direction.x,-direction.y,direction.z); - Base::Vector3d cross = flipDirection; - //special cases - if (flipDirection == stdZ) { - cross = Base::Vector3d(1.0,0.0,0.0); - } else if (flipDirection == (stdZ * -1.0)) { - cross = Base::Vector3d(1.0,0.0,0.0); - } else { - cross.Normalize(); - cross = cross.Cross(stdZ); - } // Clear previous Geometry clear(); - + Base::Vector3d origin(inputCenter.X(),inputCenter.Y(),inputCenter.Z()); + gp_Ax2 viewAxis = getViewAxis(origin,direction); auto start = chrono::high_resolution_clock::now(); Handle_HLRBRep_Algo brep_hlr = NULL; try { brep_hlr = new HLRBRep_Algo(); brep_hlr->Add(input, m_isoCount); - - gp_Ax2 viewAxis; - viewAxis = gp_Ax2(inputCenter, - gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z), -// gp_Dir(xAxis.x, -xAxis.y, xAxis.z)); - gp_Dir(cross.x, cross.y, cross.z)); HLRAlgo_Projector projector( viewAxis ); brep_hlr->Projector(projector); brep_hlr->Update(); @@ -688,15 +670,42 @@ bool GeometryObject::findVertex(Base::Vector2D v) } /// utility non-class member functions -//! Returns the centroid of shape, as viewed according to direction and xAxis -gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape, - const Base::Vector3d &direction, - const Base::Vector3d &xAxis) +//! gets a coordinate system +gp_Ax2 TechDrawGeometry::getViewAxis(const Base::Vector3d origin, + const Base::Vector3d& direction, + const bool flip) { + gp_Pnt inputCenter(origin.x,origin.y,origin.z); + Base::Vector3d stdZ(0.0,0.0,1.0); + Base::Vector3d flipDirection(direction.x,-direction.y,direction.z); + if (!flip) { + flipDirection = Base::Vector3d(direction.x,direction.y,direction.z); + } + Base::Vector3d cross = flipDirection; + //special cases + if (flipDirection == stdZ) { + cross = Base::Vector3d(1.0,0.0,0.0); + } else if (flipDirection == (stdZ * -1.0)) { + cross = Base::Vector3d(1.0,0.0,0.0); + } else { + cross.Normalize(); + cross = cross.Cross(stdZ); + } gp_Ax2 viewAxis; - viewAxis = gp_Ax2(gp_Pnt(0, 0, 0), - gp_Dir(direction.x, -direction.y, direction.z), - gp_Dir(xAxis.x, -xAxis.y, xAxis.z)); + viewAxis = gp_Ax2(inputCenter, + gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z), + gp_Dir(cross.x, cross.y, cross.z)); + return viewAxis; +} + + + +//! Returns the centroid of shape, as viewed according to direction +gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape, + const Base::Vector3d &direction) +{ + Base::Vector3d origin(0.0,0.0,0.0); + gp_Ax2 viewAxis = getViewAxis(origin,direction); gp_Trsf tempTransform; tempTransform.SetTransformation(viewAxis); diff --git a/src/Mod/TechDraw/App/GeometryObject.h b/src/Mod/TechDraw/App/GeometryObject.h index 719d39b8f..cb019c66f 100644 --- a/src/Mod/TechDraw/App/GeometryObject.h +++ b/src/Mod/TechDraw/App/GeometryObject.h @@ -25,7 +25,7 @@ #include #include -#include +//#include #include #include @@ -49,10 +49,13 @@ TopoDS_Shape TechDrawExport mirrorShape(const TopoDS_Shape &input, const gp_Pnt& inputCenter, double scale); -//! Returns the centroid of shape, as viewed according to direction and xAxis +//! Returns the centroid of shape, as viewed according to direction gp_Pnt TechDrawExport findCentroid(const TopoDS_Shape &shape, - const Base::Vector3d &direction, - const Base::Vector3d &xAxis); + const Base::Vector3d &direction); + +gp_Ax2 TechDrawExport getViewAxis(const Base::Vector3d origin, + const Base::Vector3d& direction, + const bool flip=true); class TechDrawExport GeometryObject { @@ -76,8 +79,7 @@ public: void projectShape(const TopoDS_Shape &input, const gp_Pnt& inputCenter, - const Base::Vector3d &direction, - const Base::Vector3d &xAxis); + const Base::Vector3d &direction); void extractGeometry(edgeClass category, bool visible); void addFaceGeom(Face * f); void clearFaceGeom(); diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index d64253320..11c882c51 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -335,11 +335,11 @@ void CmdTechDrawNewViewSection::activated(int iMsg) } App::DocumentObject* dObj = *(shapes.begin()); TechDraw::DrawViewPart* dvp = static_cast(dObj); - if (dvp->getSectionRef()) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("This View already has a related Section. Choose another.")); - return; - } +// if (dvp->getSectionRef()) { +// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), +// QObject::tr("This View already has a related Section. Choose another.")); +// return; +// } std::string PageName = page->getNameInDocument(); diff --git a/src/Mod/TechDraw/Gui/CommandCreateDims.cpp b/src/Mod/TechDraw/Gui/CommandCreateDims.cpp index 3f94a977e..7d8d6d947 100644 --- a/src/Mod/TechDraw/Gui/CommandCreateDims.cpp +++ b/src/Mod/TechDraw/Gui/CommandCreateDims.cpp @@ -872,6 +872,8 @@ void CmdTechDrawLinkDimension::activated(int iMsg) return; } + //TODO: if (subs.empty()) { "no geometry found in selection" } + // dialog to select the Dimension to link Gui::Control().showDialog(new TaskDlgLinkDim(obj3D,subs,page)); diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index bcf6379b2..a4c952866 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -250,7 +250,6 @@ void QGIViewPart::updateView(bool update) viewPart->isTouched() || viewPart->Source.isTouched() || viewPart->Direction.isTouched() || - viewPart->XAxisDirection.isTouched() || viewPart->Tolerance.isTouched() || viewPart->Scale.isTouched() || viewPart->HardHidden.isTouched() || @@ -394,9 +393,11 @@ void QGIViewPart::drawViewPart() } } //draw section line - if (viewPart->ShowSectionLine.getValue() && - viewPart->getSectionRef() ) { - drawSectionLine(true); + if (viewPart->ShowSectionLine.getValue()) { + auto refs = viewPart->getSectionRefs(); + for (auto& r:refs) { + drawSectionLine(r, true); + } } //draw center lines drawCenterLines(true); @@ -464,10 +465,9 @@ void QGIViewPart::removeDecorations() } } -void QGIViewPart::drawSectionLine(bool b) +void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b) { TechDraw::DrawViewPart *viewPart = static_cast(getViewObject()); - TechDraw::DrawViewSection *viewSection = viewPart->getSectionRef(); if (!viewPart || !viewSection) { return; @@ -475,32 +475,38 @@ void QGIViewPart::drawSectionLine(bool b) if (b) { QGISectionLine* sectionLine = new QGISectionLine(); addToGroup(sectionLine); - sectionLine->setSymbol(const_cast(viewPart->SymbolSection.getValue())); - Base::Vector3d sectionDir(0,1,0); - Base::Vector3d up(0,1,0); - Base::Vector3d down(0,-1,0); - Base::Vector3d right(1,0,0); - Base::Vector3d left(-1,0,0); - bool horiz = viewPart->HorizSectionLine.getValue(); - bool normal = viewPart->ArrowUpSection.getValue(); - if (horiz && normal) { - sectionDir = up; - } else if (horiz && !normal) { - sectionDir = down; - } else if (!horiz && normal) { - sectionDir = right; - } else if (!horiz && !normal) { - sectionDir = left; + sectionLine->setSymbol(const_cast(viewSection->SectionSymbol.getValue())); + + //TODO: handle oblique section lines? + //find smallest internal angle(normalDir,get?Dir()) and use -1*get?Dir() +/- angle + //Base::Vector3d normalDir = viewSection->SectionNormal.getValue(); + Base::Vector3d arrowDir(0,1,0); //for drawing only, not geom + Base::Vector3d lineDir(1,0,0); + bool horiz = false; + if (viewSection->SectionDirection.isValue("Right")) { + arrowDir = Base::Vector3d(1,0,0); + lineDir = Base::Vector3d(0,1,0); + } else if (viewSection->SectionDirection.isValue("Left")) { + arrowDir = Base::Vector3d(-1,0,0); + lineDir = Base::Vector3d(0,-1,0); + } else if (viewSection->SectionDirection.isValue("Up")) { + arrowDir = Base::Vector3d(0,1,0); + lineDir = Base::Vector3d(1,0,0); + horiz = true; + } else if (viewSection->SectionDirection.isValue("Down")) { + arrowDir = Base::Vector3d(0,-1,0); + lineDir = Base::Vector3d(-1,0,0); + horiz = true; } - sectionLine->setDirection(sectionDir.x,sectionDir.y); + sectionLine->setDirection(arrowDir.x,arrowDir.y); Base::Vector3d org = viewSection->SectionOrigin.getValue(); double scale = viewPart->Scale.getValue(); Base::Vector3d pOrg = scale * viewPart->projectPoint(org); - pOrg.y = -1 * pOrg.y; - //now project pOrg onto sectionDir + //pOrg.y = -1 * pOrg.y; + //now project pOrg onto arrowDir Base::Vector3d displace; - displace.ProjectToLine(pOrg, sectionDir); + displace.ProjectToLine(pOrg, arrowDir); Base::Vector3d offset = pOrg + displace; sectionLine->setPos(offset.x,offset.y); diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.h b/src/Mod/TechDraw/Gui/QGIViewPart.h index 01c322598..20afe7b69 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.h +++ b/src/Mod/TechDraw/Gui/QGIViewPart.h @@ -32,6 +32,7 @@ namespace TechDraw { class DrawViewPart; +class DrawViewSection; class DrawHatch; } @@ -57,7 +58,7 @@ public: virtual void updateView(bool update = false) override; void tidy(); virtual QRectF boundingRect() const override; - virtual void drawSectionLine(bool b); + virtual void drawSectionLine(TechDraw::DrawViewSection* s, bool b); virtual void drawCenterLines(bool b); bool showSection; diff --git a/src/Mod/TechDraw/Gui/QGIViewSection.cpp b/src/Mod/TechDraw/Gui/QGIViewSection.cpp index 7d2655538..32b20de4f 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSection.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewSection.cpp @@ -70,7 +70,7 @@ void QGIViewSection::drawSectionFace() auto sectionFaces( section->getFaceGeometry() ); if (sectionFaces.empty()) { - Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n"); + //Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n"); return; } std::vector::iterator fit = sectionFaces.begin(); @@ -111,8 +111,9 @@ void QGIViewSection::updateView(bool update) } } -void QGIViewSection::drawSectionLine(bool b) +void QGIViewSection::drawSectionLine(TechDraw::DrawViewSection* s, bool b) { Q_UNUSED(b); + Q_UNUSED(s); //override QGIVP::drawSectionLine } diff --git a/src/Mod/TechDraw/Gui/QGIViewSection.h b/src/Mod/TechDraw/Gui/QGIViewSection.h index d77dfdb9c..c18d1b54d 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSection.h +++ b/src/Mod/TechDraw/Gui/QGIViewSection.h @@ -39,7 +39,7 @@ public: virtual void updateView(bool update = false) override; enum {Type = QGraphicsItem::UserType + 108}; int type() const override { return Type;} - void drawSectionLine(bool b) override; + void drawSectionLine(TechDraw::DrawViewSection* s, bool b) override; protected: diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index f18104557..1087cc37b 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -45,5 +45,9 @@ icons/actions/techdraw-toggleframe.svg icons/actions/techdraw-projgroup.svg icons/actions/techdraw-spreadsheet.svg + icons/actions/section-up.svg + icons/actions/section-down.svg + icons/actions/section-left.svg + icons/actions/section-right.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/section-down.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/section-down.svg new file mode 100644 index 000000000..04175322a --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/section-down.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/section-left.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/section-left.svg new file mode 100644 index 000000000..708238664 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/section-left.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/section-right.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/section-right.svg new file mode 100644 index 000000000..149234c53 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/section-right.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/section-up.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/section-up.svg new file mode 100644 index 000000000..91d2a6f7d --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/section-up.svg @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index eb93be62c..6dcc94292 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -50,6 +50,7 @@ using namespace Gui; using namespace TechDrawGui; +void _printVect(char* label, Base::Vector3d v); TaskSectionView::TaskSectionView(TechDraw::DrawViewPart* base, TechDraw::DrawViewSection* section) : ui(new Ui_TaskSectionView), @@ -58,16 +59,14 @@ TaskSectionView::TaskSectionView(TechDraw::DrawViewPart* base, TechDraw::DrawVie { ui->setupUi(this); - connect(ui->cbHoriz, SIGNAL(clicked(bool)), - this, SLOT(onHorizontalClicked(bool))); - connect(ui->cbVert, SIGNAL(clicked(bool)), - this, SLOT(onVerticalClicked(bool))); - connect(ui->cbNormal, SIGNAL(clicked(bool)), - this, SLOT(onNormalClicked(bool))); - connect(ui->cbReverse, SIGNAL(clicked(bool)), - this, SLOT(onReverseClicked(bool))); - connect(ui->pbCalc, SIGNAL(clicked(bool)), - this, SLOT(onCalcClicked(bool))); + connect(ui->pb_Up, SIGNAL(clicked(bool)), + this, SLOT(onUpClicked(bool))); + connect(ui->pb_Down, SIGNAL(clicked(bool)), + this, SLOT(onDownClicked(bool))); + connect(ui->pb_Right, SIGNAL(clicked(bool)), + this, SLOT(onRightClicked(bool))); + connect(ui->pb_Left, SIGNAL(clicked(bool)), + this, SLOT(onLeftClicked(bool))); connect(ui->pbReset, SIGNAL(clicked(bool)), this, SLOT(onResetClicked(bool))); @@ -83,12 +82,9 @@ TaskSectionView::~TaskSectionView() void TaskSectionView::saveInitialValues() { - saveSym = m_base->SymbolSection.getValue(); - saveHorizSectionLine = m_base->HorizSectionLine.getValue(); //true(horiz)/false(vert) - saveArrowUpSection = m_base->ArrowUpSection.getValue(); //true(up/right)/false(down/left) - saveSectionOrigin = m_section->SectionOrigin.getValue(); - saveSectionXDir = m_section->XAxisDirection.getValue(); - saveSectionDirection = m_section->Direction.getValue(); + saveSym = m_section->SectionSymbol.getValue(); + saveSectionOrigin = m_base->getCentroid(); + saveSectionProjDir = m_section->Direction.getValue(); saveSectionNormal = m_section->SectionNormal.getValue(); saveLabel = m_section->Label.getValue(); } @@ -98,172 +94,203 @@ void TaskSectionView::resetValues() { ui->leSymbol->setText(QString::fromUtf8(saveSym.data(), saveSym.size())); - ui->cbHoriz->setChecked(false); - ui->cbVert->setChecked(false); - ui->cbNormal->setChecked(false); - ui->cbReverse->setChecked(false); - if (saveHorizSectionLine && !saveArrowUpSection) { - ui->cbHoriz->setChecked(true); - ui->cbNormal->setChecked(true); - } else if (saveHorizSectionLine && saveArrowUpSection) { - ui->cbHoriz->setChecked(true); - ui->cbReverse->setChecked(true); - } else if (!saveHorizSectionLine && !saveArrowUpSection) { - ui->cbVert->setChecked(true); - ui->cbNormal->setChecked(true); - } else if (!saveHorizSectionLine && saveArrowUpSection) { - ui->cbVert->setChecked(true); - ui->cbReverse->setChecked(true); - } else { - Base::Console().Error("%s Symbol Line Direction is invalid\n", m_base->getNameInDocument()); - } + checkAll(false); + enableAll(true); - ui->sbOrgX->setValue(saveSectionOrigin.x); - ui->sbOrgY->setValue(saveSectionOrigin.y); - ui->sbOrgZ->setValue(saveSectionOrigin.z); + sectionProjDir = saveSectionProjDir; + sectionNormal = saveSectionNormal; - ui->sbXX->setValue(saveSectionXDir.x); - ui->sbXY->setValue(saveSectionXDir.y); - ui->sbXZ->setValue(saveSectionXDir.z); + ui->sb_OrgX->setValue(saveSectionOrigin.x); + ui->sb_OrgY->setValue(saveSectionOrigin.y); + ui->sb_OrgZ->setValue(saveSectionOrigin.z); ui->leProjDir->setReadOnly(true); - ui->leProjDir->setText(formatVector(saveSectionDirection)); + ui->leProjDir->setText(formatVector(saveSectionProjDir)); ui->leNormal->setReadOnly(true); ui->leNormal->setText(formatVector(saveSectionNormal)); m_section->Label.setValue(saveLabel.c_str()); + Base::Console().Message(""); } //calculate good starting points from base view and push buttons void TaskSectionView::calcValues() { - arrowDir = Base::Vector3d(0,-1,0); - //section arrows should point to "remaining body" of part after sectioning. - //so the arrow direction is (-1) * sectionPlaneNormal/sectionViewDirection - if (ui->cbHoriz->isChecked() && - ui->cbNormal->isChecked()) { - arrowDir = -1.0 * m_base->getVDir(); - } else if (ui->cbHoriz->isChecked() && - ui->cbReverse->isChecked()) { - arrowDir = m_base->getVDir(); - } else if (ui->cbVert->isChecked() && - ui->cbNormal->isChecked()) { - arrowDir = -1.0 * m_base->getUDir(); - } else if (ui->cbVert->isChecked() && - ui->cbReverse->isChecked() ) { - arrowDir = m_base->getUDir(); - } else { - Base::Console().Error("%s Symbol Line Direction is invalid\n", m_base->getNameInDocument()); - } + Base::Vector3d stdX(1.0,0.0,0.0); + Base::Vector3d stdY(0.0,1.0,0.0); + Base::Vector3d stdZ(0.0,0.0,1.0); + Base::Vector3d view = m_base->Direction.getValue(); + sectionDir = "unset"; + + if (ui->pb_Up->isChecked()) { + sectionDir = "Up"; + sectionProjDir = view; + sectionNormal = Base::Vector3d(view.x,view.z,-view.y); + if (view == stdZ) { + sectionProjDir = (-1.0 * stdY); + sectionNormal = (-1.0 * stdY); + } else if (view == (-1.0 * stdZ)) { + sectionProjDir = (-1.0 * stdY); + sectionNormal = (-1.0 * stdY); + } + } else if (ui->pb_Down->isChecked()) { + sectionDir = "Down"; + sectionProjDir = view; + sectionNormal = Base::Vector3d(-view.x,-view.z,view.y); + if (view == stdZ) { + sectionProjDir = stdY; + sectionNormal = stdY; + } else if (view == (-1.0 * stdZ)) { + sectionProjDir = stdY; + sectionNormal = stdY; + } + } else if (ui->pb_Left->isChecked()) { + sectionDir = "Left"; + sectionProjDir = Base::Vector3d(-view.y,view.x,view.z); + sectionNormal = Base::Vector3d(-view.y,view.x,0.0); + if (view == stdZ) { + sectionProjDir = stdX; + sectionNormal = stdX; + } else if (view == (-1.0 * stdZ)) { + sectionProjDir = stdX; + sectionNormal = stdX; + } + } else if (ui->pb_Right->isChecked()) { + sectionProjDir = Base::Vector3d(view.y,-view.x,view.z); + sectionNormal = Base::Vector3d(view.y,-view.x,0.0); + if (view == stdZ) { + sectionProjDir = -1.0 * stdX; + sectionNormal = -1.0 * stdX; + } else if (view == (-1.0 * stdZ)) { + sectionProjDir = -1.0 * stdX; + sectionNormal = -1.0 * stdX; + } + } - sectionNormal = -1.0 * arrowDir; //point of observer (ViewDirection) is away from direction of arrows ui->leNormal->setText(formatVector(sectionNormal)); - - sectionProjDir = sectionNormal; //typical use-case is view perp to face ui->leProjDir->setText(formatVector(sectionProjDir)); - sectionOrigin = m_base->getCentroid(); //middle of the object - ui->sbOrgX->setValue(sectionOrigin.x); - ui->sbOrgY->setValue(sectionOrigin.y); - ui->sbOrgZ->setValue(sectionOrigin.z); - - sectionXDir = m_base->Direction.getValue(); //rotate 90* - ui->sbXX->setValue(sectionXDir.x); - ui->sbXY->setValue(sectionXDir.y); - ui->sbXZ->setValue(sectionXDir.z); + Base::Console().Message("Press Reset, OK or Cancel to continue\n"); } //move values from screen to DocObjs void TaskSectionView::updateValues() { + m_section->SectionDirection.setValue(sectionDir); m_section->Direction.setValue(sectionProjDir); m_section->SectionNormal.setValue(sectionNormal); - - Base::Vector3d origin(ui->sbOrgX->value().getValue(), - ui->sbOrgY->value().getValue(), - ui->sbOrgZ->value().getValue()); + Base::Vector3d origin(ui->sb_OrgX->value().getValue(), + ui->sb_OrgY->value().getValue(), + ui->sb_OrgZ->value().getValue()); m_section->SectionOrigin.setValue(origin); + m_section->SectionDirection.setValue(sectionDir); + m_section->SectionSymbol.setValue(ui->leSymbol->text().toUtf8().constData()); - Base::Vector3d xDirIn(ui->sbXX->value().getValue(), - ui->sbXY->value().getValue(), - ui->sbXZ->value().getValue()); - //edit is: can't be zero, can't be same/recip as sectionProjDir. anything else is ok. - if ((xDirIn.Length() < FLT_EPSILON) || - (xDirIn == sectionProjDir) || - (xDirIn == -1.0 * sectionProjDir)) { - Base::Console().Message("XAxisDirection Invalid. Will be substituted.\n"); - } - m_section->XAxisDirection.setValue(xDirIn); - - m_base->SymbolSection.setValue(ui->leSymbol->text().toUtf8().constData()); - m_base->HorizSectionLine.setValue(ui->cbHoriz->isChecked()); - m_base->ArrowUpSection.setValue(!ui->cbNormal->isChecked()); - - m_section->SymbolSection.setValue(ui->leSymbol->text().toUtf8().constData()); - m_section->HorizSectionLine.setValue(ui->cbHoriz->isChecked()); - m_section->ArrowUpSection.setValue(!ui->cbNormal->isChecked()); - - std::string symbol = m_base->SymbolSection.getValue(); - std::string symbolText = "Section " + symbol + "-" + symbol; - if (symbolText.compare(m_section->Label.getValue())) { - m_section->Label.setValue(symbolText.c_str()); - } - + m_base->touch(); m_base->getDocument()->recompute(); } -void TaskSectionView::onHorizontalClicked(bool b) +void TaskSectionView::blockButtons(bool b) { - Q_UNUSED(b); - ui->cbHoriz->blockSignals(true); - ui->cbVert->blockSignals(true); - ui->cbHoriz->setChecked(true); - ui->cbVert->setChecked(false); - ui->cbHoriz->blockSignals(false); - ui->cbVert->blockSignals(false); + ui->pb_Up->blockSignals(b); + ui->pb_Down->blockSignals(b); + ui->pb_Left->blockSignals(b); + ui->pb_Right->blockSignals(b); } -void TaskSectionView::onVerticalClicked(bool b) +void TaskSectionView::turnOnUp() { - Q_UNUSED(b); - ui->cbHoriz->blockSignals(true); - ui->cbVert->blockSignals(true); - ui->cbVert->setChecked(true); - ui->cbHoriz->setChecked(false); - ui->cbHoriz->blockSignals(false); - ui->cbVert->blockSignals(false); -} - -void TaskSectionView::onNormalClicked(bool b) -{ - Q_UNUSED(b); - ui->cbNormal->blockSignals(true); - ui->cbReverse->blockSignals(true); - ui->cbNormal->setChecked(true); - ui->cbReverse->setChecked(false); - ui->cbNormal->blockSignals(false); - ui->cbReverse->blockSignals(false); -} - -void TaskSectionView::onReverseClicked(bool b) -{ - Q_UNUSED(b); - ui->cbReverse->blockSignals(true); - ui->cbNormal->blockSignals(true); - ui->cbReverse->setChecked(true); - ui->cbNormal->setChecked(false); - ui->cbReverse->blockSignals(false); - ui->cbNormal->blockSignals(false); -} - - -void TaskSectionView::onCalcClicked(bool b) -{ - Q_UNUSED(b); + blockButtons(true); + checkAll(false); + enableAll(false); + ui->pb_Up->setChecked(true); + ui->pb_Up->setEnabled(true); + blockButtons(false); calcValues(); updateValues(); } +void TaskSectionView::turnOnDown() +{ + blockButtons(true); + checkAll(false); + enableAll(false); + ui->pb_Down->setChecked(true); + ui->pb_Down->setEnabled(true); + blockButtons(false); + calcValues(); + updateValues(); +} + +void TaskSectionView::turnOnLeft() +{ + blockButtons(true); + checkAll(false); + enableAll(false); + ui->pb_Left->setChecked(true); + ui->pb_Left->setEnabled(true); + blockButtons(false); + calcValues(); + updateValues(); +} + +void TaskSectionView::turnOnRight() +{ + blockButtons(true); + checkAll(false); + enableAll(false); + ui->pb_Right->setChecked(true); + ui->pb_Right->setEnabled(true); + blockButtons(false); + calcValues(); + updateValues(); +} + +void TaskSectionView::checkAll(bool b) +{ + blockButtons(true); + ui->pb_Up->setChecked(b); + ui->pb_Down->setChecked(b); + ui->pb_Left->setChecked(b); + ui->pb_Right->setChecked(b); + blockButtons(false); +} + +void TaskSectionView::enableAll(bool b) +{ + blockButtons(true); + ui->pb_Up->setEnabled(b); + ui->pb_Down->setEnabled(b); + ui->pb_Left->setEnabled(b); + ui->pb_Right->setEnabled(b); + blockButtons(false); +} + + +void TaskSectionView::onUpClicked(bool b) +{ + Q_UNUSED(b); + turnOnUp(); +} + +void TaskSectionView::onDownClicked(bool b) +{ + Q_UNUSED(b); + turnOnDown(); +} + +void TaskSectionView::onLeftClicked(bool b) +{ + Q_UNUSED(b); + turnOnLeft(); +} + +void TaskSectionView::onRightClicked(bool b) +{ + Q_UNUSED(b); + turnOnRight(); +} + void TaskSectionView::onResetClicked(bool b) { Q_UNUSED(b); @@ -275,10 +302,7 @@ void TaskSectionView::onResetClicked(bool b) bool TaskSectionView::accept() { - //calcValues(); updateValues(); - std::string BaseName = m_base->getNameInDocument(); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.ShowSectionLine=True",BaseName.c_str()); return true; } @@ -287,7 +311,6 @@ bool TaskSectionView::reject() std::string BaseName = m_base->getNameInDocument(); std::string PageName = m_base->findParentPage()->getNameInDocument(); std::string SectionName = m_section->getNameInDocument(); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.ShowSectionLine=False",BaseName.c_str()); Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)", PageName.c_str(),SectionName.c_str()); Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",SectionName.c_str()); @@ -310,6 +333,11 @@ QString TaskSectionView::formatVector(Base::Vector3d v) return data; } +void _printVect(char* label, Base::Vector3d v) +{ + Base::Console().Message("printVect: %s (%3f,%.3f,%.3f)\n",label,v.x,v.y,v.z); +} + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TaskDlgSectionView::TaskDlgSectionView(TechDraw::DrawViewPart* base, TechDraw::DrawViewSection* section) : TaskDialog() diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.h b/src/Mod/TechDraw/Gui/TaskSectionView.h index 9e698f74d..b2f281366 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.h +++ b/src/Mod/TechDraw/Gui/TaskSectionView.h @@ -50,14 +50,20 @@ public: virtual bool reject(); protected Q_SLOTS: - void onHorizontalClicked(bool b); - void onVerticalClicked(bool b); - void onNormalClicked(bool b); - void onReverseClicked(bool b); - void onCalcClicked(bool b); + void onUpClicked(bool b); + void onDownClicked(bool b); + void onLeftClicked(bool b); + void onRightClicked(bool b); void onResetClicked(bool b); protected: + void turnOnUp(void); + void turnOnDown(void); + void turnOnLeft(void); + void turnOnRight(void); + void checkAll(bool b); + void enableAll(bool b); + void blockButtons(bool b); void changeEvent(QEvent *e); void resetValues(); void calcValues(); @@ -72,19 +78,17 @@ private: Base::Vector3d sectionNormal; Base::Vector3d sectionProjDir; Base::Vector3d sectionOrigin; - Base::Vector3d sectionXDir; + char* sectionDir; Base::Vector3d arrowDir; std::string saveSym; std::string saveLabel; bool saveHorizSectionLine; bool saveArrowUpSection; - Base::Vector3d saveSectionDirection; - Base::Vector3d saveSectionXDir; + Base::Vector3d saveSectionProjDir; Base::Vector3d saveSectionOrigin; Base::Vector3d saveSectionNormal; - }; class TaskDlgSectionView : public Gui::TaskView::TaskDialog diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.ui b/src/Mod/TechDraw/Gui/TaskSectionView.ui index 333686db3..6a059de73 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.ui +++ b/src/Mod/TechDraw/Gui/TaskSectionView.ui @@ -6,8 +6,8 @@ 0 0 - 358 - 461 + 410 + 492 @@ -23,7 +23,7 @@ - Calculate Section Parameters + Quick Section Parameters @@ -35,25 +35,90 @@ - Section Line Parameters + Define Your Section - - - QFormLayout::AllNonFixedFieldsGrow - + - + Symbol - + + + Identifier for this section + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + - A + Origin Y + + + + + + + Location of section plane + + + + + + + + + + Origin X + + + + + + + Origin Z + + + + + + + Location of section plane + + + + + + + + + + Location of section plane + + + @@ -61,150 +126,146 @@ - - + + + + Looking down + - Arrows + + + + + :/icons/actions/section-down.svg + + + + + 48 + 48 + + + + true - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Looking right + - Horizontal + + + + + :/icons/actions/section-right.svg + + + + + 48 + 48 + + + + true - - + + + + Looking left + - Vertical + + + + + :/icons/actions/section-left.svg + + + + + 48 + 48 + + + + true - + + + Looking up + + + + + + + - Line + + + + + :/icons/actions/section-up.svg + + + + + 48 + 48 + + + + true - - - - Up/Right + + + + Qt::Horizontal - + + + 40 + 20 + + + - - - - Down/Left + + + + Qt::Horizontal - - - - - - - - - - - Qt::Horizontal - - - - - - - Section View Parameters - - - - - - - - X + + + 40 + 20 + - - - - - - - - - - - - - Y - - - - - - - - - - - - - - - - - - - - - - - - - - - - Section Origin - - - Qt::AlignCenter - - - - - - - X Axis - - - Qt::AlignCenter - - - - - - - Z - - - - - - - - - - - - - - - - + @@ -270,15 +331,11 @@ - - - - Calc - - - + + Start over + Reset @@ -289,6 +346,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -298,6 +368,8 @@
Gui/QuantitySpinBox.h
- + + + diff --git a/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp b/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp index 2e2a38064..7a4905d5b 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp @@ -143,7 +143,7 @@ bool ViewProviderProjGroup::setEdit(int ModNum) void ViewProviderProjGroup::unsetEdit(int ModNum) { - Base::Console().Message("TRACE - VPPG::unSetEdit(%d) \n",ModNum); + Q_UNUSED(ModNum); Gui::Control().closeDialog(); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index 04922e85f..8c0a7b1e1 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -66,9 +66,6 @@ void ViewProviderViewPart::updateData(const App::Property* prop) prop == &(getViewObject()->ArcCenterMarks) || prop == &(getViewObject()->CenterScale) || prop == &(getViewObject()->ShowSectionLine) || - prop == &(getViewObject()->HorizSectionLine) || - prop == &(getViewObject()->ArrowUpSection) || - prop == &(getViewObject()->SymbolSection) || prop == &(getViewObject()->HorizCenterLine) || prop == &(getViewObject()->VertCenterLine) ) { // redraw QGIVP