TaskSketcherGeneral.cpp
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 #include "PreCompiled.h"
00025 
00026 #ifndef _PreComp_
00027 #endif
00028 
00029 #include "ui_TaskSketcherGeneral.h"
00030 #include "TaskSketcherGeneral.h"
00031 #include <Gui/Application.h>
00032 #include <Gui/Document.h>
00033 #include <Gui/BitmapFactory.h>
00034 #include <Gui/ViewProvider.h>
00035 #include <Gui/WaitCursor.h>
00036 #include <Base/UnitsApi.h>
00037 
00038 #include "ViewProviderSketch.h"
00039 
00040 using namespace SketcherGui;
00041 using namespace Gui::TaskView;
00042 
00043 TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
00044     : TaskBox(Gui::BitmapFactory().pixmap("document-new"),tr("Edit controls"),true, 0)
00045     , sketchView(sketchView)
00046 {
00047     
00048     proxy = new QWidget(this);
00049     ui = new Ui_TaskSketcherGeneral();
00050     ui->setupUi(proxy);
00051     QMetaObject::connectSlotsByName(this);
00052 
00053     this->groupLayout()->addWidget(proxy);
00054 
00055     
00056     QObject::connect(
00057         ui->checkBoxGridSnap, SIGNAL(stateChanged(int)),
00058         this              , SLOT  (toggleGridSnap(int))
00059        );
00060 
00061     QObject::connect(
00062         ui->comboBoxGridSize, SIGNAL(currentIndexChanged(QString)),
00063         this              , SLOT  (setGridSize(QString))
00064        );
00065 
00066     QObject::connect(
00067         ui->checkBoxAutoconstraints, SIGNAL(stateChanged(int)),
00068         this              , SLOT  (toggleAutoconstraints(int))
00069        );
00070     
00071     Gui::Selection().Attach(this);
00072 }
00073 
00074 TaskSketcherGeneral::~TaskSketcherGeneral()
00075 {
00076     delete ui;
00077     Gui::Selection().Detach(this);
00078 }
00079 
00080 void TaskSketcherGeneral::setGridSize(const QString& val)
00081 {
00082     float gridSize = (float) Base::UnitsApi::translateUnit(val);
00083     if (gridSize > 0)
00084         sketchView->GridSize.setValue(gridSize);
00085 }
00086 
00087 void TaskSketcherGeneral::toggleGridSnap(int state)
00088 {
00089     setGridSize(ui->comboBoxGridSize->currentText()); 
00090     sketchView->GridSnap.setValue(state == Qt::Checked);
00091 }
00092 
00093 void TaskSketcherGeneral::toggleAutoconstraints(int state)
00094 {
00095     sketchView->Autoconstraints.setValue(state == Qt::Checked);
00096 }
00097 
00098 void TaskSketcherGeneral::changeEvent(QEvent *e)
00099 {
00100     TaskBox::changeEvent(e);
00101     if (e->type() == QEvent::LanguageChange) {
00102         ui->retranslateUi(proxy);
00103     }
00104 }
00105 
00107 void TaskSketcherGeneral::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
00108                               Gui::SelectionSingleton::MessageType Reason)
00109 {
00110     
00111     
00112     
00113     
00114     
00115 }
00117 
00118 #include "moc_TaskSketcherGeneral.cpp"