Make "Show/hide hidden lines" a tri-state button instead.
The states are: * Draw all lines (on top of shaded mesh). * Draw occluded (by shaded mesh) lines as stippled. * Do not draw occluded (by shaded mesh) lines. As usual, the export output follows the screen output.
This commit is contained in:
parent
8ce2922902
commit
6e860fb148
@ -14,6 +14,9 @@ Other new features:
|
||||
* New link to match the on-screen size of the sketch with its actual size,
|
||||
"view → set to full scale".
|
||||
* When zooming to fit, constraints are also considered.
|
||||
* The "Show/hide hidden lines" button is now a tri-state button that allows
|
||||
showing all lines (on top of shaded mesh), stippling occluded lines
|
||||
or not drawing them at all.
|
||||
|
||||
2.2
|
||||
---
|
||||
|
@ -177,7 +177,9 @@ add_resources(
|
||||
icons/text-window/constraint.png
|
||||
icons/text-window/edges.png
|
||||
icons/text-window/faces.png
|
||||
icons/text-window/hidden-lines.png
|
||||
icons/text-window/occluded-visible.png
|
||||
icons/text-window/occluded-stippled.png
|
||||
icons/text-window/occluded-invisible.png
|
||||
icons/text-window/mesh.png
|
||||
icons/text-window/normal.png
|
||||
icons/text-window/outlines.png
|
||||
|
BIN
res/icons/text-window/occluded-invisible.png
Normal file
BIN
res/icons/text-window/occluded-invisible.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 539 B After Width: | Height: | Size: 539 B |
BIN
res/icons/text-window/occluded-visible.png
Normal file
BIN
res/icons/text-window/occluded-visible.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 365 B |
14
src/draw.cpp
14
src/draw.cpp
@ -565,10 +565,18 @@ void GraphicsWindow::DrawPersistent(Canvas *canvas) {
|
||||
|
||||
// Now draw the entities.
|
||||
for(Entity &e : SK.entity) {
|
||||
if(SS.GW.showHdnLines) {
|
||||
e.Draw(Entity::DrawAs::HIDDEN, canvas);
|
||||
switch(SS.GW.drawOccludedAs) {
|
||||
case DrawOccludedAs::VISIBLE:
|
||||
e.Draw(Entity::DrawAs::OVERLAY, canvas);
|
||||
break;
|
||||
|
||||
case DrawOccludedAs::STIPPLED:
|
||||
e.Draw(Entity::DrawAs::HIDDEN, canvas);
|
||||
/* fallthrough */
|
||||
case DrawOccludedAs::INVISIBLE:
|
||||
e.Draw(Entity::DrawAs::DEFAULT, canvas);
|
||||
break;
|
||||
}
|
||||
e.Draw(Entity::DrawAs::DEFAULT, canvas);
|
||||
}
|
||||
|
||||
// Draw filled paths in all groups, when those filled paths were requested
|
||||
|
@ -474,6 +474,10 @@ void Entity::Draw(DrawAs how, Canvas *canvas) {
|
||||
stroke.layer = Canvas::Layer::NORMAL;
|
||||
break;
|
||||
|
||||
case DrawAs::OVERLAY:
|
||||
stroke.layer = Canvas::Layer::FRONT;
|
||||
break;
|
||||
|
||||
case DrawAs::HIDDEN:
|
||||
stroke.layer = Canvas::Layer::OCCLUDED;
|
||||
stroke.stipplePattern = Style::PatternType({ Style::HIDDEN_EDGE });
|
||||
|
@ -178,7 +178,7 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const std::string &filename, bool exp
|
||||
GenerateAll(Generate::ALL);
|
||||
|
||||
SMesh *sm = NULL;
|
||||
if(SS.GW.showShaded || SS.GW.showHdnLines) {
|
||||
if(SS.GW.showShaded || SS.GW.drawOccludedAs != GraphicsWindow::DrawOccludedAs::VISIBLE) {
|
||||
Group *g = SK.GetGroup(SS.GW.activeGroup);
|
||||
g->GenerateDisplayItems();
|
||||
sm = &(g->displayMesh);
|
||||
@ -410,13 +410,13 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
|
||||
// Split the original edge against the mesh
|
||||
edges.AddEdge(se->a, se->b, se->auxA);
|
||||
root->OcclusionTestLine(*se, &edges, cnt);
|
||||
if(SS.GW.showHdnLines) {
|
||||
if(SS.GW.drawOccludedAs == GraphicsWindow::DrawOccludedAs::STIPPLED) {
|
||||
for(SEdge &se : edges.l) {
|
||||
if(se.tag == 1) {
|
||||
se.auxA = Style::HIDDEN_EDGE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if(SS.GW.drawOccludedAs == GraphicsWindow::DrawOccludedAs::INVISIBLE) {
|
||||
edges.l.RemoveTagged();
|
||||
}
|
||||
|
||||
|
@ -223,11 +223,11 @@ void GraphicsWindow::Init() {
|
||||
showNormals = true;
|
||||
showPoints = true;
|
||||
showConstraints = true;
|
||||
showHdnLines = false;
|
||||
showShaded = true;
|
||||
showEdges = true;
|
||||
showMesh = false;
|
||||
showOutlines = false;
|
||||
drawOccludedAs = DrawOccludedAs::INVISIBLE;
|
||||
|
||||
showTextWindow = true;
|
||||
ShowTextWindow(showTextWindow);
|
||||
|
@ -444,7 +444,8 @@ bool Group::IsMeshGroup() {
|
||||
}
|
||||
|
||||
void Group::DrawMesh(DrawMeshAs how, Canvas *canvas) {
|
||||
if(!(SS.GW.showShaded || SS.GW.showHdnLines)) return;
|
||||
if(!(SS.GW.showShaded ||
|
||||
SS.GW.drawOccludedAs != GraphicsWindow::DrawOccludedAs::VISIBLE)) return;
|
||||
|
||||
switch(how) {
|
||||
case DrawMeshAs::DEFAULT: {
|
||||
@ -452,7 +453,7 @@ void Group::DrawMesh(DrawMeshAs how, Canvas *canvas) {
|
||||
// the sketch.
|
||||
Canvas::Fill fillFront = {};
|
||||
if(!SS.GW.showShaded) {
|
||||
fillFront.layer = Canvas::Layer::DEPTH_ONLY;
|
||||
fillFront.layer = Canvas::Layer::DEPTH_ONLY;
|
||||
}
|
||||
if(type == Type::DRAWING_3D || type == Type::DRAWING_WORKPLANE) {
|
||||
fillFront.color = Style::Color(Style::DIM_SOLID);
|
||||
@ -549,7 +550,7 @@ void Group::Draw(Canvas *canvas) {
|
||||
? Canvas::DrawOutlinesAs::EMPHASIZED_WITHOUT_CONTOUR
|
||||
: Canvas::DrawOutlinesAs::EMPHASIZED_AND_CONTOUR);
|
||||
|
||||
if(SS.GW.showHdnLines) {
|
||||
if(SS.GW.drawOccludedAs == GraphicsWindow::DrawOccludedAs::STIPPLED) {
|
||||
Canvas::Stroke strokeHidden = strokeEdge;
|
||||
strokeHidden.layer = Canvas::Layer::OCCLUDED;
|
||||
strokeHidden.width = Style::Width(Style::HIDDEN_EDGE);
|
||||
|
@ -506,7 +506,7 @@ public:
|
||||
bool IsStylable() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
enum class DrawAs { DEFAULT, HIDDEN, HOVERED, SELECTED };
|
||||
enum class DrawAs { DEFAULT, OVERLAY, HIDDEN, HOVERED, SELECTED };
|
||||
void Draw(DrawAs how, Canvas *canvas);
|
||||
void GetReferencePoints(std::vector<Vector> *refs);
|
||||
int GetPositionOfPoint(const Camera &camera, Point2d p);
|
||||
|
@ -83,6 +83,76 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class OccludedLinesButton : public Button {
|
||||
public:
|
||||
std::shared_ptr<Pixmap> visibleIcon;
|
||||
std::shared_ptr<Pixmap> stippledIcon;
|
||||
std::shared_ptr<Pixmap> invisibleIcon;
|
||||
|
||||
std::string Tooltip() override {
|
||||
switch(SS.GW.drawOccludedAs) {
|
||||
case GraphicsWindow::DrawOccludedAs::INVISIBLE:
|
||||
return "Stipple occluded lines";
|
||||
|
||||
case GraphicsWindow::DrawOccludedAs::STIPPLED:
|
||||
return "Draw occluded lines";
|
||||
|
||||
case GraphicsWindow::DrawOccludedAs::VISIBLE:
|
||||
return "Don't draw occluded lines";
|
||||
|
||||
default: ssassert(false, "Unexpected mode");
|
||||
}
|
||||
}
|
||||
|
||||
void Draw(UiCanvas *uiCanvas, int x, int y, bool asHovered) override {
|
||||
if(visibleIcon == NULL) {
|
||||
visibleIcon = LoadPng("icons/text-window/occluded-visible.png");
|
||||
}
|
||||
if(stippledIcon == NULL) {
|
||||
stippledIcon = LoadPng("icons/text-window/occluded-stippled.png");
|
||||
}
|
||||
if(invisibleIcon == NULL) {
|
||||
invisibleIcon = LoadPng("icons/text-window/occluded-invisible.png");
|
||||
}
|
||||
|
||||
std::shared_ptr<Pixmap> icon;
|
||||
switch(SS.GW.drawOccludedAs) {
|
||||
case GraphicsWindow::DrawOccludedAs::INVISIBLE: icon = invisibleIcon; break;
|
||||
case GraphicsWindow::DrawOccludedAs::STIPPLED: icon = stippledIcon; break;
|
||||
case GraphicsWindow::DrawOccludedAs::VISIBLE: icon = visibleIcon; break;
|
||||
}
|
||||
|
||||
uiCanvas->DrawPixmap(icon, x, y - 24);
|
||||
if(asHovered) {
|
||||
uiCanvas->DrawRect(x - 2, x + 26, y + 2, y - 26,
|
||||
/*fillColor=*/{ 255, 255, 0, 75 },
|
||||
/*outlineColor=*/{});
|
||||
}
|
||||
}
|
||||
|
||||
int AdvanceWidth() override { return 32; }
|
||||
|
||||
void Click() override {
|
||||
switch(SS.GW.drawOccludedAs) {
|
||||
case GraphicsWindow::DrawOccludedAs::INVISIBLE:
|
||||
SS.GW.drawOccludedAs = GraphicsWindow::DrawOccludedAs::STIPPLED;
|
||||
break;
|
||||
|
||||
case GraphicsWindow::DrawOccludedAs::STIPPLED:
|
||||
SS.GW.drawOccludedAs = GraphicsWindow::DrawOccludedAs::VISIBLE;
|
||||
break;
|
||||
|
||||
case GraphicsWindow::DrawOccludedAs::VISIBLE:
|
||||
SS.GW.drawOccludedAs = GraphicsWindow::DrawOccludedAs::INVISIBLE;
|
||||
break;
|
||||
}
|
||||
|
||||
SS.GenerateAll();
|
||||
InvalidateGraphics();
|
||||
SS.ScheduleShowTW();
|
||||
}
|
||||
};
|
||||
|
||||
static SpacerButton spacerButton;
|
||||
|
||||
static ShowHideButton workplanesButton =
|
||||
@ -102,8 +172,7 @@ static ShowHideButton outlinesButton =
|
||||
{ &(SS.GW.showOutlines), "outlines", "outline of solid model" };
|
||||
static ShowHideButton meshButton =
|
||||
{ &(SS.GW.showMesh), "mesh", "triangle mesh of solid model" };
|
||||
static ShowHideButton hdnLinesButton =
|
||||
{ &(SS.GW.showHdnLines), "hidden-lines", "hidden lines" };
|
||||
static OccludedLinesButton occludedLinesButton;
|
||||
|
||||
static Button *buttons[] = {
|
||||
&workplanesButton,
|
||||
@ -117,7 +186,7 @@ static Button *buttons[] = {
|
||||
&outlinesButton,
|
||||
&meshButton,
|
||||
&spacerButton,
|
||||
&hdnLinesButton,
|
||||
&occludedLinesButton,
|
||||
};
|
||||
|
||||
const TextWindow::Color TextWindow::fgColors[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user