TaskEdge2TracParameter.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 <QString>
00030 #include <QSlider>
00031 #include "ui_TaskEdge2TracParameter.h"
00032 #include "TaskEdge2TracParameter.h"
00033 #include <Gui/Application.h>
00034 #include <Gui/Document.h>
00035 #include <Gui/BitmapFactory.h>
00036 #include <Gui/ViewProvider.h>
00037 #include <Gui/WaitCursor.h>
00038 #include <Base/Console.h>
00039 #include <Gui/Selection.h>
00040 
00041 
00042 using namespace RobotGui;
00043 using namespace Gui;
00044 
00045 TaskEdge2TracParameter::TaskEdge2TracParameter(Robot::Edge2TracObject *pcObject,QWidget *parent)
00046     : TaskBox(Gui::BitmapFactory().pixmap("Robot_Edge2Trac"),
00047       tr("TaskEdge2TracParameter"),
00048       true, 
00049       parent),
00050       pcObject(pcObject),
00051       HideShowObj(0)
00052 {
00053     // we need a separate container widget to add all controls to
00054     proxy = new QWidget(this);
00055     ui = new Ui_TaskEdge2TracParameter();
00056     ui->setupUi(proxy);
00057     QMetaObject::connectSlotsByName(this);
00058 
00059     this->groupLayout()->addWidget(proxy);
00060 
00061     QObject::connect(ui->pushButton_HideShow,SIGNAL(clicked()),this,SLOT(hideShow()));
00062     QObject::connect(ui->doubleSpinBoxSizing,SIGNAL(valueChanged (double)),this,SLOT(sizingValueChanged(double)));
00063     QObject::connect(ui->checkBoxOrientation,SIGNAL(toggled  (bool)),this,SLOT(orientationToggled(bool)));
00064 
00065     setHideShowObject();
00066 
00067 }
00068 void TaskEdge2TracParameter::setHideShowObject(void)
00069 {
00070     HideShowObj = pcObject->Source.getValue();
00071 
00072     if(HideShowObj){
00073         QString ObjectName = QString::fromUtf8(HideShowObj->Label.getValue());
00074         ui->lineEdit_ObjectName->setText(ObjectName);
00075     }else{
00076         ui->lineEdit_ObjectName->setText(QString());
00077     }
00078 }
00079 
00080 void TaskEdge2TracParameter::hideShow(void)
00081 {
00082     setHideShowObject();
00083 
00084     if(HideShowObj){
00085         Gui::Document* doc = Gui::Application::Instance->activeDocument();
00086         if(doc->getViewProvider(HideShowObj)->isVisible())
00087             doc->getViewProvider(HideShowObj)->setVisible(false);
00088         else
00089             doc->getViewProvider(HideShowObj)->setVisible(true);
00090     }
00091 }
00092 
00093 void TaskEdge2TracParameter::sizingValueChanged(double Value)
00094 {
00095     pcObject->SegValue.setValue(Value);
00096 }
00097 
00098 void TaskEdge2TracParameter::orientationToggled(bool Value)
00099 {
00100     pcObject->UseRotation.setValue(Value);
00101 }
00102 
00103 void TaskEdge2TracParameter::setEdgeAndClusterNbr(int NbrEdges,int NbrClusters)
00104 {
00105     QPalette palette(QApplication::palette());
00106     QString  text;
00107 
00108     const int a=200,p=0;
00109 
00110     // set the text and the background color for the Edges label
00111     if(NbrEdges > 0){
00112         palette.setBrush(QPalette::WindowText,QColor(p,a,p));
00113     }else{
00114         palette.setBrush(QPalette::WindowText,QColor(a,p,p));
00115     }
00116 
00117     text = QString::fromAscii("Edges: %1").arg(NbrEdges);
00118     ui->label_Edges->setPalette(palette);
00119     ui->label_Edges->setText(text);
00120 
00121     // set the text and the background color for the Clusters label
00122     if(NbrClusters == 1){
00123         palette.setBrush(QPalette::WindowText,QColor(p,a,p));
00124     }else{
00125         palette.setBrush(QPalette::WindowText,QColor(a,p,p));
00126     }
00127 
00128     text = QString::fromAscii("Cluster: %1").arg(NbrClusters);
00129     ui->label_Cluster->setPalette(palette);
00130     ui->label_Cluster->setText(text);
00131 
00132 
00133 
00134 }
00135 
00136 
00137 TaskEdge2TracParameter::~TaskEdge2TracParameter()
00138 {
00139     delete ui;
00140 }
00141 
00142 
00143 #include "moc_TaskEdge2TracParameter.cpp"

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