Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
760fe07f
Commit
760fe07f
authored
May 20, 2003
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Image object added
parent
bad1933c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
417 additions
and
1 deletion
+417
-1
xtt/lib/flow/src/flow_browapi.cpp
xtt/lib/flow/src/flow_browapi.cpp
+4
-0
xtt/lib/flow/src/flow_browapi.h
xtt/lib/flow/src/flow_browapi.h
+2
-1
xtt/lib/flow/src/flow_draw.cpp
xtt/lib/flow/src/flow_draw.cpp
+29
-0
xtt/lib/flow/src/flow_draw.h
xtt/lib/flow/src/flow_draw.h
+1
-0
xtt/lib/flow/src/flow_image.cpp
xtt/lib/flow/src/flow_image.cpp
+308
-0
xtt/lib/flow/src/flow_image.h
xtt/lib/flow/src/flow_image.h
+73
-0
No files found.
xtt/lib/flow/src/flow_browapi.cpp
View file @
760fe07f
...
...
@@ -709,3 +709,7 @@ void brow_SetClickSensitivity( brow_tCtx ctx, int value)
flow_draw_set_click_sensitivity
(
(
FlowCtx
*
)
ctx
,
value
);
}
void
brow_SetWhiteBackground
(
brow_tCtx
ctx
)
{
flow_set_white_background
(
(
FlowCtx
*
)
ctx
);
}
xtt/lib/flow/src/flow_browapi.h
View file @
760fe07f
...
...
@@ -205,7 +205,8 @@ void brow_DeleteSecondaryCtx( brow_tCtx ctx);
int
brow_ChangeCtx
(
Widget
w
,
brow_tCtx
from_ctx
,
brow_tCtx
to_ctx
);
void
brow_SetInputFocus
(
brow_tCtx
ctx
);
void
brow_SetWidgetInputFocus
(
Widget
w
);
void
brow_SetClickSensitivity
(
brow_tCtx
ctx
,
int
value
);
void
brow_SetClickSensitivity
(
brow_tCtx
ctx
,
int
value
);
void
brow_SetWhiteBackground
(
brow_tCtx
ctx
);
#if defined __cplusplus
}
...
...
xtt/lib/flow/src/flow_draw.cpp
View file @
760fe07f
...
...
@@ -1929,4 +1929,33 @@ void flow_reset_image_clip_mask( FlowCtx *ctx)
XSetClipOrigin
(
draw_ctx
->
display
,
draw_ctx
->
gcs
[
flow_eDrawType_Line
][
0
],
0
,
0
);
}
void
flow_set_white_background
(
FlowCtx
*
ctx
)
{
XGCValues
xgcv
;
draw_tCtx
draw_ctx
=
(
draw_tCtx
)
ctx
->
draw_ctx
;
int
i
;
Arg
args
[
5
];
draw_ctx
->
background
=
XWhitePixelOfScreen
(
draw_ctx
->
screen
);
// Change erase gcs
xgcv
.
foreground
=
draw_ctx
->
background
;
xgcv
.
background
=
draw_ctx
->
background
;
for
(
i
=
0
;
i
<
DRAW_TYPE_SIZE
;
i
++
)
{
XChangeGC
(
draw_ctx
->
display
,
draw_ctx
->
gcs
[
flow_eDrawType_LineErase
][
i
],
GCForeground
|
GCBackground
,
&
xgcv
);
XChangeGC
(
draw_ctx
->
display
,
draw_ctx
->
gcs
[
flow_eDrawType_TextHelveticaErase
][
i
],
GCForeground
|
GCBackground
,
&
xgcv
);
XChangeGC
(
draw_ctx
->
display
,
draw_ctx
->
gcs
[
flow_eDrawType_TextHelveticaEraseBold
][
i
],
GCForeground
|
GCBackground
,
&
xgcv
);
}
i
=
0
;
XtSetArg
(
args
[
i
],
XmNbackground
,
draw_ctx
->
background
);
i
++
;
XtSetValues
(
draw_ctx
->
toplevel
,
args
,
i
);
if
(
!
ctx
->
no_nav
)
XtSetValues
(
draw_ctx
->
nav_toplevel
,
args
,
i
);
}
xtt/lib/flow/src/flow_draw.h
View file @
760fe07f
...
...
@@ -174,5 +174,6 @@ void flow_set_widget_inputfocus( Widget w);
void
flow_draw_set_click_sensitivity
(
FlowCtx
*
ctx
,
int
value
);
void
flow_set_image_clip_mask
(
FlowCtx
*
ctx
,
Pixmap
pixmap
,
int
x
,
int
y
);
void
flow_reset_image_clip_mask
(
FlowCtx
*
ctx
);
void
flow_set_white_background
(
FlowCtx
*
ctx
);
#endif
xtt/lib/flow/src/flow_image.cpp
0 → 100644
View file @
760fe07f
#include "flow_std.h"
#include <float.h>
#include <iostream.h>
#include "flow_image.h"
#include "flow_draw.h"
extern
"C"
{
#include "co_dcli.h"
}
FlowImage
::
FlowImage
(
FlowCtx
*
flow_ctx
,
char
*
imagefile
,
double
x
=
0
,
double
y
=
0
,
flow_mDisplayLevel
display_lev
=
flow_mDisplayLevel_1
)
:
ctx
(
flow_ctx
),
ll
(
flow_ctx
,
x
,
y
),
ur
(
flow_ctx
,
x
,
y
),
display_level
(
display_lev
),
image
(
0
),
original_image
(
0
),
pixmap
(
0
),
nav_pixmap
(
0
),
clip_mask
(
0
),
nav_clip_mask
(
0
),
current_zoom_factor
(
0
)
{
imlib
=
((
draw_tCtx
)
ctx
->
draw_ctx
)
->
imlib
;
if
(
imagefile
)
insert_image
(
imagefile
);
}
int
FlowImage
::
insert_image
(
char
*
imagefile
)
{
char
filename
[
120
];
bool
found
=
false
;
strcpy
(
image_filename
,
imagefile
);
// Look for file in $pwrp_exe, $pwr_doc and $pwr_exe
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
switch
(
i
)
{
case
1
:
strcpy
(
filename
,
"$pwrp_exe/"
);
break
;
case
2
:
strcpy
(
filename
,
"$pwr_doc/"
);
break
;
case
3
:
strcpy
(
filename
,
"$pwr_exe/"
);
break
;
}
strcat
(
filename
,
imagefile
);
dcli_translate_filename
(
filename
,
filename
);
FILE
*
fp
=
fopen
(
filename
,
"r"
);
if
(
!
fp
)
continue
;
fclose
(
fp
);
found
=
true
;
break
;
}
if
(
!
found
)
return
0
;
#if defined IMLIB
if
(
pixmap
)
{
Imlib_free_pixmap
(
imlib
,
pixmap
);
pixmap
=
0
;
}
if
(
nav_pixmap
)
{
Imlib_free_pixmap
(
imlib
,
nav_pixmap
);
nav_pixmap
=
0
;
}
if
(
image
)
Imlib_destroy_image
(
imlib
,
image
);
original_image
=
Imlib_load_image
(
imlib
,
filename
);
if
(
!
original_image
)
return
0
;
// Make a copy
image
=
Imlib_clone_image
(
imlib
,
original_image
);
current_width
=
int
(
image
->
rgb_width
*
ctx
->
zoom_factor
/
ctx
->
base_zoom_factor
);
current_height
=
int
(
image
->
rgb_height
*
ctx
->
zoom_factor
/
ctx
->
base_zoom_factor
);
current_nav_width
=
int
(
image
->
rgb_width
*
ctx
->
nav_zoom_factor
/
ctx
->
base_zoom_factor
);
current_nav_height
=
int
(
image
->
rgb_height
*
ctx
->
nav_zoom_factor
/
ctx
->
base_zoom_factor
);
Imlib_render
(
imlib
,
image
,
current_width
,
current_height
);
pixmap
=
Imlib_move_image
(
imlib
,
image
);
clip_mask
=
Imlib_move_mask
(
imlib
,
image
);
Imlib_render
(
imlib
,
image
,
current_nav_width
,
current_nav_height
);
nav_pixmap
=
Imlib_move_image
(
imlib
,
image
);
nav_clip_mask
=
Imlib_move_mask
(
imlib
,
image
);
ur
.
posit
(
ll
.
x
+
double
(
current_width
)
/
ctx
->
zoom_factor
,
ll
.
y
+
double
(
current_height
)
/
ctx
->
zoom_factor
);
current_zoom_factor
=
ctx
->
zoom_factor
;
#endif
return
1
;
}
void
FlowImage
::
zoom
()
{
ll
.
zoom
();
ur
.
zoom
();
}
void
FlowImage
::
nav_zoom
()
{
ll
.
nav_zoom
();
ur
.
nav_zoom
();
}
void
FlowImage
::
print_zoom
()
{
ll
.
print_zoom
();
ur
.
print_zoom
();
}
void
FlowImage
::
traverse
(
int
x
,
int
y
)
{
ll
.
traverse
(
x
,
y
);
ur
.
traverse
(
x
,
y
);
}
void
FlowImage
::
print
(
void
*
pos
,
void
*
node
)
{
if
(
!
(
display_level
&
ctx
->
display_level
))
return
;
if
(
fix_line_width
&&
line_width
<
0
)
return
;
if
(
draw_type
==
flow_eDrawType_LineErase
)
return
;
int
idx
=
int
(
ctx
->
print_zoom_factor
/
ctx
->
base_zoom_factor
*
line_width
-
1
);
idx
=
max
(
0
,
idx
);
idx
=
min
(
idx
,
DRAW_TYPE_SIZE
-
1
);
if
(
!
fill
)
ctx
->
print_ps
->
rect
(
ll
.
print_z_x
+
((
FlowPoint
*
)
pos
)
->
print_z_x
,
ll
.
print_z_y
+
((
FlowPoint
*
)
pos
)
->
print_z_y
,
ur
.
print_z_x
-
ll
.
print_z_x
,
ur
.
print_z_y
-
ll
.
print_z_y
,
draw_type
,
idx
);
else
ctx
->
print_ps
->
filled_rect
(
ll
.
print_z_x
+
((
FlowPoint
*
)
pos
)
->
print_z_x
,
ll
.
print_z_y
+
((
FlowPoint
*
)
pos
)
->
print_z_y
,
ur
.
print_z_x
-
ll
.
print_z_x
,
ur
.
print_z_y
-
ll
.
print_z_y
,
draw_type
,
idx
);
}
void
FlowImage
::
save
(
ofstream
&
fp
,
flow_eSaveMode
mode
)
{
fp
<<
int
(
flow_eSave_Rect
)
<<
endl
;
fp
<<
int
(
flow_eSave_Rect_draw_type
)
<<
FSPACE
<<
int
(
draw_type
)
<<
endl
;
fp
<<
int
(
flow_eSave_Rect_line_width
)
<<
FSPACE
<<
line_width
<<
endl
;
fp
<<
int
(
flow_eSave_Rect_display_level
)
<<
FSPACE
<<
int
(
display_level
)
<<
endl
;
fp
<<
int
(
flow_eSave_Rect_ll
)
<<
endl
;
ll
.
save
(
fp
,
mode
);
fp
<<
int
(
flow_eSave_Rect_ur
)
<<
endl
;
ur
.
save
(
fp
,
mode
);
fp
<<
int
(
flow_eSave_End
)
<<
endl
;
}
void
FlowImage
::
open
(
ifstream
&
fp
)
{
int
type
;
int
end_found
=
0
;
char
dummy
[
40
];
int
tmp
;
for
(;;)
{
fp
>>
type
;
switch
(
type
)
{
case
flow_eSave_Rect
:
break
;
case
flow_eSave_Rect_draw_type
:
fp
>>
tmp
;
draw_type
=
(
flow_eDrawType
)
tmp
;
break
;
case
flow_eSave_Rect_line_width
:
fp
>>
line_width
;
break
;
case
flow_eSave_Rect_display_level
:
fp
>>
tmp
;
display_level
=
(
flow_mDisplayLevel
)
tmp
;
break
;
case
flow_eSave_Rect_ll
:
ll
.
open
(
fp
);
break
;
case
flow_eSave_Rect_ur
:
ur
.
open
(
fp
);
break
;
case
flow_eSave_End
:
end_found
=
1
;
break
;
default:
cout
<<
"FlowImage:open syntax error"
<<
endl
;
fp
.
getline
(
dummy
,
sizeof
(
dummy
));
}
if
(
end_found
)
break
;
}
}
void
FlowImage
::
draw
(
void
*
pos
,
int
highlight
,
int
hot
,
void
*
node
)
{
if
(
!
(
display_level
&
ctx
->
display_level
))
return
;
if
(
pixmap
)
{
#if defined IMLIB
if
(
fabs
(
current_zoom_factor
-
ctx
->
zoom_factor
)
>
DBL_EPSILON
)
{
current_zoom_factor
=
ctx
->
zoom_factor
;
current_width
=
int
(
image
->
rgb_width
*
ctx
->
zoom_factor
/
ctx
->
base_zoom_factor
);
current_height
=
int
(
image
->
rgb_height
*
ctx
->
zoom_factor
/
ctx
->
base_zoom_factor
);
Imlib_render
(
imlib
,
image
,
current_width
,
current_height
);
Imlib_free_pixmap
(
imlib
,
pixmap
);
pixmap
=
Imlib_move_image
(
imlib
,
image
);
clip_mask
=
Imlib_move_mask
(
imlib
,
image
);
}
#endif
flow_draw_image
(
ctx
,
ll
.
z_x
+
((
FlowPoint
*
)
pos
)
->
z_x
-
ctx
->
offset_x
,
ll
.
z_y
+
((
FlowPoint
*
)
pos
)
->
z_y
-
ctx
->
offset_y
,
ur
.
z_x
-
ll
.
z_x
,
ur
.
z_y
-
ll
.
z_y
,
pixmap
,
clip_mask
);
}
else
flow_draw_fill_rect
(
ctx
,
ll
.
z_x
+
((
FlowPoint
*
)
pos
)
->
z_x
-
ctx
->
offset_x
,
ll
.
z_y
+
((
FlowPoint
*
)
pos
)
->
z_y
-
ctx
->
offset_y
,
ur
.
z_x
-
ll
.
z_x
,
ur
.
z_y
-
ll
.
z_y
,
flow_eDrawType_LineGray
);
}
void
FlowImage
::
erase
(
void
*
pos
,
int
hot
,
void
*
node
)
{
if
(
!
(
display_level
&
ctx
->
display_level
))
return
;
flow_draw_fill_rect
(
ctx
,
ll
.
z_x
+
((
FlowPoint
*
)
pos
)
->
z_x
-
ctx
->
offset_x
,
ll
.
z_y
+
((
FlowPoint
*
)
pos
)
->
z_y
-
ctx
->
offset_y
,
ur
.
z_x
-
ll
.
z_x
,
ur
.
z_y
-
ll
.
z_y
,
flow_eDrawType_LineErase
);
}
void
FlowImage
::
nav_draw
(
void
*
pos
,
int
highlight
,
void
*
node
)
{
}
void
FlowImage
::
nav_erase
(
void
*
pos
,
void
*
node
)
{
}
int
FlowImage
::
event_handler
(
void
*
pos
,
flow_eEvent
event
,
int
x
,
int
y
,
void
*
node
)
{
FlowPoint
*
p
;
p
=
(
FlowPoint
*
)
pos
;
if
(
ll
.
z_x
+
((
FlowPoint
*
)
pos
)
->
z_x
-
ctx
->
offset_x
<=
x
&&
x
<=
ur
.
z_x
+
((
FlowPoint
*
)
pos
)
->
z_x
-
ctx
->
offset_x
&&
ll
.
z_y
+
((
FlowPoint
*
)
pos
)
->
z_y
-
ctx
->
offset_y
<=
y
&&
y
<=
ur
.
z_y
+
((
FlowPoint
*
)
pos
)
->
z_y
-
ctx
->
offset_y
)
{
// cout << "Event handler: Hit in rect" << endl;
return
1
;
}
else
return
0
;
}
void
FlowImage
::
get_borders
(
double
pos_x
,
double
pos_y
,
double
*
x_right
,
double
*
x_left
,
double
*
y_high
,
double
*
y_low
,
void
*
node
)
{
if
(
display_level
!=
flow_mDisplayLevel_1
)
return
;
if
(
pos_x
+
ll
.
x
<
*
x_left
)
*
x_left
=
pos_x
+
ll
.
x
;
if
(
pos_x
+
ur
.
x
>
*
x_right
)
*
x_right
=
pos_x
+
ur
.
x
;
if
(
pos_y
+
ll
.
y
<
*
y_low
)
*
y_low
=
pos_y
+
ll
.
y
;
if
(
pos_y
+
ur
.
y
>
*
y_high
)
*
y_high
=
pos_y
+
ur
.
y
;
}
void
FlowImage
::
move
(
void
*
pos
,
double
x
,
double
y
,
int
highlight
,
int
hot
)
{
double
width
,
height
;
width
=
ur
.
x
-
ll
.
x
;
height
=
ur
.
y
-
ll
.
y
;
erase
(
pos
,
hot
,
NULL
);
nav_erase
(
pos
,
NULL
);
ll
.
x
=
x
;
ll
.
y
=
y
;
ur
.
x
=
x
+
width
;
ur
.
y
=
y
+
height
;
zoom
();
nav_zoom
();
draw
(
pos
,
highlight
,
hot
,
NULL
);
nav_draw
(
pos
,
highlight
,
NULL
);
}
void
FlowImage
::
shift
(
void
*
pos
,
double
delta_x
,
double
delta_y
,
int
highlight
,
int
hot
)
{
erase
(
pos
,
hot
,
NULL
);
nav_erase
(
pos
,
NULL
);
ll
.
x
+=
delta_x
;
ll
.
y
+=
delta_y
;
ur
.
x
+=
delta_x
;
ur
.
y
+=
delta_y
;
zoom
();
nav_zoom
();
draw
(
pos
,
highlight
,
hot
,
NULL
);
nav_draw
(
pos
,
highlight
,
NULL
);
}
ostream
&
operator
<<
(
ostream
&
o
,
const
FlowImage
r
)
{
o
<<
'('
<<
r
.
ll
.
x
<<
','
<<
r
.
ll
.
y
<<
')'
<<
'('
<<
r
.
ur
.
x
<<
','
<<
r
.
ur
.
y
<<
')'
<<
'['
<<
r
.
ll
.
z_x
<<
','
<<
r
.
ll
.
z_y
<<
']'
<<
'['
<<
r
.
ur
.
z_x
<<
','
<<
r
.
ur
.
z_y
<<
']'
;
return
o
;
}
xtt/lib/flow/src/flow_image.h
0 → 100644
View file @
760fe07f
#ifndef flow_image_h
#define flow_image_h
#include <iostream.h>
#include <fstream.h>
#include "flow.h"
#include "flow_ctx.h"
#include "flow_point.h"
#include "flow_array_elem.h"
#include "flow_draw.h"
class
FlowImage
:
public
FlowArrayElem
{
public:
FlowImage
(
FlowCtx
*
flow_ctx
,
char
*
imagefile
,
double
x
=
0
,
double
y
=
0
,
flow_mDisplayLevel
display_lev
=
flow_mDisplayLevel_1
);
friend
ostream
&
operator
<<
(
ostream
&
o
,
const
FlowImage
r
);
void
zoom
();
void
nav_zoom
();
void
print_zoom
();
void
traverse
(
int
x
,
int
y
);
int
event_handler
(
void
*
pos
,
flow_eEvent
event
,
int
x
,
int
y
,
void
*
node
);
void
conpoint_select
(
void
*
pos
,
int
x
,
int
y
,
double
*
distance
,
void
**
cp
)
{};
void
print
(
void
*
pos
,
void
*
node
);
void
save
(
ofstream
&
fp
,
flow_eSaveMode
mode
);
void
open
(
ifstream
&
fp
);
void
draw
(
void
*
pos
,
int
hightlight
,
int
hot
,
void
*
node
);
void
nav_draw
(
void
*
pos
,
int
highlight
,
void
*
node
);
void
draw_inverse
(
void
*
pos
,
int
hot
,
void
*
node
)
{
erase
(
pos
,
hot
,
node
);};
void
erase
(
void
*
pos
,
int
hot
,
void
*
node
);
void
nav_erase
(
void
*
pos
,
void
*
node
);
void
get_borders
(
double
pos_x
,
double
pos_y
,
double
*
x_right
,
double
*
x_left
,
double
*
y_high
,
double
*
y_low
,
void
*
node
);
void
move
(
void
*
pos
,
double
x
,
double
y
,
int
highlight
,
int
hot
);
void
shift
(
void
*
pos
,
double
delta_x
,
double
delta_y
,
int
highlight
,
int
hot
);
int
get_conpoint
(
int
num
,
double
*
x
,
double
*
y
,
flow_eDirection
*
dir
)
{
return
0
;};
flow_eObjectType
type
()
{
return
flow_eObjectType_Image
;};
int
insert_image
(
char
*
imagefile
);
FlowCtx
*
ctx
;
double
width
()
{
return
ur
.
x
-
ll
.
x
;};
double
height
()
{
return
ur
.
y
-
ll
.
y
;};
FlowPoint
ll
;
FlowPoint
ur
;
flow_eDrawType
draw_type
;
int
line_width
;
int
fix_line_width
;
flow_mDisplayLevel
display_level
;
int
fill
;
ImlibData
*
imlib
;
ImlibImage
*
image
;
ImlibImage
*
original_image
;
Pixmap
pixmap
;
Pixmap
nav_pixmap
;
Pixmap
clip_mask
;
Pixmap
nav_clip_mask
;
char
image_filename
[
120
];
int
current_width
;
int
current_height
;
int
current_nav_width
;
int
current_nav_height
;
double
current_zoom_factor
;
};
#endif
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