DrawSketchHandler.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2009 Jürgen Riegel <juergen.riegel@web.de>              *
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 #ifndef SKETCHERGUI_DrawSketchHandler_H
00025 #define SKETCHERGUI_DrawSketchHandler_H
00026 
00027 #include <Base/Tools2D.h>
00028 #include <Mod/Sketcher/App/Constraint.h>
00029 
00030 class QPixmap;
00031 
00032 namespace Gui {
00033     class View3DInventorViewer;
00034     class SoFCSelection;
00035 }
00036 
00037 namespace Sketcher {
00038     class Sketch;
00039     class SketchObject;
00040 }
00041 
00042 namespace SketcherGui {
00043 
00044 class ViewProviderSketch;
00045 
00046 // A Simple data type to hold basic information for suggested constraints
00047 struct AutoConstraint
00048 {
00049     Sketcher::ConstraintType Type;
00050     int Index;
00051 };
00052 
00053 enum Type
00054 {
00055     VERTEX,
00056     CURVE
00057 };
00058 
00063 class SketcherGuiExport DrawSketchHandler
00064 {
00065 public:
00066     DrawSketchHandler();
00067     virtual ~DrawSketchHandler();
00068 
00069     virtual void activated(ViewProviderSketch *sketchgui){};
00070     virtual void mouseMove(Base::Vector2D onSketchPos)=0;
00071     virtual bool pressButton(Base::Vector2D onSketchPos)=0;
00072     virtual bool releaseButton(Base::Vector2D onSketchPos)=0;
00073 
00074     virtual void quit(void);
00075 
00076     friend class ViewProviderSketch;
00077 
00078     Sketcher::SketchObject* getObject(void);
00079     // get the actual highest vertex index, the next use will be +1
00080     int getHighestVertexIndex(void);
00081     // get the actual highest edge index, the next use will be +1
00082     int getHighestCurveIndex(void);
00083 
00084     int seekAutoConstraint(std::vector<AutoConstraint> &suggestedConstraints,
00085                            const Base::Vector2D &Pos, const Base::Vector2D &Dir, Type selType = VERTEX);
00086     void createAutoConstraints(const std::vector<AutoConstraint> &autoConstrs,
00087                                int geoId, Sketcher::PointPos pointPos=Sketcher::none);
00088 
00089     void setPositionText(const Base::Vector2D &Pos);
00090     void resetPositionText(void);
00091     void renderSuggestConstraintsCursor(std::vector<AutoConstraint> &suggestedConstraints);
00092 
00093 protected:
00094     // helpers
00095     void setCursor( const QPixmap &p,int x,int y );
00096     void unsetCursor(void);
00097         void applyCursor(void);
00098         void applyCursor(QCursor &newCursor);
00099 
00100     ViewProviderSketch *sketchgui;
00101     QCursor oldCursor;
00102     QCursor actCursor;
00103 };
00104 
00105 
00106 } // namespace SketcherGui
00107 
00108 
00109 #endif // SKETCHERGUI_DrawSketchHandler_H
00110 

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