stubs for relation constraint
parent
6bb6610eae
commit
1539229d3f
|
@ -309,7 +309,9 @@ if(ENABLE_GUI)
|
|||
"${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib")
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
find_package(OpenGL REQUIRED)
|
||||
#find_package(OpenGL REQUIRED)
|
||||
set(CMAKE_C_FLAGS "-framework OpenGL ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "-framework OpenGL ${CMAKE_CXX_FLAGS}")
|
||||
find_library(APPKIT_LIBRARY AppKit REQUIRED)
|
||||
elseif(EMSCRIPTEN)
|
||||
# Everything is built in
|
||||
|
|
|
@ -8,3 +8,5 @@ endif()
|
|||
if(EMSCRIPTEN)
|
||||
set(CMAKE_C_FLAGS_DEBUG_INIT "-g4")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG_INIT "-g")
|
||||
|
|
|
@ -8,3 +8,5 @@ endif()
|
|||
if(EMSCRIPTEN)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g4")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
|
||||
|
|
|
@ -48,6 +48,7 @@ std::string Constraint::DescriptionString() const {
|
|||
case Type::EQUAL_LINE_ARC_LEN: s = C_("constr-name", "eq-line-len-arc-len"); break;
|
||||
case Type::WHERE_DRAGGED: s = C_("constr-name", "lock-where-dragged"); break;
|
||||
case Type::COMMENT: s = C_("constr-name", "comment"); break;
|
||||
case Type::RELATION: s = C_("constr-name", "relation"); break;
|
||||
default: s = "???"; break;
|
||||
}
|
||||
|
||||
|
@ -889,6 +890,23 @@ void Constraint::MenuConstrain(Command id) {
|
|||
}
|
||||
break;
|
||||
|
||||
case Command::RELATION:
|
||||
if(gs.points == 1 && gs.n == 1) {
|
||||
c.type = Type::RELATION;
|
||||
c.ptA = gs.point[0];
|
||||
c.group = SS.GW.activeGroup;
|
||||
c.workplane = SS.GW.ActiveWorkplane();
|
||||
c.expression = _("x");
|
||||
AddConstraint(&c);
|
||||
newcons.push_back(c);
|
||||
} else {
|
||||
SS.GW.pending.operation = GraphicsWindow::Pending::COMMAND;
|
||||
SS.GW.pending.command = Command::RELATION;
|
||||
SS.GW.pending.description = _("click center of comment text");
|
||||
SS.ScheduleShowTW();
|
||||
}
|
||||
break;
|
||||
|
||||
default: ssassert(false, "Unexpected menu ID");
|
||||
}
|
||||
for (auto nc:newcons){
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright 2008-2013 Jonathan Westhues.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "solvespace.h"
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
const hConstraint ConstraintBase::NO_CONSTRAINT = { 0 };
|
||||
|
@ -26,6 +27,7 @@ bool ConstraintBase::HasLabel() const {
|
|||
case Type::ARC_LINE_DIFFERENCE:
|
||||
case Type::ANGLE:
|
||||
case Type::COMMENT:
|
||||
case Type::RELATION:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -61,6 +63,7 @@ bool ConstraintBase::IsProjectible() const {
|
|||
case Type::PERPENDICULAR:
|
||||
case Type::WHERE_DRAGGED:
|
||||
case Type::COMMENT:
|
||||
case Type::RELATION:
|
||||
return true;
|
||||
|
||||
case Type::PT_PLANE_DISTANCE:
|
||||
|
@ -1067,6 +1070,12 @@ void ConstraintBase::GenerateEquations(IdList<Equation,hEquation> *l,
|
|||
|
||||
case Type::COMMENT:
|
||||
return;
|
||||
|
||||
case Type::RELATION:
|
||||
std::fprintf(stderr, "adding relation with expr! %s", exA->Print().c_str());
|
||||
AddEq(l, exA, 0); //TODO
|
||||
return;
|
||||
|
||||
}
|
||||
ssassert(false, "Unexpected constraint ID");
|
||||
}
|
||||
|
|
|
@ -1293,6 +1293,7 @@ s:
|
|||
}
|
||||
return;
|
||||
|
||||
case Type::RELATION:
|
||||
case Type::COMMENT: {
|
||||
Vector u, v;
|
||||
if(workplane == Entity::FREE_IN_3D) {
|
||||
|
|
|
@ -1042,6 +1042,9 @@ bool ExprParser::Reduce(std::string *error) {
|
|||
bool ExprParser::Parse(std::string *error, size_t reduceUntil) {
|
||||
while(true) {
|
||||
Token* t = Lex(error);
|
||||
if(error != NULL && error->length() != 0) {
|
||||
printf("Error %s", error);
|
||||
}
|
||||
tokens.push_back(t);
|
||||
switch(t->type) {
|
||||
case TokenType::ERROR:
|
||||
|
|
|
@ -165,6 +165,7 @@ const MenuEntry Menu[] = {
|
|||
{ 1, N_("Lock Point Where &Dragged"), Command::WHERE_DRAGGED, ']', KN, mCon },
|
||||
{ 1, NULL, Command::NONE, 0, KN, NULL },
|
||||
{ 1, N_("Comment"), Command::COMMENT, ';', KN, mCon },
|
||||
{ 1, N_("Relation"), Command::RELATION, ':', KN, mCon },
|
||||
|
||||
{ 0, N_("&Analyze"), Command::NONE, 0, KN, mAna },
|
||||
{ 1, N_("Measure &Volume"), Command::VOLUME, C|S|'v', KN, mAna },
|
||||
|
|
|
@ -1162,6 +1162,19 @@ void GraphicsWindow::MouseLeftDown(double mx, double my, bool shiftDown, bool ct
|
|||
hc = Constraint::AddConstraint(&c);
|
||||
break;
|
||||
}
|
||||
|
||||
case Command::RELATION: {
|
||||
//TODO
|
||||
ClearSuper();
|
||||
Constraint c = {};
|
||||
c.group = SS.GW.activeGroup;
|
||||
c.workplane = SS.GW.ActiveWorkplane();
|
||||
c.type = Constraint::Type::RELATION;
|
||||
c.disp.offset = v;
|
||||
c.expression = _("x");
|
||||
hc = Constraint::AddConstraint(&c);
|
||||
break;
|
||||
}
|
||||
default: ssassert(false, "Unexpected pending menu id");
|
||||
}
|
||||
break;
|
||||
|
@ -1492,6 +1505,7 @@ void GraphicsWindow::EditControlDone(const std::string &s) {
|
|||
break;
|
||||
}
|
||||
case Constraint::Type::ANGLE:
|
||||
case Constraint::Type::RELATION:
|
||||
case Constraint::Type::LENGTH_RATIO:
|
||||
case Constraint::Type::ARC_ARC_LEN_RATIO:
|
||||
case Constraint::Type::ARC_LINE_LEN_RATIO:
|
||||
|
@ -1511,7 +1525,7 @@ void GraphicsWindow::EditControlDone(const std::string &s) {
|
|||
|
||||
default:
|
||||
// These are always positive, and they get the units conversion.
|
||||
// Use ExprToMm since this unparameterized expressions simplify down
|
||||
// Use ExprToMm since this unparameterized expressions simplify down
|
||||
c->valA = fabs(SS.ExprToMm(e));
|
||||
break;
|
||||
}
|
||||
|
|
10
src/sketch.h
10
src/sketch.h
|
@ -689,7 +689,9 @@ public:
|
|||
ARC_LINE_LEN_RATIO = 211,
|
||||
ARC_ARC_DIFFERENCE = 212,
|
||||
ARC_LINE_DIFFERENCE = 213,
|
||||
COMMENT = 1000
|
||||
COMMENT = 1000,
|
||||
//like COMMENT, but its contents are an equation (in particular, a relation).
|
||||
RELATION = 1001
|
||||
};
|
||||
|
||||
Type type;
|
||||
|
@ -709,9 +711,9 @@ public:
|
|||
bool other;
|
||||
bool other2;
|
||||
|
||||
bool reference; // a ref dimension, that generates no eqs
|
||||
std::string comment; // since comments are represented as constraints
|
||||
std::string expression; // user-defined, may not be in mm (if entered in inch mode for example)
|
||||
bool reference; // a ref dimension, that generates no eqs
|
||||
std::string comment; // since comments are represented as constraints
|
||||
std::string expression; // user-defined, may not be in mm (if entered in inch mode for example)
|
||||
double expr_scaling_to_base; // scales expression to put in solvespace base units (like mm for distance).
|
||||
|
||||
bool Equals(const ConstraintBase &c) const {
|
||||
|
|
Loading…
Reference in New Issue