File size: 5,541 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | /***************************************************************************
* Copyright (c) 2017 WandererFan <wandererfan@gmail.com> *
* *
* 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 <App/DocumentObject.h>
#include <App/FeaturePython.h>
#include <App/PropertyFile.h>
#include <Mod/TechDraw/TechDrawGlobal.h>
#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<LineSet> getFaceOverlay(int iFace = 0);
std::vector<LineSet> getTrimmedLines(int iFace = 0);
static std::vector<LineSet> getTrimmedLines(DrawViewPart* dvp, std::vector<LineSet> lineSets, int iface,
double scale, double hatchRotation = 0.0,
Base::Vector3d hatchOffset = Base::Vector3d(0.0, 0.0, 0.0));
static std::vector<LineSet> getTrimmedLines(DrawViewPart* source,
std::vector<LineSet> lineSets,
TopoDS_Face face,
double scale , double hatchRotation = 0.0,
Base::Vector3d hatchOffset = Base::Vector3d(0.0, 0.0, 0.0));
static std::vector<LineSet> getTrimmedLinesSection(DrawViewSection* source,
std::vector<LineSet> lineSets,
TopoDS_Face face,
double scale , double hatchRotation = 0.0,
Base::Vector3d hatchOffset = Base::Vector3d(0.0, 0.0, 0.0));
static std::vector<TopoDS_Edge> 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<PATLineSpec> 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<LineSet> 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<PATLineSpec> getDecodedSpecsFromFile();
private:
std::vector<LineSet> m_lineSets;
std::string m_saveFile;
std::string m_saveName;
static App::PropertyFloatConstraint::Constraints scaleRange;
};
using DrawGeomHatchPython = App::FeaturePythonT<DrawGeomHatch>;
} //namespace TechDraw
#endif
|