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
Analyze
Contributor 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
gmsh
gmsh
Commits
5ad3aea9
Commit
5ad3aea9
authored
17 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
more work on reparam gui
parent
1cff28e0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Fltk/GUI_Projection.cpp
+116
-130
116 additions, 130 deletions
Fltk/GUI_Projection.cpp
Fltk/GUI_Projection.h
+53
-0
53 additions, 0 deletions
Fltk/GUI_Projection.h
with
169 additions
and
130 deletions
Fltk/GUI_Projection.cpp
+
116
−
130
View file @
5ad3aea9
#include
"Gmsh.h"
#include
"GmshUI.h"
#include
"GModel.h"
#include
"projectionFace.h"
#include
"Draw.h"
#include
"Options.h"
#include
"Context.h"
#include
"SelectBuffer.h"
#include
"GUI.h"
#include
"Shortcut_Window.h"
#include
<FL/Fl_Toggle_Button.H>
#include
<FL/Fl_Round_Button.H>
#include
"GUI_Projection.h"
extern
GModel
*
GMODEL
;
extern
Context_T
CTX
;
void
select_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
browse_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
update_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
close_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
action_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
compute_cb
(
Fl_Widget
*
w
,
void
*
data
);
class
uvPlot
:
public
Fl_Window
{
private:
std
::
vector
<
double
>
_u
,
_v
;
void
draw
()
{
// draw background
fl_color
(
FL_WHITE
);
fl_rectf
(
0
,
0
,
w
(),
h
());
// draw points
fl_color
(
FL_BLACK
);
if
(
_u
.
size
()
!=
_v
.
size
())
return
;
for
(
unsigned
int
i
=
0
;
i
<
_u
.
size
();
i
++
)
fl_rect
(
_u
[
i
]
*
w
(),
_v
[
i
]
*
h
(),
3
,
3
);
void
uvPlot
::
draw
()
{
// draw background
fl_color
(
FL_WHITE
);
fl_rectf
(
0
,
0
,
w
(),
h
());
// draw points
fl_color
(
FL_BLACK
);
if
(
_u
.
size
()
!=
_v
.
size
())
return
;
for
(
unsigned
int
i
=
0
;
i
<
_u
.
size
();
i
++
)
fl_rect
(
_u
[
i
]
*
w
(),
_v
[
i
]
*
h
(),
3
,
3
);
fl_font
(
FL_HELVETICA
,
14
);
fl_draw
(
"Hello"
,
w
()
/
2
,
h
()
/
2
);
}
projectionEditor
::
projectionEditor
(
std
::
vector
<
projectionFace
*>
&
faces
)
:
_faces
(
faces
)
{
// construct GUI in terms of standard sizes
const
int
BH
=
2
*
GetFontSize
()
+
1
,
BB
=
7
*
GetFontSize
(),
WB
=
7
;
const
int
width
=
3.5
*
BB
,
height
=
18
*
BH
;
// create all widgets (we construct this once, we never deallocate!)
_window
=
new
Dialog_Window
(
width
,
height
,
"Reparameterize"
);
new
Fl_Box
(
WB
,
WB
+
BH
,
0.5
*
BB
,
BH
,
"Select:"
);
Fl_Group
*
o
=
new
Fl_Group
(
WB
,
WB
,
2
*
BB
,
3
*
BH
);
_select
[
0
]
=
new
Fl_Round_Button
(
2
*
WB
+
0.5
*
BB
,
WB
,
BB
,
BH
,
"Points"
);
_select
[
0
]
->
value
(
1
);
_select
[
1
]
=
new
Fl_Round_Button
(
2
*
WB
+
0.5
*
BB
,
WB
+
BH
,
BB
,
BH
,
"Elements"
);
_select
[
2
]
=
new
Fl_Round_Button
(
2
*
WB
+
0.5
*
BB
,
WB
+
2
*
BH
,
BB
,
BH
,
"Surfaces"
);
for
(
int
i
=
0
;
i
<
3
;
i
++
){
_select
[
i
]
->
callback
(
select_cb
,
this
);
_select
[
i
]
->
type
(
FL_RADIO_BUTTON
);
}
public
:
uvPlot
(
int
x
,
int
y
,
int
w
,
int
h
,
const
char
*
l
=
0
)
:
Fl_Window
(
x
,
y
,
w
,
h
,
l
){}
void
fill
(
std
::
vector
<
double
>
&
u
,
std
::
vector
<
double
>
&
v
){
_u
=
u
;
_v
=
v
;
redraw
();
}
};
class
projectionEditor
{
private:
std
::
vector
<
projectionFace
*>
_faces
;
Fl_Window
*
_window
;
Fl_Value_Input
*
_input
[
20
];
Fl_Hold_Browser
*
_browser
;
Fl_Round_Button
*
_select
[
3
];
uvPlot
*
_uvPlot
;
public:
projectionEditor
(
std
::
vector
<
projectionFace
*>
&
faces
)
:
_faces
(
faces
)
{
const
int
BH
=
2
*
GetFontSize
()
+
1
,
BB
=
7
*
GetFontSize
(),
WB
=
7
;
const
int
width
=
3.5
*
BB
,
height
=
18
*
BH
;
_window
=
new
Dialog_Window
(
width
,
height
,
"Reparameterize"
);
new
Fl_Box
(
WB
,
WB
+
BH
,
0.5
*
BB
,
BH
,
"Select:"
);
Fl_Group
*
o
=
new
Fl_Group
(
WB
,
WB
,
2
*
BB
,
3
*
BH
);
_select
[
0
]
=
new
Fl_Round_Button
(
2
*
WB
+
0.5
*
BB
,
WB
,
BB
,
BH
,
"Points"
);
_select
[
0
]
->
callback
(
select_cb
,
(
void
*
)
"Points"
);
_select
[
0
]
->
value
(
1
);
_select
[
1
]
=
new
Fl_Round_Button
(
2
*
WB
+
0.5
*
BB
,
WB
+
BH
,
BB
,
BH
,
"Elements"
);
_select
[
1
]
->
callback
(
select_cb
,
(
void
*
)
"Elements"
);
_select
[
2
]
=
new
Fl_Round_Button
(
2
*
WB
+
0.5
*
BB
,
WB
+
2
*
BH
,
BB
,
BH
,
"Surfaces"
);
_select
[
2
]
->
callback
(
select_cb
,
(
void
*
)
"Surfaces"
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
_select
[
i
]
->
type
(
FL_RADIO_BUTTON
);
o
->
end
();
Fl_Toggle_Button
*
b1
=
new
Fl_Toggle_Button
(
width
-
WB
-
1.5
*
BB
,
WB
,
1.5
*
BB
,
BH
,
"Hide unselected"
);
b1
->
callback
(
action_cb
,
(
void
*
)
"Hide"
);
Fl_Button
*
b2
=
new
Fl_Button
(
width
-
WB
-
1.5
*
BB
,
WB
+
BH
,
1.5
*
BB
,
BH
,
"Save selection"
);
b2
->
callback
(
action_cb
,
(
void
*
)
"Save"
);
_browser
=
new
Fl_Hold_Browser
(
WB
,
2
*
WB
+
3
*
BH
,
BB
,
5
*
BH
);
_browser
->
callback
(
browse_cb
,
this
);
for
(
unsigned
int
i
=
0
;
i
<
_faces
.
size
();
i
++
){
_browser
->
add
(
"test"
);
}
Fl_Scroll
*
s
=
new
Fl_Scroll
(
2
*
WB
+
BB
,
2
*
WB
+
3
*
BH
,
width
-
3
*
WB
-
BB
,
5
*
BH
);
for
(
int
i
=
0
;
i
<
20
;
i
++
){
_input
[
i
]
=
new
Fl_Value_Input
(
2
*
WB
+
BB
,
2
*
WB
+
(
i
+
3
)
*
BH
,
BB
,
BH
);
_input
[
i
]
->
align
(
FL_ALIGN_RIGHT
);
_input
[
i
]
->
callback
(
update_cb
,
this
);
_input
[
i
]
->
minimum
(
0.
);
_input
[
i
]
->
maximum
(
1.
);
_input
[
i
]
->
step
(
0.01
);
//_input[i]->hide();
}
s
->
end
();
_uvPlot
=
new
uvPlot
(
WB
,
3
*
WB
+
8
*
BH
,
width
-
2
*
WB
,
height
-
5
*
WB
-
9
*
BH
);
_uvPlot
->
end
();
Fl_Button
*
b3
=
new
Fl_Button
(
width
-
2
*
WB
-
2
*
BB
,
height
-
WB
-
BH
,
BB
,
BH
,
"Compute"
);
b3
->
callback
(
compute_cb
,
this
);
Fl_Button
*
b4
=
new
Fl_Button
(
width
-
WB
-
BB
,
height
-
WB
-
BH
,
BB
,
BH
,
"Cancel"
);
b4
->
callback
(
close_cb
,
_window
);
_window
->
end
();
_window
->
hotspot
(
_window
);
_window
->
resizable
(
_uvPlot
);
_window
->
size_range
(
width
,
0.75
*
height
);
o
->
end
();
Fl_Toggle_Button
*
b1
=
new
Fl_Toggle_Button
(
width
-
WB
-
1.5
*
BB
,
WB
,
1.5
*
BB
,
BH
,
"Hide unselected"
);
b1
->
callback
(
hide_cb
);
Fl_Button
*
b2
=
new
Fl_Button
(
width
-
WB
-
1.5
*
BB
,
WB
+
BH
,
1.5
*
BB
,
BH
,
"Save selection"
);
b2
->
callback
(
save_cb
,
this
);
_browser
=
new
Fl_Hold_Browser
(
WB
,
2
*
WB
+
3
*
BH
,
BB
,
5
*
BH
);
_browser
->
callback
(
browse_cb
,
this
);
for
(
unsigned
int
i
=
0
;
i
<
_faces
.
size
();
i
++
){
_browser
->
add
(
"test"
);
}
void
show
()
{
_window
->
show
();
for
(
int
i
=
0
;
i
<
3
;
i
++
)
if
(
_select
[
i
]
->
value
())
_select
[
i
]
->
do_callback
();
Fl_Scroll
*
s
=
new
Fl_Scroll
(
2
*
WB
+
BB
,
2
*
WB
+
3
*
BH
,
width
-
3
*
WB
-
BB
,
5
*
BH
);
for
(
int
i
=
0
;
i
<
20
;
i
++
){
_input
[
i
]
=
new
Fl_Value_Input
(
2
*
WB
+
BB
,
2
*
WB
+
(
i
+
3
)
*
BH
,
BB
,
BH
);
_input
[
i
]
->
align
(
FL_ALIGN_RIGHT
);
_input
[
i
]
->
callback
(
update_cb
,
this
);
_input
[
i
]
->
minimum
(
0.
);
_input
[
i
]
->
maximum
(
1.
);
_input
[
i
]
->
step
(
0.01
);
//_input[i]->hide();
}
uvPlot
*
uv
()
{
return
_uvPlot
;
}
projectionFace
*
face
()
{
return
0
;
}
// return current projection face
void
reset
(){}
// reset all parameters to default values
void
save
(){}
// save all parameters to a file
void
load
(){}
// load parameters from file
};
s
->
end
();
_uvPlot
=
new
uvPlot
(
WB
,
3
*
WB
+
8
*
BH
,
width
-
2
*
WB
,
height
-
5
*
WB
-
9
*
BH
);
_uvPlot
->
end
();
Fl_Button
*
b3
=
new
Fl_Button
(
width
-
2
*
WB
-
2
*
BB
,
height
-
WB
-
BH
,
BB
,
BH
,
"Compute"
);
b3
->
callback
(
compute_cb
,
this
);
Fl_Button
*
b4
=
new
Fl_Button
(
width
-
WB
-
BB
,
height
-
WB
-
BH
,
BB
,
BH
,
"Cancel"
);
b4
->
callback
(
close_cb
,
_window
);
_window
->
end
();
_window
->
hotspot
(
_window
);
_window
->
resizable
(
_uvPlot
);
_window
->
size_range
(
width
,
0.75
*
height
);
}
int
projectionEditor
::
getSelectionMode
()
{
if
(
_select
[
0
]
->
value
())
return
ENT_POINT
;
else
if
(
_select
[
2
]
->
value
())
return
ENT_SURFACE
;
return
ENT_ALL
;
}
void
browse_cb
(
Fl_Widget
*
w
,
void
*
data
)
{
...
...
@@ -144,23 +127,17 @@ void update_cb(Fl_Widget *w, void *data)
void
select_cb
(
Fl_Widget
*
w
,
void
*
data
)
{
char
*
str
=
(
char
*
)
data
;
int
what
;
projectionEditor
*
e
=
(
projectionEditor
*
)
data
;
if
(
!
strcmp
(
str
,
"Points"
)){
CTX
.
pick_elements
=
0
;
what
=
ENT_POINT
;
}
else
if
(
!
strcmp
(
str
,
"Elements"
)){
CTX
.
pick_elements
=
1
;
what
=
ENT_ALL
;
}
else
if
(
!
strcmp
(
str
,
"Surfaces"
)){
CTX
.
pick_elements
=
0
;
what
=
ENT_SURFACE
;
int
what
=
e
->
getSelectionMode
();
char
*
str
;
switch
(
what
){
case
ENT_ALL
:
CTX
.
pick_elements
=
1
;
str
=
"Elements"
;
break
;
case
ENT_POINT
:
CTX
.
pick_elements
=
0
;
str
=
"Points"
;
break
;
case
ENT_SURFACE
:
CTX
.
pick_elements
=
0
;
str
=
"Surfaces"
;
break
;
default:
return
;
}
else
return
;
std
::
vector
<
GVertex
*>
vertices
;
std
::
vector
<
GEdge
*>
edges
;
...
...
@@ -168,8 +145,8 @@ void select_cb(Fl_Widget *w, void *data)
std
::
vector
<
GRegion
*>
regions
;
std
::
vector
<
MElement
*>
elements
;
std
::
vector
<
MElement
*>
ele
;
std
::
vector
<
GEntity
*>
ent
;
std
::
vector
<
MElement
*>
&
ele
(
e
->
getElements
())
;
std
::
vector
<
GEntity
*>
&
ent
(
e
->
getEntities
())
;
while
(
1
)
{
CTX
.
mesh
.
changed
=
ENT_ALL
;
...
...
@@ -252,17 +229,26 @@ void close_cb(Fl_Widget *w, void *data)
if
(
data
)
((
Fl_Window
*
)
data
)
->
hide
();
}
void
action
_cb
(
Fl_Widget
*
w
,
void
*
data
)
void
hide
_cb
(
Fl_Widget
*
w
,
void
*
data
)
{
char
*
str
=
(
char
*
)
data
;
if
(
!
strcmp
(
str
,
"Hide"
)){
CTX
.
hide_unselected
=
!
CTX
.
hide_unselected
;
CTX
.
mesh
.
changed
=
ENT_ALL
;
CTX
.
hide_unselected
=
!
CTX
.
hide_unselected
;
CTX
.
mesh
.
changed
=
ENT_ALL
;
Draw
();
}
void
save_cb
(
Fl_Widget
*
w
,
void
*
data
)
{
projectionEditor
*
e
=
(
projectionEditor
*
)
data
;
std
::
vector
<
GEntity
*>
&
ent
(
e
->
getEntities
());
for
(
unsigned
int
i
=
0
;
i
<
ent
.
size
();
i
++
){
printf
(
"entity %d
\n
"
,
ent
[
i
]
->
tag
());
}
else
if
(
!
strcmp
(
str
,
"Save"
)){
Msg
(
GERROR
,
"Save not implemented yet!"
);
std
::
vector
<
MElement
*>
&
ele
(
e
->
getElements
());
for
(
unsigned
int
i
=
0
;
i
<
ele
.
size
();
i
++
){
printf
(
"element %d
\n
"
,
ele
[
i
]
->
getNum
());
}
Draw
();
}
void
compute_cb
(
Fl_Widget
*
w
,
void
*
data
)
...
...
This diff is collapsed.
Click to expand it.
Fltk/GUI_Projection.h
0 → 100644
+
53
−
0
View file @
5ad3aea9
#ifndef _GUI_PROJECTION_H_
#define _GUI_PROJECTION_H_
#include
"Gmsh.h"
#include
"GmshUI.h"
#include
"GModel.h"
#include
"projectionFace.h"
#include
<vector>
#include
"GUI.h"
#include
"Shortcut_Window.h"
#include
<FL/Fl_Toggle_Button.H>
#include
<FL/Fl_Round_Button.H>
void
select_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
browse_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
update_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
close_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
hide_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
save_cb
(
Fl_Widget
*
w
,
void
*
data
);
void
compute_cb
(
Fl_Widget
*
w
,
void
*
data
);
class
uvPlot
:
public
Fl_Window
{
private:
std
::
vector
<
double
>
_u
,
_v
;
void
draw
();
public:
uvPlot
(
int
x
,
int
y
,
int
w
,
int
h
,
const
char
*
l
=
0
)
:
Fl_Window
(
x
,
y
,
w
,
h
,
l
){}
void
fill
(
std
::
vector
<
double
>
&
u
,
std
::
vector
<
double
>
&
v
){
_u
=
u
;
_v
=
v
;
redraw
();
}
};
class
projectionEditor
{
private:
std
::
vector
<
projectionFace
*>
_faces
;
std
::
vector
<
MElement
*>
_elements
;
std
::
vector
<
GEntity
*>
_entities
;
Fl_Window
*
_window
;
Fl_Value_Input
*
_input
[
20
];
Fl_Hold_Browser
*
_browser
;
Fl_Round_Button
*
_select
[
3
];
uvPlot
*
_uvPlot
;
public:
projectionEditor
(
std
::
vector
<
projectionFace
*>
&
faces
);
void
show
(){
_window
->
show
();
select_cb
(
0
,
this
);
}
uvPlot
*
uv
()
{
return
_uvPlot
;
}
std
::
vector
<
MElement
*>
&
getElements
()
{
return
_elements
;
}
std
::
vector
<
GEntity
*>
&
getEntities
()
{
return
_entities
;
}
std
::
vector
<
projectionFace
*>
&
getProjectionFaces
()
{
return
_faces
;
}
int
getSelectionMode
();
};
#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