TaskDlgEdge2Trac.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 "TaskDlgEdge2Trac.h"
00030 
00031 #include <Base/Console.h>
00032 #include <Base/Exception.h>
00033 #include <Gui/TaskView/TaskSelectLinkProperty.h>
00034 #include <Gui/Application.h>
00035 #include <Gui/Document.h>
00036 
00037 
00038 using namespace RobotGui;
00039 
00040 
00041 //**************************************************************************
00042 //**************************************************************************
00043 // TaskDialog
00044 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00045 
00046 TaskDlgEdge2Trac::TaskDlgEdge2Trac(Robot::Edge2TracObject *obj)
00047     : TaskDialog(),Edge2TaskObject(obj)
00048 {
00049     param  = new TaskEdge2TracParameter(obj);
00050     select = new Gui::TaskView::TaskSelectLinkProperty("SELECT Part::Feature SUBELEMENT Edge COUNT 1..",&(obj->Source));
00051 
00052     Content.push_back(param);
00053     Content.push_back(select);
00054 }
00055 
00056 TaskDlgEdge2Trac::~TaskDlgEdge2Trac()
00057 {
00058 
00059 }
00060 
00061 //==== calls from the TaskView ===============================================================
00062 
00063 
00064 void TaskDlgEdge2Trac::open()
00065 {
00066     select->activate();
00067     Edge2TaskObject->execute();
00068     param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster);
00069 
00070 }
00071 
00072 void TaskDlgEdge2Trac::clicked(int button)
00073 {
00074     try {
00075         if(QDialogButtonBox::Apply == button)
00076         {
00077             if (select->isSelectionValid()){
00078                 select->sendSelection2Property();
00079                 // May throw an exception which we must handle here
00080                 Edge2TaskObject->execute();
00081                 param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster);
00082             } else {
00083                 QApplication::beep();
00084                 param->setEdgeAndClusterNbr(0,0);
00085             }
00086         }
00087     }
00088     catch (const Base::Exception& e) {
00089         Base::Console().Warning("TaskDlgEdge2Trac::clicked(): %s\n", e.what());
00090     }
00091 }
00092 
00093 bool TaskDlgEdge2Trac::accept()
00094 {
00095     try {
00096         if (select->isSelectionValid()){
00097             select->accept();
00098             Edge2TaskObject->recompute();
00099             Gui::Document* doc = Gui::Application::Instance->activeDocument();
00100             if(doc) 
00101                 doc->resetEdit();
00102             return true;
00103         }
00104         else
00105             QApplication::beep();
00106     }
00107     catch (const Base::Exception& e) {
00108         Base::Console().Warning("TaskDlgEdge2Trac::accept(): %s\n", e.what());
00109     }
00110 
00111     return false;
00112 }
00113 
00114 bool TaskDlgEdge2Trac::reject()
00115 {
00116     select->reject();
00117     Edge2TaskObject->execute();
00118     return true;
00119 }
00120 
00121 void TaskDlgEdge2Trac::helpRequested()
00122 {
00123 
00124 }
00125 
00126 
00127 #include "moc_TaskDlgEdge2Trac.cpp"

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