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
738948e1
Commit
738948e1
authored
13 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
hack to force float input even if step is integer
parent
a5bd62aa
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Fltk/inputRange.h
+25
-8
25 additions, 8 deletions
Fltk/inputRange.h
with
25 additions
and
8 deletions
Fltk/inputRange.h
+
25
−
8
View file @
738948e1
...
...
@@ -7,15 +7,24 @@
#include
<sstream>
#include
<stdio.h>
#include
<stdlib.h>
#include
<math.h>
#include
<FL/Fl.H>
#include
<FL/Fl_Window.H>
#include
<FL/Fl_Value_Input.H>
#include
<FL/Fl_Toggle_Button.H>
#include
<FL/Fl_Menu_Button.H>
class
inputValue
:
public
Fl_Value_Input
{
public:
inputValue
(
int
x
,
int
y
,
int
w
,
int
h
,
const
char
*
l
=
0
)
:
Fl_Value_Input
(
x
,
y
,
w
,
h
,
l
)
{}
virtual
int
format
(
char
*
buffer
){
return
sprintf
(
buffer
,
"%g"
,
value
());
}
};
class
inputRange
:
public
Fl_Group
{
private:
Fl_Value_Input
*
_input
;
inputValue
*
_input
;
Fl_Input
*
_range
;
Fl_Toggle_Button
*
_range_butt
,
*
_loop_butt
;
Fl_Button
*
_graph_butt
;
...
...
@@ -24,6 +33,14 @@ class inputRange : public Fl_Group {
double
_min
,
_max
,
_step
,
_max_number
;
std
::
vector
<
double
>
_choices
;
bool
_do_callback_on_values
;
double
_fixStep
(
double
step
)
{
// workaround annoying behaviour of Fl_Value_Input: if step is a nonzero
// integer, one can only enter integer values in the widget; se we force
// nonzero steps to be noninteger
if
(
step
&&
step
-
floor
(
step
)
<=
0
)
step
*=
(
1.
-
1e-16
);
return
step
;
}
void
_values2string
()
{
std
::
ostringstream
tmp
;
...
...
@@ -36,7 +53,7 @@ class inputRange : public Fl_Group {
if
(
_choices
.
size
()
>
1
){
_input
->
minimum
(
_choices
[
0
]);
_input
->
maximum
(
_choices
[
_choices
.
size
()
-
1
]);
_input
->
step
(
_choices
[
1
]
-
_choices
[
0
]);
_input
->
step
(
_
fixStep
(
_
choices
[
1
]
-
_choices
[
0
])
)
;
}
_step
=
0.
;
}
...
...
@@ -53,7 +70,7 @@ class inputRange : public Fl_Group {
}
if
(
_step
==
0.
)
_step
=
1.
;
if
(
_step
!=
1.
)
tmp
<<
":"
<<
_step
;
_input
->
step
(
_step
);
_input
->
step
(
_
fixStep
(
_
step
)
)
;
_choices
.
clear
();
}
_range
->
value
(
tmp
.
str
().
c_str
());
...
...
@@ -77,7 +94,7 @@ class inputRange : public Fl_Group {
if
(
_choices
.
size
()
>
1
){
_input
->
minimum
(
_choices
[
0
]);
_input
->
maximum
(
_choices
[
_choices
.
size
()
-
1
]);
_input
->
step
(
_choices
[
1
]
-
_choices
[
0
]);
_input
->
step
(
_
fixStep
(
_
choices
[
1
]
-
_choices
[
0
])
)
;
}
_step
=
0.
;
}
...
...
@@ -110,7 +127,7 @@ class inputRange : public Fl_Group {
_step
=
atof
(
step
.
c_str
());
else
_step
=
1.
;
_input
->
step
(
_step
);
_input
->
step
(
_
fixStep
(
_
step
)
)
;
_choices
.
clear
();
}
}
...
...
@@ -240,7 +257,7 @@ class inputRange : public Fl_Group {
int
input_w
=
w
-
dot_w
-
loop_w
-
graph_w
;
int
range_w
=
input_w
/
2
;
_input
=
new
Fl_Value_Input
(
x
,
y
,
input_w
,
h
);
_input
=
new
inputValue
(
x
,
y
,
input_w
,
h
);
_input
->
callback
(
_input_cb
,
this
);
_input
->
when
(
FL_WHEN_ENTER_KEY
|
FL_WHEN_RELEASE
);
...
...
@@ -262,7 +279,7 @@ class inputRange : public Fl_Group {
_graph_butt
=
new
Fl_Button
(
x
+
input_w
+
dot_w
+
loop_w
,
y
,
graph_w
,
h
);
_graph_butt
->
label
(
"@-1gmsh_graph"
);
_graph_butt
->
align
(
FL_ALIGN_CENTER
|
FL_ALIGN_INSIDE
);
_graph_butt
->
tooltip
(
"Draw range on X-Y graph"
);
_graph_butt
->
tooltip
(
"Draw range on X-Y graph
(s)
"
);
_graph_menu
=
new
Fl_Menu_Button
(
x
+
input_w
+
dot_w
+
loop_w
,
y
,
graph_w
,
h
);
_graph_menu
->
type
(
Fl_Menu_Button
::
POPUP123
);
...
...
@@ -274,7 +291,7 @@ class inputRange : public Fl_Group {
_graph_menu
->
add
(
"Graph 3/Y "
,
0
,
_graph_menu_cb
,
this
,
FL_MENU_TOGGLE
);
_graph_menu
->
add
(
"Graph 4/X "
,
0
,
_graph_menu_cb
,
this
,
FL_MENU_TOGGLE
);
_graph_menu
->
add
(
"Graph 4/Y "
,
0
,
_graph_menu_cb
,
this
,
FL_MENU_TOGGLE
);
_graph_menu
->
add
(
"
Reset
"
,
0
,
_graph_menu_reset_cb
,
this
);
_graph_menu
->
add
(
"
None
"
,
0
,
_graph_menu_reset_cb
,
this
);
end
();
// close the group
resizable
(
_input
);
...
...
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