Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
491d0a6e
Commit
491d0a6e
authored
12 years ago
by
Francois Henrotte
Browse files
Options
Downloads
Patches
Plain Diff
python+onelab
parent
ac6ca95b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Common/onelabUtils.cpp
+101
-1
101 additions, 1 deletion
Common/onelabUtils.cpp
Common/onelabUtils.h
+3
-0
3 additions, 0 deletions
Common/onelabUtils.h
with
104 additions
and
1 deletion
Common/onelabUtils.cpp
+
101
−
1
View file @
491d0a6e
...
@@ -352,6 +352,106 @@ namespace onelabUtils {
...
@@ -352,6 +352,106 @@ namespace onelabUtils {
return
redraw
;
return
redraw
;
}
}
}
// x is the parameter as on server
// y is the argument of set
// The routine updates x on basis of y.
// If the parameter is not yet defined, set(y) as is
// If the parameter is already defined, priority must be given to the server state
// for all items editable from the GUI, i.e. value, range, Loop, Graph, Closed.
// If y.getReadOnly() is true, the value of y overrides that of x
double
updateNumber
(
onelab
::
number
&
x
,
onelab
::
number
&
y
,
const
bool
readOnlyRange
)
{
bool
noRange
=
true
,
noChoices
=
true
,
noLoop
=
true
;
bool
noGraph
=
true
,
noClosed
=
true
;
if
(
y
.
getReadOnly
()){
x
.
setValue
(
y
.
getValue
());
// use set value
x
.
setReadOnly
(
1
);
// makes the field "value" non-editable in the GUI
}
double
val
=
x
.
getValue
();
// keep track of these attributes, which can be changed server-side (unless,
// for the range/choices, when explicitely setting these attributes as
// ReadOnly)
if
(
!
readOnlyRange
){
if
(
x
.
getMin
()
!=
-
onelab
::
parameter
::
maxNumber
()
||
x
.
getMax
()
!=
onelab
::
parameter
::
maxNumber
()
||
x
.
getStep
()
!=
0.
)
noRange
=
false
;
if
(
x
.
getChoices
().
size
())
noChoices
=
false
;
}
if
(
x
.
getAttribute
(
"Loop"
).
size
())
noLoop
=
false
;
if
(
x
.
getAttribute
(
"Graph"
).
size
())
noGraph
=
false
;
if
(
x
.
getAttribute
(
"Closed"
).
size
())
noClosed
=
false
;
// send updated parameter to server
if
(
noRange
){
bool
noRangeEither
=
true
;
if
(
y
.
getMin
()
!=
-
onelab
::
parameter
::
maxNumber
()
||
y
.
getMax
()
!=
onelab
::
parameter
::
maxNumber
()
||
y
.
getStep
()
!=
0.
)
noRangeEither
=
false
;
if
(
!
noRangeEither
){
x
.
setMin
(
y
.
getMin
());
x
.
setMax
(
y
.
getMax
());
}
else
{
// if no range/min/max/step info is provided, try to compute a reasonnable
// range and step (this makes the gui much nicer to use)
bool
isInteger
=
(
floor
(
val
)
==
val
);
double
fact
=
isInteger
?
5.
:
20.
;
if
(
val
>
0
){
x
.
setMin
(
val
/
fact
);
x
.
setMax
(
val
*
fact
);
x
.
setStep
((
x
.
getMax
()
-
x
.
getMin
())
/
100.
);
}
else
if
(
val
<
0
){
x
.
setMin
(
val
*
fact
);
x
.
setMax
(
val
/
fact
);
x
.
setStep
((
x
.
getMax
()
-
x
.
getMin
())
/
100.
);
}
if
(
val
&&
isInteger
){
x
.
setMin
((
int
)
x
.
getMin
());
x
.
setMax
((
int
)
x
.
getMax
());
x
.
setStep
((
int
)
x
.
getStep
());
}
}
}
if
(
noChoices
)
{
x
.
setChoices
(
y
.
getChoices
());
x
.
setValueLabels
(
y
.
getValueLabels
());
}
if
(
noLoop
)
x
.
setAttribute
(
"Loop"
,
y
.
getAttribute
(
"Loop"
));
if
(
noGraph
)
x
.
setAttribute
(
"Graph"
,
y
.
getAttribute
(
"Graph"
));
if
(
noClosed
)
x
.
setAttribute
(
"Closed"
,
y
.
getAttribute
(
"Closed"
));
return
val
;
}
std
::
string
updateString
(
onelab
::
string
&
x
,
onelab
::
string
&
y
)
{
bool
noChoices
=
true
,
noClosed
=
true
,
noMultipleSelection
=
true
;
if
(
y
.
getReadOnly
()){
x
.
setValue
(
y
.
getValue
());
// use set value
x
.
setReadOnly
(
1
);
// makes the field "value" non-editable in the GUI
}
std
::
string
val
=
x
.
getValue
();
// keep track of these attributes, which can be changed server-side
if
(
x
.
getChoices
().
size
())
noChoices
=
false
;
if
(
x
.
getAttribute
(
"Closed"
).
size
())
noClosed
=
false
;
if
(
x
.
getAttribute
(
"MultipleSelection"
).
size
())
noMultipleSelection
=
false
;
//if(copt.count("Kind")) ps[0].setKind(copt["Kind"][0]);
if
(
noChoices
)
x
.
setChoices
(
y
.
getChoices
());
if
(
noClosed
)
x
.
setAttribute
(
"Closed"
,
y
.
getAttribute
(
"Closed"
));
if
(
noMultipleSelection
)
x
.
setAttribute
(
"MultipleSelection"
,
y
.
getAttribute
(
"MultipleSelection"
));
return
val
;
}
}
#endif
#endif
This diff is collapsed.
Click to expand it.
Common/onelabUtils.h
+
3
−
0
View file @
491d0a6e
...
@@ -22,6 +22,9 @@ namespace onelabUtils {
...
@@ -22,6 +22,9 @@ namespace onelabUtils {
bool
runGmshClient
(
const
std
::
string
&
action
,
bool
meshAuto
);
bool
runGmshClient
(
const
std
::
string
&
action
,
bool
meshAuto
);
bool
getFirstComputationFlag
();
bool
getFirstComputationFlag
();
void
setFirstComputationFlag
(
bool
val
);
void
setFirstComputationFlag
(
bool
val
);
double
updateNumber
(
onelab
::
number
&
x
,
onelab
::
number
&
y
,
const
bool
readOnlyRange
=
false
);
std
::
string
updateString
(
onelab
::
string
&
x
,
onelab
::
string
&
y
);
}
}
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment