[TD] Add SurfaceFinishSymbol command
Co-authored-by: Benjamin Bræstrup Sayoc <benj5378@outlook.com>
This commit is contained in:
@@ -82,6 +82,7 @@ set(TechDrawGui_UIC_SRCS
|
||||
TaskRichAnno.ui
|
||||
TaskSectionView.ui
|
||||
TaskWeldingSymbol.ui
|
||||
TaskSurfaceFinishSymbols.ui
|
||||
SymbolChooser.ui
|
||||
TaskMoveView.ui
|
||||
TaskProjection.ui
|
||||
@@ -186,6 +187,9 @@ SET(TechDrawGui_SRCS
|
||||
TaskWeldingSymbol.ui
|
||||
TaskWeldingSymbol.cpp
|
||||
TaskWeldingSymbol.h
|
||||
TaskSurfaceFinishSymbols.ui
|
||||
TaskSurfaceFinishSymbols.cpp
|
||||
TaskSurfaceFinishSymbols.h
|
||||
TaskSelectLineAttributes.ui
|
||||
TaskSelectLineAttributes.cpp
|
||||
TaskSelectLineAttributes.h
|
||||
@@ -404,6 +408,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
|
||||
TaskLineDecor.ui
|
||||
TaskRestoreLines.ui
|
||||
TaskWeldingSymbol.ui
|
||||
TaskSurfaceFinishSymbols.ui
|
||||
SymbolChooser.ui
|
||||
TaskActiveView.ui
|
||||
TaskDetail.ui
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
#include "ViewProviderViewPart.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGVPage.h"
|
||||
#include "TaskSurfaceFinishSymbols.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
@@ -1454,6 +1455,50 @@ bool CmdTechDrawWeldSymbol::isActive(void)
|
||||
return (havePage && haveView);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_SurfaceFinishSymbols
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawSurfaceFinishSymbols)
|
||||
|
||||
CmdTechDrawSurfaceFinishSymbols::CmdTechDrawSurfaceFinishSymbols()
|
||||
: Command("TechDraw_SurfaceFinishSymbols")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Create a Surface Finish Symbol");
|
||||
sToolTipText = QT_TR_NOOP("Select a view<br>\
|
||||
- click this button<br>\
|
||||
- select surface finish symbol attributes in opened panel");
|
||||
sWhatsThis = "TechDraw_SurfaceFinishSymbols";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/TechDraw_SurfaceFinishSymbols";
|
||||
}
|
||||
|
||||
void CmdTechDrawSurfaceFinishSymbols::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
std::vector<Gui::SelectionObject> selection = this->getSelection().getSelectionEx();
|
||||
if (selection.empty())
|
||||
{
|
||||
QMessageBox::warning(Gui::getMainWindow(),QObject::tr("SurfaceFinishSymbols"),QObject::tr("Selection is empty"));
|
||||
return;
|
||||
}
|
||||
TechDraw::DrawViewPart* objFeat = dynamic_cast<TechDraw::DrawViewPart*> (selection[0].getObject());
|
||||
if(!objFeat)
|
||||
{
|
||||
QMessageBox::warning(Gui::getMainWindow(),QObject::tr("SurfaceFinishSymbols"),QObject::tr("No object selected"));
|
||||
return;
|
||||
}
|
||||
Gui::Control().showDialog(new TechDrawGui::TaskDlgSurfaceFinishSymbols(objFeat));
|
||||
}
|
||||
|
||||
bool CmdTechDrawSurfaceFinishSymbols::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this);
|
||||
return havePage && haveView;
|
||||
}
|
||||
|
||||
void CreateTechDrawCommandsAnnotate(void)
|
||||
{
|
||||
@@ -1475,6 +1520,7 @@ void CreateTechDrawCommandsAnnotate(void)
|
||||
rcCmdMgr.addCommand(new CmdTechDrawDecorateLine());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawShowAll());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawWeldSymbol());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawSurfaceFinishSymbols());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<file>icons/actions/TechDraw_ToggleFrame.svg</file>
|
||||
<file>icons/actions/TechDraw_View.svg</file>
|
||||
<file>icons/actions/TechDraw_WeldSymbol.svg</file>
|
||||
<file>icons/actions/TechDraw_SurfaceFinishSymbols.svg</file>
|
||||
<file>icons/arrow-ccw.svg</file>
|
||||
<file>icons/arrow-cw.svg</file>
|
||||
<file>icons/arrow-down.svg</file>
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 14 KiB |
382
src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp
Normal file
382
src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp
Normal file
@@ -0,0 +1,382 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 edi *
|
||||
* *
|
||||
* 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"
|
||||
#include <App/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/Gui/ui_TaskSurfaceFinishSymbols.h>
|
||||
#include "TaskSurfaceFinishSymbols.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QLineEdit>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QComboBox>
|
||||
|
||||
using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
SvgString::SvgString(int width, int height)
|
||||
{
|
||||
svgStream << "<?xml version='1.0'?>\n";
|
||||
svgStream << "<svg width='" << width << "' height='" << height << "'>\n";
|
||||
}
|
||||
|
||||
void SvgString::addLine(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
svgStream << "<path stroke='#000' stroke-width='1' d='";
|
||||
svgStream << " M" << x1 << "," << y1; // startpoint
|
||||
svgStream << " L" << x2 << "," << y2; // endpoint
|
||||
svgStream << "' />\n";
|
||||
}
|
||||
|
||||
void SvgString::addCircle(int xCenter, int yCenter, int radius)
|
||||
{
|
||||
svgStream << "<circle cx='" << xCenter <<"' cy='" << yCenter;
|
||||
svgStream << "' r='" << radius;
|
||||
svgStream << "' fill='none' stroke='#000' stroke-width='1'/>\n";
|
||||
}
|
||||
|
||||
void SvgString::addText(int xText, int yText, std::string text)
|
||||
{
|
||||
svgStream << "<text x='" << xText << "' y='" << yText;
|
||||
svgStream << "' style='font-size:18px'>" << text << "</text>\n";
|
||||
}
|
||||
|
||||
std::string SvgString::finish(void)
|
||||
{
|
||||
svgStream << "</svg>\n";
|
||||
return svgStream.str();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TaskSurfaceFinishSymbols
|
||||
//===========================================================================
|
||||
|
||||
TaskSurfaceFinishSymbols::TaskSurfaceFinishSymbols(TechDraw::DrawViewPart* view) :
|
||||
selectedView(view),
|
||||
ui(new Ui_TaskSurfaceFinishSymbols)
|
||||
{
|
||||
raValues = {"RA50","RA25","RA12,5","RA6,3",
|
||||
"RA3,2","RA1,6","RA0,8","RA0,4",
|
||||
"RA0,2","RA0,1","RA0,05","RA0,025"};
|
||||
laySymbols = {"","=","⟂","X","M","C","R"};
|
||||
roughGrades = {"","N1","N2","N3","N4","N5",
|
||||
"N6","N7","N8","N9","N10","N11"};
|
||||
ui->setupUi(this);
|
||||
setUiEdit();
|
||||
}
|
||||
|
||||
QPixmap TaskSurfaceFinishSymbols::baseSymbol(symbolType type)
|
||||
// return QPixmap showing a base symbol
|
||||
{
|
||||
QImage img (50,64,QImage::Format_ARGB32_Premultiplied);
|
||||
img.fill(QColor(240,240,240));
|
||||
QPainter painter;
|
||||
painter.begin(&img);
|
||||
painter.setPen(QPen(Qt::black, 2, Qt::SolidLine,
|
||||
Qt::RoundCap, Qt::RoundJoin));
|
||||
painter.setRenderHints(QPainter::Antialiasing |
|
||||
QPainter::SmoothPixmapTransform |
|
||||
QPainter::TextAntialiasing);
|
||||
painter.drawLine(QLine(0,44,12,64));
|
||||
painter.drawLine(QLine(12,64,42,14));
|
||||
if (type == removeProhibit || type == removeProhibitAll)
|
||||
painter.drawEllipse(QPoint(12,46),9,9);
|
||||
if (type == removeRequired || type == removeRequiredAll)
|
||||
painter.drawLine(QLine(0,44,24,44));
|
||||
if (type > removeRequired)
|
||||
painter.drawEllipse(QPoint(42,14),6,6);
|
||||
painter.end();
|
||||
return QPixmap::fromImage(img);
|
||||
}
|
||||
|
||||
std::string TaskSurfaceFinishSymbols::completeSymbol(void)
|
||||
// return string showing the complete symbol
|
||||
{
|
||||
SvgString symbol(150,64);
|
||||
symbol.addLine(0,44,12,64);
|
||||
symbol.addLine(12,64,42,14);
|
||||
int moveLeft(0), maxTextLength(0);
|
||||
if (activeIcon == removeProhibit || activeIcon == removeProhibitAll)
|
||||
symbol.addCircle(12,46,9);
|
||||
if (activeIcon == removeRequired || activeIcon == removeRequiredAll)
|
||||
symbol.addLine(0,44,24,44);
|
||||
if (activeIcon > removeRequired)
|
||||
{
|
||||
symbol.addCircle(42,14,6);
|
||||
moveLeft = 5 ;
|
||||
}
|
||||
std::string methodText = leMethod->text().toStdString();
|
||||
symbol.addText(42+moveLeft,11,methodText);
|
||||
int methodTextLength = methodText.length();
|
||||
if (isISO)
|
||||
{
|
||||
std::string raText = cbRA->itemText(cbRA->currentIndex()).toStdString();
|
||||
symbol.addText(42+moveLeft,30,raText);
|
||||
int raTextLength = raText.length();
|
||||
maxTextLength = std::max(methodTextLength,raTextLength)*9.25+moveLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string sampleText = leSamLength->text().toStdString();
|
||||
symbol.addText(42+moveLeft,30,sampleText);
|
||||
int sampleTextLength = sampleText.length();
|
||||
maxTextLength = std::max(methodTextLength,sampleTextLength)*9.25+moveLeft;
|
||||
std::string minRoughtText = cbMinRought->itemText(cbMinRought->currentIndex()).toStdString();
|
||||
symbol.addText(-10,35,minRoughtText);
|
||||
std::string maxRoughtText = cbMaxRought->itemText(cbMaxRought->currentIndex()).toStdString();
|
||||
symbol.addText(-10,20,maxRoughtText);
|
||||
}
|
||||
symbol.addLine(42,14,42+maxTextLength,14);
|
||||
symbol.addText(20,60,cbLay->itemText(cbLay->currentIndex()).toStdString());
|
||||
symbol.addText(-25,60,leAddition->text().toStdString());
|
||||
std::string symbolAsString = symbol.finish();
|
||||
return symbolAsString;
|
||||
}
|
||||
|
||||
TaskSurfaceFinishSymbols::~TaskSurfaceFinishSymbols()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskSurfaceFinishSymbols::updateTask()
|
||||
{
|
||||
// blockUpdate = true;
|
||||
|
||||
// blockUpdate = false;
|
||||
}
|
||||
|
||||
|
||||
void TaskSurfaceFinishSymbols::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSurfaceFinishSymbols::setUiEdit()
|
||||
// arrange widget at tool start
|
||||
{
|
||||
setWindowTitle(tr("Surface Finish Symbols"));
|
||||
// create icon pixmaps of QPushButtons
|
||||
ui->pbIcon01->setIcon(baseSymbol(anyMethod));
|
||||
ui->pbIcon02->setIcon(baseSymbol(removeProhibit));
|
||||
ui->pbIcon03->setIcon(baseSymbol(removeRequired));
|
||||
ui->pbIcon04->setIcon(baseSymbol(anyMethodAll));
|
||||
ui->pbIcon05->setIcon(baseSymbol(removeProhibitAll));
|
||||
ui->pbIcon06->setIcon(baseSymbol(removeRequiredAll));
|
||||
activeIcon = anyMethod ;
|
||||
isISO = true;
|
||||
|
||||
// Create scene and all items used in the scene
|
||||
symbolScene = new(QGraphicsScene);
|
||||
ui->graphicsView->setScene(symbolScene);
|
||||
// QLineEdit showing method
|
||||
leMethod = new(QLineEdit);
|
||||
leMethod->resize(90,20);
|
||||
leMethod->setToolTip(QObject::tr("Method"));
|
||||
QGraphicsProxyWidget* proxyMethod = symbolScene->addWidget(leMethod);
|
||||
proxyMethod->setPos(2,-142);
|
||||
// QLineEdit showing addition
|
||||
leAddition = new(QLineEdit);
|
||||
leAddition->resize(25,20);
|
||||
leAddition->setToolTip(QObject::tr("Addition"));
|
||||
QGraphicsProxyWidget* proxyAddition = symbolScene->addWidget(leAddition);
|
||||
proxyAddition->setPos(-80,-85);
|
||||
proxyAddition->setZValue(-2);
|
||||
// QComboBox showing RA values
|
||||
cbRA = new(QComboBox);
|
||||
cbRA->resize(90,20);
|
||||
for (std::string nextValue : raValues)
|
||||
cbRA->addItem(QString::fromStdString(nextValue));
|
||||
cbRA->setToolTip(QObject::tr("Average roughness"));
|
||||
proxyRA = symbolScene->addWidget(cbRA);
|
||||
proxyRA->setPos(2,-113);
|
||||
// QLineEdit showing sampling length value
|
||||
leSamLength = new(QLineEdit);
|
||||
leSamLength->resize(90,20);
|
||||
leSamLength->setToolTip(QObject::tr("Roughness sampling length"));
|
||||
proxySamLength = symbolScene->addWidget(leSamLength);
|
||||
proxySamLength->setPos(2,-113);
|
||||
proxySamLength->hide();
|
||||
// QComboBox showing lay symbol
|
||||
cbLay = new(QComboBox);
|
||||
cbLay->resize(40,20);
|
||||
for (std::string nextLay : laySymbols)
|
||||
cbLay->addItem(QString::fromStdString(nextLay));
|
||||
cbLay->setToolTip(QObject::tr("Lay symbol"));
|
||||
QGraphicsProxyWidget* proxyLay = symbolScene->addWidget(cbLay);
|
||||
proxyLay->setPos(-23,-85);
|
||||
// QComboBox showing minimal roughness grade
|
||||
cbMinRought = new(QComboBox);
|
||||
cbMinRought->resize(55,20);
|
||||
for (std::string nextGrade : roughGrades)
|
||||
cbMinRought->addItem(QString::fromStdString(nextGrade));
|
||||
cbMinRought->setToolTip(QObject::tr("Minimum roughness grade number"));
|
||||
proxyMinRough = symbolScene->addWidget(cbMinRought);
|
||||
proxyMinRough->setPos(-80,-118);
|
||||
proxyMinRough-> setZValue(1);
|
||||
proxyMinRough->hide();
|
||||
// QComboBox showing maximal roughness grade
|
||||
cbMaxRought = new(QComboBox);
|
||||
cbMaxRought->resize(55,20);
|
||||
for (std::string nextGrade : roughGrades)
|
||||
cbMaxRought->addItem(QString::fromStdString(nextGrade));
|
||||
cbMaxRought->setToolTip(QObject::tr("Maximum roughness grade number"));
|
||||
proxyMaxRough = symbolScene->addWidget(cbMaxRought);
|
||||
proxyMaxRough->setPos(-80,-143);
|
||||
proxyMaxRough->setZValue(1);
|
||||
proxyMaxRough->hide();
|
||||
// add horizontal line
|
||||
symbolScene->addLine(QLine(-8,-116,90,-116),
|
||||
QPen(Qt::black,2,Qt::SolidLine,
|
||||
Qt::RoundCap, Qt::RoundJoin));
|
||||
// add pixmap of the surface finish symbol
|
||||
QIcon symbolIcon = ui->pbIcon01->icon();
|
||||
QGraphicsPixmapItem* pixmapItem = new(QGraphicsPixmapItem);
|
||||
pixmapItem->setPixmap(symbolIcon.pixmap(50,64));
|
||||
pixmapItem->setPos(-50,-130);
|
||||
pixmapItem->setZValue(-1);
|
||||
symbolScene->addItem(pixmapItem);
|
||||
|
||||
connect(ui->pbIcon01, SIGNAL(clicked()), this, SLOT(onIconChanged()));
|
||||
connect(ui->pbIcon02, SIGNAL(clicked()), this, SLOT(onIconChanged()));
|
||||
connect(ui->pbIcon03, SIGNAL(clicked()), this, SLOT(onIconChanged()));
|
||||
connect(ui->pbIcon04, SIGNAL(clicked()), this, SLOT(onIconChanged()));
|
||||
connect(ui->pbIcon05, SIGNAL(clicked()), this, SLOT(onIconChanged()));
|
||||
connect(ui->pbIcon06, SIGNAL(clicked()), this, SLOT(onIconChanged()));
|
||||
connect(ui->rbISO, SIGNAL(clicked()), this, SLOT(onISO()));
|
||||
connect(ui->rbASME, SIGNAL(clicked()), this, SLOT(onASME()));
|
||||
}
|
||||
|
||||
void TaskSurfaceFinishSymbols::onIconChanged()
|
||||
// Slot: change icon of surface finish symbol
|
||||
{
|
||||
QObject* senderObj(this->sender());
|
||||
QPushButton* pressedButton = qobject_cast<QPushButton*>(senderObj);
|
||||
if (!pressedButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ui->pbIcon01 == pressedButton) activeIcon = anyMethod;
|
||||
if (ui->pbIcon02 == pressedButton) activeIcon = removeProhibit;
|
||||
if (ui->pbIcon03 == pressedButton) activeIcon = removeRequired;
|
||||
if (ui->pbIcon04 == pressedButton) activeIcon = anyMethodAll;
|
||||
if (ui->pbIcon05 == pressedButton) activeIcon = removeProhibitAll;
|
||||
if (ui->pbIcon06 == pressedButton) activeIcon = removeRequiredAll;
|
||||
|
||||
QIcon symbolIcon = pressedButton->icon();
|
||||
QGraphicsPixmapItem* pixmapItem = new(QGraphicsPixmapItem);
|
||||
pixmapItem->setPixmap(symbolIcon.pixmap(50,64));
|
||||
pixmapItem->setPos(-50,-130);
|
||||
pixmapItem->setZValue(-1);
|
||||
symbolScene->addItem(pixmapItem);
|
||||
}
|
||||
|
||||
void TaskSurfaceFinishSymbols::onISO()
|
||||
// Slot: show ISO template in scene
|
||||
{
|
||||
isISO = true;
|
||||
proxySamLength->hide();
|
||||
proxyMinRough->hide();
|
||||
proxyMaxRough->hide();
|
||||
proxyRA->show();
|
||||
}
|
||||
|
||||
void TaskSurfaceFinishSymbols::onASME()
|
||||
// Slot: show ASME template in scene
|
||||
{
|
||||
isISO = false;
|
||||
proxySamLength->show();
|
||||
proxyMinRough->show();
|
||||
proxyMaxRough->show();
|
||||
proxyRA->hide();
|
||||
}
|
||||
|
||||
bool TaskSurfaceFinishSymbols::accept()
|
||||
// Slot: dialog finished using OK
|
||||
{
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Surface Finish Symbols"));
|
||||
App::Document *doc = Application::Instance->activeDocument()->getDocument();
|
||||
App::DocumentObject *docObject = doc->addObject("TechDraw::DrawViewSymbol","SurfaceSymbol");
|
||||
TechDraw::DrawViewSymbol *surfaceSymbol = dynamic_cast<TechDraw::DrawViewSymbol*>(docObject);
|
||||
surfaceSymbol->Symbol.setValue(completeSymbol());
|
||||
surfaceSymbol->Rotation.setValue(ui->leAngle->text().toDouble());
|
||||
TechDraw::DrawPage* page = selectedView->findParentPage();
|
||||
page->addView(surfaceSymbol);
|
||||
Gui::Command::commitCommand();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskSurfaceFinishSymbols::reject()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TaskDlgSurfaceFinishSymbols//
|
||||
//===========================================================================
|
||||
|
||||
TaskDlgSurfaceFinishSymbols::TaskDlgSurfaceFinishSymbols(TechDraw::DrawViewPart* view)
|
||||
: TaskDialog()
|
||||
{
|
||||
widget = new TaskSurfaceFinishSymbols(view);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_SurfaceFinishSymbols"),
|
||||
widget->windowTitle(), true, nullptr);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgSurfaceFinishSymbols::~TaskDlgSurfaceFinishSymbols()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgSurfaceFinishSymbols::update()
|
||||
{
|
||||
// widget->updateTask();
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
void TaskDlgSurfaceFinishSymbols::open()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgSurfaceFinishSymbols::clicked(int)
|
||||
{
|
||||
}
|
||||
|
||||
bool TaskDlgSurfaceFinishSymbols::accept()
|
||||
{
|
||||
widget->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgSurfaceFinishSymbols::reject()
|
||||
{
|
||||
widget->reject();
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_TaskSurfaceFinishSymbols.cpp>
|
||||
148
src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h
Normal file
148
src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 edi *
|
||||
* *
|
||||
* 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 TECHDRAWGUI_TASKSURFACEFINISHSYMBOLS_H
|
||||
#define TECHDRAWGUI_TASKSURFACEFINISHSYMBOLS_H
|
||||
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
|
||||
class QComboBox;
|
||||
|
||||
namespace App {
|
||||
class DocumentObject;
|
||||
}
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
class DrawPage;
|
||||
class DrawView;
|
||||
class DrawViewPart;
|
||||
class CosmeticEdge;
|
||||
class LineFormat;
|
||||
}
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
class Face;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
class MDIViewPage;
|
||||
class ViewProviderViewPart;
|
||||
class Ui_TaskSurfaceFinishSymbols;
|
||||
|
||||
class SvgString
|
||||
// Class to reate a SVG as a string
|
||||
{
|
||||
std::stringstream svgStream;
|
||||
|
||||
public:
|
||||
|
||||
SvgString(int width, int height);
|
||||
void addLine(int x1, int y1, int x2, int y2);
|
||||
void addCircle(int xCenter, int yCenter, int radius);
|
||||
void addText(int xText, int yText, std::string text);
|
||||
std::string finish(void);
|
||||
|
||||
}; // SvgString
|
||||
|
||||
class TaskSurfaceFinishSymbols : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskSurfaceFinishSymbols(TechDraw::DrawViewPart* view);
|
||||
~TaskSurfaceFinishSymbols();
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
public:
|
||||
virtual bool accept();
|
||||
virtual bool reject();
|
||||
void updateTask();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onIconChanged();
|
||||
void onISO();
|
||||
void onASME();
|
||||
|
||||
protected Q_SLOTS:
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
void setUiEdit(void);
|
||||
|
||||
private:
|
||||
enum symbolType {anyMethod=0, removeProhibit, removeRequired,
|
||||
anyMethodAll, removeProhibitAll, removeRequiredAll};
|
||||
QPixmap baseSymbol(symbolType type);
|
||||
std::string completeSymbol();
|
||||
TechDraw::DrawViewPart* selectedView;
|
||||
QGraphicsScene* symbolScene;
|
||||
std::vector<std::string> raValues, laySymbols, roughGrades;
|
||||
QGraphicsProxyWidget *proxyRA, *proxySamLength, *proxyMinRough, *proxyMaxRough;
|
||||
QLineEdit *leMethod, *leSamLength, *leAddition;
|
||||
QComboBox *cbRA, *cbMinRought, *cbMaxRought, *cbLay;
|
||||
symbolType activeIcon;
|
||||
bool isISO;
|
||||
std::unique_ptr<Ui_TaskSurfaceFinishSymbols> ui;
|
||||
}; // class TaskSurfaceFinishSymbols
|
||||
|
||||
class TaskDlgSurfaceFinishSymbols : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgSurfaceFinishSymbols(TechDraw::DrawViewPart* view);
|
||||
~TaskDlgSurfaceFinishSymbols();
|
||||
|
||||
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:
|
||||
TaskSurfaceFinishSymbols* widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
}; // class TaskDlgSurfaceFinishSymbols
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
#endif // #ifndef TECHDRAWGUI_TASKSURFACEFINISHSYMBOLS_H
|
||||
188
src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.ui
Normal file
188
src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.ui
Normal file
@@ -0,0 +1,188 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TechDrawGui::TaskSurfaceFinishSymbols</class>
|
||||
<widget class="QWidget" name="TechDrawGui::TaskSurfaceFinishSymbols">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>274</width>
|
||||
<height>454</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Surface Finish Symbols</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pbIcon05">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Material removal prohibited, whole part</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pbIcon04">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Any method allowed, whole part</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pbIcon06">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Material removal required, whole part</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pbIcon03">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Material removal required</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pbIcon02">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Material removal prohibited</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pbIcon01">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Any method allowed</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbAngle">
|
||||
<property name="text">
|
||||
<string>Symbol angle:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leAngle">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Rotation angle</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="rbISO">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Use ISO standard</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ISO</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QRadioButton" name="rbASME">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Use ASME standard</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ASME</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGraphicsView" name="graphicsView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor" stdset="0">
|
||||
<cursorShape>ArrowCursor</cursorShape>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="backgroundBrush">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>240</red>
|
||||
<green>240</green>
|
||||
<blue>240</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</property>
|
||||
<property name="sceneRect">
|
||||
<rectf>
|
||||
<x>0.000000000000000</x>
|
||||
<y>0.000000000000000</y>
|
||||
<width>3.000000000000000</width>
|
||||
<height>0.000000000000000</height>
|
||||
</rectf>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="Resources/TechDraw.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -212,6 +212,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
*draw << "TechDraw_DecorateLine";
|
||||
*draw << "TechDraw_ShowAll";
|
||||
*draw << "TechDraw_WeldSymbol";
|
||||
*draw << "TechDraw_SurfaceFinishSymbols";
|
||||
*draw << "Separator";
|
||||
*draw << "TechDraw_ProjectShape";
|
||||
return root;
|
||||
@@ -352,6 +353,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
*anno << "TechDraw_DecorateLine";
|
||||
*anno << "TechDraw_ShowAll";
|
||||
*anno << "TechDraw_WeldSymbol";
|
||||
*anno << "TechDraw_SurfaceFinishSymbols";
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -491,6 +493,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
*anno << "TechDraw_DecorateLine";
|
||||
*anno << "TechDraw_ShowAll";
|
||||
*anno << "TechDraw_WeldSymbol";
|
||||
*anno << "TechDraw_SurfaceFinishSymbols";
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user