Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5137e03c
Commit
5137e03c
authored
Jun 24, 2015
by
Chinmay Garde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for updating edits
parent
8187c685
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
8 deletions
+44
-8
solver.dart
packages/cassowary/lib/solver.dart
+44
-8
No files found.
packages/cassowary/lib/solver.dart
View file @
5137e03c
...
@@ -82,20 +82,52 @@ class Solver {
...
@@ -82,20 +82,52 @@ class Solver {
return
_optimizeObjectiveRow
(
_objective
);
return
_optimizeObjectiveRow
(
_objective
);
}
}
Result
hasConstraint
(
Constraint
c
)
{
bool
hasConstraint
(
Constraint
constraint
)
{
return
Result
.
unimplemented
;
return
_constraints
.
containsKey
(
constraint
)
;
}
}
Result
addEditVariable
(
Variable
v
,
double
priority
)
{
Result
addEditVariable
(
Variable
variable
,
double
priority
)
{
return
Result
.
unimplemented
;
if
(
_edits
.
containsKey
(
variable
))
{
return
Result
.
duplicateEditVariable
;
}
}
Result
removeEditVariable
(
Variable
v
)
{
if
(!
_isValidNonRequiredPriority
(
priority
)
)
{
return
Result
.
unimplemented
;
return
Result
.
badRequiredStrength
;
}
}
Result
hasEditVariable
(
Variable
v
)
{
Constraint
constraint
=
new
Constraint
(
return
Result
.
unimplemented
;
new
Expression
([
new
Term
(
variable
,
1.0
)],
0.0
),
Relation
.
equalTo
);
if
(
addConstraint
(
constraint
)
!=
Result
.
success
)
{
return
Result
.
internalSolverError
;
}
EditInfo
info
=
new
EditInfo
();
info
.
tag
=
_constraints
[
constraint
];
info
.
constraint
=
constraint
;
info
.
constant
=
0.0
;
_edits
[
variable
]
=
info
;
return
Result
.
success
;
}
Result
removeEditVariable
(
Variable
variable
)
{
EditInfo
info
=
_edits
[
variable
];
if
(
info
==
null
)
{
return
Result
.
unknownEditVariable
;
}
if
(
removeConstraint
(
info
.
constraint
)
!=
Result
.
success
)
{
return
Result
.
internalSolverError
;
}
_edits
.
remove
(
variable
);
return
Result
.
success
;
}
bool
hasEditVariable
(
Variable
variable
)
{
return
_edits
.
containsKey
(
variable
);
}
}
Result
suggestVariable
(
Variable
v
,
double
value
)
{
Result
suggestVariable
(
Variable
v
,
double
value
)
{
...
@@ -411,3 +443,7 @@ class EditInfo {
...
@@ -411,3 +443,7 @@ class EditInfo {
Constraint
constraint
;
Constraint
constraint
;
double
constant
;
double
constant
;
}
}
bool
_isValidNonRequiredPriority
(
double
priority
)
{
return
(
priority
>=
0.0
&&
priority
<
Constraint
.
requiredPriority
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment