SelectionFilter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef GUI_SelectionFilter_H
00025 #define GUI_SelectionFilter_H
00026
00027 #include <string>
00028 #include <CXX/Extensions.hxx>
00029 #include "Selection.h"
00030
00031 namespace App {
00032 class DocumentObject;
00033 }
00034
00035 namespace Gui {
00036 struct Node_Block;
00037
00038
00049 class GuiExport SelectionFilter
00050 {
00051
00052 public:
00054 SelectionFilter(const char* filter);
00055 SelectionFilter(const std::string& filter);
00056 virtual ~SelectionFilter();
00057
00059 void setFilter(const char* filter);
00065 bool match(void);
00071 bool test(App::DocumentObject*pObj, const char*sSubName);
00072
00073 void addError(const char* e);
00074
00075 friend class SelectionSingleton;
00076
00077 std::vector<std::vector<SelectionObject> > Result;
00078
00080 bool isValid(void) const {return Ast;}
00081
00082 protected:
00083 std::string Filter;
00084 std::string Errors;
00085 bool parse(void);
00086
00087 Node_Block *Ast;
00088
00089 };
00090
00099 class GuiExport SelectionFilterGate: public SelectionGate
00100 {
00101 public:
00103 SelectionFilterGate(const char* filter);
00104 SelectionFilterGate(SelectionFilter* filter);
00105 ~SelectionFilterGate();
00106 virtual bool allow(App::Document*,App::DocumentObject*, const char*);
00107
00108 protected:
00109 SelectionFilter *Filter;
00110 };
00111
00117 class SelectionFilterPy : public Py::PythonExtension<SelectionFilterPy>
00118 {
00119 private:
00120 SelectionFilter filter;
00121
00122 public:
00123 static void init_type(void);
00124
00125 SelectionFilterPy(const std::string&);
00126 ~SelectionFilterPy();
00127
00128 Py::Object repr();
00129 Py::Object match(const Py::Tuple&);
00130 Py::Object result(const Py::Tuple&);
00131 Py::Object test(const Py::Tuple&);
00132
00133 private:
00134 static PyObject *PyMake(struct _typeobject *, PyObject *, PyObject *);
00135 };
00136
00137
00138
00139 struct Node_Slice
00140 {
00141 Node_Slice(int min=1,int max=INT_MAX):Min(min),Max(max){}
00142 int Min,Max;
00143
00144 };
00145
00146
00147 struct Node_Object
00148 {
00149 Node_Object(std::string *type,std::string *subname,Node_Slice* slc )
00150 :Slice(slc)
00151 {
00152 ObjectType = Base::Type::fromName(type->c_str());
00153 delete (type);
00154 if(subname){
00155 SubName = *subname;
00156 delete subname;
00157 }
00158 }
00159 ~Node_Object(){
00160 delete Slice;
00161 }
00162 Base::Type ObjectType;
00163 Node_Slice *Slice;
00164 std::string SubName;
00165 };
00166
00167 struct Node_Block
00168 {
00169 Node_Block(Node_Object* obj){Objects.push_back(obj);}
00170 std::vector< Node_Object *> Objects;
00171 };
00172
00173
00174 }
00175
00176
00177 #endif // GUI_SelectionFilter_H
00178