/*************************************************************************** * Copyright (c) 2017 WandererFan * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #ifndef TechDraw_DrawGeomHatch_h_ #define TechDraw_DrawGeomHatch_h_ #include #include #include #include #include "HatchLine.h" class TopoDS_Edge; class TopoDS_Face; class Bnd_Box; namespace TechDraw { class BaseGeom; } namespace TechDraw { class DrawViewPart; class DrawViewSection; class PATLineSpec; class LineSet; class DashSet; class TechDrawExport DrawGeomHatch : public App::DocumentObject { PROPERTY_HEADER_WITH_OVERRIDE(TechDraw::DrawGeomHatch); public: DrawGeomHatch(); ~DrawGeomHatch() override = default; App::PropertyLinkSub Source; //the dvX & face(s) this crosshatch belongs to App::PropertyFile FilePattern; App::PropertyFileIncluded PatIncluded; App::PropertyString NamePattern; App::PropertyFloatConstraint ScalePattern; App::PropertyFloat PatternRotation; App::PropertyVector PatternOffset; App::DocumentObjectExecReturn *execute() override; void onChanged(const App::Property* prop) override; const char* getViewProviderName() const override { return "TechDrawGui::ViewProviderGeomHatch"; } PyObject *getPyObject() override; void setupObject() override; void unsetupObject() override; void onDocumentRestored() override; DrawViewPart* getSourceView() const; std::vector getFaceOverlay(int iFace = 0); std::vector getTrimmedLines(int iFace = 0); static std::vector getTrimmedLines(DrawViewPart* dvp, std::vector lineSets, int iface, double scale, double hatchRotation = 0.0, Base::Vector3d hatchOffset = Base::Vector3d(0.0, 0.0, 0.0)); static std::vector getTrimmedLines(DrawViewPart* source, std::vector lineSets, TopoDS_Face face, double scale , double hatchRotation = 0.0, Base::Vector3d hatchOffset = Base::Vector3d(0.0, 0.0, 0.0)); static std::vector getTrimmedLinesSection(DrawViewSection* source, std::vector lineSets, TopoDS_Face face, double scale , double hatchRotation = 0.0, Base::Vector3d hatchOffset = Base::Vector3d(0.0, 0.0, 0.0)); static std::vector makeEdgeOverlay(PATLineSpec hatchLine, Bnd_Box bBox, double scale, double rotation); static TopoDS_Edge makeLine(const Base::Vector3d& start, const Base::Vector3d& end); static std::vector getDecodedSpecsFromFile(std::string fileSpec, std::string myPattern); static TopoDS_Face extractFace(DrawViewPart* source, int iface ); static std::string prefGeomHatchFile(); static std::string prefGeomHatchName(); static Base::Color prefGeomHatchColor(); static std::vector makeLineSets(std::string fileSpec, std::string myPattern); void translateLabel(std::string context, std::string baseName, std::string uniqueName); protected: void replacePatIncluded(std::string newHatchFileName); void makeLineSets(); std::vector getDecodedSpecsFromFile(); private: std::vector m_lineSets; std::string m_saveFile; std::string m_saveName; static App::PropertyFloatConstraint::Constraints scaleRange; }; using DrawGeomHatchPython = App::FeaturePythonT; } //namespace TechDraw #endif