[TD]Add Show/Hide invisible lines tool

This commit is contained in:
wandererfan
2019-07-17 18:14:46 -04:00
committed by WandererFan
parent 12a35a0955
commit d745257cc3
7 changed files with 255 additions and 5 deletions

View File

@@ -61,6 +61,7 @@
#include "TaskCenterLine.h"
#include "TaskLineDecor.h"
#include "ViewProviderPage.h"
#include "ViewProviderViewPart.h"
#include "QGVPage.h"
using namespace TechDrawGui;
@@ -1204,6 +1205,63 @@ bool CmdTechDrawDecorateLine::isActive(void)
return (havePage && haveView);
}
//===========================================================================
// TechDraw_ShowAll
//===========================================================================
DEF_STD_CMD_A(CmdTechDrawShowAll);
CmdTechDrawShowAll::CmdTechDrawShowAll()
: Command("TechDraw_ShowAll")
{
sAppModule = "TechDraw";
sGroup = QT_TR_NOOP("TechDraw");
sMenuText = QT_TR_NOOP("Show/Hide invisible edges in a View");
sToolTipText = sMenuText;
sWhatsThis = "TechDraw_ShowAll";
sStatusTip = sToolTipText;
sPixmap = "actions/techdraw-showall";
}
void CmdTechDrawShowAll::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::DrawView* baseFeat = nullptr;
if (!selection.empty()) {
baseFeat = dynamic_cast<TechDraw::DrawView *>(selection[0].getObject());
}
Gui::ViewProvider* vp = QGIView::getViewProvider(baseFeat);
auto partVP = dynamic_cast<ViewProviderViewPart*>(vp);
if ( vp != nullptr ) {
bool state = partVP->ShowAllEdges.getValue();
state = !state;
partVP->ShowAllEdges.setValue(state);
baseFeat->requestPaint();
}
}
bool CmdTechDrawShowAll::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();
@@ -1221,6 +1279,7 @@ void CreateTechDrawCommandsAnnotate(void)
rcCmdMgr.addCommand(new CmdTechDrawAnnotation());
rcCmdMgr.addCommand(new CmdTechDrawCosmeticEraser());
rcCmdMgr.addCommand(new CmdTechDrawDecorateLine());
rcCmdMgr.addCommand(new CmdTechDrawShowAll());
}
//===========================================================================

View File

@@ -355,6 +355,7 @@ void QGIViewPart::drawViewPart()
float lineWidthHid = vp->HiddenWidth.getValue() * lineScaleFactor;
float lineWidthIso = vp->IsoWidth.getValue() * lineScaleFactor;
// float lineWidthExtra = viewPart->ExtraWidth.getValue() * lineScaleFactor;
bool showAll = vp->ShowAllEdges.getValue();
prepareGeometryChange();
removePrimitives(); //clean the slate
@@ -418,6 +419,12 @@ void QGIViewPart::drawViewPart()
#endif //#if MOD_TECHDRAW_HANDLE_FACES
// Draw Edges
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcEdgeColor;
fcEdgeColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
QColor edgeColor = fcEdgeColor.asValue<QColor>();
const std::vector<TechDraw::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
std::vector<TechDraw::BaseGeom *>::const_iterator itGeom = geoms.begin();
QGIEdge* item;
@@ -441,9 +448,11 @@ void QGIViewPart::drawViewPart()
}
}
bool showItem = true;
if (showEdge) {
if (showEdge) { //based on hard/seam/hidden/etc
item = new QGIEdge(i);
item->setWidth(lineWidth);
item->setNormalColor(edgeColor);
item->setStyle(Qt::SolidLine);
if ((*itGeom)->cosmetic == true) {
int source = (*itGeom)->source();
int sourceIndex = (*itGeom)->sourceIndex();
@@ -455,7 +464,6 @@ void QGIViewPart::drawViewPart()
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>());
@@ -478,8 +486,10 @@ void QGIViewPart::drawViewPart()
item->setWidth(lineWidthIso);
}
item->setPrettyNormal();
if (!showItem) {
item->hide();
if (!showAll) { //view level "show" status
if (!showItem) { //individual edge "show" status
item->hide();
}
}
//debug a path
// QPainterPath edgePath=drawPainterPath(*itGeom);
@@ -491,7 +501,7 @@ void QGIViewPart::drawViewPart()
// Draw Vertexs:
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
double vertexScaleFactor = hGrp->GetFloat("VertexScale", 3.0);
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->

View File

@@ -72,6 +72,7 @@
<file>icons/actions/techdraw-eraser.svg</file>
<file>icons/actions/techdraw-linedecor.svg</file>
<file>icons/actions/techdraw-facedecor.svg</file>
<file>icons/actions/techdraw-showall.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: 5.8 KiB

View File

@@ -98,6 +98,8 @@ ViewProviderViewPart::ViewProviderViewPart()
//properties that affect Detail Highlights
ADD_PROPERTY_TYPE(HighlightAdjust,(0.0),hgroup,App::Prop_None,"Adjusts the rotation of the Detail highlight");
ADD_PROPERTY_TYPE(ShowAllEdges ,(false) ,dgroup,App::Prop_None,"Temporarily show invisible lines");
}
ViewProviderViewPart::~ViewProviderViewPart()

View File

@@ -53,6 +53,7 @@ public:
App::PropertyBool VertCenterLine;
App::PropertyBool ShowSectionLine;
App::PropertyFloat HighlightAdjust;
App::PropertyBool ShowAllEdges;
virtual void attach(App::DocumentObject *);
virtual void setDisplayMode(const char* ModeName);

View File

@@ -98,6 +98,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*draw << "TechDraw_2PointCenterLine";
*draw << "TechDraw_CosmeticEraser";
*draw << "TechDraw_DecorateLine";
*draw << "TechDraw_ShowAll";
return root;
}
@@ -166,6 +167,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
// *anno << "TechDraw_2PointCenterLine";
*anno << "TechDraw_CosmeticEraser";
*anno << "TechDraw_DecorateLine";
*anno << "TechDraw_ShowAll";
return root;
}
@@ -231,6 +233,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
// *anno << "TechDraw_2PointCenterLine";
*anno << "TechDraw_CosmeticEraser";
*anno << "TechDraw_DecorateLine";
*anno << "TechDraw_ShowAll";
return root;
}