dimonly fix

pull/1333/head
77maxikov 2020-04-29 13:17:14 +03:00 committed by Paul Kahler
parent 4a34253a37
commit a0219b2228
10 changed files with 106 additions and 22 deletions

View File

@ -268,6 +268,8 @@ add_resources(
icons/graphics-window/trim.png icons/graphics-window/trim.png
icons/graphics-window/vert.png icons/graphics-window/vert.png
icons/text-window/constraint.png icons/text-window/constraint.png
icons/text-window/constraint-dimo.png
icons/text-window/constraint-wo.png
icons/text-window/construction.png icons/text-window/construction.png
icons/text-window/edges.png icons/text-window/edges.png
icons/text-window/faces.png icons/text-window/faces.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

View File

@ -449,21 +449,39 @@ void Constraint::DoArcForAngle(Canvas *canvas, Canvas::hStroke hcs,
} }
bool Constraint::IsVisible() const { bool Constraint::IsVisible() const {
if(!SS.GW.showConstraints) return false; if(SS.GW.showConstraints == GraphicsWindow::ShowConstraintMode::SCM_NOSHOW ) return false;
Group *g = SK.GetGroup(group); bool isDim = false;
// If the group is hidden, then the constraints are hidden and not
// able to be selected. if(SS.GW.showConstraints == GraphicsWindow::ShowConstraintMode::SCM_SHOW_DIM )
if(!(g->visible)) return false; switch (type){
// And likewise if the group is not the active group; except for comments case ConstraintBase::Type::ANGLE:
// with an assigned style. case ConstraintBase::Type::DIAMETER:
if(g->h != SS.GW.activeGroup && !(type == Type::COMMENT && disp.style.v)) { case ConstraintBase::Type::PT_PT_DISTANCE:
return false; case ConstraintBase::Type::PT_FACE_DISTANCE:
case ConstraintBase::Type::PT_LINE_DISTANCE:
case ConstraintBase::Type::PT_PLANE_DISTANCE:
isDim = true;
break;
default:;
}
if(SS.GW.showConstraints == GraphicsWindow::ShowConstraintMode::SCM_SHOW_ALL || isDim ) {
Group *g = SK.GetGroup(group);
// If the group is hidden, then the constraints are hidden and not
// able to be selected.
if(!(g->visible)) return false;
// And likewise if the group is not the active group; except for comments
// with an assigned style.
if(g->h != SS.GW.activeGroup && !(type == Type::COMMENT && disp.style.v)) {
return false;
}
if(disp.style.v) {
Style *s = Style::Get(disp.style);
if(!s->visible) return false;
}
return true;
} }
if(disp.style.v) { return false;
Style *s = Style::Get(disp.style);
if(!s->visible) return false;
}
return true;
} }
bool Constraint::DoLineExtend(Canvas *canvas, Canvas::hStroke hcs, bool Constraint::DoLineExtend(Canvas *canvas, Canvas::hStroke hcs,

View File

@ -227,7 +227,7 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const Platform::Path &filename, bool
} }
} }
if(SS.GW.showConstraints) { if(SS.GW.showConstraints != GraphicsWindow::ShowConstraintMode::SCM_NOSHOW ) {
if(!out->OutputConstraints(&SK.constraint)) { if(!out->OutputConstraints(&SK.constraint)) {
GetEdgesCanvas canvas = {}; GetEdgesCanvas canvas = {};
canvas.camera = SS.GW.GetCamera(); canvas.camera = SS.GW.GetCamera();

View File

@ -409,7 +409,7 @@ void GraphicsWindow::Init() {
showNormals = true; showNormals = true;
showPoints = true; showPoints = true;
showConstruction = true; showConstruction = true;
showConstraints = true; showConstraints = GraphicsWindow::ShowConstraintMode::SCM_SHOW_ALL;
showShaded = true; showShaded = true;
showEdges = true; showEdges = true;
showMesh = false; showMesh = false;

View File

@ -719,7 +719,7 @@ void SolveSpaceUI::MenuFile(Command id) {
// If the user is exporting something where it would be // If the user is exporting something where it would be
// inappropriate to include the constraints, then warn. // inappropriate to include the constraints, then warn.
if(SS.GW.showConstraints && if(SS.GW.showConstraints != GraphicsWindow::ShowConstraintMode::SCM_NOSHOW &&
(dialog->GetFilename().HasExtension("txt") || (dialog->GetFilename().HasExtension("txt") ||
fabs(SS.exportOffset) > LENGTH_EPS)) fabs(SS.exportOffset) > LENGTH_EPS))
{ {

View File

@ -194,8 +194,7 @@ void TextWindow::ScreenHoverRequest(int link, uint32_t v) {
SS.GW.hover.emphasized = true; SS.GW.hover.emphasized = true;
} }
void TextWindow::ScreenHoverConstraint(int link, uint32_t v) { void TextWindow::ScreenHoverConstraint(int link, uint32_t v) {
if(!SS.GW.showConstraints) return; if( SS.GW.showConstraints == GraphicsWindow::ShowConstraintMode::SCM_NOSHOW ) return;
hConstraint hc = { v }; hConstraint hc = { v };
SS.GW.hover.Clear(); SS.GW.hover.Clear();
SS.GW.hover.constraint = hc; SS.GW.hover.constraint = hc;

View File

@ -82,6 +82,62 @@ public:
} }
} }
}; };
#include <array>
class TriStateButton : public Button {
public:
TriStateButton(GraphicsWindow::ShowConstraintMode*variable,
const std::array<GraphicsWindow::ShowConstraintMode,3> &states,
const std::array<std::string,3> &tooltips,
const std::array<std::string,3> &iconNames ):variable(variable),states(states),tooltips(tooltips),iconNames(iconNames){}
GraphicsWindow::ShowConstraintMode* variable;
std::array<GraphicsWindow::ShowConstraintMode,3> states;
std::array<std::string,3> tooltips;
std::array<std::string,3> iconNames;
std::shared_ptr<Pixmap> icons[3];
std::string Tooltip() override {
for (size_t k = 0; k < 3; ++k )
if ( *variable == states[k] ) return tooltips[k];
ssassert(false, "Unexpected mode");
}
void Draw(UiCanvas *uiCanvas, int x, int y, bool asHovered) override {
for (size_t k = 0; k < 3;++k)
if(icons[k] == nullptr)
icons[k] = LoadPng("icons/text-window/" + iconNames[k] + ".png");
std::shared_ptr<Pixmap> icon;
for (size_t k = 0; k < 3; ++k )
if ( *variable == states[k] ){
icon = icons[k];
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 {
for (size_t k = 0;k < 3;++k)
if ( *variable == states[k] ){
*variable = states[(k+1)%3];
break;
}
SS.GenerateAll();
SS.GW.Invalidate();
SS.ScheduleShowTW();
}
};
class OccludedLinesButton : public Button { class OccludedLinesButton : public Button {
public: public:
@ -163,8 +219,15 @@ static ShowHideButton pointsButton =
{ &(SS.GW.showPoints), "point", "points" }; { &(SS.GW.showPoints), "point", "points" };
static ShowHideButton constructionButton = static ShowHideButton constructionButton =
{ &(SS.GW.showConstruction), "construction", "construction entities" }; { &(SS.GW.showConstruction), "construction", "construction entities" };
static ShowHideButton constraintsButton = static TriStateButton constraintsButton =
{ &(SS.GW.showConstraints), "constraint", "constraints and dimensions" }; { &(SS.GW.showConstraints),
{GraphicsWindow::ShowConstraintMode::SCM_SHOW_ALL,
GraphicsWindow::ShowConstraintMode::SCM_SHOW_DIM,
GraphicsWindow::ShowConstraintMode::SCM_NOSHOW},
{"constraints and dimensions","dimensions","none"},
{"constraint","constraint-dimo","constraint-wo"}
};
static FacesButton facesButton; static FacesButton facesButton;
static ShowHideButton shadedButton = static ShowHideButton shadedButton =
{ &(SS.GW.showShaded), "shaded", "shaded view of solid model" }; { &(SS.GW.showShaded), "shaded", "shaded view of solid model" };

View File

@ -801,12 +801,14 @@ public:
bool ToolbarMouseDown(int x, int y); bool ToolbarMouseDown(int x, int y);
Command toolbarHovered; Command toolbarHovered;
enum class ShowConstraintMode{SCM_NOSHOW,SCM_SHOW_ALL,SCM_SHOW_DIM};
// This sets what gets displayed. // This sets what gets displayed.
bool showWorkplanes; bool showWorkplanes;
bool showNormals; bool showNormals;
bool showPoints; bool showPoints;
bool showConstruction; bool showConstruction;
bool showConstraints; ShowConstraintMode showConstraints;
bool showTextWindow; bool showTextWindow;
bool showShaded; bool showShaded;
bool showEdges; bool showEdges;