From ec96217335bb5b6fd86bc69582b580ed20d1237f Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 23 Apr 2015 23:11:47 +0200 Subject: [PATCH] + FEM: cleanup of unused dialog --- src/Mod/Fem/Gui/CMakeLists.txt | 5 - src/Mod/Fem/Gui/Command.cpp | 8 +- src/Mod/Fem/Gui/Hypothesis.cpp | 186 --------------------------------- src/Mod/Fem/Gui/Hypothesis.h | 75 ------------- src/Mod/Fem/Gui/Hypothesis.ui | 166 ----------------------------- 5 files changed, 2 insertions(+), 438 deletions(-) delete mode 100644 src/Mod/Fem/Gui/Hypothesis.cpp delete mode 100644 src/Mod/Fem/Gui/Hypothesis.h delete mode 100644 src/Mod/Fem/Gui/Hypothesis.ui diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt index 7a951863a..27288f250 100755 --- a/src/Mod/Fem/Gui/CMakeLists.txt +++ b/src/Mod/Fem/Gui/CMakeLists.txt @@ -42,7 +42,6 @@ SOURCE_GROUP("Python" FILES ${Python_SRCS}) set(FemGui_MOC_HDRS DlgSettingsFemImp.h - Hypothesis.h TaskObjectName.h TaskCreateNodeSet.h TaskDlgCreateNodeSet.h @@ -63,7 +62,6 @@ SOURCE_GROUP("Moc" FILES ${FemGui_MOC_SRCS}) set(FemGui_UIC_SRCS DlgSettingsFem.ui - Hypothesis.ui TaskCreateNodeSet.ui TaskObjectName.ui TaskFemConstraint.ui @@ -81,9 +79,6 @@ SET(FemGui_DLG_SRCS DlgSettingsFem.ui DlgSettingsFemImp.cpp DlgSettingsFemImp.h - Hypothesis.ui - Hypothesis.cpp - Hypothesis.h TaskFemConstraint.ui TaskFemConstraint.cpp TaskFemConstraint.h diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index c8c6d6dcf..7e6509088 100755 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -57,8 +58,6 @@ #include #include - -#include "Hypothesis.h" #include "ActiveAnalysisObserver.h" using namespace std; @@ -142,10 +141,8 @@ bool CmdFemCreateAnalysis::isActive(void) return !FemGui::ActiveAnalysisObserver::instance()->hasActiveObject(); } - - - //===================================================================================== + DEF_STD_CMD_A(CmdFemAddPart); CmdFemAddPart::CmdFemAddPart() @@ -207,7 +204,6 @@ bool CmdFemAddPart::isActive(void) return Gui::Selection().countObjectsOfType(type) > 0; } - //===================================================================================== DEF_STD_CMD_A(CmdFemConstraintBearing); diff --git a/src/Mod/Fem/Gui/Hypothesis.cpp b/src/Mod/Fem/Gui/Hypothesis.cpp deleted file mode 100644 index 3625b438f..000000000 --- a/src/Mod/Fem/Gui/Hypothesis.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2012 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" -#ifndef _PreComp_ -# include -#endif - -#include "Hypothesis.h" -#include "ui_Hypothesis.h" - -#include -#include -#include - -using namespace FemGui; - -HypothesisWidget::HypothesisWidget(QWidget* parent) - : QWidget(parent), ui(new Ui_HypothesisWidget) -{ - ui->setupUi(this); -} - -HypothesisWidget::~HypothesisWidget() -{ - delete ui; -} - -bool HypothesisWidget::accept() -{ - Base::Type type = Base::Type::fromName("Part::Feature"); - std::vector obj = Gui::Selection().getObjectsOfType(type); - - Gui::Command::openCommand("Create FEM"); - Gui::Command::doCommand(Gui::Command::Doc, "import Fem"); - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) { - QString cmd; - QTextStream str(&cmd); - App::Document* doc = (*it)->getDocument(); - QString doc_name = QString::fromAscii(doc->getName()); - QString obj_name = QString::fromAscii((*it)->getNameInDocument()); - str << QString::fromAscii( - "__fem__=Fem.FemMesh()\n" - "__fem__.setShape(FreeCAD.getDocument('%1').%2.Shape)\n") - .arg(doc_name).arg(obj_name); - int hyp=0; - - if (ui->maxLength->isChecked()) { - str << QString::fromAscii( - "hyp=Fem.StdMeshers_MaxLength(%1,__fem__)\n" - "hyp.setLength(%2)\n" - "__fem__.addHypothesis(hyp)\n") - .arg(hyp++).arg(ui->valMaxLength->value()); - } - - if (ui->localLength->isChecked()) { - str << QString::fromAscii( - "hyp=Fem.StdMeshers_LocalLength(%1,__fem__)\n" - "hyp.setLength(%2)\n" - "__fem__.addHypothesis(hyp)\n") - .arg(hyp++).arg(ui->valLocalLength->value()); - } - - if (ui->maxArea->isChecked()) { - str << QString::fromAscii( - "hyp=Fem.StdMeshers_MaxElementArea(%1,__fem__)\n" - "hyp.setMaxArea(%2)\n" - "__fem__.addHypothesis(hyp)\n"). - arg(hyp++).arg(ui->valMaxArea->value()); - } -#if 0 - str << QString::fromAscii( - "hyp=Fem.StdMeshers_NumberOfSegments(%1,__fem__)\n" - "hyp.setNumberOfSegments(1)\n" - "__fem__.addHypothesis(hyp)\n") - .arg(hyp++); - - str << QString::fromAscii( - "hyp=Fem.StdMeshers_Deflection1D(%1,__fem__)\n" - "hyp.setDeflection(0.02)\n" - "__fem__.addHypothesis(hyp)\n") - .arg(hyp++); -#endif - str << QString::fromAscii( - "hyp=Fem.StdMeshers_Regular_1D(%1,__fem__)\n" - "__fem__.addHypothesis(hyp)\n") - .arg(hyp++); - - if (ui->quadPref->isChecked()) { - str << QString::fromAscii( - "hyp=Fem.StdMeshers_QuadranglePreference(%1,__fem__)\n" - "__fem__.addHypothesis(hyp)\n") - .arg(hyp++); - } - - str << QString::fromAscii( - "hyp=Fem.StdMeshers_Quadrangle_2D(%1,__fem__)\n" - "__fem__.addHypothesis(hyp)\n") - .arg(hyp++); - - str << QString::fromAscii( - "__fem__.compute()\n" - "FreeCAD.getDocument('%1').addObject" - "(\"Fem::FemMeshObject\",'%2').FemMesh=__fem__\n" - "del __fem__, hyp\n") - .arg(doc_name).arg(obj_name); - Gui::Command::doCommand(Gui::Command::Doc, "%s", (const char*)cmd.toAscii()); - } - Gui::Command::commitCommand(); - return true; -} - -bool HypothesisWidget::reject() -{ - return true; -} - -void HypothesisWidget::changeEvent(QEvent *e) -{ - QWidget::changeEvent(e); - if (e->type() == QEvent::LanguageChange) { - ui->retranslateUi(this); - } -} - -// ----------------------------------------------- - -TaskHypothesis::TaskHypothesis() -{ - widget = new HypothesisWidget(); - taskbox = new Gui::TaskView::TaskBox( - QPixmap(), - widget->windowTitle(), true, 0); - taskbox->groupLayout()->addWidget(widget); - Content.push_back(taskbox); -} - -TaskHypothesis::~TaskHypothesis() -{ -} - -void TaskHypothesis::open() -{ -} - -bool TaskHypothesis::accept() -{ - try { - return widget->accept(); - } - catch (const Base::Exception& e) { - Base::Console().Error("%s\n", e.what()); - return false; - } - catch (...) { - Base::Console().Error("Unknown error\n"); - return false; - } -} - -bool TaskHypothesis::reject() -{ - return widget->reject(); -} - -#include "moc_Hypothesis.cpp" diff --git a/src/Mod/Fem/Gui/Hypothesis.h b/src/Mod/Fem/Gui/Hypothesis.h deleted file mode 100644 index c3edfe9bf..000000000 --- a/src/Mod/Fem/Gui/Hypothesis.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2012 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#ifndef FEMGUI_HYPOTHESIS_H -#define FEMGUI_HYPOTHESIS_H - -#include -#include - -namespace FemGui { - -class Ui_HypothesisWidget; -class HypothesisWidget : public QWidget -{ - Q_OBJECT - -public: - HypothesisWidget(QWidget* parent = 0); - ~HypothesisWidget(); - bool accept(); - bool reject(); - -private: - void changeEvent(QEvent *e); - -private: - Ui_HypothesisWidget* ui; -}; - -class TaskHypothesis : public Gui::TaskView::TaskDialog -{ - Q_OBJECT - -public: - TaskHypothesis(); - ~TaskHypothesis(); - -public: - void open(); - bool accept(); - bool reject(); - - QDialogButtonBox::StandardButtons getStandardButtons() const - { return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; } - bool needsFullSpace() const - { return true; } - -private: - HypothesisWidget* widget; - Gui::TaskView::TaskBox* taskbox; -}; - -} //namespace FemGui - -#endif // FEMGUI_HYPOTHESIS_H diff --git a/src/Mod/Fem/Gui/Hypothesis.ui b/src/Mod/Fem/Gui/Hypothesis.ui deleted file mode 100644 index c5ecd67d2..000000000 --- a/src/Mod/Fem/Gui/Hypothesis.ui +++ /dev/null @@ -1,166 +0,0 @@ - - - FemGui::HypothesisWidget - - - - 0 - 0 - 299 - 238 - - - - Hypothesis - - - - - - - - Quadrangle - - - true - - - - - - - Maximum length - - - true - - - - - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Local length - - - true - - - - - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Maximum element area - - - true - - - - - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - - Qt::Vertical - - - - 20 - 65 - - - - - - - - quadPref - maxLength - valMaxLength - localLength - valLocalLength - maxArea - valMaxArea - - - - - maxLength - toggled(bool) - valMaxLength - setEnabled(bool) - - - 73 - 92 - - - 172 - 88 - - - - - localLength - toggled(bool) - valLocalLength - setEnabled(bool) - - - 44 - 116 - - - 186 - 118 - - - - - maxArea - toggled(bool) - valMaxArea - setEnabled(bool) - - - 61 - 144 - - - 197 - 145 - - - - -