[TD]harmonize Arrow enums

This commit is contained in:
wandererfan
2020-03-10 13:23:05 -04:00
committed by WandererFan
parent c7d3ae2d83
commit dcef41782e
19 changed files with 335 additions and 72 deletions

View File

@@ -25,10 +25,18 @@
#include "PreCompiled.h"
#include <App/Application.h>
#include <Base/Parameter.h>
#include <Base/Console.h>
#include "DrawGuiUtil.h"
#include "DlgPrefsTechDraw3Imp.h"
#include <Gui/PrefWidgets.h>
using namespace TechDrawGui;
using namespace TechDraw;
DlgPrefsTechDraw3Imp::DlgPrefsTechDraw3Imp( QWidget* parent )
: PreferencePage( parent )
@@ -95,6 +103,11 @@ void DlgPrefsTechDraw3Imp::loadSettings()
plsb_ArrowSize->onRestore();
plsb_FontSize->onRestore();
sbAltDecimals->onRestore();
DrawGuiUtil::loadArrowBox(pcbBalloonArrow);
pcbBalloonArrow->setCurrentIndex(prefBalloonArrow());
DrawGuiUtil::loadArrowBox(pcbArrow);
pcbArrow->setCurrentIndex(prefArrowStyle());
}
/**
@@ -112,4 +125,24 @@ void DlgPrefsTechDraw3Imp::changeEvent(QEvent *e)
}
}
int DlgPrefsTechDraw3Imp::prefBalloonArrow(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Decorations");
int end = hGrp->GetInt("BalloonArrow", 1);
return end;
}
int DlgPrefsTechDraw3Imp::prefArrowStyle(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Dimensions");
int style = hGrp->GetInt("ArrowStyle", 1);
return style;
}
#include <Mod/TechDraw/Gui/moc_DlgPrefsTechDraw3Imp.cpp>

View File

@@ -43,6 +43,11 @@ protected:
void saveSettings();
void loadSettings();
void changeEvent(QEvent *e);
int prefBalloonArrow(void) const;
int prefArrowStyle(void) const;
};
} // namespace TechDrawGui

View File

@@ -73,6 +73,7 @@
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/ArrowPropEnum.h>
#include "QGVPage.h"
#include "MDIViewPage.h"
@@ -82,6 +83,18 @@
using namespace TechDrawGui;
using namespace TechDraw;
void DrawGuiUtil::loadArrowBox(QComboBox* qcb)
{
qcb->clear();
int i = 0;
for (; i < ArrowPropEnum::ArrowCount; i++) {
qcb->addItem(QString::fromUtf8(ArrowPropEnum::ArrowTypeEnums[i]));
QIcon itemIcon(QString::fromUtf8(ArrowPropEnum::ArrowTypeIcons[i].c_str()));
qcb->setItemIcon(i, itemIcon);
}
}
//===========================================================================
// validate helper routines
//===========================================================================

View File

@@ -26,8 +26,11 @@
#include <string>
#include <QRectF>
#include <QPointF>
#include <QComboBox>
#include <Base/Vector3D.h>
/*#include <Gui/PrefWidgets.h>*/
namespace Part {
class Feature;
}
@@ -51,7 +54,10 @@ class TechDrawGuiExport DrawGuiUtil {
static void dumpRectF(const char* text, const QRectF& r);
static void dumpPointF(const char* text, const QPointF& p);
static std::pair<Base::Vector3d,Base::Vector3d> get3DDirAndRot();
static std::pair<Base::Vector3d,Base::Vector3d> getProjDirFromFace(App::DocumentObject* obj, std::string faceName);
static std::pair<Base::Vector3d,Base::Vector3d> getProjDirFromFace(App::DocumentObject* obj,
std::string faceName);
static void loadArrowBox(QComboBox* qcb);
};

View File

@@ -36,10 +36,13 @@
#include <Base/Parameter.h>
#include <Base/Console.h>
#include <Mod/TechDraw/App/ArrowPropEnum.h>
#include "Rez.h"
#include "QGIArrow.h"
using namespace TechDrawGui;
using namespace TechDraw;
QGIArrow::QGIArrow() :
m_fill(Qt::SolidPattern),
@@ -62,35 +65,35 @@ QGIArrow::QGIArrow() :
void QGIArrow::draw() {
QPainterPath path;
if (m_style == FILLED_TRIANGLE) {
if (m_style == ArrowType::FILLED_ARROW) {
if (m_dirMode) {
path = makeFilledTriangle(getDirection(), m_size,m_size/6.0);
} else {
path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //"arrow l/w sb 3/1" ??
}
} else if (m_style == OPEN_ARROW) {
} else if (m_style == ArrowType::OPEN_ARROW) {
if (m_dirMode) {
path = makeOpenArrow(getDirection(), m_size,m_size/3.0); //broad arrow?
} else {
path = makeOpenArrow(m_size,m_size/3.0,isFlipped());
}
} else if (m_style == HASH_MARK) {
} else if (m_style == ArrowType::TICK) {
if (m_dirMode) {
path = makeHashMark(getDirection(), m_size/2.0,m_size/2.0); //big enough?
} else {
path = makeHashMark(m_size/2.0,m_size/2.0,isFlipped()); //big enough?
}
} else if (m_style == DOT) {
} else if (m_style == ArrowType::DOT) {
path = makeDot(m_size/2.0,m_size/2.0,isFlipped());
} else if (m_style == OPEN_CIRCLE) {
} else if (m_style == ArrowType::OPEN_CIRCLE) {
path = makeOpenDot(m_size/2.0,m_size/2.0,isFlipped());
} else if (m_style == FORK) {
} else if (m_style == ArrowType::FORK) {
if (m_dirMode) {
path = makeForkArrow(getDirection(), m_size/2.0,m_size/2.0); //big enough?
} else {
path = makeForkArrow(m_size/2.0,m_size/2.0,isFlipped()); //big enough?
}
} else if (m_style == PYRAMID){
} else if (m_style == ArrowType::FILLED_TRIANGLE){
if (m_dirMode) {
path = makePyramid(getDirection(), m_size);
} else {
@@ -331,13 +334,13 @@ double QGIArrow::getOverlapAdjust(int style, double size)
// Base::Console().Message("QGIA::getOverlapAdjust(%d, %.3f) \n",style, size);
double result = 1.0;
switch(style) {
case FILLED_TRIANGLE:
case FILLED_ARROW:
result = 0.50 * size;
break;
case OPEN_ARROW:
result = 0.10 * size;
break;
case HASH_MARK:
case TICK:
result = 0.0;
break;
case DOT:
@@ -350,7 +353,7 @@ double QGIArrow::getOverlapAdjust(int style, double size)
case FORK:
result = 0.0;
break;
case PYRAMID:
case FILLED_TRIANGLE:
result = size;
break;
case NONE:

View File

@@ -35,16 +35,16 @@ QT_END_NAMESPACE
namespace TechDrawGui
{
enum ArrowType {
FILLED_TRIANGLE = 0,
OPEN_ARROW,
HASH_MARK,
DOT,
OPEN_CIRCLE,
FORK,
PYRAMID,
NONE
};
/*enum ArrowType {*/
/* FILLED_TRIANGLE = 0,*/
/* OPEN_ARROW,*/
/* HASH_MARK,*/
/* DOT,*/
/* OPEN_CIRCLE,*/
/* FORK,*/
/* PYRAMID,*/
/* NONE*/
/*};*/
class TechDrawGuiExport QGIArrow : public QGIPrimPath
{

View File

@@ -53,6 +53,7 @@
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/LineGroup.h>
#include <Mod/TechDraw/App/ArrowPropEnum.h>
#include "Rez.h"
#include "ZVALUE.h"
@@ -423,11 +424,11 @@ QPainterPath QGILeaderLine::makeLeaderPath(std::vector<QPointF> qPoints)
double endAdjLength(0.0);
if (qPoints.size() > 1) {
//make path adjustment to hide leaderline ends behind arrowheads
if (featLeader->StartSymbol.getValue() > -1) {
if (featLeader->StartSymbol.getValue() > ArrowType::NONE) {
startAdjLength = QGIArrow::getOverlapAdjust(featLeader->StartSymbol.getValue(),
QGIArrow::getPrefArrowSize());
}
if (featLeader->EndSymbol.getValue() > -1) {
if (featLeader->EndSymbol.getValue() > ArrowType::NONE) {
endAdjLength = QGIArrow::getOverlapAdjust(featLeader->EndSymbol.getValue(),
QGIArrow::getPrefArrowSize());
}
@@ -498,7 +499,7 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
QPointF lastOffset = (pathPoints.back() - pathPoints.front());
if (featLeader->StartSymbol.getValue() > -1) {
if (featLeader->StartSymbol.getValue() > ArrowType::NONE) {
m_arrow1->setStyle(featLeader->StartSymbol.getValue());
m_arrow1->setWidth(getLineWidth());
// TODO: variable size arrow heads
@@ -520,7 +521,7 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
m_arrow1->hide();
}
if (featLeader->EndSymbol.getValue() > -1) {
if (featLeader->EndSymbol.getValue() > ArrowType::NONE) {
m_arrow2->setStyle(featLeader->EndSymbol.getValue());
m_arrow2->setWidth(getLineWidth());
m_arrow2->setDirMode(true);

View File

@@ -56,6 +56,7 @@
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/ArrowPropEnum.h>
#include "Rez.h"
#include "ZVALUE.h"
@@ -417,13 +418,11 @@ void QGIViewBalloon::updateBalloon(bool obtuse)
if ( vp == nullptr ) {
return;
}
const TechDraw::DrawViewPart *refObj = balloon->getViewPart();
if (refObj == nullptr) {
return;
}
QFont font = balloonLabel->getFont();
font.setPixelSize(calculateFontPixelSize(vp->Fontsize.getValue()));
font.setFamily(QString::fromUtf8(vp->Font.getValue()));
@@ -444,7 +443,6 @@ void QGIViewBalloon::updateBalloon(bool obtuse)
}
balloonLabel->setDimString(labelText, Rez::guiX(balloon->TextWrapLen.getValue()));
float x = Rez::guiX(balloon->X.getValue() * refObj->getScale());
float y = Rez::guiX(balloon->Y.getValue() * refObj->getScale());
balloonLabel->setPosFromCenter(x, -y);
@@ -520,7 +518,7 @@ void QGIViewBalloon::placeBalloon(QPointF pos)
return;
}
QGIView* qgivParent = nullptr;
QPointF viewPos;
Gui::ViewProvider* objVp = QGIView::getViewProvider(balloonParent);
@@ -595,7 +593,7 @@ void QGIViewBalloon::draw()
float x = Rez::guiX(balloon->X.getValue() * refObj->getScale());
float y = Rez::guiX(balloon->Y.getValue() * refObj->getScale());
Base::Vector3d lblCenter(x, -y, 0.0);
float arrowTipX = Rez::guiX(balloon->OriginX.getValue() * refObj->getScale());
float arrowTipY = - Rez::guiX(balloon->OriginY.getValue() * refObj->getScale());
@@ -706,11 +704,10 @@ void QGIViewBalloon::draw()
double xAdj = 0.0;
double yAdj = 0.0;
int endType = balloon->EndType.getValue();
std::string endTypeString = balloon->EndType.getValueAsString();
double arrowAdj = QGIArrow::getOverlapAdjust(endType,
QGIArrow::getPrefArrowSize());
if (endTypeString == "NONE") {
if (endType == ArrowType::NONE) {
arrow->hide();
} else {
arrow->setStyle(endType);
@@ -729,7 +726,7 @@ void QGIViewBalloon::draw()
float arAngle = atan2(dirballoonLinesLine.y, dirballoonLinesLine.x) * 180 / M_PI;
arrow->setPos(arrowTipX, arrowTipY);
if ( (endTypeString == "PYRAMID") &&
if ( (endType == ArrowType::FILLED_TRIANGLE) &&
(prefOrthoPyramid()) ) {
if (arAngle < 0.0) {
arAngle += 360.0;

View File

@@ -36,6 +36,7 @@
<file>icons/TechDraw_VerticalExtentDimension.svg</file>
<file>icons/techdraw-landmarkdistance.svg</file>
<file>icons/preferences-techdraw.svg</file>
<file>icons/arrownone.svg</file>
<file>icons/arrowdot.svg</file>
<file>icons/arrowopendot.svg</file>
<file>icons/arrowfilled.svg</file>

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg3942"
height="48"
width="48"
version="1.1">
<defs
id="defs3944" />
<metadata
id="metadata3947">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(1.6490345,-1.6458526)"
id="g881">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.72050047;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 2.2263108,45.766302 42.468226,5.5381284"
id="path70" />
<path
id="path72"
d="M 2.2342858,5.5186032 42.475039,45.773102"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.72166395;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -46,9 +46,11 @@
#include <Mod/TechDraw/App/DrawViewBalloon.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/ArrowPropEnum.h>
#include <Mod/TechDraw/Gui/ui_TaskBalloon.h>
#include "DrawGuiUtil.h"
#include "QGIViewBalloon.h"
#include "TaskBalloon.h"
@@ -74,12 +76,12 @@ TaskBalloon::TaskBalloon(QGIViewBalloon *parent) :
ui->inputValue->selectAll();
QTimer::singleShot(0, ui->inputValue, SLOT(setFocus()));
DrawGuiUtil::loadArrowBox(ui->comboEndType);
i = parent->dvBalloon->EndType.getValue();
ui->comboEndType->setCurrentIndex(i);
i = parent->dvBalloon->Symbol.getValue();
ui->comboSymbol->setCurrentIndex(i);
}
TaskBalloon::~TaskBalloon()
@@ -87,7 +89,6 @@ TaskBalloon::~TaskBalloon()
delete ui;
}
bool TaskBalloon::accept()
{
m_parent->dvBalloon->Text.setValue(ui->inputValue->text().toUtf8().constData());

View File

@@ -262,8 +262,12 @@ void TaskLeaderLine::setUiPrimary()
ui->pbCancelEdit->setEnabled(false);
}
int aSize = getPrefArrowStyle() + 1;
ui->cboxStartSym->setCurrentIndex(aSize);
DrawGuiUtil::loadArrowBox(ui->cboxStartSym);
int aStyle = getPrefArrowStyle();
ui->cboxStartSym->setCurrentIndex(aStyle);
DrawGuiUtil::loadArrowBox(ui->cboxEndSym);
ui->cboxEndSym->setCurrentIndex(0);
ui->dsbWeight->setUnit(Base::Unit::Length);
ui->dsbWeight->setMinimum(0);
@@ -290,8 +294,12 @@ void TaskLeaderLine::setUiEdit()
if (m_lineFeat != nullptr) {
std::string baseName = m_lineFeat->LeaderParent.getValue()->getNameInDocument();
ui->tbBaseView->setText(Base::Tools::fromStdString(baseName));
ui->cboxStartSym->setCurrentIndex(m_lineFeat->StartSymbol.getValue() + 1);
ui->cboxEndSym->setCurrentIndex(m_lineFeat->EndSymbol.getValue() + 1);
DrawGuiUtil::loadArrowBox(ui->cboxStartSym);
ui->cboxStartSym->setCurrentIndex(m_lineFeat->StartSymbol.getValue());
DrawGuiUtil::loadArrowBox(ui->cboxEndSym);
ui->cboxEndSym->setCurrentIndex(m_lineFeat->EndSymbol.getValue());
ui->pbTracker->setText(QString::fromUtf8("Edit points"));
if (m_haveMdi) {
ui->pbTracker->setEnabled(true);
@@ -391,8 +399,8 @@ void TaskLeaderLine::updateLeaderFeature(void)
void TaskLeaderLine::commonFeatureUpdate(void)
{
int start = ui->cboxStartSym->currentIndex() - 1;
int end = ui->cboxEndSym->currentIndex() - 1;
int start = ui->cboxStartSym->currentIndex();
int end = ui->cboxEndSym->currentIndex();
m_lineFeat->StartSymbol.setValue(start);
m_lineFeat->EndSymbol.setValue(end);
}
@@ -719,7 +727,7 @@ int TaskLeaderLine::getPrefArrowStyle()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
int style = hGrp->GetInt("ArrowStyle", 0);
int style = hGrp->GetInt("ArrowStyle", 1);
return style;
}