TaskSketcherGeneral.cpp

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 #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     // we need a separate container widget to add all controls to
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     // connecting the needed signals
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()); // Ensure consistency
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     //if (Reason.Type == SelectionChanges::AddSelection ||
00111     //    Reason.Type == SelectionChanges::RmvSelection ||
00112     //    Reason.Type == SelectionChanges::SetSelection ||
00113     //    Reason.Type == SelectionChanges::ClrSelection) {
00114     //}
00115 }
00117 
00118 #include "moc_TaskSketcherGeneral.cpp"

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