[TD]Add line appearance editor
This commit is contained in:
@@ -364,24 +364,24 @@ void CosmeticEdge::dump(char* title)
|
||||
//*********************************************************
|
||||
CenterLine::CenterLine(void)
|
||||
{
|
||||
start = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
end = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
mode = 0;
|
||||
hShift = 0.0;
|
||||
vShift = 0.0;
|
||||
rotate = 0.0;
|
||||
extendBy = 0.0;
|
||||
m_start = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
m_end = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
m_mode = 0;
|
||||
m_hShift = 0.0;
|
||||
m_vShift = 0.0;
|
||||
m_rotate = 0.0;
|
||||
m_extendBy = 0.0;
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2)
|
||||
{
|
||||
start = p1;
|
||||
end = p2;
|
||||
mode = 0;
|
||||
hShift = 0.0;
|
||||
vShift = 0.0;
|
||||
rotate = 0.0;
|
||||
extendBy = 0.0;
|
||||
m_start = p1;
|
||||
m_end = p2;
|
||||
m_mode = 0;
|
||||
m_hShift = 0.0;
|
||||
m_vShift = 0.0;
|
||||
m_rotate = 0.0;
|
||||
m_extendBy = 0.0;
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2,
|
||||
@@ -391,13 +391,13 @@ CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2,
|
||||
double r,
|
||||
double x)
|
||||
{
|
||||
start = p1;
|
||||
end = p2;
|
||||
mode = m;
|
||||
hShift = h;
|
||||
vShift = v;
|
||||
rotate = r;
|
||||
extendBy = x;
|
||||
m_start = p1;
|
||||
m_end = p2;
|
||||
m_mode = m;
|
||||
m_hShift = h;
|
||||
m_vShift = v;
|
||||
m_rotate = r;
|
||||
m_extendBy = x;
|
||||
}
|
||||
|
||||
CenterLine::~CenterLine()
|
||||
@@ -415,8 +415,8 @@ TechDraw::BaseGeom* CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFeat)
|
||||
std::pair<Base::Vector3d, Base::Vector3d> ends =
|
||||
calcEndPoints(partFeat,
|
||||
m_faces,
|
||||
mode, extendBy,
|
||||
hShift,vShift, rotate);
|
||||
m_mode, m_extendBy,
|
||||
m_hShift,m_vShift, m_rotate);
|
||||
TechDraw::BaseGeom* newGeom = nullptr;
|
||||
Base::Vector3d p1 = DrawUtil::invertY(ends.first);
|
||||
Base::Vector3d p2 = DrawUtil::invertY(ends.second);
|
||||
@@ -435,17 +435,17 @@ TechDraw::BaseGeom* CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFeat)
|
||||
std::string CenterLine::toCSV(void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << start.x << "," << //0
|
||||
start.y << "," << //1
|
||||
start.z << "," << //2
|
||||
end.x << "," << //3
|
||||
end.y << "," << //4
|
||||
end.z << "," << //5
|
||||
mode << "," << //6
|
||||
hShift << "," << //7
|
||||
vShift << "," << //8
|
||||
rotate << "," << //9
|
||||
extendBy << "," << //10
|
||||
ss << m_start.x << "," << //0
|
||||
m_start.y << "," << //1
|
||||
m_start.z << "," << //2
|
||||
m_end.x << "," << //3
|
||||
m_end.y << "," << //4
|
||||
m_end.z << "," << //5
|
||||
m_mode << "," << //6
|
||||
m_hShift << "," << //7
|
||||
m_vShift << "," << //8
|
||||
m_rotate << "," << //9
|
||||
m_extendBy << "," << //10
|
||||
m_faces.size(); //11
|
||||
if (!m_faces.empty()) {
|
||||
for (auto& f: m_faces) {
|
||||
@@ -456,7 +456,7 @@ std::string CenterLine::toCSV(void) const
|
||||
}
|
||||
|
||||
std::string clCSV = ss.str();
|
||||
std::string fmtCSV = fmt.toCSV();
|
||||
std::string fmtCSV = m_format.toCSV();
|
||||
return clCSV + ",$$$," + fmtCSV;
|
||||
}
|
||||
|
||||
@@ -483,22 +483,22 @@ bool CenterLine::fromCSV(std::string& lineSpec)
|
||||
double x = atof(values[0].c_str());
|
||||
double y = atof(values[1].c_str());
|
||||
double z = atof(values[2].c_str());
|
||||
start = Base::Vector3d (x,y,z);
|
||||
m_start = Base::Vector3d (x,y,z);
|
||||
x = atof(values[3].c_str());
|
||||
y = atof(values[4].c_str());
|
||||
z = atof(values[5].c_str());
|
||||
end = Base::Vector3d (x,y,z);
|
||||
mode = atoi(values[6].c_str());
|
||||
hShift = atof(values[7].c_str());
|
||||
vShift = atof(values[8].c_str());
|
||||
rotate = atof(values[9].c_str());
|
||||
extendBy = atof(values[10].c_str());
|
||||
int faceCount = atoi(values[11].c_str());
|
||||
m_end = Base::Vector3d (x,y,z);
|
||||
m_mode = atoi(values[6].c_str());
|
||||
m_hShift = atof(values[7].c_str());
|
||||
m_vShift = atof(values[8].c_str());
|
||||
m_rotate = atof(values[9].c_str());
|
||||
m_extendBy = atof(values[10].c_str());
|
||||
int m_faceCount = atoi(values[11].c_str());
|
||||
int i = 0;
|
||||
for ( ; i < faceCount; i++ ) {
|
||||
for ( ; i < m_faceCount; i++ ) {
|
||||
m_faces.push_back(values[12 + i]);
|
||||
}
|
||||
fmt.fromCSV(tokens[1]);
|
||||
m_format.fromCSV(tokens[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -511,7 +511,7 @@ void CenterLine::dump(char* title)
|
||||
std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart* partFeat,
|
||||
std::vector<std::string> faceNames,
|
||||
int vert, double ext,
|
||||
double hShift, double vShift,
|
||||
double m_hShift, double m_vShift,
|
||||
double rotate)
|
||||
{
|
||||
std::pair<Base::Vector3d, Base::Vector3d> result;
|
||||
@@ -524,8 +524,8 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart
|
||||
faceBox.SetGap(0.0);
|
||||
|
||||
double scale = partFeat->getScale();
|
||||
double hss = hShift * scale;
|
||||
double vss = vShift * scale;
|
||||
double hss = m_hShift * scale;
|
||||
double vss = m_vShift * scale;
|
||||
|
||||
for (auto& fn: faceNames) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(fn) != "Face") {
|
||||
@@ -595,3 +595,71 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart
|
||||
return result;
|
||||
}
|
||||
|
||||
GeomFormat::GeomFormat() :
|
||||
m_geomIndex(-1)
|
||||
{
|
||||
m_format.m_style = LineFormat::getDefEdgeStyle();
|
||||
m_format.m_weight = LineFormat::getDefEdgeWidth();
|
||||
m_format.m_color = LineFormat::getDefEdgeColor();
|
||||
m_format.m_visible = true;
|
||||
}
|
||||
|
||||
GeomFormat::GeomFormat(int idx,
|
||||
TechDraw::LineFormat fmt) :
|
||||
m_geomIndex(idx)
|
||||
{
|
||||
m_format.m_style = fmt.m_style;
|
||||
m_format.m_weight = fmt.m_weight;
|
||||
m_format.m_color = fmt.m_color;
|
||||
m_format.m_visible = fmt.m_visible;
|
||||
//m_format = fmt; //???
|
||||
}
|
||||
|
||||
GeomFormat::~GeomFormat()
|
||||
{
|
||||
}
|
||||
|
||||
void GeomFormat::dump(char* title)
|
||||
{
|
||||
Base::Console().Message("GF::dump - %s \n",title);
|
||||
Base::Console().Message("GF::dump - %s \n",toCSV().c_str());
|
||||
}
|
||||
|
||||
std::string GeomFormat::toCSV(void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << m_geomIndex << ",$$$," <<
|
||||
m_format.toCSV();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool GeomFormat::fromCSV(std::string& lineSpec)
|
||||
{
|
||||
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
|
||||
if (tokens.empty()) {
|
||||
Base::Console().Message("GeomFormat::fromCSV - tokenize failed - no tokens\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tokens[0].length() == 0) {
|
||||
Base::Console().Message( "GeomFormat::fromCSV - token0 empty\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> values = DrawUtil::split(tokens[0]);
|
||||
unsigned int maxCells = 1;
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "GeomFormat::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
}
|
||||
m_geomIndex = atoi(values[0].c_str());
|
||||
|
||||
int lastToken = 1;
|
||||
if (tokens.size() != 2) {
|
||||
Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
|
||||
return false;
|
||||
}
|
||||
m_format.fromCSV(tokens[lastToken]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,21 +123,39 @@ public:
|
||||
TechDraw::DrawViewPart* partFeat,
|
||||
std::vector<std::string> faceNames,
|
||||
int vert, double ext,
|
||||
double hShift, double vShift,
|
||||
double m_hShift, double m_vShift,
|
||||
double rotate);
|
||||
void dump(char* title);
|
||||
|
||||
Base::Vector3d start;
|
||||
Base::Vector3d end;
|
||||
Base::Vector3d m_start;
|
||||
Base::Vector3d m_end;
|
||||
std::vector<std::string> m_faces;
|
||||
int mode; // vert/horiz/aligned
|
||||
double hShift;
|
||||
double vShift;
|
||||
double rotate;
|
||||
double extendBy;
|
||||
LineFormat fmt;
|
||||
int m_mode; // 0 - vert/ 1 - horiz/ 2 - aligned
|
||||
double m_hShift;
|
||||
double m_vShift;
|
||||
double m_rotate;
|
||||
double m_extendBy;
|
||||
LineFormat m_format;
|
||||
};
|
||||
|
||||
class TechDrawExport GeomFormat
|
||||
{
|
||||
public:
|
||||
GeomFormat();
|
||||
GeomFormat(int idx,
|
||||
LineFormat fmt);
|
||||
~GeomFormat();
|
||||
|
||||
std::string toCSV(void) const;
|
||||
bool fromCSV(std::string& lineSpec);
|
||||
void dump(char* title);
|
||||
|
||||
int m_geomIndex;
|
||||
LineFormat m_format;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} //end namespace TechDraw
|
||||
|
||||
#endif //TECHDRAW_COSMETIC_H
|
||||
|
||||
@@ -152,11 +152,13 @@ DrawViewPart::DrawViewPart(void) :
|
||||
ADD_PROPERTY_TYPE(CosmeticVertexList ,(""),sgroup,App::Prop_None,"CosmeticVertex Save/Restore");
|
||||
ADD_PROPERTY_TYPE(CosmeticEdgeList ,(""),sgroup,App::Prop_None,"CosmeticEdge Save/Restore");
|
||||
ADD_PROPERTY_TYPE(CenterLineList ,(""),sgroup,App::Prop_None,"CenterLine Save/Restore");
|
||||
ADD_PROPERTY_TYPE(GeomFormatList ,(""),sgroup,App::Prop_None,"Geometry format Save/Restore");
|
||||
|
||||
std::vector<std::string> emptyList;
|
||||
CosmeticVertexList.setValues(emptyList);
|
||||
CosmeticEdgeList.setValues(emptyList);
|
||||
CenterLineList.setValues(emptyList);
|
||||
GeomFormatList.setValues(emptyList);
|
||||
|
||||
geometryObject = nullptr;
|
||||
getRunControl();
|
||||
@@ -1380,11 +1382,96 @@ void DrawViewPart::addCenterLinesToGeom(void)
|
||||
}
|
||||
}
|
||||
|
||||
//build GFormatTable from GeomFormatList
|
||||
void DrawViewPart::readGFormatProp(void)
|
||||
{
|
||||
GFormatTable.clear();
|
||||
std::vector<std::string> restoreFormats = GeomFormatList.getValues();
|
||||
if (restoreFormats.empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto& rf: restoreFormats) {
|
||||
if (!rf.empty()) {
|
||||
GeomFormat* gf = new GeomFormat();
|
||||
bool rc = gf->fromCSV(rf);
|
||||
if (rc) {
|
||||
GFormatTable.push_back(gf);
|
||||
} else {
|
||||
delete gf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::writeGFormatProp(void)
|
||||
{
|
||||
std::vector<std::string> saveFormats;
|
||||
const std::vector<TechDraw::GeomFormat*> gForms = getGeomFormats();
|
||||
for (auto& gf: gForms) {
|
||||
std::string csv = gf->toCSV();
|
||||
saveFormats.push_back(csv);
|
||||
}
|
||||
GeomFormatList.setValues(saveFormats);
|
||||
}
|
||||
|
||||
void DrawViewPart::clearGeomFormats(void)
|
||||
{
|
||||
GFormatTable.clear();
|
||||
std::vector<std::string> noFormats;
|
||||
GeomFormatList.setValues(noFormats);
|
||||
}
|
||||
|
||||
// adds a GeomFormat to GFormatTable and GeomFormatList
|
||||
int DrawViewPart::addGeomFormat(GeomFormat* gf)
|
||||
{
|
||||
int newIdx = (int) (GFormatTable.size());
|
||||
GFormatTable.push_back(gf);
|
||||
std::string csv = gf->toCSV();
|
||||
std::vector<std::string> formatList = GeomFormatList.getValues();
|
||||
formatList.push_back(csv);
|
||||
GeomFormatList.setValues(formatList);
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
void DrawViewPart::removeGeomFormat(int idx)
|
||||
{
|
||||
if (idx < (int) GFormatTable.size()) {
|
||||
GFormatTable.erase(GFormatTable.begin() + idx);
|
||||
writeGFormatProp();
|
||||
requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
TechDraw::GeomFormat* DrawViewPart::getGeomFormatByIndex(int idx) const
|
||||
{
|
||||
GeomFormat* result = nullptr;
|
||||
const std::vector<TechDraw::GeomFormat*> fmts = getGeomFormats();
|
||||
if (idx < (int) fmts.size()) {
|
||||
result = fmts.at(idx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//find the format corresponding to geometry edge idx
|
||||
TechDraw::GeomFormat* DrawViewPart::getGeomFormatByGeom(int idx) const
|
||||
{
|
||||
GeomFormat* result = nullptr;
|
||||
const std::vector<TechDraw::GeomFormat*> fmts = getGeomFormats();
|
||||
for (auto& f: fmts) {
|
||||
if (f->m_geomIndex == idx) {
|
||||
result = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawViewPart::onDocumentRestored()
|
||||
{
|
||||
readCVertexProp();
|
||||
readCEdgeProp();
|
||||
readCLineProp();
|
||||
readGFormatProp();
|
||||
// requestPaint();
|
||||
//if execute has not run yet, there will be no GO, and paint will not do anything.
|
||||
execute();
|
||||
|
||||
@@ -71,6 +71,7 @@ class DrawViewBalloon;
|
||||
class CosmeticVertex;
|
||||
class CosmeticEdge;
|
||||
class CenterLine;
|
||||
class GeomFormat;
|
||||
}
|
||||
|
||||
namespace TechDraw
|
||||
@@ -107,6 +108,7 @@ public:
|
||||
App::PropertyStringList CosmeticVertexList;
|
||||
App::PropertyStringList CosmeticEdgeList;
|
||||
App::PropertyStringList CenterLineList;
|
||||
App::PropertyStringList GeomFormatList;
|
||||
|
||||
virtual short mustExecute() const;
|
||||
virtual void onDocumentRestored() override;
|
||||
@@ -199,6 +201,13 @@ public:
|
||||
void addCosmeticEdgesToGeom(void);
|
||||
void addCenterLinesToGeom(void);
|
||||
|
||||
int addGeomFormat(TechDraw::GeomFormat* gf);
|
||||
virtual void writeGFormatProp(void);
|
||||
virtual void removeGeomFormat(int idx);
|
||||
const std::vector<TechDraw::GeomFormat*> & getGeomFormats(void) const { return GFormatTable; }
|
||||
TechDraw::GeomFormat* getGeomFormatByIndex(int idx) const;
|
||||
TechDraw::GeomFormat* getGeomFormatByGeom(int idx) const;
|
||||
void clearGeomFormats(void);
|
||||
|
||||
protected:
|
||||
TechDraw::GeometryObject *geometryObject;
|
||||
@@ -231,6 +240,9 @@ protected:
|
||||
std::vector<TechDraw::CenterLine*> CLineTable;
|
||||
void readCLineProp(void);
|
||||
|
||||
std::vector<TechDraw::GeomFormat*> GFormatTable;
|
||||
void readGFormatProp(void);
|
||||
|
||||
private:
|
||||
bool nowUnsetting;
|
||||
/* bool m_restoreComplete;*/
|
||||
|
||||
@@ -63,6 +63,16 @@
|
||||
<UserDocu>clearCosmeticEdges() - remove all CosmeticLines from the View. Returns nothing.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="clearCenterLines">
|
||||
<Documentation>
|
||||
<UserDocu>clearCenterLines() - remove all CenterLines from the View. Returns nothing.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="clearGeomFormats">
|
||||
<Documentation>
|
||||
<UserDocu>clearGeomFormats() - remove all GeomFormats from the View. Returns nothing.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -80,6 +80,25 @@ PyObject* DrawViewPartPy::clearCosmeticEdges(PyObject *args)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::clearCenterLines(PyObject *args)
|
||||
{
|
||||
(void) args;
|
||||
DrawViewPart* item = getDrawViewPartPtr();
|
||||
item->clearCenterLines();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::clearGeomFormats(PyObject *args)
|
||||
{
|
||||
(void) args;
|
||||
DrawViewPart* item = getDrawViewPartPtr();
|
||||
item->clearGeomFormats();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticVertex(PyObject *args)
|
||||
{
|
||||
PyObject* pPnt1 = nullptr;
|
||||
|
||||
@@ -100,7 +100,7 @@ class TechDrawExport BaseGeom
|
||||
std::string dump();
|
||||
|
||||
protected:
|
||||
int m_source;
|
||||
int m_source; //0 - geom, 1 - cosmetic edge, 2 - centerline
|
||||
int m_sourceIndex;
|
||||
|
||||
};
|
||||
|
||||
@@ -54,6 +54,7 @@ set(TechDrawGui_MOC_HDRS
|
||||
TaskRichAnno.h
|
||||
TaskCosVertex.h
|
||||
TaskCenterLine.h
|
||||
TaskLineDecor.h
|
||||
QGEPath.h
|
||||
QGTracker.h
|
||||
QGILeaderLine.h
|
||||
@@ -87,6 +88,7 @@ set(TechDrawGui_UIC_SRCS
|
||||
TaskBalloon.ui
|
||||
TaskCosVertex.ui
|
||||
TaskCenterLine.ui
|
||||
TaskLineDecor.ui
|
||||
)
|
||||
|
||||
if(BUILD_QT5)
|
||||
@@ -159,6 +161,9 @@ SET(TechDrawGui_SRCS
|
||||
TaskCenterLine.ui
|
||||
TaskCenterLine.cpp
|
||||
TaskCenterLine.h
|
||||
TaskLineDecor.ui
|
||||
TaskLineDecor.cpp
|
||||
TaskLineDecor.h
|
||||
DrawGuiUtil.cpp
|
||||
DrawGuiUtil.h
|
||||
Rez.cpp
|
||||
@@ -311,6 +316,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
|
||||
mrichtextedit.ui
|
||||
TaskBalloon.ui
|
||||
TaskCenterLine.ui
|
||||
TaskLineDecor.ui
|
||||
)
|
||||
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "TaskRichAnno.h"
|
||||
#include "TaskCosVertex.h"
|
||||
#include "TaskCenterLine.h"
|
||||
#include "TaskLineDecor.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "QGVPage.h"
|
||||
|
||||
@@ -796,6 +797,89 @@ bool CmdTechDrawCosmeticEraser::isActive(void)
|
||||
return (havePage && haveView);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_DecorateLine
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawDecorateLine);
|
||||
|
||||
CmdTechDrawDecorateLine::CmdTechDrawDecorateLine()
|
||||
: Command("TechDraw_DecorateLine")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Change the appearance of a line");
|
||||
sToolTipText = QT_TR_NOOP("Change the appearance of a line");
|
||||
sWhatsThis = "TechDraw_DecorateLine";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/techdraw-linedecor";
|
||||
}
|
||||
|
||||
void CmdTechDrawDecorateLine::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
if (dlg != nullptr) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
|
||||
QObject::tr("Close active task dialog and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
TechDraw::DrawViewPart* baseFeat = nullptr;
|
||||
if (!selection.empty()) {
|
||||
baseFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
if( baseFeat == nullptr ) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("No View in Selection."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("You must select line(s) in a View."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> SubNames;
|
||||
|
||||
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
|
||||
for (; itSel != selection.end(); itSel++) {
|
||||
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
|
||||
baseFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
|
||||
SubNames = (*itSel).getSubNames();
|
||||
}
|
||||
}
|
||||
std::vector<std::string> edgeNames;
|
||||
for (auto& s: SubNames) {
|
||||
std::string geomType = DrawUtil::getGeomTypeFromName(s);
|
||||
if (geomType == "Edge") {
|
||||
edgeNames.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
if ( edgeNames.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("You must select line(s) to edit."));
|
||||
return;
|
||||
} else {
|
||||
Gui::Control().showDialog(new TaskDlgLineDecor(baseFeat,
|
||||
edgeNames));
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdTechDrawDecorateLine::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this, false);
|
||||
return (havePage && haveView);
|
||||
}
|
||||
|
||||
void CreateTechDrawCommandsAnnotate(void)
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
@@ -809,6 +893,7 @@ void CreateTechDrawCommandsAnnotate(void)
|
||||
rcCmdMgr.addCommand(new CmdTechDrawAnnotation());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawFaceCenterLine());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawCosmeticEraser());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawDecorateLine());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -440,21 +440,31 @@ void QGIViewPart::drawViewPart()
|
||||
showEdge = true;
|
||||
}
|
||||
}
|
||||
bool showItem = true;
|
||||
if (showEdge) {
|
||||
item = new QGIEdge(i);
|
||||
item->setWidth(lineWidth);
|
||||
//TODO: implement formats for geom lines.
|
||||
if ((*itGeom)->cosmetic == true) {
|
||||
int source = (*itGeom)->source();
|
||||
int sourceIndex = (*itGeom)->sourceIndex();
|
||||
if (source == 1) { //this is a "CosmeticEdge"
|
||||
formatGeomFromCosmetic(sourceIndex, item);
|
||||
showItem = formatGeomFromCosmetic(sourceIndex, item);
|
||||
} else if (source == 2) { //this is a "CenterLine"
|
||||
formatGeomFromCenterLine(sourceIndex, item);
|
||||
showItem = formatGeomFromCenterLine(sourceIndex, item);
|
||||
} else {
|
||||
Base::Console().Message("QGIVP::drawVP - edge: %d is confused - source: %d\n",i,source);
|
||||
}
|
||||
} else {
|
||||
//TODO: implement formats for geom lines.
|
||||
TechDraw::GeomFormat* gf = viewPart->getGeomFormatByGeom(i);
|
||||
if (gf != nullptr) {
|
||||
item->setNormalColor(gf->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(gf->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(gf->m_format.m_style);
|
||||
showItem = gf->m_format.m_visible;
|
||||
}
|
||||
}
|
||||
|
||||
addToGroup(item); //item is at scene(0,0), not group(0,0)
|
||||
item->setPos(0.0,0.0); //now at group(0,0)
|
||||
item->setPath(drawPainterPath(*itGeom));
|
||||
@@ -468,6 +478,9 @@ void QGIViewPart::drawViewPart()
|
||||
item->setWidth(lineWidthIso);
|
||||
}
|
||||
item->setPrettyNormal();
|
||||
if (!showItem) {
|
||||
item->hide();
|
||||
}
|
||||
//debug a path
|
||||
// QPainterPath edgePath=drawPainterPath(*itGeom);
|
||||
// std::stringstream edgeId;
|
||||
@@ -548,28 +561,34 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
}
|
||||
|
||||
void QGIViewPart::formatGeomFromCosmetic(int sourceIndex, QGIEdge* item)
|
||||
bool QGIViewPart::formatGeomFromCosmetic(int sourceIndex, QGIEdge* item)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::formatGeomFromCosmetic(%d)\n",sourceIndex);
|
||||
bool result = true;
|
||||
auto partFeat( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
TechDraw::CosmeticEdge* ce = partFeat->getCosmeticEdgeByIndex(sourceIndex);
|
||||
if (ce != nullptr) {
|
||||
item->setNormalColor(ce->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(ce->m_format.m_style);
|
||||
result = ce->m_format.m_visible;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void QGIViewPart::formatGeomFromCenterLine(int sourceIndex, QGIEdge* item)
|
||||
bool QGIViewPart::formatGeomFromCenterLine(int sourceIndex, QGIEdge* item)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::formatGeomFromCenterLine(%d)\n",sourceIndex);
|
||||
bool result = true;
|
||||
auto partFeat( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
TechDraw::CenterLine* cl = partFeat->getCenterLineByIndex(sourceIndex);
|
||||
if (cl != nullptr) {
|
||||
item->setNormalColor(cl->fmt.m_color.asValue<QColor>());
|
||||
item->setWidth(cl->fmt.m_weight * lineScaleFactor);
|
||||
item->setStyle(cl->fmt.m_style);
|
||||
item->setNormalColor(cl->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(cl->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(cl->m_format.m_style);
|
||||
result = cl->m_format.m_visible;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QGIFace* QGIViewPart::drawFace(TechDraw::Face* f, int idx)
|
||||
|
||||
@@ -107,8 +107,8 @@ protected:
|
||||
bool prefPrintCenters(void);
|
||||
|
||||
|
||||
void formatGeomFromCosmetic(int sourceIndex, QGIEdge* item);
|
||||
void formatGeomFromCenterLine(int sourceIndex, QGIEdge* item);
|
||||
bool formatGeomFromCosmetic(int sourceIndex, QGIEdge* item);
|
||||
bool formatGeomFromCenterLine(int sourceIndex, QGIEdge* item);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -68,6 +68,8 @@
|
||||
<file>icons/actions/techdraw-quadrant.svg</file>
|
||||
<file>icons/actions/techdraw-facecenterline.svg</file>
|
||||
<file>icons/actions/techdraw-eraser.svg</file>
|
||||
<file>icons/actions/techdraw-linedecor.svg</file>
|
||||
<file>icons/actions/techdraw-facedecor.svg</file>
|
||||
<file>icons/actions/section-up.svg</file>
|
||||
<file>icons/actions/section-down.svg</file>
|
||||
<file>icons/actions/section-left.svg</file>
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,545 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||
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"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="64px"
|
||||
height="64px"
|
||||
id="svg2943"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.92.3 (unknown)"
|
||||
sodipodi:docname="techdraw-linedecor.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
version="1.1">
|
||||
<defs
|
||||
id="defs2945">
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient3876">
|
||||
<stop
|
||||
style="stop-color:#956363;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3878" />
|
||||
<stop
|
||||
style="stop-color:#ebe0a9;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop3880" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3858">
|
||||
<stop
|
||||
style="stop-color:#956363;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3860" />
|
||||
<stop
|
||||
style="stop-color:#d17878;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3862" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4158">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4160" />
|
||||
<stop
|
||||
style="stop-color:#f6f6f6;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4162" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4122">
|
||||
<stop
|
||||
style="stop-color:#e3d328;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4124" />
|
||||
<stop
|
||||
style="stop-color:#e1dec3;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop4126" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4088">
|
||||
<stop
|
||||
style="stop-color:#e9cd23;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4090" />
|
||||
<stop
|
||||
style="stop-color:#040000;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4092" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient4060">
|
||||
<stop
|
||||
style="stop-color:#ada9a9;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4062" />
|
||||
<stop
|
||||
style="stop-color:#ada9a9;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4064" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4052">
|
||||
<stop
|
||||
style="stop-color:#ada9a9;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4054" />
|
||||
<stop
|
||||
style="stop-color:#ada9a9;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4056" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4349">
|
||||
<stop
|
||||
style="stop-color:#898709;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4351" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop4353" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient5241">
|
||||
<stop
|
||||
style="stop-color:#212c45;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop5243" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop5245" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient5227"
|
||||
osb:paint="solid">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop5229" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3902">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:0.58823532;"
|
||||
offset="0"
|
||||
id="stop3904" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:0.39215687;"
|
||||
offset="1"
|
||||
id="stop3906" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3894">
|
||||
<stop
|
||||
style="stop-color:#45351d;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3896" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3898" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3886">
|
||||
<stop
|
||||
style="stop-color:#45351d;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3888" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3890" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3792">
|
||||
<stop
|
||||
style="stop-color:#aaaaaa;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3794" />
|
||||
<stop
|
||||
style="stop-color:#d2d2d2;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3796" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3784">
|
||||
<stop
|
||||
style="stop-color:#bebebe;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3786" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0.39215687;"
|
||||
offset="1"
|
||||
id="stop3788" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3377">
|
||||
<stop
|
||||
id="stop3379"
|
||||
offset="0"
|
||||
style="stop-color:#71b2f8;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3381"
|
||||
offset="1"
|
||||
style="stop-color:#002795;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 32 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="64 : 32 : 1"
|
||||
inkscape:persp3d-origin="32 : 21.333333 : 1"
|
||||
id="perspective2951" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4052"
|
||||
id="linearGradient4058"
|
||||
x1="138.99986"
|
||||
y1="44.863674"
|
||||
x2="92.497559"
|
||||
y2="-14.356517"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(248.6744,65.825928)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4060"
|
||||
id="linearGradient4066"
|
||||
x1="103.93729"
|
||||
y1="49.179436"
|
||||
x2="120.49899"
|
||||
y2="0.21229285"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(248.6744,65.825928)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4122"
|
||||
id="linearGradient4128"
|
||||
x1="391.3074"
|
||||
y1="120.81136"
|
||||
x2="394.43201"
|
||||
y2="112.43636"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-8.034794,-1.0606602)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4158"
|
||||
id="linearGradient4164"
|
||||
x1="419.99387"
|
||||
y1="102.77802"
|
||||
x2="458.7193"
|
||||
y2="69.431564"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-49.22376,-0.88388348)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4122"
|
||||
id="linearGradient3856"
|
||||
x1="116.83871"
|
||||
y1="21.107124"
|
||||
x2="89.015228"
|
||||
y2="23.486774"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3858"
|
||||
id="linearGradient3864"
|
||||
x1="94.744598"
|
||||
y1="31.189295"
|
||||
x2="70.261253"
|
||||
y2="42.461311"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3876"
|
||||
id="linearGradient3882"
|
||||
x1="123.75154"
|
||||
y1="-0.084563509"
|
||||
x2="104.85488"
|
||||
y2="16.387842"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3858"
|
||||
id="linearGradient3892"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="94.744598"
|
||||
y1="31.189295"
|
||||
x2="70.261253"
|
||||
y2="42.461311" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4122"
|
||||
id="linearGradient3895"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="116.83871"
|
||||
y1="21.107124"
|
||||
x2="89.015228"
|
||||
y2="23.486774" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3876"
|
||||
id="linearGradient3897"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="123.75154"
|
||||
y1="-0.084563509"
|
||||
x2="104.85488"
|
||||
y2="16.387842" />
|
||||
<filter
|
||||
id="filter3911"
|
||||
inkscape:menu-tooltip="Make the lightest parts of the object progressively transparent"
|
||||
inkscape:menu="Transparency utilities"
|
||||
inkscape:label="Light eraser"
|
||||
height="1"
|
||||
width="1"
|
||||
y="0"
|
||||
x="0"
|
||||
color-interpolation-filters="sRGB">
|
||||
<feColorMatrix
|
||||
id="feColorMatrix3913"
|
||||
result="result14"
|
||||
type="luminanceToAlpha"
|
||||
in="SourceGraphic" />
|
||||
<feComposite
|
||||
id="feComposite3915"
|
||||
in2="result14"
|
||||
in="SourceGraphic"
|
||||
result="fbSourceGraphic"
|
||||
operator="out" />
|
||||
<feBlend
|
||||
id="feBlend3917"
|
||||
in2="fbSourceGraphic"
|
||||
mode="normal"
|
||||
result="result15" />
|
||||
</filter>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4061"
|
||||
id="linearGradient4059"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="266.08176"
|
||||
y1="90.401306"
|
||||
x2="301.7092"
|
||||
y2="119.88659" />
|
||||
<linearGradient
|
||||
id="linearGradient4061"
|
||||
inkscape:collect="always">
|
||||
<stop
|
||||
id="stop4063"
|
||||
offset="0"
|
||||
style="stop-color:#ef2929;stop-opacity:1" />
|
||||
<stop
|
||||
id="stop4065"
|
||||
offset="1"
|
||||
style="stop-color:#a40000;stop-opacity:1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
gradientTransform="matrix(-0.02477995,1.1554758,-1.231953,0.36165297,588.8059,-370.77187)"
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3944"
|
||||
id="linearGradient3950"
|
||||
x1="285.7092"
|
||||
y1="75.886589"
|
||||
x2="301.7092"
|
||||
y2="119.88659"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient3944">
|
||||
<stop
|
||||
style="stop-color:#8ae234;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop3946" />
|
||||
<stop
|
||||
style="stop-color:#4e9a06;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop3948" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3953"
|
||||
id="linearGradient3959"
|
||||
x1="214.70918"
|
||||
y1="80.886589"
|
||||
x2="218.70918"
|
||||
y2="104.88659"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(-0.02477995,1.1554758,-1.231953,0.36165297,586.8235,-278.33381)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient3953">
|
||||
<stop
|
||||
style="stop-color:#babdb6;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop3955" />
|
||||
<stop
|
||||
style="stop-color:#555753;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop3957" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3961"
|
||||
id="linearGradient3967"
|
||||
x1="196.70918"
|
||||
y1="106.88659"
|
||||
x2="190.70918"
|
||||
y2="80.886589"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(-0.02477995,1.1554758,-1.231953,0.36165297,586.8235,-278.33381)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient3961">
|
||||
<stop
|
||||
style="stop-color:#babdb6;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop3963" />
|
||||
<stop
|
||||
style="stop-color:#d3d7cf;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop3965" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="5.6458057"
|
||||
inkscape:cx="50.322754"
|
||||
inkscape:cy="16.335057"
|
||||
inkscape:current-layer="g3939"
|
||||
showgrid="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="716"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="26"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:snap-global="false">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3080"
|
||||
empspacing="2"
|
||||
visible="true"
|
||||
enabled="true"
|
||||
snapvisiblegridlinesonly="true" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata2948">
|
||||
<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
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<g
|
||||
id="g3629"
|
||||
transform="translate(-256.70919,-66.886588)">
|
||||
<path
|
||||
style="fill:#e3d328;fill-opacity:1;stroke:#040400;stroke-width:0.08838835;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d=""
|
||||
id="path4102"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(256.70919,66.886588)" />
|
||||
<g
|
||||
id="g3973"
|
||||
transform="matrix(-0.78031416,0.35176755,0.0870326,0.86674487,567.28599,-160.53129)"
|
||||
style="stroke:#271903;stroke-width:1">
|
||||
<g
|
||||
id="g3939"
|
||||
style="stroke-width:1"
|
||||
transform="matrix(-0.41402493,-0.77441636,-1.0699456,0.41402494,675.14647,458.62926)">
|
||||
<g
|
||||
id="g1135">
|
||||
<g
|
||||
transform="matrix(1.0952502,0.01482131,-0.00108275,1.1460561,-40.671675,-25.429792)"
|
||||
id="g1102">
|
||||
<rect
|
||||
transform="matrix(0.61920579,-0.78522875,-0.859092,-0.51182119,0,0)"
|
||||
y="-452.2778"
|
||||
x="133.36198"
|
||||
height="4.1084733"
|
||||
width="16.667767"
|
||||
id="rect3933"
|
||||
style="fill:#fce94f;fill-opacity:1;stroke:#2e3436;stroke-width:2.38884711;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.89999998;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
style="fill:#ffffff;stroke:#302b00;stroke-width:2.37868023;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="m 435.83118,105.73766 -8.85181,-15.089687 19.53477,2.189409 2.86855,3.340104 -8.75107,11.097434 z"
|
||||
id="path3969"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccc" />
|
||||
<path
|
||||
style="fill:#729fcf;stroke:#302b00;stroke-width:2.37868047;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 467.59719,124.66289 3.44025,-4.36267 -30.88361,-18.39953 c 0.6854,3.41806 0.0448,3.2327 -4.32265,3.83697 z"
|
||||
id="path3843-5-6"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
<path
|
||||
style="fill:#3465a4;stroke:#302b00;stroke-width:2.37868023;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="m 471.03744,120.30022 3.44027,-4.36267 -30.88363,-18.399533 c 0.625,3.494403 0.68541,3.418073 -3.44025,4.362673 z"
|
||||
id="path3843-5-6-2"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
<path
|
||||
style="fill:#204a87;stroke:#302b00;stroke-width:2.37868023;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="m 474.47771,115.93755 3.44025,-4.36267 -30.88361,-18.399531 c 0.0446,3.232733 0.62499,3.494399 -3.44027,4.362668 z"
|
||||
id="path3843-5-6-9"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
<path
|
||||
style="fill:#271903;stroke:#271903;stroke-width:1.18934011px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="m 431.56331,97.992416 c 3.27386,-0.862299 4.99399,-3.043633 4.95035,-6.277661 l -9.53429,-1.066782 4.58394,7.344443 v 0"
|
||||
id="path3971"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
<rect
|
||||
transform="matrix(0.61920579,-0.78522875,-0.859092,-0.51182119,0,0)"
|
||||
y="-458.52631"
|
||||
x="133.40527"
|
||||
height="6.1627097"
|
||||
width="16.667767"
|
||||
id="rect3935"
|
||||
style="fill:#cc0000;fill-opacity:1;stroke:#280000;stroke-width:2.38884711;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.89999998;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3937"
|
||||
d="m 473.8828,125.4571 2.64717,1.57711 7.74059,-9.81601"
|
||||
style="fill:none;stroke:#ef2929;stroke-width:2.37868047;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
</g>
|
||||
<path
|
||||
inkscape:transform-center-y="-4.5369833"
|
||||
inkscape:transform-center-x="2.9631703"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1104"
|
||||
d="m 427.13977,84.091963 c 3.37488,59.927087 3.37488,59.927087 3.37488,59.927087"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.37868047;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 18 KiB |
@@ -173,9 +173,9 @@ void TaskCenterLine::setUiEdit()
|
||||
ui->lstSubList->addItem(listItem);
|
||||
}
|
||||
|
||||
ui->cpLineColor->setColor(m_cl->fmt.m_color.asValue<QColor>());
|
||||
ui->dsbWeight->setValue(m_cl->fmt.m_weight);
|
||||
ui->cboxStyle->setCurrentIndex(m_cl->fmt.m_style);
|
||||
ui->cpLineColor->setColor(m_cl->m_format.m_color.asValue<QColor>());
|
||||
ui->dsbWeight->setValue(m_cl->m_format.m_weight);
|
||||
ui->cboxStyle->setCurrentIndex(m_cl->m_format.m_style);
|
||||
|
||||
int precision = Base::UnitsApi::getDecimals();
|
||||
ui->dsbRotate->setDecimals(precision);
|
||||
@@ -183,21 +183,21 @@ void TaskCenterLine::setUiEdit()
|
||||
ui->rbVertical->setChecked(false);
|
||||
ui->rbHorizontal->setChecked(false);
|
||||
ui->rbAligned->setChecked(false);
|
||||
if (m_cl->mode == 0) {
|
||||
if (m_cl->m_mode == 0) {
|
||||
ui->rbVertical->setChecked(true);
|
||||
} else if (m_cl->mode == 1) {
|
||||
} else if (m_cl->m_mode == 1) {
|
||||
ui->rbHorizontal->setChecked(true);
|
||||
} else if (m_cl->mode ==2) {
|
||||
} else if (m_cl->m_mode ==2) {
|
||||
ui->rbAligned->setChecked(true);
|
||||
}
|
||||
ui->dsbRotate->setValue(m_cl->rotate);
|
||||
ui->dsbRotate->setValue(m_cl->m_rotate);
|
||||
Base::Quantity qVal;
|
||||
qVal.setUnit(Base::Unit::Length);
|
||||
qVal.setValue(m_cl->vShift);
|
||||
qVal.setValue(m_cl->m_vShift);
|
||||
ui->qsbVertShift->setValue(qVal);
|
||||
qVal.setValue(m_cl->hShift);
|
||||
qVal.setValue(m_cl->m_hShift);
|
||||
ui->qsbHorizShift->setValue(qVal);
|
||||
qVal.setValue(m_cl->extendBy);
|
||||
qVal.setValue(m_cl->m_extendBy);
|
||||
ui->qsbExtend->setValue(qVal);
|
||||
}
|
||||
|
||||
@@ -221,28 +221,28 @@ void TaskCenterLine::createCenterLine(void)
|
||||
extendBy,
|
||||
hShift, vShift, rotate);
|
||||
TechDraw::CenterLine* cl = new TechDraw::CenterLine(ends.first, ends.second);
|
||||
cl->start = ends.first;
|
||||
cl->end = ends.second;
|
||||
cl->m_start = ends.first;
|
||||
cl->m_end = ends.second;
|
||||
|
||||
App::Color ac;
|
||||
ac.setValue<QColor>(ui->cpLineColor->color());
|
||||
cl->fmt.m_color = ac;
|
||||
cl->fmt.m_weight = ui->dsbWeight->value();
|
||||
cl->fmt.m_style = ui->cboxStyle->currentIndex();
|
||||
cl->fmt.m_visible = true;
|
||||
cl->m_format.m_color = ac;
|
||||
cl->m_format.m_weight = ui->dsbWeight->value();
|
||||
cl->m_format.m_style = ui->cboxStyle->currentIndex();
|
||||
cl->m_format.m_visible = true;
|
||||
|
||||
if (ui->rbVertical->isChecked()) {
|
||||
cl->mode = 0;
|
||||
cl->m_mode = 0;
|
||||
} else if (ui->rbHorizontal->isChecked()) {
|
||||
cl->mode = 1;
|
||||
cl->m_mode = 1;
|
||||
} else if (ui->rbAligned->isChecked()) {
|
||||
cl->mode = 2;
|
||||
cl->m_mode = 2;
|
||||
}
|
||||
cl->m_faces = m_subNames;
|
||||
cl->rotate = rotate;
|
||||
cl->vShift = vShift;
|
||||
cl->hShift = hShift;
|
||||
cl->extendBy = extendBy;
|
||||
cl->m_rotate = rotate;
|
||||
cl->m_vShift = vShift;
|
||||
cl->m_hShift = hShift;
|
||||
cl->m_extendBy = extendBy;
|
||||
|
||||
m_partFeat->addCenterLine(cl);
|
||||
|
||||
@@ -256,22 +256,22 @@ void TaskCenterLine::updateCenterLine(void)
|
||||
{
|
||||
// Base::Console().Message("TCL::updateCenterLine()\n");
|
||||
Gui::Command::openCommand("Edit CenterLine");
|
||||
m_cl->fmt.m_color.setValue<QColor>(ui->cpLineColor->color() );
|
||||
m_cl->fmt.m_weight = ui->dsbWeight->value();
|
||||
m_cl->fmt.m_style = ui->cboxStyle->currentIndex();
|
||||
m_cl->fmt.m_visible = true;
|
||||
m_cl->m_format.m_color.setValue<QColor>(ui->cpLineColor->color() );
|
||||
m_cl->m_format.m_weight = ui->dsbWeight->value();
|
||||
m_cl->m_format.m_style = ui->cboxStyle->currentIndex();
|
||||
m_cl->m_format.m_visible = true;
|
||||
|
||||
if (ui->rbVertical->isChecked()) {
|
||||
m_cl->mode = 0;
|
||||
m_cl->m_mode = 0;
|
||||
} else if (ui->rbHorizontal->isChecked()) {
|
||||
m_cl->mode = 1;
|
||||
m_cl->m_mode = 1;
|
||||
} else if (ui->rbAligned->isChecked()) {
|
||||
m_cl->mode = 2;
|
||||
m_cl->m_mode = 2;
|
||||
}
|
||||
m_cl->rotate = ui->dsbRotate->value();
|
||||
m_cl->vShift = ui->qsbVertShift->rawValue();
|
||||
m_cl->hShift = ui->qsbHorizShift->rawValue();
|
||||
m_cl->extendBy = ui->qsbExtend->rawValue();
|
||||
m_cl->m_rotate = ui->dsbRotate->value();
|
||||
m_cl->m_vShift = ui->qsbVertShift->rawValue();
|
||||
m_cl->m_hShift = ui->qsbHorizShift->rawValue();
|
||||
m_cl->m_extendBy = ui->qsbExtend->rawValue();
|
||||
m_partFeat->replaceCenterLine(m_clIdx, m_cl);
|
||||
m_partFeat->requestPaint(); //is requestPaint enough here?
|
||||
// m_partFeat->recomputeFeature();
|
||||
|
||||
275
src/Mod/TechDraw/Gui/TaskLineDecor.cpp
Normal file
275
src/Mod/TechDraw/Gui/TaskLineDecor.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2018 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/Tools.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 <Gui/FileDialog.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
#include <Mod/TechDraw/App/DrawViewPart.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
#include <Mod/TechDraw/App/Cosmetic.h>
|
||||
|
||||
#include "TaskLineDecor.h"
|
||||
#include <Mod/TechDraw/Gui/ui_TaskLineDecor.h>
|
||||
|
||||
using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
TaskLineDecor::TaskLineDecor(TechDraw::DrawViewPart* partFeat,
|
||||
std::vector<std::string> edgeNames) :
|
||||
ui(new Ui_TaskLineDecor),
|
||||
m_partFeat(partFeat),
|
||||
m_edges(edgeNames)
|
||||
{
|
||||
getDefaults();
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->cb_Style, SIGNAL(currentIndexChanged( int )), this, SLOT(onStyleChanged(void)));
|
||||
connect(ui->cc_Color, SIGNAL(changed( )), this, SLOT(onColorChanged(void)));
|
||||
connect(ui->dsb_Weight, SIGNAL(valueChanged( double )), this, SLOT(onWeightChanged( void )));
|
||||
connect(ui->cb_Visible, SIGNAL(currentIndexChanged( int )), this, SLOT(onVisibleChanged( void )));
|
||||
|
||||
initUi();
|
||||
}
|
||||
|
||||
TaskLineDecor::~TaskLineDecor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskLineDecor::initUi()
|
||||
{
|
||||
std::string viewName = m_partFeat->getNameInDocument();
|
||||
ui->le_View->setText(Base::Tools::fromStdString(viewName));
|
||||
|
||||
std::stringstream ss;
|
||||
for (auto& e: m_edges) {
|
||||
int num = DrawUtil::getIndexFromName(e);
|
||||
ss << num << ", ";
|
||||
}
|
||||
std::string temp = ss.str();
|
||||
if (!temp.empty()) {
|
||||
temp.pop_back();
|
||||
}
|
||||
ui->le_Lines->setText(Base::Tools::fromStdString(temp));
|
||||
|
||||
ui->cb_Style->setCurrentIndex(m_style);
|
||||
ui->cc_Color->setColor(m_color.asValue<QColor>());
|
||||
ui->dsb_Weight->setValue(m_weight);
|
||||
ui->cb_Visible->setCurrentIndex(m_visible);
|
||||
}
|
||||
|
||||
void TaskLineDecor::getDefaults(void)
|
||||
{
|
||||
m_style = LineFormat::getDefEdgeStyle();
|
||||
m_color = LineFormat::getDefEdgeColor();
|
||||
m_weight = LineFormat::getDefEdgeWidth();
|
||||
m_visible = 1;
|
||||
|
||||
//set defaults to format of 1st edge
|
||||
int num = DrawUtil::getIndexFromName(m_edges.front());
|
||||
BaseGeom* bg = m_partFeat->getGeomByIndex(num);
|
||||
if (bg != nullptr) {
|
||||
if (bg->cosmetic) {
|
||||
if (bg->source() == 1) {
|
||||
TechDraw::CosmeticEdge* ce = m_partFeat->getCosmeticEdgeByIndex(bg->sourceIndex());
|
||||
m_style = ce->m_format.m_style;
|
||||
m_color = ce->m_format.m_color;
|
||||
m_weight = ce->m_format.m_weight;
|
||||
m_visible = ce->m_format.m_visible;
|
||||
} else if (bg->source() == 2) {
|
||||
TechDraw::CenterLine* cl = m_partFeat->getCenterLineByIndex(bg->sourceIndex());
|
||||
m_style = cl->m_format.m_style;
|
||||
m_color = cl->m_format.m_color;
|
||||
m_weight = cl->m_format.m_weight;
|
||||
m_visible = cl->m_format.m_visible;
|
||||
}
|
||||
} else {
|
||||
TechDraw::GeomFormat* gf = m_partFeat->getGeomFormatByGeom(num);
|
||||
if (gf != nullptr) {
|
||||
m_style = gf->m_format.m_style;
|
||||
m_color = gf->m_format.m_color;
|
||||
m_weight = gf->m_format.m_weight;
|
||||
m_visible = gf->m_format.m_visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskLineDecor::onStyleChanged(void)
|
||||
{
|
||||
m_style = ui->cb_Style->currentIndex();
|
||||
//livePreview();
|
||||
}
|
||||
|
||||
void TaskLineDecor::onColorChanged(void)
|
||||
{
|
||||
m_color.setValue<QColor>(ui->cc_Color->color());
|
||||
//livePreview();
|
||||
}
|
||||
|
||||
void TaskLineDecor::onWeightChanged(void)
|
||||
{
|
||||
m_weight = ui->dsb_Weight->value();
|
||||
//livePreview();
|
||||
}
|
||||
|
||||
void TaskLineDecor::onVisibleChanged(void)
|
||||
{
|
||||
m_visible = ui->cb_Visible->currentIndex();
|
||||
//livePreview();
|
||||
}
|
||||
|
||||
void TaskLineDecor::applyDecorations(void)
|
||||
{
|
||||
// Base::Console().Message("TLD::applyDecorations()\n");
|
||||
for (auto& e: m_edges) {
|
||||
int num = DrawUtil::getIndexFromName(e);
|
||||
BaseGeom* bg = m_partFeat->getGeomByIndex(num);
|
||||
if (bg != nullptr) {
|
||||
if (bg->cosmetic) {
|
||||
if (bg->source() == 1) {
|
||||
TechDraw::CosmeticEdge* ce = m_partFeat->getCosmeticEdgeByIndex(bg->sourceIndex());
|
||||
ce->m_format.m_style = m_style;
|
||||
ce->m_format.m_color = m_color;
|
||||
ce->m_format.m_weight = m_weight;
|
||||
ce->m_format.m_visible = m_visible;
|
||||
} else if (bg->source() == 2) {
|
||||
TechDraw::CenterLine* cl = m_partFeat->getCenterLineByIndex(bg->sourceIndex());
|
||||
cl->m_format.m_style = m_style;
|
||||
cl->m_format.m_color = m_color;
|
||||
cl->m_format.m_weight = m_weight;
|
||||
cl->m_format.m_visible = m_visible;
|
||||
}
|
||||
} else {
|
||||
TechDraw::GeomFormat* gf = m_partFeat->getGeomFormatByGeom(num);
|
||||
if (gf != nullptr) {
|
||||
gf->m_format.m_style = m_style;
|
||||
gf->m_format.m_color = m_color;
|
||||
gf->m_format.m_weight = m_weight;
|
||||
gf->m_format.m_visible = m_visible;
|
||||
} else {
|
||||
TechDraw::LineFormat fmt(m_style,
|
||||
m_weight,
|
||||
m_color,
|
||||
m_visible);
|
||||
TechDraw::GeomFormat* newGF = new TechDraw::GeomFormat(num,
|
||||
fmt);
|
||||
// int idx =
|
||||
m_partFeat->addGeomFormat(newGF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TaskLineDecor::accept()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument());
|
||||
if (!doc) return false;
|
||||
|
||||
applyDecorations();
|
||||
m_partFeat->requestPaint();
|
||||
|
||||
//Gui::Command::updateActive(); //no chain of updates here
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskLineDecor::reject()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument());
|
||||
if (!doc) return false;
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
return false;
|
||||
}
|
||||
|
||||
void TaskLineDecor::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TaskDlgLineDecor::TaskDlgLineDecor(TechDraw::DrawViewPart* partFeat,
|
||||
std::vector<std::string> edgeNames) :
|
||||
TaskDialog()
|
||||
{
|
||||
widget = new TaskLineDecor(partFeat, edgeNames);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-linedecor"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgLineDecor::~TaskDlgLineDecor()
|
||||
{
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
void TaskDlgLineDecor::open()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskDlgLineDecor::clicked(int i)
|
||||
{
|
||||
Q_UNUSED(i);
|
||||
}
|
||||
|
||||
bool TaskDlgLineDecor::accept()
|
||||
{
|
||||
widget->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgLineDecor::reject()
|
||||
{
|
||||
widget->reject();
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_TaskLineDecor.cpp>
|
||||
111
src/Mod/TechDraw/Gui/TaskLineDecor.h
Normal file
111
src/Mod/TechDraw/Gui/TaskLineDecor.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2018 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_TASKLINEDECOR_H
|
||||
#define GUI_TASKVIEW_TASKLINEDECOR_H
|
||||
|
||||
#include <App/Material.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskLineDecor.h>
|
||||
|
||||
class Ui_TaskLineDecor;
|
||||
|
||||
namespace App
|
||||
{
|
||||
class DocumentObject;
|
||||
}
|
||||
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
class TaskLineDecor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskLineDecor(TechDraw::DrawViewPart* partFeat,
|
||||
std::vector<std::string> edgeNames);
|
||||
~TaskLineDecor();
|
||||
|
||||
public:
|
||||
virtual bool accept();
|
||||
virtual bool reject();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onStyleChanged(void);
|
||||
void onColorChanged(void);
|
||||
void onWeightChanged(void);
|
||||
void onVisibleChanged(void);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void initUi(void);
|
||||
void applyDecorations(void);
|
||||
void getDefaults(void);
|
||||
|
||||
private:
|
||||
Ui_TaskLineDecor* ui;
|
||||
TechDraw::DrawViewPart* m_partFeat;
|
||||
std::vector<std::string> m_edges;
|
||||
int m_style;
|
||||
App::Color m_color;
|
||||
double m_weight;
|
||||
bool m_visible;
|
||||
};
|
||||
|
||||
class TaskDlgLineDecor : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgLineDecor(TechDraw::DrawViewPart* partFeat,
|
||||
std::vector<std::string> edgeNames);
|
||||
~TaskDlgLineDecor();
|
||||
|
||||
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; }
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
TaskLineDecor * widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} //namespace TechDrawGui
|
||||
|
||||
#endif // #ifndef GUI_TASKVIEW_TASKLINEDECOR_H
|
||||
256
src/Mod/TechDraw/Gui/TaskLineDecor.ui
Normal file
256
src/Mod/TechDraw/Gui/TaskLineDecor.ui
Normal file
@@ -0,0 +1,256 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TechDrawGui::TaskLineDecor</class>
|
||||
<widget class="QWidget" name="TechDrawGui::TaskLineDecor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>395</width>
|
||||
<height>294</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" 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>Line Decoration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_Lines">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>View</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_View">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,1">
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<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="1" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Weight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::ColorButton" name="cc_Color">
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QDoubleSpinBox" name="dsb_Weight">
|
||||
<property name="toolTip">
|
||||
<string>Thickness of pattern lines.</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Visible</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QComboBox" name="cb_Visible">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maxCount">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>False</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>True</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="cb_Style">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>NoLine</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Solid</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dash</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dot</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>DashDot</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>DashDotDot</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Resources/TechDraw.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -94,6 +94,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
*draw << "TechDraw_Midpoints";
|
||||
*draw << "TechDraw_Quadrant";
|
||||
*draw << "TechDraw_CosmeticEraser";
|
||||
*draw << "TechDraw_DecorateLine";
|
||||
|
||||
return root;
|
||||
}
|
||||
@@ -158,7 +159,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
*anno << "TechDraw_CosmeticVertexGrp";
|
||||
*anno << "TechDraw_FaceCenterLine";
|
||||
*anno << "TechDraw_CosmeticEraser";
|
||||
|
||||
*anno << "TechDraw_DecorateLine";
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -220,6 +221,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
*anno << "TechDraw_CosmeticVertexGrp";
|
||||
*anno << "TechDraw_FaceCenterLine";
|
||||
*anno << "TechDraw_CosmeticEraser";
|
||||
*anno << "TechDraw_DecorateLine";
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user