TaskChamfer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2010 Werner Mayer <wmayer[at]users.sourceforge.net>     *
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 #ifndef PARTDESIGNGUI_TASKCHAMFER_H
00024 #define PARTDESIGNGUI_TASKCHAMFER_H
00025 
00026 #include <Gui/TaskView/TaskDialog.h>
00027 #include <Gui/TaskView/TaskView.h>
00028 #include <Gui/Selection.h>
00029 #include <QStandardItemModel>
00030 #include <QItemDelegate>
00031 #include <Mod/Part/Gui/ViewProvider.h>
00032 
00033 namespace PartDesignGui {
00034 
00035 class Ui_TaskChamfer;
00036 class ChamferDistanceDelegate : public QItemDelegate
00037 {
00038     Q_OBJECT
00039 
00040 public:
00041     ChamferDistanceDelegate(QObject *parent = 0);
00042 
00043     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
00044                           const QModelIndex &index) const;
00045 
00046     void setEditorData(QWidget *editor, const QModelIndex &index) const;
00047     void setModelData(QWidget *editor, QAbstractItemModel *model,
00048                       const QModelIndex &index) const;
00049 
00050     void updateEditorGeometry(QWidget *editor, 
00051         const QStyleOptionViewItem &option, const QModelIndex &index) const;
00052 };
00053 
00054 class ChamferDistanceModel : public QStandardItemModel
00055 {
00056     Q_OBJECT
00057 
00058 public:
00059     ChamferDistanceModel(QObject * parent = 0);
00060 
00061     Qt::ItemFlags flags (const QModelIndex & index) const;
00062     bool setData (const QModelIndex & index, const QVariant & value,
00063                   int role = Qt::EditRole);
00064 Q_SIGNALS:
00065     void toggleCheckState(const QModelIndex&);
00066 };
00067 
00068 class ChamferWidgetP;
00069 class ChamferWidget : public QWidget, public Gui::SelectionObserver
00070 {
00071     Q_OBJECT
00072 
00073 public:
00074     ChamferWidget(QWidget* parent = 0, Qt::WFlags fl = 0);
00075     ~ChamferWidget();
00076     bool accept();
00077 
00078 protected:
00079     void findShapes();
00080     void changeEvent(QEvent *e);
00081 
00082 private:
00083     void onSelectionChanged(const Gui::SelectionChanges& msg);
00084     void onDeleteObject(const App::DocumentObject&);
00085     void onDeleteDocument(const App::Document&);
00086 
00087 private Q_SLOTS:
00088     void on_shapeObject_activated(int);
00089     void on_selectAllButton_clicked();
00090     void on_selectNoneButton_clicked();
00091     void on_chamferType_activated(int);
00092     void on_chamferStartDistance_valueChanged(double);
00093     void on_chamferEndDistance_valueChanged(double);
00094     void toggleCheckState(const QModelIndex&);
00095 
00096 private:
00097     std::auto_ptr<Ui_TaskChamfer> ui;
00098     std::auto_ptr<ChamferWidgetP> d;
00099 };
00100 
00101 class TaskChamfer : public Gui::TaskView::TaskDialog
00102 {
00103     Q_OBJECT
00104 
00105 public:
00106     TaskChamfer();
00107     ~TaskChamfer();
00108 
00109 public:
00110     virtual void open();
00111     virtual void clicked(int);
00112     virtual bool accept();
00113     virtual bool reject();
00114 
00115     virtual QDialogButtonBox::StandardButtons getStandardButtons() const
00116     { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
00117 
00118 private:
00119     ChamferWidget* widget;
00120 };
00121 
00122 class ViewProviderChamfer : public PartGui::ViewProviderPart
00123 {
00124     PROPERTY_HEADER(PartDesignGui::ViewProviderChamfer);
00125 
00126 public:
00128     ViewProviderChamfer();
00130     virtual ~ViewProviderChamfer();
00131 };
00132 
00133 } // namespace PartDesignGui
00134 
00135 #endif // PARTDESIGNGUI_TASKCHAMFER_H

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