diff --git a/src/App/Extension.cpp b/src/App/Extension.cpp index 962ef781c..94aff5ce4 100644 --- a/src/App/Extension.cpp +++ b/src/App/Extension.cpp @@ -33,6 +33,7 @@ #include "Base/Exception.h" #include #include +#include /* We do not use a standard property macro for type initiation. The reason is that we have the first * PropertyData in the extension chain, there is no parent property data. @@ -96,7 +97,12 @@ void Extension::initExtension(ExtensionContainer* obj) { PyObject* Extension::getExtensionPyObject(void) { - return nullptr; + if (ExtensionPythonObject.is(Py::_None())){ + // ref counter is set to 1 + auto grp = new ExtensionPy(this); + ExtensionPythonObject = Py::Object(grp,true); + } + return Py::new_reference_to(ExtensionPythonObject); } const char* Extension::name() { diff --git a/src/App/GroupExtension.h b/src/App/GroupExtension.h index 7e24846a5..01fe0fa79 100644 --- a/src/App/GroupExtension.h +++ b/src/App/GroupExtension.h @@ -117,7 +117,7 @@ public: EXTENSION_PROXY_ONEARG(allowObject, pyobj); if(result.isNone()) - ExtensionT::allowObject(obj); + return ExtensionT::allowObject(obj); if(result.isBoolean()) return result.isTrue(); diff --git a/src/Base/Matrix.cpp b/src/Base/Matrix.cpp index bf9b5810d..f27267dbd 100644 --- a/src/Base/Matrix.cpp +++ b/src/Base/Matrix.cpp @@ -871,3 +871,79 @@ std::string Matrix4D::analyse(void) const } return text; } + +Matrix4D& Matrix4D::Outer(const Vector3f& rV1, const Vector3f& rV2) +{ + setToUnity(); + + dMtrx4D[0][0] = rV1.x * rV2.x; + dMtrx4D[0][1] = rV1.x * rV2.y; + dMtrx4D[0][2] = rV1.x * rV2.z; + + dMtrx4D[1][0] = rV1.y * rV2.x; + dMtrx4D[1][1] = rV1.y * rV2.y; + dMtrx4D[1][2] = rV1.y * rV2.z; + + dMtrx4D[2][0] = rV1.z * rV2.x; + dMtrx4D[2][1] = rV1.z * rV2.y; + dMtrx4D[2][2] = rV1.z * rV2.z; + + return *this; +} + +Matrix4D& Matrix4D::Outer(const Vector3d& rV1, const Vector3d& rV2) +{ + setToUnity(); + + dMtrx4D[0][0] = rV1.x * rV2.x; + dMtrx4D[0][1] = rV1.x * rV2.y; + dMtrx4D[0][2] = rV1.x * rV2.z; + + dMtrx4D[1][0] = rV1.y * rV2.x; + dMtrx4D[1][1] = rV1.y * rV2.y; + dMtrx4D[1][2] = rV1.y * rV2.z; + + dMtrx4D[2][0] = rV1.z * rV2.x; + dMtrx4D[2][1] = rV1.z * rV2.y; + dMtrx4D[2][2] = rV1.z * rV2.z; + + return *this; +} + +Matrix4D& Matrix4D::Hat(const Vector3f& rV) +{ + setToUnity(); + + dMtrx4D[0][0] = 0.0; + dMtrx4D[0][1] = -rV.z; + dMtrx4D[0][2] = rV.y; + + dMtrx4D[1][0] = rV.z; + dMtrx4D[1][1] = 0.0; + dMtrx4D[1][2] = -rV.x; + + dMtrx4D[2][0] = -rV.y; + dMtrx4D[2][1] = rV.x; + dMtrx4D[2][2] = 0.0; + + return *this; +} + +Matrix4D& Matrix4D::Hat(const Vector3d& rV) +{ + setToUnity(); + + dMtrx4D[0][0] = 0.0; + dMtrx4D[0][1] = -rV.z; + dMtrx4D[0][2] = rV.y; + + dMtrx4D[1][0] = rV.z; + dMtrx4D[1][1] = 0.0; + dMtrx4D[1][2] = -rV.x; + + dMtrx4D[2][0] = -rV.y; + dMtrx4D[2][1] = rV.x; + dMtrx4D[2][2] = 0.0; + + return *this; +} diff --git a/src/Base/Matrix.h b/src/Base/Matrix.h index a7986fb6b..dc27d349a 100644 --- a/src/Base/Matrix.h +++ b/src/Base/Matrix.h @@ -95,6 +95,12 @@ public: double determinant() const; /// Analyse the transformation std::string analyse(void) const; + /// Outer product (Dyadic product) + Matrix4D& Outer(const Vector3f& rV1, const Vector3f& rV2); + Matrix4D& Outer(const Vector3d& rV1, const Vector3d& rV2); + /// Hat operator (skew symmetric) + Matrix4D& Hat(const Vector3f& rV); + Matrix4D& Hat(const Vector3d& rV); //@} void getMatrix (double dMtrx[16]) const; diff --git a/src/Base/Vector3D.cpp b/src/Base/Vector3D.cpp index 782ee4a44..0d0729013 100644 --- a/src/Base/Vector3D.cpp +++ b/src/Base/Vector3D.cpp @@ -96,7 +96,7 @@ Vector3<_Precision> Vector3<_Precision>::operator - (const Vector3<_Precision>& cVctRes.z = z - rcVct.z; return cVctRes; } - + template Vector3<_Precision> Vector3<_Precision>::operator - (void) const { @@ -131,7 +131,7 @@ Vector3<_Precision>& Vector3<_Precision>::operator *= (_Precision fScale) } template -Vector3<_Precision>& Vector3<_Precision>::operator /= (_Precision fDiv) +Vector3<_Precision>& Vector3<_Precision>::operator /= (_Precision fDiv) { x /= fDiv; y /= fDiv; @@ -194,7 +194,7 @@ Vector3<_Precision> Vector3<_Precision>::Cross(const Vector3<_Precision>& rcVct) template bool Vector3<_Precision>::operator != (const Vector3<_Precision>& rcVct) const -{ +{ return !((*this) == rcVct); } @@ -213,7 +213,7 @@ bool Vector3<_Precision>::IsEqual(const Vector3<_Precision> &rclPnt, _Precision } template -Vector3<_Precision>& Vector3<_Precision>::ProjectToPlane (const Vector3<_Precision> &rclBase, +Vector3<_Precision>& Vector3<_Precision>::ProjectToPlane (const Vector3<_Precision> &rclBase, const Vector3<_Precision> &rclNorm) { Vector3<_Precision> clTemp(rclNorm); @@ -231,7 +231,7 @@ void Vector3<_Precision>::ProjectToPlane (const Vector3 &rclBase, } template -_Precision Vector3<_Precision>::DistanceToPlane (const Vector3<_Precision> &rclBase, +_Precision Vector3<_Precision>::DistanceToPlane (const Vector3<_Precision> &rclBase, const Vector3<_Precision> &rclNorm) const { return ((*this - rclBase) * rclNorm) / rclNorm.Length(); @@ -244,7 +244,7 @@ _Precision Vector3<_Precision>::Length (void) const } template -_Precision Vector3<_Precision>::DistanceToLine (const Vector3<_Precision> &rclBase, +_Precision Vector3<_Precision>::DistanceToLine (const Vector3<_Precision> &rclBase, const Vector3<_Precision> &rclDirect) const { return (_Precision) fabs((rclDirect % Vector3(*this - rclBase)).Length() / rclDirect.Length()); @@ -401,7 +401,7 @@ _Precision Vector3<_Precision>::GetAngle (const Vector3 &rcVect) const _Precision divid, fNum; divid = Length() * ((Vector3<_Precision>&)rcVect).Length(); - + if ((divid < -1e-10f) || (divid > 1e-10f)) { fNum = (*this * rcVect) / divid; if (fNum < -1) diff --git a/src/Base/Vector3D.h b/src/Base/Vector3D.h index da39a80af..f6816cc5d 100644 --- a/src/Base/Vector3D.h +++ b/src/Base/Vector3D.h @@ -126,6 +126,7 @@ public: Vector3 operator % (const Vector3<_Precision>& rcVct) const; /// Cross product Vector3 Cross (const Vector3<_Precision>& rcVct) const; + /// Comparing for inequality bool operator != (const Vector3<_Precision>& rcVct) const; /// Comparing for equality @@ -159,8 +160,8 @@ public: Vector3 & Normalize (void); /// Get angle between both vectors. The returned value lies in the interval [0,pi]. _Precision GetAngle (const Vector3 &rcVect) const; - /** Transforms this point to the coordinate system defined by origin \a rclBase, - * vector \a vector rclDirX and vector \a vector rclDirY. + /** Transforms this point to the coordinate system defined by origin \a rclBase, + * vector \a vector rclDirX and vector \a vector rclDirY. * \note \a rclDirX must be perpendicular to \a rclDirY, i.e. \a rclDirX * \a rclDirY = 0.. */ void TransformToCoordinateSystem (const Vector3 &rclBase, const Vector3 &rclDirX, const Vector3 &rclDirY); @@ -183,7 +184,7 @@ public: /// Projects this point onto the line given by the base \a rclPoint and the direction \a rclLine. /** * Projects a point \a rclPoint onto the line defined by the origin and the direction \a rclLine. - * The result is a vector from \a rclPoint to the point on the line. The length of this vector + * The result is a vector from \a rclPoint to the point on the line. The length of this vector * is the distance from \a rclPoint to the line. * Note: The resulting vector does not depend on the current vector. */ @@ -286,4 +287,3 @@ inline _Vec1 convertTo(const _Vec2& v) } // namespace Base #endif // BASE_VECTOR3D_H - diff --git a/src/Gui/ViewProvider.cpp b/src/Gui/ViewProvider.cpp index 3a1224f50..5d1cbe2b6 100644 --- a/src/Gui/ViewProvider.cpp +++ b/src/Gui/ViewProvider.cpp @@ -580,9 +580,12 @@ void ViewProvider::dragObject(App::DocumentObject* obj) { bool ViewProvider::canDropObject(App::DocumentObject* obj) const { auto vector = getExtensionsDerivedFromType(); - for(Gui::ViewProviderExtension* ext : vector) + Base::Console().Message("Check extensions for drop\n"); + for(Gui::ViewProviderExtension* ext : vector){ + Base::Console().Message("Check extensions %s\n", ext->name()); if(ext->extensionCanDropObject(obj)) return true; + } return false; } diff --git a/src/Gui/ViewProviderExtension.h b/src/Gui/ViewProviderExtension.h index 636a5d50a..bde1f2323 100644 --- a/src/Gui/ViewProviderExtension.h +++ b/src/Gui/ViewProviderExtension.h @@ -97,13 +97,14 @@ public: ViewProviderExtensionPythonT() { ExtensionT::m_isPythonExtension = true; + ExtensionT::initExtension(ViewProviderExtensionPythonT::getExtensionClassTypeId()); - EXTENSION_ADD_PROPERTY(Proxy,(Py::Object())); + EXTENSION_ADD_PROPERTY(ExtensionProxy,(Py::Object())); } virtual ~ViewProviderExtensionPythonT() { } - App::PropertyPythonObject Proxy; + App::PropertyPythonObject ExtensionProxy; }; typedef ViewProviderExtensionPythonT ViewProviderExtensionPython; diff --git a/src/Gui/ViewProviderGroupExtension.cpp b/src/Gui/ViewProviderGroupExtension.cpp index db1ead3de..03050117b 100644 --- a/src/Gui/ViewProviderGroupExtension.cpp +++ b/src/Gui/ViewProviderGroupExtension.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include using namespace Gui; @@ -76,6 +77,8 @@ bool ViewProviderGroupExtension::extensionCanDropObjects() const { bool ViewProviderGroupExtension::extensionCanDropObject(App::DocumentObject* obj) const { + Base::Console().Message("Check ViewProviderGroupExtension"); + auto* group = getExtendedViewProvider()->getObject()->getExtensionByType(); //we cannot drop thing of this group into it again diff --git a/src/Gui/ViewProviderPy.xml b/src/Gui/ViewProviderPy.xml index 9087834a4..732a5d43f 100644 --- a/src/Gui/ViewProviderPy.xml +++ b/src/Gui/ViewProviderPy.xml @@ -1,13 +1,13 @@ diff --git a/src/Mod/Part/App/ArcOfConicPyImp.cpp b/src/Mod/Part/App/ArcOfConicPyImp.cpp index ef90ab370..e6806f5ec 100644 --- a/src/Mod/Part/App/ArcOfConicPyImp.cpp +++ b/src/Mod/Part/App/ArcOfConicPyImp.cpp @@ -51,7 +51,7 @@ PyObject *ArcOfConicPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // } // constructor method -int ArcOfConicPy::PyInit(PyObject* args, PyObject* /*kwds*/) +int ArcOfConicPy::PyInit(PyObject* /*args*/, PyObject* /*kwds*/) { return -1; } diff --git a/src/Mod/Part/App/Geom2d/Curve2dPyImp.cpp b/src/Mod/Part/App/Geom2d/Curve2dPyImp.cpp index be49457e7..40cc226d5 100644 --- a/src/Mod/Part/App/Geom2d/Curve2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/Curve2dPyImp.cpp @@ -87,7 +87,7 @@ int Curve2dPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/) return 0; } -PyObject* Curve2dPy::reverse(PyObject *args) +PyObject* Curve2dPy::reverse(PyObject * /*args*/) { try { Handle_Geom2d_Curve curve = Handle_Geom2d_Curve::DownCast(getGeom2dCurvePtr()->handle()); diff --git a/src/Mod/Path/PathScripts/PathPost.py b/src/Mod/Path/PathScripts/PathPost.py index 1827b3d04..1be6689bc 100644 --- a/src/Mod/Path/PathScripts/PathPost.py +++ b/src/Mod/Path/PathScripts/PathPost.py @@ -162,6 +162,28 @@ class CommandPathPost: return True return False + def exportObjectsWith(self, objs, job, needFilename = True): + # check if the user has a project and has set the default post and + # output filename + postArgs = PathPreferences.defaultPostProcessorArgs() + if hasattr(job, "PostProcessorArgs") and job.PostProcessorArgs: + postArgs = job.PostProcessorArgs + elif hasattr(job, "PostProcessor") and job.PostProcessor: + postArgs = '' + + postname = self.resolvePostProcessor(job) + filename = '-' + if postname and needFilename: + filename = self.resolveFileName(job) + + if postname and filename: + print("post: %s(%s, %s)" % (postname, filename, postArgs)) + processor = PostProcessor.load(postname) + gcode = processor.export(objs, filename, postArgs) + return (False, gcode) + else: + return (True, '') + def Activated(self): FreeCAD.ActiveDocument.openTransaction( translate("Path_Post", "Post Process the Selected path(s)")) @@ -187,7 +209,7 @@ class CommandPathPost: else: job = jobs.pop() print("Job for selected objects = %s" % job.Name) - (fail, rc) = exportObjectsWith(selected, job) + (fail, rc) = self.exportObjectsWith(selected, job) if fail: FreeCAD.ActiveDocument.abortTransaction() @@ -195,27 +217,7 @@ class CommandPathPost: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() - def exportObjectsWith(self, objs, job, needFilename = True): - # check if the user has a project and has set the default post and - # output filename - postArgs = PathPreferences.defaultPostProcessorArgs() - if hasattr(job, "PostProcessorArgs") and job.PostProcessorArgs: - postArgs = job.PostProcessorArgs - elif hasattr(job, "PostProcessor") and job.PostProcessor: - postArgs = '' - postname = self.resolvePostProcessor(job) - filename = '-' - if postname and needFilename: - filename = self.resolveFileName(job) - - if postname and filename: - print("post: %s(%s, %s)" % (postname, filename, postArgs)) - processor = PostProcessor.load(postname) - gcode = processor.export(objs, filename, postArgs) - return (False, gcode) - else: - return (True, '') if FreeCAD.GuiUp: # register the FreeCAD command diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index 9c9304b61..ebb729ad2 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -26,6 +26,7 @@ #ifndef _PreComp_ # include #include +#include #endif #include @@ -35,6 +36,7 @@ #include #include + #include "DrawUtil.h" #include "DrawPage.h" #include "DrawProjGroupItem.h" @@ -65,13 +67,91 @@ DrawProjGroup::DrawProjGroup(void) ADD_PROPERTY_TYPE(spacingX, (15), agroup, App::Prop_None, "Horizontal spacing between views"); ADD_PROPERTY_TYPE(spacingY, (15), agroup, App::Prop_None, "Vertical spacing between views"); - ADD_PROPERTY(viewOrientationMatrix, (Base::Matrix4D())); } DrawProjGroup::~DrawProjGroup() { } +void DrawProjGroup::onChanged(const App::Property* prop) +{ + //TODO: For some reason, when the projection type is changed, the isometric views show change appropriately, but the orthographic ones dont... Or vice-versa. why would you change from 1st to 3rd in mid drawing? + //if group hasn't been added to page yet, can't scale or distribute projItems + TechDraw::DrawPage *page = getPage(); + if (!isRestoring() && page) { + if ( prop == &Views ) { + recompute(); + } else if (prop == &Scale) { + updateChildren(Scale.getValue()); + //resetPositions(); + distributeProjections(); + } else if (prop == &Source) { + App::DocumentObject* sourceObj = Source.getValue(); + if (sourceObj != nullptr) { + if (!hasAnchor()) { + addProjection("Front"); + } + } else { + //Source has been changed to null! Why? What to do? + } + } else if (prop == &ScaleType) { + recompute(); + } else if (prop == &AutoDistribute && + AutoDistribute.getValue()) { + resetPositions(); + recompute(); + } + } + TechDraw::DrawViewCollection::onChanged(prop); +} + +App::DocumentObjectExecReturn *DrawProjGroup::execute(void) +{ + //if group hasn't been added to page yet, can't scale or distribute projItems + TechDraw::DrawPage *page = getPage(); + if (!page) { + return DrawViewCollection::execute(); + } + + App::DocumentObject* docObj = Source.getValue(); + if (docObj == nullptr) { + return DrawViewCollection::execute(); + } + + docObj = Anchor.getValue(); //must have an anchor, so create one as soon as we have a Page and Source + if (docObj == nullptr) { + docObj = addProjection("Front"); + } + + double newScale = Scale.getValue(); + if (ScaleType.isValue("Automatic")) { + //Recalculate scale if Group is too big or too small! + if (!checkFit(page)) { + newScale = calculateAutomaticScale(); + if(std::abs(Scale.getValue() - newScale) > FLT_EPSILON) { + resetPositions(); + Scale.setValue(newScale); + } + } + } else if (ScaleType.isValue("Page")) { + newScale = page->Scale.getValue(); + if(std::abs(Scale.getValue() - newScale) > FLT_EPSILON) { + resetPositions(); + Scale.setValue(newScale); + } + } else if (ScaleType.isValue("Custom")) { + //don't have to do anything special + } + + // recalculate positions for children + if (Views.getSize()) { + updateChildren(newScale); + distributeProjections(); + } + + return DrawViewCollection::execute(); +} + short DrawProjGroup::mustExecute() const { short result = 0; @@ -169,7 +249,6 @@ QRectF DrawProjGroup::getRect() const //this is current rect, not potent arrangeViewPointers(viewPtrs); double width, height; minimumBbViews(viewPtrs, width, height); // w,h of just the views at 1:1 scale - //need to add spacingX,spacingY double xSpace = spacingX.getValue() * 3.0 * std::max(1.0,Scale.getValue()); double ySpace = spacingY.getValue() * 2.0 * std::max(1.0,Scale.getValue()); double rectW = Scale.getValue() * width + xSpace; //scale the 1:1 w,h and add whitespace @@ -200,28 +279,6 @@ void DrawProjGroup::minimumBbViews(DrawProjGroupItem *viewPtrs[10], height = row0h + row1h + row2h; } -void DrawProjGroup::onChanged(const App::Property* prop) -{ - //TODO: For some reason, when the projection type is changed, the isometric views show change appropriately, but the orthographic ones dont... Or vice-versa. - //if group hasn't been added to page yet, can't scale or distribute projItems - TechDraw::DrawPage *page = getPage(); - if (!isRestoring() && page) { - if ( prop == &Views ) { - recompute(); - } else if (prop == &Scale) { - updateChildren(Scale.getValue()); - //resetPositions(); - distributeProjections(); - } else if (prop == &ScaleType) { - recompute(); - } else if (prop == &AutoDistribute && - AutoDistribute.getValue()) { - resetPositions(); - recompute(); - } - } - TechDraw::DrawViewCollection::onChanged(prop); -} void DrawProjGroup::moveToCentre(void) { @@ -247,6 +304,14 @@ App::DocumentObject * DrawProjGroup::getProjObj(const char *viewProjType) const return 0; } +DrawProjGroupItem* DrawProjGroup::getProjItem(const char *viewProjType) const +{ + App::DocumentObject* docObj = getProjObj(viewProjType); + DrawProjGroupItem* result = static_cast(docObj); + return result; +} + + bool DrawProjGroup::checkViewProjType(const char *in) { if ( strcmp(in, "Front") == 0 || @@ -288,9 +353,6 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType) std::string FeatName = getDocument()->getUniqueObjectName("ProjItem"); auto docObj( getDocument()->addObject( "TechDraw::DrawProjGroupItem", //add to Document FeatName.c_str() ) ); - if( strcmp(viewProjType,"Front") == 0 ) { - Anchor.setValue(docObj); - } view = static_cast( docObj ); view->Source.setValue( Source.getValue() ); if (ScaleType.isValue("Automatic")) { @@ -301,7 +363,17 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType) view->Scale.setValue( Scale.getValue() ); view->Type.setValue( viewProjType ); view->Label.setValue( viewProjType ); - setViewOrientation( view, viewProjType ); + if( strcmp(viewProjType,"Front") == 0 ) { + + Anchor.setValue(docObj); + view->Direction.setValue(nameToStdDirection("Front")); //just (Base::Vector3d(0.0,-1.0,0.0)) + view->recomputeFeature(); + makeInitialMap(view); + //dumpMap(); + } else { + //dumpMap(); + view->Direction.setValue(m_viewDir[viewProjType]); + } addView(view); //from DrawViewCollection - add to ProjGroup Views moveToCentre(); @@ -351,44 +423,6 @@ int DrawProjGroup::purgeProjections() return Views.getValues().size(); } -void DrawProjGroup::setViewOrientation(DrawProjGroupItem *v, const char *projType) const -{ - Base::Vector3d dir; - - // Traditional orthographic - if(strcmp(projType, "Front") == 0) { - dir.Set(0, -1, 0); - } else if(strcmp(projType, "Rear") == 0) { - dir.Set(0, 1, 0); - } else if(strcmp(projType, "Right") == 0) { - dir.Set(1, 0, 0); - } else if(strcmp(projType, "Left") == 0) { - dir.Set(-1, 0, 0); - } else if(strcmp(projType, "Top") == 0) { - dir.Set(0, 0, 1); - } else if(strcmp(projType, "Bottom") == 0) { - dir.Set(0, 0, -1); - - // Isometric - } else if(strcmp(projType, "FrontTopLeft") == 0) { - dir.Set(-1,-1,1); - dir.Normalize(); - } else if(strcmp(projType, "FrontTopRight") == 0) { - dir.Set(1, -1, 1); - dir.Normalize(); - } else if(strcmp(projType, "FrontBottomRight") == 0) { - dir.Set(1, -1, -1); - dir.Normalize(); - } else if(strcmp(projType, "FrontBottomLeft") == 0) { - dir.Set(-1, -1, -1); - dir.Normalize(); - } else { - throw Base::Exception("Unknown view type in DrawProjGroup::setViewOrientation()"); - } - dir = viewOrientationMatrix.getValue() * dir; //multiply std dir by transform matrix - v->Direction.setValue(dir); -} - void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const { for (int i=0; i<10; ++i) { @@ -570,58 +604,7 @@ void DrawProjGroup::resetPositions(void) } } -//TODO: Turn this into a command so it can be issued from python -//????: this sets the orientation for all views, not just Front??? -void DrawProjGroup::setFrontViewOrientation(const Base::Matrix4D &newMat) -{ - viewOrientationMatrix.setValue(newMat); - for( auto it : Views.getValues() ) { - auto view( dynamic_cast(it) ); - if( view ) { - setViewOrientation(view, view->Type.getValueAsString()); - // TODO: Seems we should ensure that modifying the view triggers this automatically? IR - view->touch(); - } - } -} - -App::DocumentObjectExecReturn *DrawProjGroup::execute(void) -{ - //if group hasn't been added to page yet, can't scale or distribute projItems - TechDraw::DrawPage *page = getPage(); - if (!page) { - return DrawViewCollection::execute(); - } - - double newScale = Scale.getValue(); - if (ScaleType.isValue("Automatic")) { - //Recalculate scale if Group is too big or too small! - if (!checkFit(page)) { - newScale = calculateAutomaticScale(); - if(std::abs(Scale.getValue() - newScale) > FLT_EPSILON) { - resetPositions(); - Scale.setValue(newScale); - } - } - } else if (ScaleType.isValue("Page")) { - newScale = page->Scale.getValue(); - if(std::abs(Scale.getValue() - newScale) > FLT_EPSILON) { - resetPositions(); - Scale.setValue(newScale); - } - } else if (ScaleType.isValue("Custom")) { - //don't have to do anything special - } - - // recalculate positions for children - if (Views.getSize()) { - updateChildren(newScale); - //resetPositions(); - distributeProjections(); - } - return DrawViewCollection::execute(); -} void DrawProjGroup::updateChildren(double scale) { @@ -686,8 +669,277 @@ App::Enumeration DrawProjGroup::usedProjectionType(void) return ret; } +bool DrawProjGroup::hasAnchor(void) +{ + bool result = false; + App::DocumentObject* docObj = Anchor.getValue(); + if (docObj != nullptr) { + result = true; + } + return result; +} + + + +void DrawProjGroup::setAnchorDirection(const Base::Vector3d dir) +{ + App::DocumentObject* docObj = Anchor.getValue(); + DrawProjGroupItem* item = static_cast(docObj); + item->Direction.setValue(dir); +} + +Base::Vector3d DrawProjGroup::getAnchorDirection(void) +{ + Base::Vector3d result; + App::DocumentObject* docObj = Anchor.getValue(); + if (docObj != nullptr) { + DrawProjGroupItem* item = static_cast(docObj); + result = item->Direction.getValue(); + } else { + Base::Console().Log("ERROR - DPG::getAnchorDir - no Anchor!!\n"); + } + return result; +} + +//static +Base::Vector3d DrawProjGroup::nameToStdDirection(std::string name) +{ + Base::Vector3d result; + //name to standard view direction + std::map stdViews = { + { "Front", Base::Vector3d(0, -1, 0) }, + { "Rear", Base::Vector3d(0, 1, 0) }, + { "Right", Base::Vector3d(1, 0, 0) }, + { "Left", Base::Vector3d(-1, 0, 0) }, + { "Top", Base::Vector3d(0, 0, 1) }, + { "Bottom", Base::Vector3d(0, 0, -1) }, + { "FrontTopLeft", Base::Vector3d(-1,-1,1) }, + { "FrontTopRight", Base::Vector3d(1, -1, 1) }, + { "FrontBottomRight", Base::Vector3d(1, -1, -1) }, + { "FrontBottomLeft", Base::Vector3d(-1, -1, -1) } }; + auto it = stdViews.find(name); + if (it != stdViews.end()) { + result = (*it).second; + } + return result; +} + + +//************************************* +//* view direction manipulation routines +//************************************* + +//make map from anchor u,v,w +//std::map DrawProjGroup::makeInitialMap(TechDraw::DrawProjGroupItem* anchor) +void DrawProjGroup::makeInitialMap(TechDraw::DrawProjGroupItem* anchor) +{ + m_viewDir = makeUnspunMap(anchor->Direction.getValue(), + anchor->getUDir(), + anchor->getVDir() * -1); //the infamous flipped Y +} + +//! remake map from FRT +std::map DrawProjGroup::makeUnspunMap() +{ + return makeUnspunMap(m_viewDir["Front"], + m_viewDir["Right"], + m_viewDir["Top"]); +} + +//remake this everytime Anchor.Direction changes +std::map DrawProjGroup::makeUnspunMap(Base::Vector3d f, Base::Vector3d r, Base::Vector3d t) +{ + std::map viewDir; + viewDir["Front"] = f; + viewDir["Right"] = r; + viewDir["Top"] = t; + viewDir["Rear"] = viewDir["Front"] * -1.0; + viewDir["Left"] = viewDir["Right"] * -1.0; + viewDir["Bottom"] = viewDir["Top"] * -1.0; + viewDir["FrontTopRight"] = viewDir["Right"] + viewDir["Front"] + viewDir["Top"]; + viewDir["FrontTopLeft"] = viewDir["Left"] + viewDir["Front"] + viewDir["Top"]; + viewDir["FrontBottomRight"] = viewDir["Right"] + viewDir["Front"] + viewDir["Bottom"]; + viewDir["FrontBottomLeft"] = viewDir["Left"] + viewDir["Front"] + viewDir["Bottom"]; + return viewDir; +} + +void DrawProjGroup::dumpMap() +{ + Base::Console().Message("TRACE - DPG::dumpMap - entries: %d\n",m_viewDir.size()); + std::map::const_iterator it; + for (it = m_viewDir.begin(); it != m_viewDir.end(); it++) + { + Base::Console().Message("%s - %s\n",(it->first).c_str(), DrawUtil::formatVector(it->second).c_str()); + } +} + +void DrawProjGroup::updateSecondaryDirs() +{ + for (auto& docObj: Views.getValues()) { + Base::Vector3d newDir; + DrawProjGroupItem* v = static_cast(docObj); + ProjItemType t = static_cast(v->Type.getValue()); + switch (t) { + case Front : { + newDir = m_viewDir["Front"]; + break; + } + case Rear : { + newDir = m_viewDir["Rear"]; + break; + } + case Left : { + newDir = m_viewDir["Left"]; + break; + } + case Right : { + newDir = m_viewDir["Right"]; + break; + } + case Top : { + newDir = m_viewDir["Top"]; + break; + } + case Bottom : { + newDir = m_viewDir["Bottom"]; + break; + } + case FrontTopLeft : { + newDir = m_viewDir["FrontTopLeft"]; + break; + } + case FrontTopRight : { + newDir = m_viewDir["FrontTopRight"]; + break; + } + case FrontBottomLeft : { + newDir = m_viewDir["FrontBottomLeft"]; + break; + } + case FrontBottomRight : { + newDir = m_viewDir["FrontBottomRight"]; + break; + } + default: { + //TARFU invalid secondary type + Base::Console().Message("ERROR - DPG::updateSecondaryDirs - invalid projection type\n"); + newDir = v->Direction.getValue(); + } + } + v->Direction.setValue(newDir); + } +} + + +void DrawProjGroup::rotateRight() +{ +//Front -> Right -> Rear -> Left -> Front + Base::Vector3d f,r,t; + f = m_viewDir["Left"]; + r = m_viewDir["Front"]; + t = m_viewDir["Top"]; + m_viewDir = makeUnspunMap(f,r,t); + updateSecondaryDirs(); +} + +void DrawProjGroup::rotateLeft() +{ +//Front -> Left -> Rear -> Right -> Front + Base::Vector3d f,r,t; + f = m_viewDir["Right"]; + r = m_viewDir["Rear"]; + t = m_viewDir["Top"]; + m_viewDir = makeUnspunMap(f,r,t); + updateSecondaryDirs(); +} + +void DrawProjGroup::rotateUp() +{ +//Front -> Top -> Rear -> Bottom -> Front + Base::Vector3d f,r,t; + f = m_viewDir["Bottom"]; + r = m_viewDir["Right"]; + t = m_viewDir["Front"]; + m_viewDir = makeUnspunMap(f,r,t); + updateSecondaryDirs(); +} + +void DrawProjGroup::rotateDown() +{ +//Front -> Bottom -> Rear -> Top -> Front + Base::Vector3d f,r,t; + f = m_viewDir["Top"]; + r = m_viewDir["Right"]; + t = m_viewDir["Rear"]; + m_viewDir = makeUnspunMap(f,r,t); + updateSecondaryDirs(); +} + +void DrawProjGroup::spinCW() +{ +//Top -> Right -> Bottom -> Left -> Top + Base::Vector3d f,r,t; + f = m_viewDir["Front"]; + t = m_viewDir["Left"]; + r = m_viewDir["Top"]; + m_viewDir = makeUnspunMap(f,r,t); + updateSecondaryDirs(); +} + +void DrawProjGroup::spinCCW() +{ +//Top -> Left -> Bottom -> Right -> Top + Base::Vector3d f,r,t; + f = m_viewDir["Front"]; + t = m_viewDir["Right"]; + r = m_viewDir["Bottom"]; + m_viewDir = makeUnspunMap(f,r,t); + updateSecondaryDirs(); +} + +//************************************* + +//! rebuild view direction map from existing DPGI's if possible or from Anchor void DrawProjGroup::onDocumentRestored() { + Base::Vector3d f,r,t; + bool ffound = false; + bool rfound = false; + bool tfound = false; + + for (auto& docObj: Views.getValues()) { + DrawProjGroupItem* v = static_cast(docObj); + ProjItemType type = static_cast(v->Type.getValue()); + switch (type) { + case Front : { + f = v->Direction.getValue(); + ffound = true; + break; + } + case Right : { + r = v->Direction.getValue(); + rfound = true; + break; + } + case Top : { + t = v->Direction.getValue(); + tfound = true; + break; + } + default: { + break; + } + } + } + if (ffound && rfound && tfound) { + m_viewDir = makeUnspunMap(f,r,t); + } else { + App::DocumentObject* docObj = Anchor.getValue(); + TechDraw::DrawProjGroupItem* view = static_cast( docObj ); + makeInitialMap(view); + Base::Console().Log("LOG: - DPG::restore - making map from Anchor\n"); + } + //dumpMap(); DrawViewCollection::onDocumentRestored(); } diff --git a/src/Mod/TechDraw/App/DrawProjGroup.h b/src/Mod/TechDraw/App/DrawProjGroup.h index b84164fa2..2cd2b7299 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.h +++ b/src/Mod/TechDraw/App/DrawProjGroup.h @@ -23,12 +23,14 @@ #ifndef _TECHDRAW_FEATUREVIEWGROUP_H_ #define _TECHDRAW_FEATUREVIEWGROUP_H_ +#include # include #include #include #include #include +#include #include "DrawViewCollection.h" @@ -58,9 +60,6 @@ public: /// Default vertical spacing between adjacent views on Drawing, in mm App::PropertyFloat spacingY; - /// Transforms Direction and XAxisDirection vectors in child views - App::PropertyMatrix viewOrientationMatrix; - App::PropertyLink Anchor; /// Anchor Element to align views to Base::BoundBox3d getBoundingBox() const; @@ -71,6 +70,7 @@ public: bool hasProjection(const char *viewProjType) const; App::DocumentObject * getProjObj(const char *viewProjType) const; + DrawProjGroupItem* getProjItem(const char *viewProjType) const; //! Adds a projection to the group /*! @@ -88,11 +88,6 @@ public: /// Automatically position child views bool distributeProjections(void); void resetPositions(void); - /// Changes child views' coordinate space - /*! - * Used to set the Direction and XAxisDirection in child views - */ - void setFrontViewOrientation(const Base::Matrix4D &newMat); short mustExecute() const; /** @name methods overide Feature */ @@ -115,29 +110,25 @@ public: /// Allowed projection types - either Document, First Angle or Third Angle static const char* ProjectionTypeEnums[]; - /// Sets Direction in v - /*! - * Applies viewOrientationMatrix to appropriate unit vectors depending on projType - */ - void setViewOrientation(DrawProjGroupItem *v, const char *projType) const; - /// Populates an array of DrawProjGroupItem*s arranged for drawing - /*! - * Setup array of pointers to the views that we're displaying, - * assuming front is in centre (index 4): - *
-     * [0]  [1]  [2]
-     * [3]  [4]  [5]  [6]
-     * [7]  [8]  [9]
-     *
-     * Third Angle:  FTL  T  FTRight
-     *                L   F   Right   Rear
-     *               FBL  B  FBRight
-     *
-     * First Angle:  FBRight  B  FBL
-     *                Right   F   L  Rear
-     *               FTRight  T  FTL
-     * 
- */ + bool hasAnchor(void); + void setAnchorDirection(Base::Vector3d dir); + Base::Vector3d getAnchorDirection(void); + + void makeInitialMap(TechDraw::DrawProjGroupItem* anchor); + std::map makeUnspunMap(Base::Vector3d f, Base::Vector3d r, Base::Vector3d t); + std::map makeUnspunMap(void); + void dumpMap(); + void updateSecondaryDirs(); + + void rotateRight(void); + void rotateLeft(void); + void rotateUp(void); + void rotateDown(void); + void spinCW(void); + void spinCCW(void); + + static Base::Vector3d nameToStdDirection(std::string name); + protected: void onChanged(const App::Property* prop); @@ -174,6 +165,8 @@ protected: /// Returns pointer to our page, or NULL if it couldn't be located TechDraw::DrawPage * getPage(void) const; void updateChildren(double scale); + + std::map m_viewDir; }; diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index b03cb97aa..0d24934dc 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -34,6 +34,7 @@ #include // generated from DrawProjGroupItemPy.xml + using namespace TechDraw; const char* DrawProjGroupItem::TypeEnums[] = {"Front", diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.h b/src/Mod/TechDraw/App/DrawProjGroupItem.h index c6f6885bd..79be59c05 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.h +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.h @@ -30,6 +30,18 @@ namespace TechDraw { + +enum ProjItemType{ Front, + Left, + Right, + Rear, + Top, + Bottom, + FrontTopLeft, + FrontTopRight, + FrontBottomLeft, + FrontBottomRight }; + class DrawProjGroup; class TechDrawExport DrawProjGroupItem : public TechDraw::DrawViewPart diff --git a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp index cb016fdde..0100bf27c 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp @@ -71,6 +71,7 @@ PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args) return new DrawProjGroupItemPy(newProj); } +//TODO: this is no longer required? PyObject* DrawProjGroupPy::setViewOrientation(PyObject* args) { const char* projType; @@ -78,15 +79,15 @@ PyObject* DrawProjGroupPy::setViewOrientation(PyObject* args) if (!PyArg_ParseTuple(args, "Os", &pcObj,&projType)) throw Py::Exception(); - App::DocumentObject* obj = static_cast(pcObj)->getDocumentObjectPtr(); - if (obj->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { - TechDraw::DrawProjGroupItem* view = static_cast(obj); - TechDraw::DrawProjGroup* projGroup = getDrawProjGroupPtr(); - projGroup->setViewOrientation( view, projType ); +// App::DocumentObject* obj = static_cast(pcObj)->getDocumentObjectPtr(); +// if (obj->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { +// TechDraw::DrawProjGroupItem* view = static_cast(obj); +// TechDraw::DrawProjGroup* projGroup = getDrawProjGroupPtr(); +// projGroup->setViewOrientation( view, projType ); - } else { - Base::Console().Message("'%s' is not a DrawProjGroup Item, it will be ignored.\n", obj->Label.getValue()); - } +// } else { +// Base::Console().Message("'%s' is not a DrawProjGroup Item, it will be ignored.\n", obj->Label.getValue()); +// } return Py_None; } diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index a1b32abab..983f99b99 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -103,7 +103,6 @@ DrawViewDetail::DrawViewDetail() ADD_PROPERTY_TYPE(Reference ,("1"),dgroup,App::Prop_None,"An identifier for this detail"); getParameters(); - } DrawViewDetail::~DrawViewDetail() @@ -235,7 +234,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) gp_Pnt inputCenter; try { - inputCenter = TechDrawGeometry::findCentroid(detail, + inputCenter = TechDrawGeometry::findCentroid(tool, Direction.getValue()); TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(detail, inputCenter, diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 60a2b1060..557e590db 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -143,6 +143,7 @@ DrawViewPart::~DrawViewPart() App::DocumentObjectExecReturn *DrawViewPart::execute(void) { + //Base::Console().Message("TRACE - DVP::execute() - %s\n",getNameInDocument()); App::DocumentObject *link = Source.getValue(); if (!link) { return new App::DocumentObjectExecReturn("FVP - No Source object linked"); diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 21bf0aa14..da9595cd3 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -74,6 +74,7 @@ #include "Geometry.h" #include "GeometryObject.h" #include "EdgeWalker.h" +#include "DrawUtil.h" #include "DrawProjectSplit.h" #include "DrawViewSection.h" @@ -449,6 +450,50 @@ bool DrawViewSection::isReallyInBox (const Base::Vector3d v, const Base::BoundBo return true; } +//! calculate the section Normal/Projection Direction given baseView projection direction and section name +/*static*/ +Base::Vector3d DrawViewSection::getSectionVector (const Base::Vector3d baseViewDir, const std::string sectionName) +{ + Base::Vector3d result; + 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 = baseViewDir; + view.Normalize(); + Base::Vector3d left = view.Cross(stdZ); + left.Normalize(); //redundent? + Base::Vector3d down = view.Cross(left); + down.Normalize(); //redundent? + double dot = view.Dot(stdZ); + + if (sectionName == "Up") { + result = down; + if (DrawUtil::fpCompare(fabs(dot),1.0)) { + result = (-1.0 * stdY); + } + } else if (sectionName == "Down") { + result = down * -1.0; + if (DrawUtil::fpCompare(fabs(dot),1.0)) { + result = stdY; + } + } else if (sectionName == "Left") { + result = left * -1.0; + if (DrawUtil::fpCompare(fabs(dot),1.0)) { + result = stdX; + } + } else if (sectionName == "Right") { + result = left; + if (DrawUtil::fpCompare(fabs(dot),1.0)) { + result = -1.0 * stdX; + } + } else { + Base::Console().Log("Error - DVS::getSectionVector - bad sectionName: %s\n",sectionName.c_str()); + result = stdZ; + } + + return result; +} + void DrawViewSection::getParameters() { Base::Reference hGrp = App::GetApplication().GetUserParameter() diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 9f60ba1ec..cc1afe8fd 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -84,6 +84,8 @@ public: public: std::vector getFaceGeometry(); + static Base::Vector3d getSectionVector (const Base::Vector3d baseViewDir, const std::string sectionName); + static const char* SectionDirEnums[]; protected: diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index d7c03ffe3..e970bcd9d 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -481,16 +481,17 @@ void CmdTechDrawProjGroup::activated(int iMsg) std::string multiViewName = getUniqueObjectName("cView"); std::string SourceName = (*shapes.begin())->getNameInDocument(); doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawProjGroup','%s')",multiViewName.c_str()); + doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str()); doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",multiViewName.c_str(),SourceName.c_str()); App::DocumentObject *docObj = getDocument()->getObject(multiViewName.c_str()); auto multiView( static_cast(docObj) ); // set the anchor - std::string anchor = "Front"; - doCommand(Doc,"App.activeDocument().%s.addProjection('%s')",multiViewName.c_str(),anchor.c_str()); +// std::string anchor = "Front"; +// doCommand(Doc,"App.activeDocument().%s.addProjection('%s')",multiViewName.c_str(),anchor.c_str()); // add the multiView to the page - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str()); +// doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str()); // create the rest of the desired views Gui::Control().showDialog(new TaskDlgProjGroup(multiView,true)); diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index 545c8f988..741989f81 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -180,19 +180,6 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget* MDIViewPage::~MDIViewPage() { - // Safely remove graphicview items that have built up TEMP SOLUTION - for(auto it : deleteItems) { - auto qObjPtr( dynamic_cast(it) ); - if (qObjPtr) { - qObjPtr->deleteLater(); - } else { - delete it; - } - } - deleteItems.clear(); - - //m_view will be deleted by MDIViewPage as a Qt child - //delete m_view; } @@ -403,7 +390,6 @@ void MDIViewPage::updateDrawing(bool forceUpdate) Base::Console().Log("ERROR - MDIViewPage::updateDrawing - %s already removed from QGraphicsScene\n", (*itGraphics)->getViewName()); } - deleteItems.append(*itGraphics); // delete in the destructor when completly safe. TEMP SOLUTION } itGraphics++; } diff --git a/src/Mod/TechDraw/Gui/QGIMatting.cpp b/src/Mod/TechDraw/Gui/QGIMatting.cpp index f6dd69799..d6502b31d 100644 --- a/src/Mod/TechDraw/Gui/QGIMatting.cpp +++ b/src/Mod/TechDraw/Gui/QGIMatting.cpp @@ -23,9 +23,6 @@ #include "PreCompiled.h" #ifndef _PreComp_ #include -//#include -//#include -//#include #include #include #endif @@ -55,16 +52,18 @@ QGIMatting::QGIMatting() : setFlag(QGraphicsItem::ItemIsSelectable, false); setFlag(QGraphicsItem::ItemIsMovable, false); - m_mat = new QGraphicsPathItem(); //QGIPrimPath?? + m_mat = new QGraphicsPathItem(); addToGroup(m_mat); m_border = new QGraphicsPathItem(); addToGroup(m_border); m_pen.setColor(Qt::white); - m_brush.setColor(Qt::white); - m_brush.setStyle(Qt::SolidPattern); // m_pen.setColor(Qt::black); // m_pen.setStyle(Qt::DashLine); + m_brush.setColor(Qt::white); +// m_brush.setColor(Qt::black); + m_brush.setStyle(Qt::SolidPattern); +// m_brush.setStyle(Qt::CrossPattern); // m_brush.setStyle(Qt::NoBrush); m_penB.setColor(Qt::black); m_brushB.setStyle(Qt::NoBrush); @@ -77,29 +76,14 @@ QGIMatting::QGIMatting() : setZValue(ZVALUE::MATTING); } -void QGIMatting::centerAt(QPointF centerPos) -{ - QRectF box = boundingRect(); - double width = box.width(); - double height = box.height(); - double newX = centerPos.x() - width/2.; - double newY = centerPos.y() - height/2.; - setPos(newX,newY); -} - -void QGIMatting::centerAt(double cX, double cY) -{ - QRectF box = boundingRect(); - double width = box.width(); - double height = box.height(); - double newX = cX - width/2.; - double newY = cY - height/2.; - setPos(newX,newY); -} - void QGIMatting::draw() { - QRectF outline(-m_width/2.0,-m_height/2.0,m_width,m_height); + prepareGeometryChange(); + double radiusFudge = 1.15; //keep slightly larger than fudge in App/DVDetail to prevent bleed through + double outerRadius = m_radius * radiusFudge; + m_width = outerRadius; + m_height = outerRadius; + QRectF outline(-m_width,-m_height,2.0 * m_width,2.0 * m_height); QPainterPath ppOut; ppOut.addRect(outline); QPainterPath ppCut; @@ -107,13 +91,15 @@ void QGIMatting::draw() QRectF roundCutout (-m_radius,-m_radius,2.0 * m_radius,2.0 * m_radius); ppCut.addEllipse(roundCutout); } else { - double squareSize = m_radius / 1.4142; //fit within radius + double squareSize = m_radius/ 1.4142; //fit just within radius QRectF squareCutout (-squareSize,-squareSize,2.0 * squareSize,2.0 * squareSize); ppCut.addRect(squareCutout); } ppOut.addPath(ppCut); m_mat->setPath(ppOut); m_border->setPath(ppCut); + m_mat->setZValue(ZVALUE::MATTING); + m_border->setZValue(ZVALUE::MATTING); } int QGIMatting::getHoleStyle() @@ -124,9 +110,19 @@ int QGIMatting::getHoleStyle() return style; } +//need this because QQGIG only updates BR when items added/deleted. +QRectF QGIMatting::boundingRect() const +{ + QRectF result ; + result = childrenBoundingRect().adjusted(-1,-1,1,1); + return result; +} + void QGIMatting::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { QStyleOptionGraphicsItem myOption(*option); myOption.state &= ~QStyle::State_Selected; + //painter->drawRect(boundingRect().adjusted(-2.0,-2.0,2.0,2.0)); + QGraphicsItemGroup::paint (painter, &myOption, widget); } diff --git a/src/Mod/TechDraw/Gui/QGIMatting.h b/src/Mod/TechDraw/Gui/QGIMatting.h index 054b5eaa5..e24ec978b 100644 --- a/src/Mod/TechDraw/Gui/QGIMatting.h +++ b/src/Mod/TechDraw/Gui/QGIMatting.h @@ -49,8 +49,7 @@ public: int type() const { return Type;} virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ); - virtual void centerAt(QPointF centerPos); - virtual void centerAt(double cX, double cY); + virtual QRectF boundingRect() const; virtual void setSize(double w, double h) {m_height = h; m_width = w;} //virtual void setHoleStyle(int hs) {m_holeStyle = hs;} diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index a92f46e57..e5915fe11 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -329,6 +329,7 @@ void QGIView::drawCaption() QRectF displayArea = customChildrenBoundingRect(); m_caption->setDefaultTextColor(m_colCurrent); m_font.setFamily(getPrefFont()); + m_font.setPointSize(getPrefFontSize()); //scene units (mm), not points m_caption->setFont(m_font); QString captionStr = QString::fromUtf8(getViewObject()->Caption.getValue()); m_caption->setPlainText(captionStr); @@ -361,6 +362,7 @@ void QGIView::drawBorder() m_label->setDefaultTextColor(m_colCurrent); m_font.setFamily(getPrefFont()); + m_font.setPointSize(getPrefFontSize()); //scene units (mm), not points m_label->setFont(m_font); QString labelStr = QString::fromUtf8(getViewObject()->Label.getValue()); m_label->setPlainText(labelStr); diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 974f6eb1e..4e49dc45a 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -310,8 +310,8 @@ void QGIViewPart::updateView(bool update) void QGIViewPart::draw() { drawViewPart(); - drawBorder(); drawMatting(); + drawBorder(); } void QGIViewPart::drawViewPart() @@ -492,6 +492,9 @@ void QGIViewPart::removeDecorations() QGIDecoration* decor = dynamic_cast(c); QGIMatting* mat = dynamic_cast(c); if (decor) { + removeFromGroup(decor); + scene()->removeItem(decor); + delete decor; } else if (mat) { removeFromGroup(mat); scene()->removeItem(mat); @@ -622,11 +625,8 @@ void QGIViewPart::drawMatting() double radius = dvd->Radius.getValue() * scale; QGIMatting* mat = new QGIMatting(); addToGroup(mat); - mat->setPos(0.0,0.0); mat->setRadius(radius); - QRectF displayArea = customChildrenBoundingRect(); - mat->setSize(displayArea.width(),displayArea.height()); - //mat->setHoleStyle(dvd->getMattingStyle()); + mat->setPos(0.0,0.0); mat->draw(); mat->show(); } diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index 685d8b3e7..d5f2fe60f 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -53,5 +53,11 @@ icons/actions/section-down.svg icons/actions/section-left.svg icons/actions/section-right.svg + icons/arrow-right.svg + icons/arrow-left.svg + icons/arrow-up.svg + icons/arrow-down.svg + icons/arrow-ccw.svg + icons/arrow-cw.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/arrow-ccw.svg b/src/Mod/TechDraw/Gui/Resources/icons/arrow-ccw.svg new file mode 100644 index 000000000..71f10ca01 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/arrow-ccw.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/arrow-cw.svg b/src/Mod/TechDraw/Gui/Resources/icons/arrow-cw.svg new file mode 100644 index 000000000..4cbb4fc6b --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/arrow-cw.svg @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/arrow-down.svg b/src/Mod/TechDraw/Gui/Resources/icons/arrow-down.svg new file mode 100644 index 000000000..db50c3031 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/arrow-down.svg @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/arrow-left.svg b/src/Mod/TechDraw/Gui/Resources/icons/arrow-left.svg new file mode 100644 index 000000000..cf3c6e933 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/arrow-left.svg @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/arrow-right.svg b/src/Mod/TechDraw/Gui/Resources/icons/arrow-right.svg new file mode 100644 index 000000000..c5d0c6d74 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/arrow-right.svg @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/arrow-up.svg b/src/Mod/TechDraw/Gui/Resources/icons/arrow-up.svg new file mode 100644 index 000000000..4c975cc7a --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/arrow-up.svg @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index 9fd34ebe5..dd74658a4 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -34,10 +34,15 @@ #include #include #include +#include +#include + +#include #include #include +#include #include #include @@ -51,6 +56,7 @@ #include using namespace Gui; +using namespace TechDraw; using namespace TechDrawGui; //TODO: Look into this, seems we might be able to delete it now? IR @@ -89,6 +95,11 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : connect(ui->butLeftRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); connect(ui->butCCWRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); + //3D button + connect(ui->but3D, SIGNAL(clicked()), this, SLOT(on3DClicked(void))); + //Reset button + connect(ui->butReset, SIGNAL(clicked()), this, SLOT(onResetClicked(void))); + // Slot for Scale Type connect(ui->cmbScaleType, SIGNAL(currentIndexChanged(int)), this, SLOT(scaleTypeChanged(int))); connect(ui->sbScaleNum, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int))); @@ -102,6 +113,8 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : Gui::ViewProvider* vp = activeGui->getViewProvider(m_page); ViewProviderPage* dvp = dynamic_cast(vp); m_mdi = dvp->getMDIViewPage(); + + setUiPrimary(); } TaskProjGroup::~TaskProjGroup() @@ -142,31 +155,50 @@ void TaskProjGroup::rotateButtonClicked(void) if ( multiView && ui ) { const QObject *clicked = sender(); - // Any translation/scale/etc applied here will be ignored, as - // DrawProjGroup::setFrontViewOrientation() only - // uses it to set Direction and XAxisDirection. - Base::Matrix4D m = multiView->viewOrientationMatrix.getValue(); - // TODO: Construct these directly - Base::Matrix4D t; - - //TODO: Consider changing the vectors around depending on whether we're in First or Third angle mode - might be more intuitive? IR - if ( clicked == ui->butTopRotate ) { - t.rotX(M_PI / -2); - } else if ( clicked == ui->butCWRotate ) { - t.rotY(M_PI / -2); - } else if ( clicked == ui->butRightRotate) { - t.rotZ(M_PI / 2); + if ( clicked == ui->butTopRotate ) { //change Front View Dir by 90 + multiView->rotateUp(); } else if ( clicked == ui->butDownRotate) { - t.rotX(M_PI / 2); + multiView->rotateDown(); + } else if ( clicked == ui->butRightRotate) { + multiView->rotateRight(); } else if ( clicked == ui->butLeftRotate) { - t.rotZ(M_PI / -2); + multiView->rotateLeft(); + } else if ( clicked == ui->butCWRotate ) { //doesn't change Anchor view dir. changes projType of secondaries, not dir + multiView->spinCW(); } else if ( clicked == ui->butCCWRotate) { - t.rotY(M_PI / 2); + multiView->spinCCW(); } - m *= t; + setUiPrimary(); + Gui::Command::updateActive(); + } +} - multiView->setFrontViewOrientation(m); +void TaskProjGroup::on3DClicked(void) +{ + Base::Vector3d dir3D = get3DViewDir(); + TechDraw::DrawProjGroupItem* front = multiView->getProjItem("Front"); + if (front) { + front->Direction.setValue(dir3D); + front->recomputeFeature(); + setUiPrimary(); + multiView->makeInitialMap(front); + multiView->updateSecondaryDirs(); + Gui::Command::updateActive(); + } +} + +void TaskProjGroup::onResetClicked(void) +{ + Base::Vector3d dir = multiView->nameToStdDirection("Front"); + TechDraw::DrawProjGroupItem* front = multiView->getProjItem("Front"); + if (front) { + front->Direction.setValue(dir); + front->recomputeFeature(); + setUiPrimary(); + multiView->makeInitialMap(front); + multiView->updateSecondaryDirs(); + multiView->dumpMap(); Gui::Command::updateActive(); } } @@ -375,8 +407,51 @@ void TaskProjGroup::setupViewCheckboxes(bool addConnections) } } +void TaskProjGroup::setUiPrimary() +{ + Base::Vector3d frontDir = multiView->getAnchorDirection(); + ui->lePrimary->setText(formatVector(frontDir)); +} + +Base::Vector3d TaskProjGroup::get3DViewDir() +{ + Base::Vector3d viewDir(0.0,-1.0,0.0); //default to front + std::list mdis = Gui::Application::Instance->activeDocument()->getMDIViews(); + Gui::View3DInventor *view; + Gui::View3DInventorViewer *viewer; + for (auto& m: mdis) { //find the 3D viewer + view = dynamic_cast(m); + if (view) { + viewer = view->getViewer(); + break; + } + } + if (!viewer) { + Base::Console().Log("LOG - TaskProjGroup could not find a 3D viewer\n"); + return viewDir; + } + + SbVec3f dvec = viewer->getViewDirection(); + viewDir = Base::Vector3d(dvec[0], dvec[1], dvec[2]); + viewDir = viewDir * -1; //Inventor coords are opposite projection direction coords + return viewDir; +} + + +QString TaskProjGroup::formatVector(Base::Vector3d v) +{ + QString data = QString::fromLatin1("[%1 %2 %3]") + .arg(QLocale::system().toString(v.x, 'f', 2)) + .arg(QLocale::system().toString(v.y, 'f', 2)) + .arg(QLocale::system().toString(v.z, 'f', 2)); + return data; +} + bool TaskProjGroup::accept() { + Gui::Document* doc = Gui::Application::Instance->getDocument(multiView->getDocument()); + if (!doc) return false; + Gui::Command::commitCommand(); Gui::Command::updateActive(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); @@ -386,6 +461,9 @@ bool TaskProjGroup::accept() bool TaskProjGroup::reject() { + Gui::Document* doc = Gui::Application::Instance->getDocument(multiView->getDocument()); + if (!doc) return false; + if (getCreateMode()) { std::string multiViewName = multiView->getNameInDocument(); std::string PageName = multiView->findParentPage()->getNameInDocument(); diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.h b/src/Mod/TechDraw/Gui/TaskProjGroup.h index b1a5cbd59..1ea902590 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.h +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.h @@ -24,7 +24,10 @@ #ifndef GUI_TASKVIEW_TASKVIEWGROUP_H #define GUI_TASKVIEW_TASKVIEWGROUP_H +#include + #include +#include #include #include @@ -72,6 +75,9 @@ protected Q_SLOTS: /// Requests appropriate rotation of our DrawProjGroup void rotateButtonClicked(void); + void on3DClicked(void); + void onResetClicked(void); + void projectionTypeChanged(int index); void scaleTypeChanged(int index); void scaleManuallyChanged(int i); @@ -85,6 +91,9 @@ protected: * between checkboxes and viewToggled() */ void setupViewCheckboxes(bool addConnections = false); + Base::Vector3d get3DViewDir(void); + void setUiPrimary(void); + QString formatVector(Base::Vector3d v); private: //class Private; diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.ui b/src/Mod/TechDraw/Gui/TaskProjGroup.ui index df5d062b6..beebff70e 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.ui +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.ui @@ -6,8 +6,8 @@ 0 0 - 342 - 431 + 371 + 491 @@ -57,6 +57,9 @@ + + First or Third Angle + false @@ -90,6 +93,9 @@ + + Scale Page/Auto/Custom + Page @@ -133,6 +139,9 @@ + + Scale Numerator + 1 @@ -150,6 +159,9 @@ + + Scale Denominator + 1 @@ -174,90 +186,179 @@ + + + 0 + 0 + + - View From + Adjust Primary Direction + + + true - Qt::AlignBottom|Qt::AlignHCenter + Qt::AlignCenter + + + 0 - - - - - About 3D Y + + + + + true - - Spin CW + + + 11 + 50 + false + false + + + + Qt::NoFocus + + + Primary View Direction + + + Qt::AlignCenter + + + true - + - About 3D Z + Rotate right - > + + + + + :/icons/arrow-right.svg + + + + + 24 + 24 + - - - - About 3D Y - - - Spin CCW - - - - + + + + 0 + 0 + + - About 3D X + Rotate up - /\ + + + + + :/icons/arrow-up.svg + + + + + 24 + 24 + - - + + + + Rotate left + + + + + + + :/icons/arrow-left.svg + + + + + 24 + 24 + + + + + + - false + true + + + Set Primary Direction to match 3D Match 3D - - + + - About 3D Y + Rotate down - < + + + + + :/icons/arrow-down.svg + + + + + 24 + 24 + - - + + - About 3D X + Set Primary Direction to 3D Front - \/ + 3D Front + + + + Qt::Horizontal + + + @@ -265,6 +366,9 @@ Secondary Projections + + Qt::AlignCenter + @@ -276,6 +380,16 @@ true + + Bottom + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -299,6 +413,16 @@ false + + Primary + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -309,6 +433,16 @@ + + Right + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -329,6 +463,16 @@ + + Left + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -336,6 +480,16 @@ + + LeftFrontBottom + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -343,6 +497,16 @@ + + Top + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -350,6 +514,16 @@ + + RightFrontBottom + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -357,6 +531,16 @@ + + RightFrontTop + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -364,6 +548,16 @@ + + Rear + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + @@ -371,20 +565,111 @@ + + LeftFrontTop + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + 24 + 24 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Spin CW + + + + + + + :/icons/arrow-cw.svg + + + + + + + + Spin CCW + + + + + + + :/icons/arrow-ccw.svg + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - + + + diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index 3c3e72578..c29d26be4 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -43,11 +43,13 @@ #include #include +#include #include "TaskSectionView.h" #include using namespace Gui; +using namespace TechDraw; using namespace TechDrawGui; void _printVect(char* label, Base::Vector3d v); @@ -119,61 +121,26 @@ void TaskSectionView::resetValues() bool TaskSectionView::calcValues() { bool result = true; - 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); - } + sectionProjDir = DrawViewSection::getSectionVector(view,sectionDir); } 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; - } + sectionProjDir = DrawViewSection::getSectionVector(view,sectionDir); } 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; - } + sectionProjDir = DrawViewSection::getSectionVector(view,sectionDir); } else if (ui->pb_Right->isChecked()) { sectionDir = "Right"; - 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; - } + sectionProjDir = DrawViewSection::getSectionVector(view,sectionDir); } else { Base::Console().Message("Select a direction\n"); result = false; } + sectionNormal = sectionProjDir; if (result) { ui->leNormal->setText(formatVector(sectionNormal)); ui->leProjDir->setText(formatVector(sectionProjDir)); diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewSection.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewSection.cpp index 4b14e2ea0..6b73f0ab7 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewSection.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewSection.cpp @@ -76,7 +76,6 @@ std::vector ViewProviderViewSection::getDisplayModes(void) const void ViewProviderViewSection::updateData(const App::Property* prop) { - Base::Console().Log("ViewProviderViewSection::updateData - Update View: %s\n",prop->getName()); if (prop == &(getViewObject()->ShowCutSurface) || prop == &(getViewObject()->CutSurfaceColor) ) { // redraw QGIVP diff --git a/src/Mod/Test/Document.py b/src/Mod/Test/Document.py index 8f1465dbc..ed49486df 100644 --- a/src/Mod/Test/Document.py +++ b/src/Mod/Test/Document.py @@ -234,7 +234,29 @@ class DocumentBasicCases(unittest.TestCase): self.Doc.removeObject(obj.Name) del obj + def testExtensionBugViewProvider(self): + class Layer(): + def __init__(self, obj): + obj.addExtension("App::GroupExtensionPython", self) + + class LayerViewProvider(): + def __init__(self, obj): + obj.addExtension("Gui::ViewProviderGroupExtensionPython", self) + obj.Proxy = self + + obj = self.Doc.addObject("App::FeaturePython","Layer") + Layer(obj) + self.failUnless(obj.hasExtension("App::GroupExtension")) + + if FreeCAD.GuiUp: + LayerViewProvider(obj.ViewObject) + self.failUnless(obj.ViewObject.hasExtension("Gui::ViewProviderGroupExtension")) + self.failUnless(obj.ViewObject.hasExtension("Gui::ViewProviderGroupExtensionPython")) + + self.Doc.removeObject(obj.Name) + del obj + def tearDown(self): #closing doc FreeCAD.closeDocument("CreateTest")