[TD]Add restore invisible lines

This commit is contained in:
wandererfan
2019-07-06 11:44:55 -04:00
committed by WandererFan
parent 3d2edd0f7e
commit b561190d4f
7 changed files with 354 additions and 38 deletions

View File

@@ -1276,7 +1276,7 @@ int DrawViewPart::addCenterLine(CenterLine* cl)
return newIdx;
}
void DrawViewPart::writeCListProp(void)
void DrawViewPart::writeCLineProp(void)
{
std::vector<std::string> saveLines;
const std::vector<TechDraw::CenterLine*> cLines = getCenterLines();
@@ -1309,7 +1309,7 @@ void DrawViewPart::removeCenterLine(int idx)
{
if (idx < (int) CLineTable.size()) {
CLineTable.erase(CLineTable.begin() + idx);
writeCListProp();
writeCLineProp();
recomputeFeature();
}
}
@@ -1319,7 +1319,7 @@ void DrawViewPart::replaceCenterLine(int idx, TechDraw::CenterLine* cl)
std::vector<TechDraw::CenterLine*> lines = getCenterLines();
if (idx < (int) lines.size()) {
lines.at(idx) = cl;
writeCListProp();
writeCLineProp();
recomputeFeature();
}
}

View File

@@ -188,7 +188,7 @@ public:
void clearCosmeticEdges(void);
virtual int addCenterLine(TechDraw::CenterLine*);
virtual void writeCListProp(void);
virtual void writeCLineProp(void);
virtual void removeCenterLine(TechDraw::CenterLine* cl);
virtual void removeCenterLine(int idx);
const std::vector<TechDraw::CenterLine*> & getCenterLines(void) const { return CLineTable; }

View File

@@ -89,6 +89,7 @@ set(TechDrawGui_UIC_SRCS
TaskCosVertex.ui
TaskCenterLine.ui
TaskLineDecor.ui
TaskRestoreLines.ui
)
if(BUILD_QT5)
@@ -164,6 +165,7 @@ SET(TechDrawGui_SRCS
TaskLineDecor.ui
TaskLineDecor.cpp
TaskLineDecor.h
TaskRestoreLines.ui
DrawGuiUtil.cpp
DrawGuiUtil.h
Rez.cpp
@@ -317,6 +319,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
TaskBalloon.ui
TaskCenterLine.ui
TaskLineDecor.ui
TaskRestoreLines.ui
)
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})

View File

@@ -842,7 +842,7 @@ void CmdTechDrawDecorateLine::activated(int iMsg)
}
} else {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
QObject::tr("You must select line(s) in a View."));
QObject::tr("You must select a View and/or line(s)."));
return;
}
@@ -863,14 +863,8 @@ void CmdTechDrawDecorateLine::activated(int iMsg)
}
}
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,
Gui::Control().showDialog(new TaskDlgLineDecor(baseFeat,
edgeNames));
}
}
bool CmdTechDrawDecorateLine::isActive(void)

View File

@@ -48,8 +48,10 @@
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/Cosmetic.h>
#include "TaskLineDecor.h"
#include <Mod/TechDraw/Gui/ui_TaskLineDecor.h>
#include <Mod/TechDraw/Gui/ui_TaskRestoreLines.h>
#include "TaskLineDecor.h"
using namespace Gui;
using namespace TechDraw;
@@ -107,31 +109,33 @@ void TaskLineDecor::getDefaults(void)
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;
if (!m_edges.empty()) {
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;
}
}
}
}
}
@@ -162,7 +166,7 @@ void TaskLineDecor::onVisibleChanged(void)
void TaskLineDecor::applyDecorations(void)
{
// Base::Console().Message("TLD::applyDecorations()\n");
Base::Console().Message("TLD::applyDecorations()\n");
for (auto& e: m_edges) {
int num = DrawUtil::getIndexFromName(e);
BaseGeom* bg = m_partFeat->getGeomByIndex(num);
@@ -174,6 +178,7 @@ void TaskLineDecor::applyDecorations(void)
ce->m_format.m_color = m_color;
ce->m_format.m_weight = m_weight;
ce->m_format.m_visible = m_visible;
Base::Console().Message("TLD::applyDecorations()\n");
} else if (bg->source() == 2) {
TechDraw::CenterLine* cl = m_partFeat->getCenterLineByIndex(bg->sourceIndex());
cl->m_format.m_style = m_style;
@@ -201,14 +206,20 @@ void TaskLineDecor::applyDecorations(void)
}
}
}
}
bool TaskLineDecor::accept()
{
Base::Console().Message("TLD::accept()\n");
Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument());
if (!doc) return false;
applyDecorations();
m_partFeat->writeGFormatProp();
m_partFeat->writeCEdgeProp();
m_partFeat->writeCLineProp();
m_partFeat->requestPaint();
//Gui::Command::updateActive(); //no chain of updates here
@@ -219,6 +230,7 @@ bool TaskLineDecor::accept()
bool TaskLineDecor::reject()
{
Base::Console().Message("TLD::reject()\n");
Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument());
if (!doc) return false;
@@ -232,6 +244,170 @@ void TaskLineDecor::changeEvent(QEvent *e)
ui->retranslateUi(this);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskRestoreLines::TaskRestoreLines(TechDraw::DrawViewPart* partFeat) :
ui(new Ui_TaskRestoreLines),
m_partFeat(partFeat)
{
ui->setupUi(this);
connect(ui->pb_All, SIGNAL(clicked( )), this, SLOT(onAllPressed(void)));
connect(ui->pb_Geometry, SIGNAL(clicked( )), this, SLOT(onGeometryPressed(void)));
connect(ui->pb_Cosmetic, SIGNAL(clicked( )), this, SLOT(onCosmeticPressed( void )));
connect(ui->pb_Center, SIGNAL(clicked( )), this, SLOT(onCenterPressed( void )));
initUi();
}
TaskRestoreLines::~TaskRestoreLines()
{
delete ui;
}
void TaskRestoreLines::initUi()
{
ui->l_All->setText(QString::number(countInvisibleLines()));
ui->l_Geometry->setText(QString::number(countInvisibleGeoms()));
ui->l_Cosmetic->setText(QString::number(countInvisibleCosmetics()));
ui->l_Center->setText(QString::number(countInvisibleCenters()));
}
void TaskRestoreLines::onAllPressed(void)
{
Base::Console().Message("TRL::onAllPressed()\n");
onGeometryPressed();
onCosmeticPressed();
onCenterPressed();
}
void TaskRestoreLines::onGeometryPressed(void)
{
Base::Console().Message("TRL::onGeometryPressed()\n");
restoreInvisibleGeoms();
ui->l_Geometry->setText(QString::number(0));
ui->l_All->setText(QString::number(countInvisibleLines()));
m_partFeat->writeGFormatProp();
}
void TaskRestoreLines::onCosmeticPressed(void)
{
Base::Console().Message("TRL::onCosmeticPressed()\n");
restoreInvisibleCosmetics();
ui->l_Cosmetic->setText(QString::number(0));
ui->l_All->setText(QString::number(countInvisibleLines()));
m_partFeat->writeCEdgeProp();
}
void TaskRestoreLines::onCenterPressed(void)
{
Base::Console().Message("TRL::onCenterPressed()\n");
restoreInvisibleCenters();
ui->l_Center->setText(QString::number(0));
ui->l_All->setText(QString::number(countInvisibleLines()));
m_partFeat->writeCLineProp();
}
int TaskRestoreLines::countInvisibleLines(void)
{
int result = 0;
result += countInvisibleGeoms();
result += countInvisibleCosmetics();
result += countInvisibleCenters();
return result;
}
int TaskRestoreLines::countInvisibleGeoms(void)
{
int iGeoms = 0;
const std::vector<TechDraw::GeomFormat*> geoms = m_partFeat->getGeomFormats();
for (auto& g : geoms) {
if (!g->m_format.m_visible) {
iGeoms++;
}
}
return iGeoms;
}
int TaskRestoreLines::countInvisibleCosmetics(void)
{
int iCosmos = 0;
const std::vector<TechDraw::CosmeticEdge*> cosmos = m_partFeat->getCosmeticEdges();
for (auto& c : cosmos) {
if (!c->m_format.m_visible) {
iCosmos++;
}
}
return iCosmos++;
}
int TaskRestoreLines::countInvisibleCenters(void)
{
int iCenter = 0;
const std::vector<TechDraw::CenterLine*> centers = m_partFeat->getCenterLines();
for (auto& c : centers) {
if (!c->m_format.m_visible) {
iCenter++;
}
}
return iCenter++;
}
void TaskRestoreLines::restoreInvisibleLines(void)
{
restoreInvisibleGeoms();
restoreInvisibleCosmetics();
restoreInvisibleCenters();
}
void TaskRestoreLines::restoreInvisibleGeoms(void)
{
const std::vector<TechDraw::GeomFormat*> geoms = m_partFeat->getGeomFormats();
for (auto& g : geoms) {
if (!g->m_format.m_visible) {
g->m_format.m_visible = true;
}
}
}
void TaskRestoreLines::restoreInvisibleCosmetics(void)
{
const std::vector<TechDraw::CosmeticEdge*> cosmos = m_partFeat->getCosmeticEdges();
for (auto& c : cosmos) {
if (!c->m_format.m_visible) {
c->m_format.m_visible = true;
}
}
}
void TaskRestoreLines::restoreInvisibleCenters(void)
{
const std::vector<TechDraw::CenterLine*> centers = m_partFeat->getCenterLines();
for (auto& c : centers) {
if (!c->m_format.m_visible) {
c->m_format.m_visible = true;
}
}
}
bool TaskRestoreLines::accept()
{
Base::Console().Message("TRL::accept()\n");
return true;
}
bool TaskRestoreLines::reject()
{
Base::Console().Message("TRL::reject()\n");
return false;
}
void TaskRestoreLines::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskDlgLineDecor::TaskDlgLineDecor(TechDraw::DrawViewPart* partFeat,
@@ -243,6 +419,15 @@ TaskDlgLineDecor::TaskDlgLineDecor(TechDraw::DrawViewPart* partFeat,
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
if (edgeNames.empty()) {
taskbox->hideGroupBox();
}
restore = new TaskRestoreLines(partFeat);
restoreBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-linedecor"),
tr("Restore Invisible Lines"), true, 0);
restoreBox->groupLayout()->addWidget(restore);
Content.push_back(restoreBox);
}
TaskDlgLineDecor::~TaskDlgLineDecor()
@@ -262,12 +447,14 @@ void TaskDlgLineDecor::clicked(int i)
bool TaskDlgLineDecor::accept()
{
Base::Console().Message("TDLD::accept()\n");
widget->accept();
return true;
}
bool TaskDlgLineDecor::reject()
{
Base::Console().Message("TDLD::reject()\n");
widget->reject();
return true;
}

View File

@@ -29,6 +29,7 @@
#include <Gui/FileDialog.h>
#include <Mod/TechDraw/Gui/ui_TaskLineDecor.h>
#include <Mod/TechDraw/Gui/ui_TaskRestoreLines.h> //????
class Ui_TaskLineDecor;
@@ -76,6 +77,42 @@ private:
bool m_visible;
};
class TaskRestoreLines : public QWidget
{
Q_OBJECT
public:
TaskRestoreLines(TechDraw::DrawViewPart* partFeat);
~TaskRestoreLines();
public:
virtual bool accept();
virtual bool reject();
protected Q_SLOTS:
void onAllPressed(void);
void onGeometryPressed(void);
void onCosmeticPressed(void);
void onCenterPressed(void);
protected:
void changeEvent(QEvent *e);
void initUi(void);
int countInvisibleLines(void);
int countInvisibleGeoms(void);
int countInvisibleCosmetics(void);
int countInvisibleCenters(void);
void restoreInvisibleLines(void);
void restoreInvisibleGeoms(void);
void restoreInvisibleCosmetics(void);
void restoreInvisibleCenters(void);
private:
Ui_TaskRestoreLines* ui;
TechDraw::DrawViewPart* m_partFeat;
};
class TaskDlgLineDecor : public Gui::TaskView::TaskDialog
{
Q_OBJECT
@@ -103,7 +140,9 @@ protected:
private:
TaskLineDecor * widget;
TaskRestoreLines* restore;
Gui::TaskView::TaskBox* taskbox;
Gui::TaskView::TaskBox* restoreBox;
};
} //namespace TechDrawGui

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TechDrawGui::TaskRestoreLines</class>
<widget class="QWidget" name="TechDrawGui::TaskRestoreLines">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>227</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Restore Invisible Lines</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pb_All">
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_Geometry">
<property name="text">
<string>Geometry</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pb_Center">
<property name="text">
<string>CenterLine</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pb_Cosmetic">
<property name="text">
<string>Cosmetic</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="l_All">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="l_Geometry">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="l_Cosmetic">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="l_Center">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>