SketchObject.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Jürgen Riegel          (juergen.riegel@web.de) 2008     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 
00025 #ifndef SKETCHER_SKETCHOBJECT_H
00026 #define SKETCHER_SKETCHOBJECT_H
00027 
00028 #include <App/PropertyStandard.h>
00029 #include <App/PropertyFile.h>
00030 #include <App/FeaturePython.h>
00031 
00032 #include <Mod/Part/App/Part2DObject.h>
00033 #include <Mod/Part/App/PropertyGeometryList.h>
00034 #include <Mod/Sketcher/App/PropertyConstraintList.h>
00035 
00036 namespace Sketcher
00037 {
00038 
00039 class SketcherExport SketchObject : public Part::Part2DObject
00040 {
00041     PROPERTY_HEADER(Sketcher::SketchObject);
00042 
00043 public:
00044     SketchObject();
00045 
00047     Part    ::PropertyGeometryList   Geometry;
00048     Sketcher::PropertyConstraintList Constraints;
00049     App     ::PropertyLinkSubList    ExternalConstraints;
00052 
00053     App::DocumentObjectExecReturn *execute(void);
00054 
00056     const char* getViewProviderName(void) const {
00057         return "SketcherGui::ViewProviderSketch";
00058     }
00060 
00062     int addGeometry(const Part::Geometry *geo);
00064     int addGeometry(const std::vector<Part::Geometry *> &geoList);
00066     int delGeometry(int GeoNbr);
00068     int addConstraints(const std::vector<Constraint *> &ConstraintList);
00070     int addConstraint(const Constraint *constraint);
00072     int delConstraint(int ConstrId);
00073     int delConstraintOnPoint(int GeoId, PointPos PosId, bool onlyCoincident=true);
00074     int delConstraintOnPoint(int VertexId, bool onlyCoincident=true);
00076     int transferConstraints(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId);
00078     int addExternal(App::DocumentObject *Obj, const char* SubName);
00080     std::vector<Part::Geometry *> getExternalGeometry(void);
00082     int delExternal(int ConstrId);
00083 
00085     int hasConflicts(void) const;
00086 
00088     int setDatum(int ConstrId, double Datum);
00090     int movePoint(int geoIndex1, PointPos Pos1, const Base::Vector3d& toPoint, bool relative=false);
00092     Base::Vector3d getPoint(int geoIndex1, PointPos Pos1);
00093 
00095     int toggleConstruction(int GeoNbr);
00096 
00098     int fillet(int geoId, PointPos pos, double radius, bool trim=true);
00099     int fillet(int geoId1, int geoId2,
00100                const Base::Vector3d& refPnt1, const Base::Vector3d& refPnt2,
00101                double radius, bool trim=true);
00102 
00104     int trim(int geoId, const Base::Vector3d& point);
00105 
00107     void getGeoVertexIndex(int VertexId, int &GeoId, PointPos &PosId);
00108     int getHighestVertexIndex(void) { return VertexId2GeoId.size() - 1; }
00109     int getHighestCurveIndex(void) { return Geometry.getSize() - 1; }
00110     void rebuildVertexIndex(void);
00111 
00113     void getCoincidentPoints(int GeoId, PointPos PosId, std::vector<int> &GeoIdList,
00114                              std::vector<PointPos> &PosIdList);
00115     void getCoincidentPoints(int VertexId, std::vector<int> &GeoIdList, std::vector<PointPos> &PosIdList);
00116 
00118     static void appendConflictMsg(const std::vector<int> &conflicting, std::string &msg);
00119 
00120     // from base class
00121     virtual PyObject *getPyObject(void);
00122     virtual unsigned int getMemSize(void) const;
00123     virtual void Save(Base::Writer &/*writer*/) const;
00124     virtual void Restore(Base::XMLReader &/*reader*/);
00125 
00126 protected:
00128     virtual void onChanged(const App::Property* /*prop*/);
00129 
00130 private:
00131     std::vector<int> VertexId2GeoId;
00132     std::vector<PointPos> VertexId2PosId;
00133 };
00134 
00135 typedef App::FeaturePythonT<SketchObject> SketchObjectPython;
00136 
00137 } //namespace Sketcher
00138 
00139 
00140 #endif // SKETCHER_SKETCHOBJECT_H

Generated on Wed Nov 23 19:00:38 2011 for FreeCAD by  doxygen 1.6.1