Rename some functions in Entity; those specific to a given type all

start with some prefix.

[git-p4: depot-paths = "//depot/solvespace/": change = 1674]
solver
Jonathan Westhues 2008-04-19 03:44:44 -08:00
parent cc03fe40aa
commit ed50632610
5 changed files with 27 additions and 27 deletions

View File

@ -19,8 +19,8 @@ void Constraint::DrawOrGetDistance(void) {
glxColor(1, 0.3, 1); glxColor(1, 0.3, 1);
switch(type) { switch(type) {
case PT_PT_DISTANCE: { case PT_PT_DISTANCE: {
Vector ap = SS.GetEntity(ptA)->GetPointCoords(); Vector ap = SS.GetEntity(ptA)->PointGetCoords();
Vector bp = SS.GetEntity(ptB)->GetPointCoords(); Vector bp = SS.GetEntity(ptB)->PointGetCoords();
Vector ref = ((ap.Plus(bp)).ScaledBy(0.5)).Plus(disp.offset); Vector ref = ((ap.Plus(bp)).ScaledBy(0.5)).Plus(disp.offset);

View File

@ -5,7 +5,7 @@ char *Entity::DescriptionString(void) {
return r->DescriptionString(); return r->DescriptionString();
} }
void Entity::Get2dCsysBasisVectors(Vector *u, Vector *v) { void Entity::Csys2dGetBasisVectors(Vector *u, Vector *v) {
double q[4]; double q[4];
for(int i = 0; i < 4; i++) { for(int i = 0; i < 4; i++) {
q[i] = SS.GetParam(param.h[i])->val; q[i] = SS.GetParam(param.h[i])->val;
@ -26,7 +26,7 @@ bool Entity::IsPoint(void) {
} }
} }
bool Entity::IsFromReferences(void) { bool Entity::PointIsFromReferences(void) {
hRequest hr = h.request(); hRequest hr = h.request();
if(hr.v == Request::HREQUEST_REFERENCE_XY.v) return true; if(hr.v == Request::HREQUEST_REFERENCE_XY.v) return true;
if(hr.v == Request::HREQUEST_REFERENCE_YZ.v) return true; if(hr.v == Request::HREQUEST_REFERENCE_YZ.v) return true;
@ -34,7 +34,7 @@ bool Entity::IsFromReferences(void) {
return false; return false;
} }
void Entity::ForcePointTo(Vector p) { void Entity::PointForceTo(Vector p) {
switch(type) { switch(type) {
case POINT_IN_3D: case POINT_IN_3D:
SS.GetParam(param.h[0])->ForceTo(p.x); SS.GetParam(param.h[0])->ForceTo(p.x);
@ -45,7 +45,7 @@ void Entity::ForcePointTo(Vector p) {
case POINT_IN_2D: { case POINT_IN_2D: {
Entity *c = SS.GetEntity(csys); Entity *c = SS.GetEntity(csys);
Vector u, v; Vector u, v;
c->Get2dCsysBasisVectors(&u, &v); c->Csys2dGetBasisVectors(&u, &v);
SS.GetParam(param.h[0])->ForceTo(p.Dot(u)); SS.GetParam(param.h[0])->ForceTo(p.Dot(u));
SS.GetParam(param.h[1])->ForceTo(p.Dot(v)); SS.GetParam(param.h[1])->ForceTo(p.Dot(v));
break; break;
@ -54,7 +54,7 @@ void Entity::ForcePointTo(Vector p) {
} }
} }
Vector Entity::GetPointCoords(void) { Vector Entity::PointGetCoords(void) {
Vector p; Vector p;
switch(type) { switch(type) {
case POINT_IN_3D: case POINT_IN_3D:
@ -66,7 +66,7 @@ Vector Entity::GetPointCoords(void) {
case POINT_IN_2D: { case POINT_IN_2D: {
Entity *c = SS.GetEntity(csys); Entity *c = SS.GetEntity(csys);
Vector u, v; Vector u, v;
c->Get2dCsysBasisVectors(&u, &v); c->Csys2dGetBasisVectors(&u, &v);
p = u.ScaledBy(SS.GetParam(param.h[0])->val); p = u.ScaledBy(SS.GetParam(param.h[0])->val);
p = p.Plus(v.ScaledBy(SS.GetParam(param.h[1])->val)); p = p.Plus(v.ScaledBy(SS.GetParam(param.h[1])->val));
break; break;
@ -115,7 +115,7 @@ void Entity::DrawOrGetDistance(void) {
Entity *isfor = SS.GetEntity(h.request().entity(0)); Entity *isfor = SS.GetEntity(h.request().entity(0));
if(!SS.GW.show2dCsyss && isfor->type == Entity::CSYS_2D) break; if(!SS.GW.show2dCsyss && isfor->type == Entity::CSYS_2D) break;
Vector v = GetPointCoords(); Vector v = PointGetCoords();
if(dogd.drawing) { if(dogd.drawing) {
double s = 4; double s = 4;
@ -140,10 +140,10 @@ void Entity::DrawOrGetDistance(void) {
if(!SS.GW.show2dCsyss) break; if(!SS.GW.show2dCsyss) break;
Vector p; Vector p;
p = SS.GetEntity(assoc[0])->GetPointCoords(); p = SS.GetEntity(assoc[0])->PointGetCoords();
Vector u, v; Vector u, v;
Get2dCsysBasisVectors(&u, &v); Csys2dGetBasisVectors(&u, &v);
double s = (min(SS.GW.width, SS.GW.height))*0.4/SS.GW.scale; double s = (min(SS.GW.width, SS.GW.height))*0.4/SS.GW.scale;
@ -172,8 +172,8 @@ void Entity::DrawOrGetDistance(void) {
} }
case LINE_SEGMENT: { case LINE_SEGMENT: {
Vector a = SS.GetEntity(assoc[0])->GetPointCoords(); Vector a = SS.GetEntity(assoc[0])->PointGetCoords();
Vector b = SS.GetEntity(assoc[1])->GetPointCoords(); Vector b = SS.GetEntity(assoc[1])->PointGetCoords();
LineDrawOrGetDistance(a, b); LineDrawOrGetDistance(a, b);
break; break;
} }

View File

@ -148,7 +148,7 @@ void GraphicsWindow::MenuView(int id) {
SS.GW.projRight, SS.GW.projUp); SS.GW.projRight, SS.GW.projUp);
// And with our final rotation // And with our final rotation
Vector pr, pu; Vector pr, pu;
e->Get2dCsysBasisVectors(&pr, &pu); e->Csys2dGetBasisVectors(&pr, &pu);
Quaternion quatf = Quaternion::MakeFrom(pr, pu); Quaternion quatf = Quaternion::MakeFrom(pr, pu);
// Make sure we take the shorter of the two possible paths. // Make sure we take the shorter of the two possible paths.
double mp = (quatf.Minus(quat0)).Magnitude(); double mp = (quatf.Minus(quat0)).Magnitude();
@ -160,7 +160,7 @@ void GraphicsWindow::MenuView(int id) {
// And also get the offsets. // And also get the offsets.
Vector offset0 = SS.GW.offset; Vector offset0 = SS.GW.offset;
Vector offsetf = SS.GetEntity(e->assoc[0])->GetPointCoords(); Vector offsetf = SS.GetEntity(e->assoc[0])->PointGetCoords();
// Animate transition, unless it's a tiny move. // Animate transition, unless it's a tiny move.
SDWORD dt = (mp < 0.01) ? (-20) : (SDWORD)(100 + 1000*mp); SDWORD dt = (mp < 0.01) ? (-20) : (SDWORD)(100 + 1000*mp);
@ -294,9 +294,9 @@ c:
void GraphicsWindow::UpdateDraggedEntity(hEntity hp, double mx, double my) { void GraphicsWindow::UpdateDraggedEntity(hEntity hp, double mx, double my) {
Entity *p = SS.GetEntity(hp); Entity *p = SS.GetEntity(hp);
Vector pos = p->GetPointCoords(); Vector pos = p->PointGetCoords();
UpdateDraggedPoint(&pos, mx, my); UpdateDraggedPoint(&pos, mx, my);
p->ForcePointTo(pos); p->PointForceTo(pos);
} }
void GraphicsWindow::UpdateDraggedPoint(Vector *pos, double mx, double my) { void GraphicsWindow::UpdateDraggedPoint(Vector *pos, double mx, double my) {
@ -353,7 +353,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
// constraint labels. // constraint labels.
if(hover.entity.v && if(hover.entity.v &&
SS.GetEntity(hover.entity)->IsPoint() && SS.GetEntity(hover.entity)->IsPoint() &&
!SS.GetEntity(hover.entity)->IsFromReferences()) !SS.GetEntity(hover.entity)->PointIsFromReferences())
{ {
ClearSelection(); ClearSelection();
UpdateDraggedEntity(hover.entity, x, y); UpdateDraggedEntity(hover.entity, x, y);
@ -488,17 +488,17 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
switch(pendingOperation) { switch(pendingOperation) {
case MNU_DATUM_POINT: case MNU_DATUM_POINT:
hr = AddRequest(Request::DATUM_POINT); hr = AddRequest(Request::DATUM_POINT);
SS.GetEntity(hr.entity(0))->ForcePointTo(v); SS.GetEntity(hr.entity(0))->PointForceTo(v);
pendingOperation = 0; pendingOperation = 0;
break; break;
case MNU_LINE_SEGMENT: case MNU_LINE_SEGMENT:
hr = AddRequest(Request::LINE_SEGMENT); hr = AddRequest(Request::LINE_SEGMENT);
SS.GetEntity(hr.entity(1))->ForcePointTo(v); SS.GetEntity(hr.entity(1))->PointForceTo(v);
pendingOperation = PENDING_OPERATION_DRAGGING_POINT; pendingOperation = PENDING_OPERATION_DRAGGING_POINT;
pendingPoint = hr.entity(2); pendingPoint = hr.entity(2);
pendingDescription = "click to place next point of line"; pendingDescription = "click to place next point of line";
SS.GetEntity(pendingPoint)->ForcePointTo(v); SS.GetEntity(pendingPoint)->PointForceTo(v);
break; break;
case PENDING_OPERATION_DRAGGING_POINT: case PENDING_OPERATION_DRAGGING_POINT:

View File

@ -115,14 +115,14 @@ public:
hEntity csys; // or Entity::NO_CSYS hEntity csys; // or Entity::NO_CSYS
// Applies only for a CSYS_2D type // Applies only for a CSYS_2D type
void Get2dCsysBasisVectors(Vector *u, Vector *v); void Csys2dGetBasisVectors(Vector *u, Vector *v);
bool IsPoint(void); bool IsPoint(void);
// Applies for any of the point types // Applies for any of the point types
void GetPointExprs(Expr **x, Expr **y, Expr **z); void PointGetExprs(Expr **x, Expr **y, Expr **z);
Vector GetPointCoords(void); Vector PointGetCoords(void);
void ForcePointTo(Vector v); void PointForceTo(Vector v);
bool IsFromReferences(void); bool PointIsFromReferences(void);
// Routines to draw and hit-test the representation of the entity // Routines to draw and hit-test the representation of the entity
// on-screen. // on-screen.

View File

@ -85,7 +85,7 @@ void SolveSpace::ForceReferences(void) {
hRequest hr = Quat[i].hr; hRequest hr = Quat[i].hr;
// The origin for our coordinate system, always zero // The origin for our coordinate system, always zero
Vector v = Vector::MakeFrom(0, 0, 0); Vector v = Vector::MakeFrom(0, 0, 0);
GetEntity(hr.entity(1))->ForcePointTo(v); GetEntity(hr.entity(1))->PointForceTo(v);
// The quaternion that defines the rotation, from the table. // The quaternion that defines the rotation, from the table.
GetParam(hr.param(0))->ForceTo(Quat[i].a); GetParam(hr.param(0))->ForceTo(Quat[i].a);
GetParam(hr.param(1))->ForceTo(Quat[i].b); GetParam(hr.param(1))->ForceTo(Quat[i].b);