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
parent
cc03fe40aa
commit
ed50632610
|
@ -19,8 +19,8 @@ void Constraint::DrawOrGetDistance(void) {
|
|||
glxColor(1, 0.3, 1);
|
||||
switch(type) {
|
||||
case PT_PT_DISTANCE: {
|
||||
Vector ap = SS.GetEntity(ptA)->GetPointCoords();
|
||||
Vector bp = SS.GetEntity(ptB)->GetPointCoords();
|
||||
Vector ap = SS.GetEntity(ptA)->PointGetCoords();
|
||||
Vector bp = SS.GetEntity(ptB)->PointGetCoords();
|
||||
|
||||
Vector ref = ((ap.Plus(bp)).ScaledBy(0.5)).Plus(disp.offset);
|
||||
|
||||
|
|
22
entity.cpp
22
entity.cpp
|
@ -5,7 +5,7 @@ char *Entity::DescriptionString(void) {
|
|||
return r->DescriptionString();
|
||||
}
|
||||
|
||||
void Entity::Get2dCsysBasisVectors(Vector *u, Vector *v) {
|
||||
void Entity::Csys2dGetBasisVectors(Vector *u, Vector *v) {
|
||||
double q[4];
|
||||
for(int i = 0; i < 4; i++) {
|
||||
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();
|
||||
if(hr.v == Request::HREQUEST_REFERENCE_XY.v) return true;
|
||||
if(hr.v == Request::HREQUEST_REFERENCE_YZ.v) return true;
|
||||
|
@ -34,7 +34,7 @@ bool Entity::IsFromReferences(void) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void Entity::ForcePointTo(Vector p) {
|
||||
void Entity::PointForceTo(Vector p) {
|
||||
switch(type) {
|
||||
case POINT_IN_3D:
|
||||
SS.GetParam(param.h[0])->ForceTo(p.x);
|
||||
|
@ -45,7 +45,7 @@ void Entity::ForcePointTo(Vector p) {
|
|||
case POINT_IN_2D: {
|
||||
Entity *c = SS.GetEntity(csys);
|
||||
Vector u, v;
|
||||
c->Get2dCsysBasisVectors(&u, &v);
|
||||
c->Csys2dGetBasisVectors(&u, &v);
|
||||
SS.GetParam(param.h[0])->ForceTo(p.Dot(u));
|
||||
SS.GetParam(param.h[1])->ForceTo(p.Dot(v));
|
||||
break;
|
||||
|
@ -54,7 +54,7 @@ void Entity::ForcePointTo(Vector p) {
|
|||
}
|
||||
}
|
||||
|
||||
Vector Entity::GetPointCoords(void) {
|
||||
Vector Entity::PointGetCoords(void) {
|
||||
Vector p;
|
||||
switch(type) {
|
||||
case POINT_IN_3D:
|
||||
|
@ -66,7 +66,7 @@ Vector Entity::GetPointCoords(void) {
|
|||
case POINT_IN_2D: {
|
||||
Entity *c = SS.GetEntity(csys);
|
||||
Vector u, v;
|
||||
c->Get2dCsysBasisVectors(&u, &v);
|
||||
c->Csys2dGetBasisVectors(&u, &v);
|
||||
p = u.ScaledBy(SS.GetParam(param.h[0])->val);
|
||||
p = p.Plus(v.ScaledBy(SS.GetParam(param.h[1])->val));
|
||||
break;
|
||||
|
@ -115,7 +115,7 @@ void Entity::DrawOrGetDistance(void) {
|
|||
Entity *isfor = SS.GetEntity(h.request().entity(0));
|
||||
if(!SS.GW.show2dCsyss && isfor->type == Entity::CSYS_2D) break;
|
||||
|
||||
Vector v = GetPointCoords();
|
||||
Vector v = PointGetCoords();
|
||||
|
||||
if(dogd.drawing) {
|
||||
double s = 4;
|
||||
|
@ -140,10 +140,10 @@ void Entity::DrawOrGetDistance(void) {
|
|||
if(!SS.GW.show2dCsyss) break;
|
||||
|
||||
Vector p;
|
||||
p = SS.GetEntity(assoc[0])->GetPointCoords();
|
||||
p = SS.GetEntity(assoc[0])->PointGetCoords();
|
||||
|
||||
Vector u, v;
|
||||
Get2dCsysBasisVectors(&u, &v);
|
||||
Csys2dGetBasisVectors(&u, &v);
|
||||
|
||||
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: {
|
||||
Vector a = SS.GetEntity(assoc[0])->GetPointCoords();
|
||||
Vector b = SS.GetEntity(assoc[1])->GetPointCoords();
|
||||
Vector a = SS.GetEntity(assoc[0])->PointGetCoords();
|
||||
Vector b = SS.GetEntity(assoc[1])->PointGetCoords();
|
||||
LineDrawOrGetDistance(a, b);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ void GraphicsWindow::MenuView(int id) {
|
|||
SS.GW.projRight, SS.GW.projUp);
|
||||
// And with our final rotation
|
||||
Vector pr, pu;
|
||||
e->Get2dCsysBasisVectors(&pr, &pu);
|
||||
e->Csys2dGetBasisVectors(&pr, &pu);
|
||||
Quaternion quatf = Quaternion::MakeFrom(pr, pu);
|
||||
// Make sure we take the shorter of the two possible paths.
|
||||
double mp = (quatf.Minus(quat0)).Magnitude();
|
||||
|
@ -160,7 +160,7 @@ void GraphicsWindow::MenuView(int id) {
|
|||
|
||||
// And also get the offsets.
|
||||
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.
|
||||
SDWORD dt = (mp < 0.01) ? (-20) : (SDWORD)(100 + 1000*mp);
|
||||
|
@ -294,9 +294,9 @@ c:
|
|||
|
||||
void GraphicsWindow::UpdateDraggedEntity(hEntity hp, double mx, double my) {
|
||||
Entity *p = SS.GetEntity(hp);
|
||||
Vector pos = p->GetPointCoords();
|
||||
Vector pos = p->PointGetCoords();
|
||||
UpdateDraggedPoint(&pos, mx, my);
|
||||
p->ForcePointTo(pos);
|
||||
p->PointForceTo(pos);
|
||||
}
|
||||
|
||||
void GraphicsWindow::UpdateDraggedPoint(Vector *pos, double mx, double my) {
|
||||
|
@ -353,7 +353,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
|
|||
// constraint labels.
|
||||
if(hover.entity.v &&
|
||||
SS.GetEntity(hover.entity)->IsPoint() &&
|
||||
!SS.GetEntity(hover.entity)->IsFromReferences())
|
||||
!SS.GetEntity(hover.entity)->PointIsFromReferences())
|
||||
{
|
||||
ClearSelection();
|
||||
UpdateDraggedEntity(hover.entity, x, y);
|
||||
|
@ -488,17 +488,17 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
|
|||
switch(pendingOperation) {
|
||||
case MNU_DATUM_POINT:
|
||||
hr = AddRequest(Request::DATUM_POINT);
|
||||
SS.GetEntity(hr.entity(0))->ForcePointTo(v);
|
||||
SS.GetEntity(hr.entity(0))->PointForceTo(v);
|
||||
pendingOperation = 0;
|
||||
break;
|
||||
|
||||
case MNU_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;
|
||||
pendingPoint = hr.entity(2);
|
||||
pendingDescription = "click to place next point of line";
|
||||
SS.GetEntity(pendingPoint)->ForcePointTo(v);
|
||||
SS.GetEntity(pendingPoint)->PointForceTo(v);
|
||||
break;
|
||||
|
||||
case PENDING_OPERATION_DRAGGING_POINT:
|
||||
|
|
10
sketch.h
10
sketch.h
|
@ -115,14 +115,14 @@ public:
|
|||
hEntity csys; // or Entity::NO_CSYS
|
||||
|
||||
// Applies only for a CSYS_2D type
|
||||
void Get2dCsysBasisVectors(Vector *u, Vector *v);
|
||||
void Csys2dGetBasisVectors(Vector *u, Vector *v);
|
||||
|
||||
bool IsPoint(void);
|
||||
// Applies for any of the point types
|
||||
void GetPointExprs(Expr **x, Expr **y, Expr **z);
|
||||
Vector GetPointCoords(void);
|
||||
void ForcePointTo(Vector v);
|
||||
bool IsFromReferences(void);
|
||||
void PointGetExprs(Expr **x, Expr **y, Expr **z);
|
||||
Vector PointGetCoords(void);
|
||||
void PointForceTo(Vector v);
|
||||
bool PointIsFromReferences(void);
|
||||
|
||||
// Routines to draw and hit-test the representation of the entity
|
||||
// on-screen.
|
||||
|
|
|
@ -85,7 +85,7 @@ void SolveSpace::ForceReferences(void) {
|
|||
hRequest hr = Quat[i].hr;
|
||||
// The origin for our coordinate system, always zero
|
||||
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.
|
||||
GetParam(hr.param(0))->ForceTo(Quat[i].a);
|
||||
GetParam(hr.param(1))->ForceTo(Quat[i].b);
|
||||
|
|
Loading…
Reference in New Issue