Add dialog for GeomHatch creation
This commit is contained in:
parent
84b858a142
commit
b1a5fd971c
|
@ -36,6 +36,7 @@ set(TechDrawGui_MOC_HDRS
|
|||
TaskLinkDim.h
|
||||
DlgTemplateField.h
|
||||
TaskSectionView.h
|
||||
TaskGeomHatch.h
|
||||
)
|
||||
|
||||
fc_wrap_cpp(TechDrawGui_MOC_SRCS ${TechDrawGui_MOC_HDRS})
|
||||
|
@ -54,6 +55,7 @@ set(TechDrawGui_UIC_SRCS
|
|||
TaskLinkDim.ui
|
||||
DlgTemplateField.ui
|
||||
TaskSectionView.ui
|
||||
TaskGeomHatch.ui
|
||||
)
|
||||
|
||||
if(BUILD_QT5)
|
||||
|
@ -92,6 +94,9 @@ SET(TechDrawGui_SRCS
|
|||
TaskSectionView.ui
|
||||
TaskSectionView.cpp
|
||||
TaskSectionView.h
|
||||
TaskGeomHatch.ui
|
||||
TaskGeomHatch.cpp
|
||||
TaskGeomHatch.h
|
||||
DrawGuiUtil.cpp
|
||||
DrawGuiUtil.h
|
||||
Rez.cpp
|
||||
|
@ -213,6 +218,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
|
|||
TaskProjGroup.ui
|
||||
TaskLinkDim.ui
|
||||
TaskSectionView.ui
|
||||
TaskGeomHatch.ui
|
||||
)
|
||||
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "TaskGeomHatch.h"
|
||||
#include "ViewProviderGeomHatch.h"
|
||||
#include "ViewProviderPage.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
@ -171,6 +173,13 @@ void CmdTechDrawNewGeomHatch::activated(int iMsg)
|
|||
|
||||
auto geomhatch( static_cast<TechDraw::DrawGeomHatch *>(getDocument()->getObject(FeatName.c_str())) );
|
||||
geomhatch->Source.setValue(objFeat, subNames);
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(getDocument())->getViewProvider(geomhatch);
|
||||
TechDrawGui::ViewProviderGeomHatch* hvp = dynamic_cast<TechDrawGui::ViewProviderGeomHatch*>(vp);
|
||||
// if (!hvp) {
|
||||
|
||||
// dialog to fill in hatch values
|
||||
Gui::Control().showDialog(new TaskDlgGeomHatch(geomhatch,hvp));
|
||||
|
||||
|
||||
commitCommand();
|
||||
|
||||
|
|
195
src/Mod/TechDraw/Gui/TaskGeomHatch.cpp
Normal file
195
src/Mod/TechDraw/Gui/TaskGeomHatch.cpp
Normal file
|
@ -0,0 +1,195 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2017 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* 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 <cmath>
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#include <Mod/TechDraw/App/HatchLine.h>
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
|
||||
#include "ViewProviderGeomHatch.h"
|
||||
#include "TaskGeomHatch.h"
|
||||
#include <Mod/TechDraw/Gui/ui_TaskGeomHatch.h>
|
||||
|
||||
using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
TaskGeomHatch::TaskGeomHatch(TechDraw::DrawGeomHatch* inHatch,TechDrawGui::ViewProviderGeomHatch* inVp) :
|
||||
ui(new Ui_TaskGeomHatch),
|
||||
m_hatch(inHatch),
|
||||
m_Vp(inVp)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->fcFile, SIGNAL(fileNameSelected( const QString & )), this, SLOT(onFileChanged(void)));
|
||||
|
||||
m_source = m_hatch->Source.getValue();
|
||||
getParameters();
|
||||
initUi();
|
||||
}
|
||||
|
||||
TaskGeomHatch::~TaskGeomHatch()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void TaskGeomHatch::initUi()
|
||||
{
|
||||
ui->fcFile->setFileName(QString::fromUtf8(m_file.data(), m_file.size()));
|
||||
std::vector<std::string> names = HatchLine::getPatternList(m_file);
|
||||
QStringList qsNames = listToQ(names);
|
||||
ui->cbName->addItems(qsNames);
|
||||
ui->sbScale->setValue(m_scale);
|
||||
ui->sbWeight->setValue(m_weight);
|
||||
ui->ccColor->setColor(m_color.asValue<QColor>());
|
||||
}
|
||||
|
||||
//move values from screen to DocObjs
|
||||
void TaskGeomHatch::updateValues()
|
||||
{
|
||||
m_file = (ui->fcFile->fileName()).toUtf8().constData();
|
||||
m_hatch->FilePattern.setValue(m_file);
|
||||
QString cText = ui->cbName->currentText();
|
||||
m_name = cText.toUtf8().constData();
|
||||
m_hatch->NamePattern.setValue(m_name);
|
||||
m_scale = ui->sbScale->value();
|
||||
m_hatch->ScalePattern.setValue(m_scale);
|
||||
m_color.setValue<QColor>(ui->ccColor->color());
|
||||
m_Vp->ColorPattern.setValue(m_color);
|
||||
m_weight = ui->sbWeight->value();
|
||||
m_Vp->WeightPattern.setValue(m_weight);
|
||||
}
|
||||
|
||||
QStringList TaskGeomHatch::listToQ(std::vector<std::string> in)
|
||||
{
|
||||
QStringList result;
|
||||
for (auto& s: in) {
|
||||
QString qs = QString::fromUtf8(s.data(), s.size());
|
||||
result.append(qs);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void TaskGeomHatch::onFileChanged(void)
|
||||
{
|
||||
m_file = ui->fcFile->fileName().toUtf8().constData();
|
||||
std::vector<std::string> names = HatchLine::getPatternList(m_file);
|
||||
QStringList qsNames = listToQ(names);
|
||||
ui->cbName->clear();
|
||||
ui->cbName->addItems(qsNames);
|
||||
}
|
||||
|
||||
bool TaskGeomHatch::accept()
|
||||
{
|
||||
updateValues();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskGeomHatch::reject()
|
||||
{
|
||||
std::string HatchName = m_hatch->getNameInDocument();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",HatchName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
m_source->touch();
|
||||
m_source->getDocument()->recompute();
|
||||
return false;
|
||||
}
|
||||
|
||||
void TaskGeomHatch::getParameters()
|
||||
{
|
||||
m_file = m_hatch->FilePattern.getValue();
|
||||
m_name = m_hatch->NamePattern.getValue();
|
||||
m_scale = m_hatch->ScalePattern.getValue();
|
||||
m_color = m_Vp->ColorPattern.getValue();
|
||||
m_weight = m_Vp->WeightPattern.getValue();
|
||||
}
|
||||
|
||||
void TaskGeomHatch::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TaskDlgGeomHatch::TaskDlgGeomHatch(TechDraw::DrawGeomHatch* inHatch, TechDrawGui::ViewProviderGeomHatch* inVp) :
|
||||
TaskDialog()
|
||||
{
|
||||
widget = new TaskGeomHatch(inHatch,inVp);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("TechDraw_Tree_View"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgGeomHatch::~TaskDlgGeomHatch()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgGeomHatch::update()
|
||||
{
|
||||
//widget->updateTask();
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
void TaskDlgGeomHatch::open()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgGeomHatch::clicked(int i)
|
||||
{
|
||||
Q_UNUSED(i);
|
||||
}
|
||||
|
||||
bool TaskDlgGeomHatch::accept()
|
||||
{
|
||||
widget->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgGeomHatch::reject()
|
||||
{
|
||||
widget->reject();
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_TaskGeomHatch.cpp>
|
116
src/Mod/TechDraw/Gui/TaskGeomHatch.h
Normal file
116
src/Mod/TechDraw/Gui/TaskGeomHatch.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2017 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* 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 GUI_TASKVIEW_TASKGEOMHATCH_H
|
||||
#define GUI_TASKVIEW_TASKGEOMHATCH_H
|
||||
|
||||
#include <App/Material.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskGeomHatch.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawGeomHatch.h>
|
||||
|
||||
|
||||
class Ui_TaskGeomHatch;
|
||||
|
||||
namespace App
|
||||
{
|
||||
class DocumentObject;
|
||||
}
|
||||
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class ViewProviderGeomHatch;
|
||||
|
||||
class TaskGeomHatch : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskGeomHatch(TechDraw::DrawGeomHatch* inHatch,TechDrawGui::ViewProviderGeomHatch* inVp);
|
||||
~TaskGeomHatch();
|
||||
|
||||
public:
|
||||
virtual bool accept();
|
||||
virtual bool reject();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onFileChanged(void);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void initUi();
|
||||
// bool resetUi();
|
||||
void updateValues();
|
||||
void getParameters();
|
||||
QStringList listToQ(std::vector<std::string> in);
|
||||
|
||||
private:
|
||||
Ui_TaskGeomHatch * ui;
|
||||
TechDraw::DrawGeomHatch* m_hatch;
|
||||
TechDrawGui::ViewProviderGeomHatch* m_Vp;
|
||||
App::DocumentObject* m_source;
|
||||
std::string m_file;
|
||||
std::string m_name;
|
||||
double m_scale;
|
||||
double m_weight;
|
||||
App::Color m_color;
|
||||
|
||||
};
|
||||
|
||||
class TaskDlgGeomHatch : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgGeomHatch(TechDraw::DrawGeomHatch* inHatch,TechDrawGui::ViewProviderGeomHatch* inVp);
|
||||
~TaskDlgGeomHatch();
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
/// is called by the framework if the user presses the help button
|
||||
virtual void helpRequested() { return;}
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
void update();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
TaskGeomHatch * widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} //namespace TechDrawGui
|
||||
|
||||
#endif // #ifndef GUI_TASKVIEW_TASKGEOMHATCH_H
|
178
src/Mod/TechDraw/Gui/TaskGeomHatch.ui
Normal file
178
src/Mod/TechDraw/Gui/TaskGeomHatch.ui
Normal file
|
@ -0,0 +1,178 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TechDrawGui::TaskGeomHatch</class>
|
||||
<widget class="QWidget" name="TechDrawGui::TaskGeomHatch">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>385</width>
|
||||
<height>265</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Apply Geometric Hatch to Face</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Define your pattern</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,1">
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::FileChooser" name="fcFile">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The PAT file containing your pattern</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Pattern File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Pattern Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Line Weight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Pattern Scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Line Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="cbName">
|
||||
<property name="toolTip">
|
||||
<string>Name of pattern within file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="Gui::ColorButton" name="ccColor">
|
||||
<property name="toolTip">
|
||||
<string>Color of pattern lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QDoubleSpinBox" name="sbScale">
|
||||
<property name="toolTip">
|
||||
<string>Enlarges/shrinks the pattern</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QDoubleSpinBox" name="sbWeight">
|
||||
<property name="toolTip">
|
||||
<string>Thickness of lines within the pattern</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::FileChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/FileDialog.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../../../Documents/CAD/DrawingModule/Resources/TechDraw.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user