Replace convenience #defines with const auto references.
These are nicer as they are scoped, and so it's clear where they can be used.
This commit is contained in:
parent
f5a37ae2fd
commit
a8e723381c
|
@ -121,7 +121,7 @@ void Constraint::MenuConstrain(Command id) {
|
||||||
c.workplane = SS.GW.ActiveWorkplane();
|
c.workplane = SS.GW.ActiveWorkplane();
|
||||||
|
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
#define gs (SS.GW.gs)
|
auto const &gs = SS.GW.gs;
|
||||||
|
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case Command::DISTANCE_DIA:
|
case Command::DISTANCE_DIA:
|
||||||
|
|
|
@ -19,13 +19,13 @@ void TextWindow::ScreenEditTtfText(int link, uint32_t v) {
|
||||||
SS.TW.edit.request = hr;
|
SS.TW.edit.request = hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define gs (SS.GW.gs)
|
|
||||||
void TextWindow::ScreenSetTtfFont(int link, uint32_t v) {
|
void TextWindow::ScreenSetTtfFont(int link, uint32_t v) {
|
||||||
int i = (int)v;
|
int i = (int)v;
|
||||||
if(i < 0) return;
|
if(i < 0) return;
|
||||||
if(i >= SS.fonts.l.n) return;
|
if(i >= SS.fonts.l.n) return;
|
||||||
|
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
|
auto const &gs = SS.GW.gs;
|
||||||
if(gs.entities != 1 || gs.n != 1) return;
|
if(gs.entities != 1 || gs.n != 1) return;
|
||||||
|
|
||||||
Entity *e = SK.entity.FindByIdNoOops(gs.entity[0]);
|
Entity *e = SK.entity.FindByIdNoOops(gs.entity[0]);
|
||||||
|
@ -57,6 +57,7 @@ void TextWindow::DescribeSelection() {
|
||||||
int i;
|
int i;
|
||||||
Printf(false, "");
|
Printf(false, "");
|
||||||
|
|
||||||
|
auto const &gs = SS.GW.gs;
|
||||||
if(gs.n == 1 && (gs.points == 1 || gs.entities == 1)) {
|
if(gs.n == 1 && (gs.points == 1 || gs.entities == 1)) {
|
||||||
e = SK.GetEntity(gs.points == 1 ? gs.point[0] : gs.entity[0]);
|
e = SK.GetEntity(gs.points == 1 ? gs.point[0] : gs.entity[0]);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ void SolveSpaceUI::ExportSectionTo(const std::string &filename) {
|
||||||
double d;
|
double d;
|
||||||
|
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
#define gs (SS.GW.gs)
|
auto const &gs = SS.GW.gs;
|
||||||
if((gs.n == 0 && g->activeWorkplane.v != Entity::FREE_IN_3D.v)) {
|
if((gs.n == 0 && g->activeWorkplane.v != Entity::FREE_IN_3D.v)) {
|
||||||
Entity *wrkpl = SK.GetEntity(g->activeWorkplane);
|
Entity *wrkpl = SK.GetEntity(g->activeWorkplane);
|
||||||
origin = wrkpl->WorkplaneGetOffset();
|
origin = wrkpl->WorkplaneGetOffset();
|
||||||
|
|
|
@ -13,8 +13,6 @@ const hParam Param::NO_PARAM = { 0 };
|
||||||
|
|
||||||
const hGroup Group::HGROUP_REFERENCES = { 1 };
|
const hGroup Group::HGROUP_REFERENCES = { 1 };
|
||||||
|
|
||||||
#define gs (SS.GW.gs)
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// The group structure includes pointers to other dynamically-allocated
|
// The group structure includes pointers to other dynamically-allocated
|
||||||
// memory. This clears and frees them all.
|
// memory. This clears and frees them all.
|
||||||
|
@ -83,6 +81,7 @@ void Group::MenuGroup(Command id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
|
auto const &gs = SS.GW.gs;
|
||||||
|
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case Command::GROUP_3D:
|
case Command::GROUP_3D:
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
#define gs (SS.GW.gs)
|
|
||||||
|
|
||||||
void Group::AssembleLoops(bool *allClosed,
|
void Group::AssembleLoops(bool *allClosed,
|
||||||
bool *allCoplanar,
|
bool *allCoplanar,
|
||||||
bool *allNonZeroLen)
|
bool *allNonZeroLen)
|
||||||
|
@ -513,6 +511,7 @@ void Group::DrawMesh(DrawMeshAs how, Canvas *canvas) {
|
||||||
|
|
||||||
std::vector<uint32_t> faces;
|
std::vector<uint32_t> faces;
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
|
auto const &gs = SS.GW.gs;
|
||||||
if(gs.faces > 0) faces.push_back(gs.face[0].v);
|
if(gs.faces > 0) faces.push_back(gs.face[0].v);
|
||||||
if(gs.faces > 1) faces.push_back(gs.face[1].v);
|
if(gs.faces > 1) faces.push_back(gs.face[1].v);
|
||||||
canvas->DrawFaces(displayMesh, faces, hcf);
|
canvas->DrawFaces(displayMesh, faces, hcf);
|
||||||
|
|
|
@ -570,7 +570,7 @@ void SolveSpaceUI::MenuFile(Command id) {
|
||||||
|
|
||||||
void SolveSpaceUI::MenuAnalyze(Command id) {
|
void SolveSpaceUI::MenuAnalyze(Command id) {
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
#define gs (SS.GW.gs)
|
auto const &gs = SS.GW.gs;
|
||||||
|
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case Command::STEP_DIM:
|
case Command::STEP_DIM:
|
||||||
|
|
|
@ -448,11 +448,11 @@ done:
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define gs (SS.GW.gs)
|
|
||||||
void TextWindow::Show() {
|
void TextWindow::Show() {
|
||||||
if(SS.GW.pending.operation == GraphicsWindow::Pending::NONE) SS.GW.ClearPending();
|
if(SS.GW.pending.operation == GraphicsWindow::Pending::NONE) SS.GW.ClearPending();
|
||||||
|
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
|
auto const &gs = SS.GW.gs;
|
||||||
|
|
||||||
// Make sure these tests agree with test used to draw indicator line on
|
// Make sure these tests agree with test used to draw indicator line on
|
||||||
// main list of groups screen.
|
// main list of groups screen.
|
||||||
|
@ -963,6 +963,7 @@ void TextWindow::Paint() {
|
||||||
// The line to indicate the column of radio buttons that indicates the
|
// The line to indicate the column of radio buttons that indicates the
|
||||||
// active group.
|
// active group.
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
|
auto const &gs = SS.GW.gs;
|
||||||
// Make sure this test agrees with test to determine which screen is drawn
|
// Make sure this test agrees with test to determine which screen is drawn
|
||||||
if(!SS.GW.pending.description && gs.n == 0 && gs.constraints == 0 &&
|
if(!SS.GW.pending.description && gs.n == 0 && gs.constraints == 0 &&
|
||||||
shown.screen == Screen::LIST_OF_GROUPS)
|
shown.screen == Screen::LIST_OF_GROUPS)
|
||||||
|
@ -1023,34 +1024,31 @@ void TextWindow::MouseEvent(bool leftClick, bool leftDown, double x, double y) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(r >= rows || c >= MAX_COLS) {
|
if(r < rows && c < MAX_COLS) {
|
||||||
SetMousePointerToHand(false);
|
SetMousePointerToHand(false);
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
hoveredRow = r;
|
hoveredRow = r;
|
||||||
hoveredCol = c;
|
hoveredCol = c;
|
||||||
|
|
||||||
#define META (meta[r][c])
|
const auto &item = meta[r][c];
|
||||||
if(leftClick) {
|
if(leftClick) {
|
||||||
if(META.link && META.f) {
|
if(item.link && item.f) {
|
||||||
(META.f)(META.link, META.data);
|
(item.f)(item.link, item.data);
|
||||||
Show();
|
Show();
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(META.link) {
|
if(item.link) {
|
||||||
SetMousePointerToHand(true);
|
SetMousePointerToHand(true);
|
||||||
if(META.h) {
|
if(item.h) {
|
||||||
(META.h)(META.link, META.data);
|
(item.h)(item.link, item.data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SetMousePointerToHand(false);
|
SetMousePointerToHand(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#undef META
|
}
|
||||||
|
|
||||||
done:
|
|
||||||
if((!ps.Equals(&(SS.GW.hover))) ||
|
if((!ps.Equals(&(SS.GW.hover))) ||
|
||||||
prevHoveredRow != hoveredRow ||
|
prevHoveredRow != hoveredRow ||
|
||||||
prevHoveredCol != hoveredCol)
|
prevHoveredCol != hoveredCol)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user