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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
120088a5
There was an error fetching the commit references. Please try again later.
Commit
120088a5
authored
18 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
add fancy colors in uv plot
parent
e113dc75
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Fltk/GUI_Projection.cpp
+74
-10
74 additions, 10 deletions
Fltk/GUI_Projection.cpp
Fltk/GUI_Projection.h
+7
-5
7 additions, 5 deletions
Fltk/GUI_Projection.h
with
81 additions
and
15 deletions
Fltk/GUI_Projection.cpp
+
74
−
10
View file @
120088a5
...
@@ -9,6 +9,47 @@ extern Context_T CTX;
...
@@ -9,6 +9,47 @@ extern Context_T CTX;
#if defined(HAVE_FOURIER_MODEL)
#if defined(HAVE_FOURIER_MODEL)
uvPlot
::
uvPlot
(
int
x
,
int
y
,
int
w
,
int
h
,
const
char
*
l
)
:
Fl_Window
(
x
,
y
,
w
,
h
,
l
),
_dmin
(
0.
),
_dmax
(
0.
)
{
ColorTable_InitParam
(
2
,
&
_colorTable
);
ColorTable_Recompute
(
&
_colorTable
);
}
void
uvPlot
::
fill
(
std
::
vector
<
double
>
&
u
,
std
::
vector
<
double
>
&
v
,
std
::
vector
<
double
>
&
f
)
{
_u
=
u
;
_v
=
v
;
_f
=
f
;
// compute min/max distance
if
(
_f
.
size
()){
_dmin
=
1.e200
;
_dmax
=
0.
;
for
(
unsigned
int
i
=
0
;
i
<
_f
.
size
();
i
++
){
// only compute min/max for valid projections
if
(
_u
[
i
]
>=
0.
&&
_u
[
i
]
<=
1.
&&
_v
[
i
]
>=
0.
&&
_v
[
i
]
<=
1.
){
_dmin
=
std
::
min
(
_dmin
,
_f
[
i
]);
_dmax
=
std
::
max
(
_dmax
,
_f
[
i
]);
}
}
}
redraw
();
}
void
uvPlot
::
color
(
double
d
)
{
int
numcol
=
_colorTable
.
size
;
int
index
;
if
(
_dmin
==
_dmax
)
index
=
numcol
/
2
;
else
index
=
(
int
)((
d
-
_dmin
)
*
(
numcol
-
1
)
/
(
_dmax
-
_dmin
));
unsigned
int
color
=
_colorTable
.
table
[
index
];
int
r
=
CTX
.
UNPACK_RED
(
color
);
int
g
=
CTX
.
UNPACK_GREEN
(
color
);
int
b
=
CTX
.
UNPACK_BLUE
(
color
);
fl_color
(
r
,
g
,
b
);
}
void
uvPlot
::
draw
()
void
uvPlot
::
draw
()
{
{
// draw background
// draw background
...
@@ -17,16 +58,37 @@ void uvPlot::draw()
...
@@ -17,16 +58,37 @@ void uvPlot::draw()
// draw points
// draw points
if
(
_u
.
size
()
!=
_v
.
size
())
return
;
if
(
_u
.
size
()
!=
_v
.
size
())
return
;
int
pw
=
w
();
int
ph
=
h
()
-
30
;
for
(
unsigned
int
i
=
0
;
i
<
_u
.
size
();
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
_u
.
size
();
i
++
){
int
x
=
(
int
)(
_u
[
i
]
*
w
());
if
(
_u
[
i
]
>=
0.
&&
_u
[
i
]
<=
1.
&&
int
y
=
(
int
)(
_v
[
i
]
*
h
());
_v
[
i
]
>=
0.
&&
_v
[
i
]
<=
1.
){
// fixme: change color depending on f
int
x
=
(
int
)(
_u
[
i
]
*
pw
);
fl_color
(
FL_BLACK
);
int
y
=
(
int
)(
_v
[
i
]
*
ph
);
color
(
_f
[
i
]);
fl_rect
(
x
,
y
,
3
,
3
);
fl_rect
(
x
,
y
,
3
,
3
);
}
}
}
//fl_font(FL_HELVETICA, 14);
for
(
int
i
=
0
;
i
<
w
();
i
++
){
//fl_draw("Hello", w() / 2, h() / 2);
int
index
=
(
int
)(
i
*
(
_colorTable
.
size
-
1
)
/
w
());
unsigned
int
color
=
_colorTable
.
table
[
index
];
int
r
=
CTX
.
UNPACK_RED
(
color
);
int
g
=
CTX
.
UNPACK_GREEN
(
color
);
int
b
=
CTX
.
UNPACK_BLUE
(
color
);
fl_color
(
r
,
g
,
b
);
fl_line
(
i
,
ph
,
i
,
ph
+
10
);
}
fl_color
(
FL_BLACK
);
fl_font
(
FL_HELVETICA
,
13
);
static
char
min
[
256
],
max
[
256
];
sprintf
(
min
,
"%g"
,
_dmin
);
sprintf
(
max
,
"%g"
,
_dmax
);
fl_draw
(
min
,
5
,
h
()
-
5
);
fl_draw
(
max
,
pw
-
fl_width
(
max
)
-
5
,
h
()
-
5
);
}
}
projection
::
projection
(
FProjectionFace
*
f
,
int
x
,
int
y
,
int
w
,
int
h
,
int
BB
,
int
BH
,
projection
::
projection
(
FProjectionFace
*
f
,
int
x
,
int
y
,
int
w
,
int
h
,
int
BB
,
int
BH
,
...
@@ -176,7 +238,8 @@ void browse_cb(Fl_Widget *w, void *data)
...
@@ -176,7 +238,8 @@ void browse_cb(Fl_Widget *w, void *data)
p
->
face
->
setVisibility
(
true
);
p
->
face
->
setVisibility
(
true
);
p
->
group
->
show
();
p
->
group
->
show
();
}
}
Draw
();
update_cb
(
w
,
data
);
}
}
void
update_cb
(
Fl_Widget
*
w
,
void
*
data
)
void
update_cb
(
Fl_Widget
*
w
,
void
*
data
)
...
@@ -202,7 +265,6 @@ void update_cb(Fl_Widget *w, void *data)
...
@@ -202,7 +265,6 @@ void update_cb(Fl_Widget *w, void *data)
for
(
int
i
=
9
;
i
<
9
+
ps
->
GetNumParameters
();
i
++
)
for
(
int
i
=
9
;
i
<
9
+
ps
->
GetNumParameters
();
i
++
)
ps
->
SetParameter
(
i
-
9
,
p
->
parameters
[
i
]
->
value
());
ps
->
SetParameter
(
i
-
9
,
p
->
parameters
[
i
]
->
value
());
p
->
face
->
computeGraphicsRep
(
64
,
64
);
// FIXME: hardcoded for now!
p
->
face
->
computeGraphicsRep
(
64
,
64
);
// FIXME: hardcoded for now!
Draw
();
// project all selected points and update u,v display
// project all selected points and update u,v display
std
::
vector
<
double
>
u
,
v
,
f
;
std
::
vector
<
double
>
u
,
v
,
f
;
...
@@ -226,6 +288,8 @@ void update_cb(Fl_Widget *w, void *data)
...
@@ -226,6 +288,8 @@ void update_cb(Fl_Widget *w, void *data)
// loop over elements and do the same thing
// loop over elements and do the same thing
e
->
uv
()
->
fill
(
u
,
v
,
f
);
e
->
uv
()
->
fill
(
u
,
v
,
f
);
}
}
Draw
();
}
}
void
select_cb
(
Fl_Widget
*
w
,
void
*
data
)
void
select_cb
(
Fl_Widget
*
w
,
void
*
data
)
...
...
This diff is collapsed.
Click to expand it.
Fltk/GUI_Projection.h
+
7
−
5
View file @
120088a5
...
@@ -6,8 +6,10 @@
...
@@ -6,8 +6,10 @@
#include
"GModel.h"
#include
"GModel.h"
#include
"GUI.h"
#include
"GUI.h"
#include
"Shortcut_Window.h"
#include
"Shortcut_Window.h"
#include
"ColorTable.h"
#include
<FL/Fl_Toggle_Button.H>
#include
<FL/Fl_Toggle_Button.H>
#include
<FL/Fl_Round_Button.H>
#include
<FL/Fl_Round_Button.H>
#if defined(HAVE_FOURIER_MODEL)
#if defined(HAVE_FOURIER_MODEL)
#include
"Utils.h"
#include
"Utils.h"
...
@@ -34,13 +36,13 @@ void compute_cb(Fl_Widget *w, void *data);
...
@@ -34,13 +36,13 @@ void compute_cb(Fl_Widget *w, void *data);
class
uvPlot
:
public
Fl_Window
{
class
uvPlot
:
public
Fl_Window
{
private:
private:
std
::
vector
<
double
>
_u
,
_v
,
_f
;
std
::
vector
<
double
>
_u
,
_v
,
_f
;
GmshColorTable
_colorTable
;
double
_dmin
,
_dmax
;
void
color
(
double
d
);
void
draw
();
void
draw
();
public:
public:
uvPlot
(
int
x
,
int
y
,
int
w
,
int
h
,
const
char
*
l
=
0
)
:
Fl_Window
(
x
,
y
,
w
,
h
,
l
){}
uvPlot
(
int
x
,
int
y
,
int
w
,
int
h
,
const
char
*
l
=
0
);
void
fill
(
std
::
vector
<
double
>
&
u
,
std
::
vector
<
double
>
&
v
,
std
::
vector
<
double
>
&
f
)
void
fill
(
std
::
vector
<
double
>
&
u
,
std
::
vector
<
double
>
&
v
,
std
::
vector
<
double
>
&
f
);
{
_u
=
u
;
_v
=
v
;
_f
=
f
;
redraw
();
}
};
};
class
projectionEditor
;
class
projectionEditor
;
...
...
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