2013-07-28 22:08:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Implementation of our Request class; a request is a user-created thing
|
|
|
|
// that will generate an entity (line, curve) when the sketch is generated,
|
|
|
|
// in the same way that other entities are generated automatically, like
|
|
|
|
// by an extrude or a step and repeat.
|
|
|
|
//
|
|
|
|
// Copyright 2008-2013 Jonathan Westhues.
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-06-06 08:14:37 +00:00
|
|
|
#include "solvespace.h"
|
|
|
|
|
|
|
|
const hRequest Request::HREQUEST_REFERENCE_XY = { 1 };
|
|
|
|
const hRequest Request::HREQUEST_REFERENCE_YZ = { 2 };
|
|
|
|
const hRequest Request::HREQUEST_REFERENCE_ZX = { 3 };
|
|
|
|
|
2009-10-22 14:02:08 +00:00
|
|
|
const EntReqTable::TableEntry EntReqTable::Table[] = {
|
|
|
|
// request type entity type pts xtra? norml dist description
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
{ Request::Type::WORKPLANE, Entity::Type::WORKPLANE, 1, false, true, false, "workplane" },
|
|
|
|
{ Request::Type::DATUM_POINT, Entity::Type::DATUM_POINT, 1, false, false, false, "datum-point" },
|
|
|
|
{ Request::Type::LINE_SEGMENT, Entity::Type::LINE_SEGMENT, 2, false, false, false, "line-segment" },
|
|
|
|
{ Request::Type::CUBIC, Entity::Type::CUBIC, 4, true, false, false, "cubic-bezier" },
|
|
|
|
{ Request::Type::CUBIC_PERIODIC, Entity::Type::CUBIC_PERIODIC, 3, true, false, false, "periodic-cubic" },
|
|
|
|
{ Request::Type::CIRCLE, Entity::Type::CIRCLE, 1, false, true, true, "circle" },
|
|
|
|
{ Request::Type::ARC_OF_CIRCLE, Entity::Type::ARC_OF_CIRCLE, 3, false, true, false, "arc-of-circle" },
|
|
|
|
{ Request::Type::TTF_TEXT, Entity::Type::TTF_TEXT, 2, false, true, false, "ttf-text" },
|
|
|
|
{ Request::Type::UNKNOWN, Entity::Type::UNKNOWN, 0, false, false, false, NULL },
|
2009-10-22 14:02:08 +00:00
|
|
|
};
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
const char *EntReqTable::DescriptionForRequest(Request::Type req) {
|
|
|
|
for(int i = 0; Table[i].reqType != Request::Type::UNKNOWN; i++) {
|
2009-10-22 14:02:08 +00:00
|
|
|
if(req == Table[i].reqType) {
|
|
|
|
return Table[i].description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
|
|
|
|
void EntReqTable::CopyEntityInfo(const TableEntry *te, int extraPoints,
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
Entity::Type *ent, Request::Type *req, int *pts, bool *hasNormal, bool *hasDistance)
|
2009-10-22 14:02:08 +00:00
|
|
|
{
|
|
|
|
int points = te->points;
|
|
|
|
if(te->useExtraPoints) points += extraPoints;
|
|
|
|
|
|
|
|
if(ent) *ent = te->entType;
|
|
|
|
if(req) *req = te->reqType;
|
|
|
|
if(pts) *pts = points;
|
|
|
|
if(hasNormal) *hasNormal = te->hasNormal;
|
|
|
|
if(hasDistance) *hasDistance = te->hasDistance;
|
|
|
|
}
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
bool EntReqTable::GetRequestInfo(Request::Type req, int extraPoints,
|
|
|
|
Entity::Type *ent, int *pts, bool *hasNormal, bool *hasDistance)
|
2009-10-22 14:02:08 +00:00
|
|
|
{
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
for(int i = 0; Table[i].reqType != Request::Type::UNKNOWN; i++) {
|
2009-10-22 14:02:08 +00:00
|
|
|
const TableEntry *te = &(Table[i]);
|
|
|
|
if(req == te->reqType) {
|
|
|
|
CopyEntityInfo(te, extraPoints,
|
|
|
|
ent, NULL, pts, hasNormal, hasDistance);
|
2009-12-04 08:08:41 +00:00
|
|
|
return true;
|
2009-10-22 14:02:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-04 08:08:41 +00:00
|
|
|
return false;
|
2009-10-22 14:02:08 +00:00
|
|
|
}
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
bool EntReqTable::GetEntityInfo(Entity::Type ent, int extraPoints,
|
|
|
|
Request::Type *req, int *pts, bool *hasNormal, bool *hasDistance)
|
2009-10-22 14:02:08 +00:00
|
|
|
{
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
for(int i = 0; Table[i].reqType != Request::Type::UNKNOWN; i++) {
|
2009-10-22 14:02:08 +00:00
|
|
|
const TableEntry *te = &(Table[i]);
|
|
|
|
if(ent == te->entType) {
|
|
|
|
CopyEntityInfo(te, extraPoints,
|
|
|
|
NULL, req, pts, hasNormal, hasDistance);
|
2009-12-04 08:08:41 +00:00
|
|
|
return true;
|
2009-10-22 14:02:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-04 08:08:41 +00:00
|
|
|
return false;
|
2009-10-22 14:02:08 +00:00
|
|
|
}
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
Request::Type EntReqTable::GetRequestForEntity(Entity::Type ent) {
|
|
|
|
Request::Type req = Request::Type::UNKNOWN;
|
2009-10-22 14:02:08 +00:00
|
|
|
GetEntityInfo(ent, 0, &req, NULL, NULL, NULL);
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
2008-06-06 08:14:37 +00:00
|
|
|
|
|
|
|
void Request::Generate(IdList<Entity,hEntity> *entity,
|
2016-05-21 05:18:00 +00:00
|
|
|
IdList<Param,hParam> *param) const
|
2008-06-06 08:14:37 +00:00
|
|
|
{
|
|
|
|
int points = 0;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
Entity::Type et = Entity::Type::UNKNOWN;
|
2008-06-06 08:14:37 +00:00
|
|
|
bool hasNormal = false;
|
|
|
|
bool hasDistance = false;
|
|
|
|
int i;
|
|
|
|
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity e = {};
|
2009-10-22 14:02:08 +00:00
|
|
|
EntReqTable::GetRequestInfo(type, extraPoints,
|
|
|
|
&et, &points, &hasNormal, &hasDistance);
|
2008-06-06 08:14:37 +00:00
|
|
|
|
|
|
|
// Generate the entity that's specific to this request.
|
|
|
|
e.type = et;
|
2009-10-21 04:46:01 +00:00
|
|
|
e.extraPoints = extraPoints;
|
2008-06-06 08:14:37 +00:00
|
|
|
e.group = group;
|
2009-09-18 08:14:15 +00:00
|
|
|
e.style = style;
|
2008-06-06 08:14:37 +00:00
|
|
|
e.workplane = workplane;
|
|
|
|
e.construction = construction;
|
2015-11-06 08:40:12 +00:00
|
|
|
e.str = str;
|
|
|
|
e.font = font;
|
2008-06-06 08:14:37 +00:00
|
|
|
e.h = h.entity(0);
|
|
|
|
|
|
|
|
// And generate entities for the points
|
|
|
|
for(i = 0; i < points; i++) {
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity p = {};
|
2008-06-06 08:14:37 +00:00
|
|
|
p.workplane = workplane;
|
|
|
|
// points start from entity 1, except for datum point case
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
p.h = h.entity(i+((et != Entity::Type::DATUM_POINT) ? 1 : 0));
|
2008-06-06 08:14:37 +00:00
|
|
|
p.group = group;
|
2009-09-18 08:14:15 +00:00
|
|
|
p.style = style;
|
2008-06-06 08:14:37 +00:00
|
|
|
|
|
|
|
if(workplane.v == Entity::FREE_IN_3D.v) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
p.type = Entity::Type::POINT_IN_3D;
|
2008-06-06 08:14:37 +00:00
|
|
|
// params for x y z
|
|
|
|
p.param[0] = AddParam(param, h.param(16 + 3*i + 0));
|
|
|
|
p.param[1] = AddParam(param, h.param(16 + 3*i + 1));
|
|
|
|
p.param[2] = AddParam(param, h.param(16 + 3*i + 2));
|
|
|
|
} else {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
p.type = Entity::Type::POINT_IN_2D;
|
2008-06-06 08:14:37 +00:00
|
|
|
// params for u v
|
|
|
|
p.param[0] = AddParam(param, h.param(16 + 3*i + 0));
|
|
|
|
p.param[1] = AddParam(param, h.param(16 + 3*i + 1));
|
|
|
|
}
|
|
|
|
entity->Add(&p);
|
|
|
|
e.point[i] = p.h;
|
|
|
|
}
|
|
|
|
if(hasNormal) {
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity n = {};
|
2008-06-06 08:14:37 +00:00
|
|
|
n.workplane = workplane;
|
|
|
|
n.h = h.entity(32);
|
|
|
|
n.group = group;
|
2009-09-18 08:14:15 +00:00
|
|
|
n.style = style;
|
2008-06-06 08:14:37 +00:00
|
|
|
if(workplane.v == Entity::FREE_IN_3D.v) {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
n.type = Entity::Type::NORMAL_IN_3D;
|
2008-06-06 08:14:37 +00:00
|
|
|
n.param[0] = AddParam(param, h.param(32+0));
|
|
|
|
n.param[1] = AddParam(param, h.param(32+1));
|
|
|
|
n.param[2] = AddParam(param, h.param(32+2));
|
|
|
|
n.param[3] = AddParam(param, h.param(32+3));
|
|
|
|
} else {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
n.type = Entity::Type::NORMAL_IN_2D;
|
2008-06-06 08:14:37 +00:00
|
|
|
// and this is just a copy of the workplane quaternion,
|
|
|
|
// so no params required
|
|
|
|
}
|
2016-05-18 22:51:36 +00:00
|
|
|
ssassert(points >= 1, "Positioning a normal requires a point");
|
2008-06-06 08:14:37 +00:00
|
|
|
// The point determines where the normal gets displayed on-screen;
|
|
|
|
// it's entirely cosmetic.
|
|
|
|
n.point[0] = e.point[0];
|
|
|
|
entity->Add(&n);
|
|
|
|
e.normal = n.h;
|
|
|
|
}
|
|
|
|
if(hasDistance) {
|
2015-03-27 15:31:23 +00:00
|
|
|
Entity d = {};
|
2008-06-06 08:14:37 +00:00
|
|
|
d.workplane = workplane;
|
|
|
|
d.h = h.entity(64);
|
|
|
|
d.group = group;
|
2009-09-18 08:14:15 +00:00
|
|
|
d.style = style;
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
d.type = Entity::Type::DISTANCE;
|
2008-06-06 08:14:37 +00:00
|
|
|
d.param[0] = AddParam(param, h.param(64));
|
|
|
|
entity->Add(&d);
|
|
|
|
e.distance = d.h;
|
|
|
|
}
|
|
|
|
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(et != Entity::Type::DATUM_POINT) entity->Add(&e);
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
|
|
|
|
2016-05-21 05:18:00 +00:00
|
|
|
std::string Request::DescriptionString() const {
|
2013-08-26 18:58:35 +00:00
|
|
|
const char *s;
|
2008-06-06 08:14:37 +00:00
|
|
|
if(h.v == Request::HREQUEST_REFERENCE_XY.v) {
|
|
|
|
s = "#XY";
|
|
|
|
} else if(h.v == Request::HREQUEST_REFERENCE_YZ.v) {
|
|
|
|
s = "#YZ";
|
|
|
|
} else if(h.v == Request::HREQUEST_REFERENCE_ZX.v) {
|
|
|
|
s = "#ZX";
|
|
|
|
} else {
|
2009-10-22 14:02:08 +00:00
|
|
|
s = EntReqTable::DescriptionForRequest(type);
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
2015-11-06 08:40:12 +00:00
|
|
|
|
|
|
|
return ssprintf("r%03x-%s", h.v, s);
|
2008-06-06 08:14:37 +00:00
|
|
|
}
|
|
|
|
|
2016-05-21 05:18:00 +00:00
|
|
|
int Request::IndexOfPoint(hEntity he) const {
|
Convert all enumerations to use `enum class`.
Specifically, take the old code that looks like this:
class Foo {
enum { X = 1, Y = 2 };
int kind;
}
... foo.kind = Foo::X; ...
and convert it to this:
class Foo {
enum class Kind : uint32_t { X = 1, Y = 2 };
Kind kind;
}
... foo.kind = Foo::Kind::X;
(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)
The benefits are as follows:
* The type of the field gives a clear indication of intent, both
to humans and tools (such as binding generators).
* The compiler is able to automatically warn when a switch is not
exhaustive; but this is currently suppressed by the
default: ssassert(false, ...)
idiom.
* Integers and plain enums are weakly type checked: they implicitly
convert into each other. This can hide bugs where type conversion
is performed but not intended. Enum classes are strongly type
checked.
* Plain enums pollute parent namespaces; enum classes do not.
Almost every defined enum we have already has a kind of ad-hoc
namespacing via `NAMESPACE_`, which is now explicit.
* Plain enums do not have a well-defined ABI size, which is
important for bindings. Enum classes can have it, if specified.
We specify the base type for all enums as uint32_t, which is
a safe choice and allows us to not change the numeric values
of any variants.
This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-20 08:31:20 +00:00
|
|
|
if(type == Type::DATUM_POINT) {
|
2016-04-07 14:44:56 +00:00
|
|
|
return (he.v == h.entity(0).v) ? 0 : -1;
|
|
|
|
}
|
|
|
|
for(int i = 0; i < MAX_POINTS_IN_ENTITY; i++) {
|
|
|
|
if(he.v == h.entity(i + 1).v) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-06-06 08:14:37 +00:00
|
|
|
hParam Request::AddParam(IdList<Param,hParam> *param, hParam hp) {
|
2015-03-27 15:31:23 +00:00
|
|
|
Param pa = {};
|
2008-06-06 08:14:37 +00:00
|
|
|
pa.h = hp;
|
|
|
|
param->Add(&pa);
|
|
|
|
return hp;
|
|
|
|
}
|
|
|
|
|