1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

1
src/Xw/EXTERNLIB Executable file
View File

@@ -0,0 +1 @@
CSF_XwLibs

146
src/Xw/FILES Executable file
View File

@@ -0,0 +1,146 @@
Test.com
Test_deb.com
Xw_Extension.h
Xw_Cextern.hxx
Xw_alloc_color.cxx
Xw_alloc_pixel.cxx
Xw_convert_image.cxx
Xw_def_background_color.cxx
Xw_def_color.cxx
Xw_def_colormap.cxx
Xw_def_font.cxx
Xw_def_fontmap.cxx
Xw_def_highlight_color.cxx
Xw_def_marker.cxx
Xw_def_markmap.cxx
Xw_def_tile.cxx
Xw_def_tilemap.cxx
Xw_def_type.cxx
Xw_def_typemap.cxx
Xw_def_width.cxx
Xw_def_widthmap.cxx
Xw_def_window.cxx
Xw_draw_arc.cxx
Xw_draw_buffer.cxx
Xw_draw_image.cxx
Xw_draw_zoomed_image.cxx
Xw_draw_line.cxx
Xw_draw_marker.cxx
Xw_draw_point.cxx
Xw_draw_poly.cxx
Xw_draw_polyarc.cxx
Xw_draw_polytext.cxx
Xw_draw_segment.cxx
Xw_draw_text.cxx
Xw_erase_area.cxx
Xw_erase_window.cxx
Xw_flush.cxx
Xw_gamma_image.cxx
Xw_get_background_color.cxx
Xw_get_background_image.cxx
Xw_get_background_index.cxx
Xw_get_background_pixel.cxx
Xw_get_color.cxx
Xw_get_color_index.cxx
Xw_get_color_name.cxx
Xw_get_color_pixel.cxx
Xw_get_colormap_info.cxx
Xw_get_colormap_visual.cxx
Xw_get_colormap_xid.cxx
Xw_get_cursor_position.cxx
Xw_get_display_info.cxx
Xw_get_display_visual.cxx
Xw_get_double_buffer.cxx
Xw_get_env.cxx
Xw_get_filename.cxx
Xw_get_font.cxx
Xw_get_font_index.cxx
Xw_get_fontmap_info.cxx
Xw_get_highlight_color.cxx
Xw_get_image.cxx
Xw_get_image_info.cxx
Xw_get_marker_index.cxx
Xw_get_markmap_info.cxx
Xw_get_mmscreen_pixelvalue.cxx
Xw_get_pixel.cxx
Xw_get_pixel_mmscreenvalue.cxx
Xw_get_pixel_screencoord.cxx
Xw_get_pixel_screenvalue.cxx
Xw_get_pixel_windowcoord.cxx
Xw_get_pixel_windowvalue.cxx
Xw_get_rgbpixel.cxx
Xw_get_screen_pixelcoord.cxx
Xw_get_screen_pixelvalue.cxx
Xw_get_screen_size.cxx
Xw_get_text_size.cxx
Xw_get_tilemap_info.cxx
Xw_get_type.cxx
Xw_get_type_index.cxx
Xw_get_typemap_info.cxx
Xw_get_width.cxx
Xw_get_width_index.cxx
Xw_get_widthmap_info.cxx
Xw_get_window_info.cxx
Xw_get_window_pixelcoord.cxx
Xw_get_window_pixelvalue.cxx
Xw_get_window_position.cxx
Xw_get_window_visual.cxx
Xw_isdefine_color.cxx
Xw_isdefine_colormap.cxx
Xw_isdefine_display.cxx
Xw_isdefine_font.cxx
Xw_isdefine_fontmap.cxx
Xw_isdefine_image.cxx
Xw_isdefine_marker.cxx
Xw_isdefine_markmap.cxx
Xw_isdefine_tile.cxx
Xw_isdefine_tilemap.cxx
Xw_isdefine_type.cxx
Xw_isdefine_typemap.cxx
Xw_isdefine_width.cxx
Xw_isdefine_widthmap.cxx
Xw_isdefine_window.cxx
Xw_load_icons.cxx
Xw_load_image.cxx
Xw_load_gif_image.cxx
Xw_load_xwd_image.cxx
Xw_load_bmp_image.cxx
Xw_open_display.cxx
Xw_open_image.cxx
Xw_open_pixmap.cxx
Xw_open_window.cxx
Xw_put_background_image.cxx
Xw_put_pixel.cxx
Xw_put_rgbpixel.cxx
Xw_resize_window.cxx
Xw_restore_area.cxx
Xw_restore_window.cxx
Xw_save_image.cxx
Xw_set_background_index.cxx
Xw_set_colormap.cxx
Xw_set_double_buffer.cxx
Xw_set_event.cxx
Xw_set_extended_text_attrib.cxx
Xw_set_fontmap.cxx
Xw_set_hard_cursor.cxx
Xw_set_internal_event.cxx
Xw_set_line_attrib.cxx
Xw_set_marker_attrib.cxx
Xw_set_markmap.cxx
Xw_set_poly_attrib.cxx
Xw_set_soft_cursor.cxx
Xw_set_text_attrib.cxx
Xw_set_tilemap.cxx
Xw_set_trace.cxx
Xw_set_typemap.cxx
Xw_set_widthmap.cxx
Xw_set_window_ratio.cxx
Xw_set_window_state.cxx
Xw_wait_event.cxx
Xw_zoom_image.cxx
Xw.edl
Xw_CMPLRS.edl
Xw_WOKUMake.edl
EXTERNLIB
Xw_WOKSteps.edl
Xw_calc_points.cxx

3
src/Xw/Test.com Executable file
View File

@@ -0,0 +1,3 @@
#csh
../drv/MEM/$STATION/Test$1

3
src/Xw/Test_deb.com Executable file
View File

@@ -0,0 +1,3 @@
#csh
$DEBUG ../drv/MEM/$STATION/Test$1

142
src/Xw/Xw.cdl Executable file
View File

@@ -0,0 +1,142 @@
--
-- File: Xw.cdl
-- Created: Jeudi 24 JUIN 1993
-- Author: GG
--
---Copyright: MatraDatavision 1993
--
package Xw
---Version:
---Purpose: This package contains the common X graphic interface.
-- Warning: All the interface is described by a set of C routines.
-- All these C routines are stored in the library
-- of this package.
---References:
uses
TCollection,
TShort,
Aspect,
Quantity,
Image,
TColQuantity,
MFT,
TColStd
is
--------------------
-- Category: Classes
--------------------
class Driver;
---Purpose: Creates the X driver.
-- Activates the c routines of the X interface.
---Category: Classes
class Window;
---Purpose: Creates the X Window drawable.
---Category: Classes
class PixMap;
---Purpose: Creates a X pixmap
---Category: Classes
class ColorMap;
---Purpose: Creates the X Colormap
---Category: Classes
class TypeMap;
---Purpose: Creates the X Typemap
---Category: Classes
class WidthMap;
---Purpose: Creates the X Widthmap
---Category: Classes
class FontMap;
---Purpose: Creates the X Fontmap
---Category: Classes
class MarkMap;
---Purpose: Creates the X Markmap
---Category: Classes
class GraphicDevice;
---Purpose: Creates the X Device (Connexion & Visual)
---Category: Classes
class IconBox;
---Purpose: Creates the X Icon Box
---Category: Classes
class TextManager;
---Purpose: Creates a text manager for MFT fonts.
---Category: Classes
-------------------------
-- Category: Enumerations
-------------------------
enumeration WindowQuality is WQ_3DQUALITY,
WQ_PICTUREQUALITY,
WQ_DRAWINGQUALITY,
WQ_SAMEQUALITY,
WQ_TRANSPARENT,
WQ_OVERLAY
end WindowQuality ;
---Purpose: Definition of the Window graphic quality
enumeration TypeOfVisual is TOV_STATICGRAY,
TOV_GRAYSCALE,
TOV_STATICCOLOR,
TOV_PSEUDOCOLOR,
TOV_TRUECOLOR,
TOV_DIRECTCOLOR,
TOV_DEFAULT,
TOV_PREFERRED_PSEUDOCOLOR,
TOV_PREFERRED_TRUECOLOR,
TOV_PREFERRED_OVERLAY,
TOV_OVERLAY
end TypeOfVisual from Xw;
---Purpose: Definition of the visual type
enumeration TypeOfMapping is TOM_HARDRAMP,
TOM_SIMPLERAMP,
TOM_BESTRAMP,
TOM_COLORCUBE,
TOM_READONLY
end TypeOfMapping from Xw;
---Purpose: Definition of the colormap type
---------------------------------
-- Category: Instantiated classes
---------------------------------
class ListOfMFTFonts instantiates
Array1 from TCollection (FontManager from MFT);
class HListOfMFTFonts instantiates
HArray1 from TCollection (FontManager from MFT, ListOfMFTFonts);
-----------------------------
-- Category: Trace management
-----------------------------
SetTrace( TraceLevel,ErrorLevel : Integer ) ;
---Purpose: Global Trace Level for Maintenance Only
---Category: Trace management
TraceLevel returns Integer is private ;
---Purpose: Return current global Trace level .
---Category: Trace management
ErrorLevel returns Integer is private ;
---Purpose: Return current global Error level .
---Category: Trace management
end Xw;

54
src/Xw/Xw.cxx Executable file
View File

@@ -0,0 +1,54 @@
// File Xw.cxx
// Created September 1992
// Author GG
//-Copyright MatraDatavision 1991,1992
//-Version
//-Design
//-Warning
//-References
//-Language C++ 2.1
//-Declarations
// for the class
#include <Xw.ixx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Aliases
//-Global data definitions
//-Local data definitions
static Standard_Integer MyTraceLevel = 0 ;
static Standard_Integer MyErrorLevel = 4 ;
//-Constructors
void Xw::SetTrace(const Standard_Integer TraceLevel,const Standard_Integer ErrorLevel) {
MyTraceLevel = TraceLevel ;
MyErrorLevel = ErrorLevel ;
Xw_set_trace((int)MyTraceLevel,(int)MyErrorLevel) ;
}
Standard_Integer Xw::TraceLevel() {
return MyTraceLevel ;
}
Standard_Integer Xw::ErrorLevel() {
return MyErrorLevel ;
}

10
src/Xw/Xw.edl Executable file
View File

@@ -0,0 +1,10 @@
--
-- File: Xw.edl
-- Author: Jean GAUTIER
-- History: Thu Oct 3 13:25:43 1996 Jean GAUTIER Creation
-- Copyright: Matra Datavision 1996
--
@ifnotdefined ( %Xw_EDL) then
@set %Xw_EDL = "";
@endif;

41
src/Xw/Xw_CMPLRS.edl Executable file
View File

@@ -0,0 +1,41 @@
@ifnotdefined ( %Xw_CMPLRS_EDL) then
@set %Xw_CMPLRS_EDL = "";
@uses "CSF.edl";
@if ( %Station == "wnt" ) then
-- Pas de compile sur WNT
@set %WOKUMake_Steps = "src";
@endif;
@string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " -DITYPE_REF ";
-- @string %CMPLRS_C_Options = %CMPLRS_C_Options " -DHAVE_X11_EXTENSIONS_MULTIBUF_H ";
@if ( %Station == "sun" ) then
@string %CMPLRS_C_Options += %CSF_X11_INCLUDE " -DHAVE_X11_EXTENSIONS_TRANSOLV_H -DHAVE_X11_EXTENSIONS_MULTIBUF_H " ;
@string %CMPLRS_CXX_Options += %CSF_X11_INCLUDE " -DHAVE_X11_EXTENSIONS_TRANSOLV_H -DHAVE_X11_EXTENSIONS_MULTIBUF_H " ;
@endif;
@if ( %Station == "sil" ) then
@string %CMPLRS_C_Options = %CMPLRS_C_Options " -ansi ";
@string %CMPLRS_C_Options += " -DHAVE_X11_EXTENSIONS_READDISPLAY_H ";
@string %CMPLRS_CXX_Options += " -DHAVE_X11_EXTENSIONS_READDISPLAY_H ";
@endif;
@if ( %Station == "ao1" ) then
@string %CMPLRS_C_Options = %CMPLRS_C_Options " -std1";
@endif;
@if ( %Station == "hp" ) then
@string %CMPLRS_C_Options = %CSF_X11_INCLUDE " " %CSF_XMU_INCLUDE %CMPLRS_C_Options ;
@string %CMPLRS_C_Options = %CMPLRS_C_Options " -Ac";
@string %CMPLRS_CXX_Options = %CSF_X11_INCLUDE " " %CSF_XMU_INCLUDE %CMPLRS_CXX_Options ;
@endif;
@string %CMPLRS_C_Options = %CMPLRS_C_Options " -DXW";
--@string %CMPLRS_C_Options = %CMPLRS_C_Options " -DXW -DTRACE";
@string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " -DXW";
--@string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " -DXW -DTRACE";
@endif;

1970
src/Xw/Xw_Cextern.hxx Executable file

File diff suppressed because it is too large Load Diff

300
src/Xw/Xw_ColorMap.cdl Executable file
View File

@@ -0,0 +1,300 @@
--
-- File: Xw_ColorMap.cdl
-- Created: 24/08/93
-- Author: GG
--
---Copyright: MatraDatavision 1993
--
class ColorMap from Xw inherits TShared from MMgt
---Version: 0.0
---Purpose: This class defines a GenericColorMap object.
---Keywords:
---Warning:
---References:
uses
ColorMap from Aspect,
ColorMapEntry from Aspect,
Parameter from Quantity,
Color from Quantity,
NameOfColor from Quantity,
TypeOfVisual from Xw,
TypeOfMapping from Xw,
Handle from Aspect
raises
ColorMapDefinitionError from Aspect,
BadAccess from Aspect
is
Create
returns mutable ColorMap from Xw
is protected;
---Level: Internal
Create (Connexion : CString from Standard ;
Visual : TypeOfVisual from Xw = Xw_TOV_PREFERRED_PSEUDOCOLOR;
Mapping : TypeOfMapping from Xw = Xw_TOM_COLORCUBE;
Ncolors : Integer from Standard = 0;
UseDefault: Boolean from Standard = Standard_True )
returns mutable ColorMap from Xw
---Level: Public
---Purpose: Creates a generic ColorMap with a maximum of
-- unallocated ColorMapEntry.
-- Sets this colormap with the best colorcube in
-- the Default HardWare Colormap.
raises ColorMapDefinitionError from Aspect;
---Error if ColorMap creation failed according
-- to the supported hardware
SetEntry ( me : mutable ;
Index: Integer from Standard;
Red,Green,Blue: Real from Standard)
---Level: Public
---Purpose: Modifies an entry in the color map <me>.
raises BadAccess from Aspect is virtual;
---Purpose: Warning if Index is < 0 or >= MaxColors()
-- or ColorMap is not defined properly
SetEntry ( me : mutable ;
Entry : ColorMapEntry from Aspect)
---Level: Public
---Purpose: Modifies an entry in the color map <me>.
raises BadAccess from Aspect is virtual;
---Purpose: Warning if ColorMap size is exceeded.
-- or ColorMap is not defined properly
-- or ColorMapEntry Index is out of range according
-- to the supported hardware,
-- or the Mapping type of this colormap is READ_ONLY.
SetEntries ( me : mutable ;
Colormap : ColorMap from Aspect )
---Level: Public
---Purpose: Modifies all Entries from the new colormap
raises BadAccess from Aspect is virtual;
---Purpose: Warning if ColorMap size is exceeded.
-- or ColorMap is not defined properly
-- or One of the new ColorMapEntry Index is out of range
-- according to the supported hardware
SetHighlightColor( me : mutable ; aColor : Color from Quantity )
---Level: Public
---Purpose: Sets the Highlight Color for all Windows
-- which use it .
-- Error if Colormap is not defined properly
raises BadAccess from Aspect is virtual;
Destroy( me : mutable ) is virtual;
---Level: Public
---Purpose: Destroies the Colormap
---C++: alias ~
----------------------------
-- Category: Inquire methods
----------------------------
HighlightColor( me )
returns Color from Quantity is virtual;
---Level: Public
---Purpose: Returns the highlight color .
PixelOfColor ( me ; aColor : Color from Quantity )
returns Integer from Standard
---Level: Public
---Purpose: Returns a pixel value of an RGB color given as
-- Quantity_Color, depending of the HardWare and
-- Visual class.
raises BadAccess from Aspect is virtual;
---Error If ColorMap is not defined properly
AllocatesPixelOfColor ( me )
returns Integer from Standard
---Level: Advanced
---Purpose: Returns an allocated pixel of color
-- writable by using the method SetColorOfPixel(..)
-- or -1 if no more pixel must be allocated.
-- Warning: this call take has an effect in PseudoColor model only.
raises BadAccess from Aspect is virtual;
---Error If ColorMap is not defined properly
FreePixelOfColor ( me ; aPixel: Integer from Standard );
---Level: Advanced
---Purpose: Free an allocated pixel of color
-- Warning: this call take has an effect in PseudoColor model only.
SetColorOfPixel ( me ; aPixel: Integer from Standard;
aColor : Color from Quantity )
returns Boolean from Standard
---Level: Advanced
---Purpose: Returns TRUE if the allocated pixel <aPixel>
-- has been updated correctly with the color <aColor>
raises BadAccess from Aspect is virtual;
---Error If ColorMap is not defined properly
Entry ( me ; Index : Integer from Standard;
Red,Green,Blue: out Real from Standard )
returns Integer from Standard
---Level: Public
---Purpose: Returns a pixel value and the components of the
-- corresponding color index.
raises BadAccess from Aspect is virtual;
---Error If ColorMap is not defined properly
-- or Index is < 0 or >= MaxColors().
HighlightPixel (me)
returns Integer from Standard
---Level: Public
---Purpose: Returns the current HighLight pixel value ,
-- depending of the HardWare and Visual class
raises BadAccess from Aspect is virtual;
---Error If ColorMap is not defined properly
MaxColors ( me )
returns Integer from Standard is static;
---Level: Public
---Purpose: Returns the number of available colors in the colormap.
-- or 0 if the colormap is not enabled.
MaxOverlayColors ( me )
returns Integer from Standard is static;
---Level: Public
---Purpose: Returns the number of available colors in the associated
-- overlay colormap if any.
-- or 0 if the overlay colormap is not enabled.
XColorMap ( me )
returns Handle from Aspect
---Level: Public
---Purpose: Returns the Colormap XId of the Colormap
-- depending of the HardWare and Visual class
raises BadAccess from Aspect is static;
---Error If ColorMap is not defined properly
XColorCube ( me ; ColormapID: out Handle from Aspect;
VisualID: out Integer from Standard;
BasePixel: out Integer from Standard;
RedMax: out Integer from Standard;
RedMult: out Integer from Standard;
GreenMax: out Integer from Standard;
GreenMult: out Integer from Standard;
BlueMax: out Integer from Standard;
BlueMult: out Integer from Standard )
returns Boolean from Standard is static;
---Level: Public
---Purpose: Returns TRUE and the color-cube definition of the colormap
-- depending of the HardWare and Visual class
-- or returns FALSE if the colormap dont't have a color-cube defined.
-- Color computation from the colorcube :
-- colorindex = BasePixel +
-- r*RedMax*RedMult + g*GreenMax*GreenMult + b*BlueMax*BlueMult
-- where r,g,b are the red,green,blue components of the color in the
-- range [0.,1.]
XGrayRamp ( me ; ColormapID: out Handle from Aspect;
VisualID: out Integer from Standard;
BasePixel: out Integer from Standard;
GrayMax: out Integer from Standard;
GrayMult: out Integer from Standard)
returns Boolean from Standard is static;
---Level: Public
---Purpose: Returns TRUE and the gray-ramp definition of the colormap
-- depending of the HardWare and Visual class
-- or returns FALSE if the colormap dont't have a gray-ramp defined.
-- Color computation from the grayramp :
-- colorindex = BasePixel + g*GrayMax*GrayMult
-- where g is the gray intensity of the color in the
-- range [0.,1.]
XOverlayColorMap ( me )
returns Handle from Aspect
---Level: Public
---Purpose: Returns the Colormap XId of the associated Overlay Colormap
-- depending of the HardWare and Visual class
raises BadAccess from Aspect is static;
---Error If ColorMap is not defined properly
XVisual ( me )
returns Address from Standard
---Level: Public
---Purpose: Returns the Visual address of the Colormap
-- depending of the HardWare
raises BadAccess from Aspect is static;
---Error If ColorMap is not defined properly
XOverlayVisual ( me )
returns Address from Standard
---Level: Public
---Purpose: Returns the Visual address of the associated Overlay Colormap
-- depending of the HardWare
raises BadAccess from Aspect is static;
---Error If ColorMap is not defined properly
VisualClass ( me )
returns TypeOfVisual from Xw
---Level: Public
---Purpose: Returns the Visual Class of the Colormap
-- depending of the HardWare
raises BadAccess from Aspect is static;
---Error If ColorMap is not defined properly
OverlayVisualClass ( me )
returns TypeOfVisual from Xw
---Level: Public
---Purpose: Returns the Visual Class of the associated Overlay Colormap
-- depending of the HardWare
raises BadAccess from Aspect is static;
---Error If ColorMap is not defined properly
VisualID ( me )
returns Integer from Standard
---Level: Public
---Purpose: Returns the Visual ID of the Colormap
-- depending of the HardWare
raises BadAccess from Aspect is static;
---Error If ColorMap is not defined properly
OverlayVisualID ( me )
returns Integer from Standard
---Level: Public
---Purpose: Returns the Visual ID of the associated Overlay Colormap
-- depending of the HardWare
raises BadAccess from Aspect is static;
---Error If ColorMap is not defined properly
ExtendedColorMap ( me )
returns Address from Standard
is static protected ;
---Level: Public
---Purpose: Returns extended data colormap structure pointer.
---Category: Inquire methods
ExtendedOverlayColorMap ( me )
returns Address from Standard
is static protected ;
---Level: Public
---Purpose: Returns extended data overlay colormap structure pointer.
---Category: Inquire methods
PrintError(myclass) is protected;
---Purpose: Print last error or raise depending of the error gravity.
fields
MyExtendedDisplay : Address from Standard ;
MyExtendedColorMap : Address from Standard ;
MyExtendedOverlayColorMap : Address from Standard ;
MyMapping : TypeOfMapping from Xw ;
friends
class GraphicDevice from Xw,
class Window from Xw
end ColorMap;

398
src/Xw/Xw_ColorMap.cxx Executable file
View File

@@ -0,0 +1,398 @@
#define PRO7349 //GG_11/04/97
// Modification de la methode PixelOfColor
// qui renvoie maintenant un numero de pixel negatif
// lorsqu'il correspond a une couleur approximee.
#define PRO10676 //GG_151297
// Permettre de reserver un index de couleur modifiable
// dans la colormap.
#include <Xw_ColorMap.ixx>
#include <Quantity_Color.hxx>
#include <Standard_ShortReal.hxx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Static data definitions
static XW_STATUS status ;
void Xw_ColorMap::PrintError() {
Standard_CString ErrorMessag ;
Standard_Integer ErrorNumber ;
Standard_Integer ErrorGravity ;
status = XW_SUCCESS ;
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 ) Aspect_ColorMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
Xw_ColorMap::Xw_ColorMap () {
}
Xw_ColorMap::Xw_ColorMap (const Standard_CString Connexion, const Xw_TypeOfVisual Visual, const Xw_TypeOfMapping Mapping, const Standard_Integer Ncolors, const Standard_Boolean UseDefault) {
Aspect_Handle BaseMap = 0 ;
MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ;
if( !MyExtendedDisplay ) PrintError() ;
if( UseDefault ) {
Aspect_Handle *display,root ;
Xw_TypeOfVisual vclass ;
int depth ;
status = Xw_get_display_info (MyExtendedDisplay,
&display,&root,&BaseMap,&vclass,&depth);
if( Visual != vclass ) BaseMap = 0;
}
MyExtendedColorMap = Xw_def_colormap(MyExtendedDisplay,
Visual,Ncolors,BaseMap,Mapping) ;
if( !Xw_isdefine_colormap(MyExtendedColorMap) ) PrintError() ;
MyExtendedOverlayColorMap = Xw_def_colormap(MyExtendedDisplay,
Xw_TOV_OVERLAY,0,0,Xw_TOM_READONLY) ;
SetHighlightColor(Quantity_NOC_WHITESMOKE) ;
MyMapping = Mapping ;
}
void Xw_ColorMap::SetEntry (const Standard_Integer Index,const Standard_Real Red, const Standard_Real Green, const Standard_Real Blue) {
switch ( MyMapping ) {
case Xw_TOM_HARDRAMP:
case Xw_TOM_SIMPLERAMP:
case Xw_TOM_BESTRAMP:
status = Xw_def_color(MyExtendedColorMap,
(int)Index,(float)Red,(float)Green,(float)Blue) ;
if( !status ) PrintError() ;
break ;
case Xw_TOM_COLORCUBE:
case Xw_TOM_READONLY:
Aspect_BadAccess::Raise ("Try to write in a READ ONLY colormap");
}
}
void Xw_ColorMap::SetEntry (const Aspect_ColorMapEntry& Entry) {
Standard_Real r,g,b ;
(Entry.Color()).Values(r,g,b,Quantity_TOC_RGB) ;
SetEntry(Entry.Index(),r,g,b) ;
}
void Xw_ColorMap::SetEntries (const Handle(Aspect_ColorMap)& Colormap) {
Standard_Integer size = Colormap->Size() ;
Standard_Integer i ;
for( i=1 ; i<=size ; i++ ) {
SetEntry(Colormap->Entry(i)) ;
}
}
void Xw_ColorMap::SetHighlightColor ( const Quantity_Color& aColor) {
Standard_Real r,g,b ;
aColor.Values(r,g,b,Quantity_TOC_RGB) ;
status = Xw_def_highlight_color(MyExtendedColorMap,
(float)r,(float)g,(float)b) ;
if( !status ) PrintError() ;
if( MyExtendedOverlayColorMap ) {
status = Xw_def_highlight_color(MyExtendedOverlayColorMap,
(float)r,(float)g,(float)b) ;
if( !status ) PrintError() ;
}
}
void Xw_ColorMap::Destroy() {
if( MyExtendedColorMap ) {
Xw_close_colormap(MyExtendedColorMap) ;
MyExtendedColorMap = NULL ;
}
if( MyExtendedOverlayColorMap ) {
Xw_close_colormap(MyExtendedOverlayColorMap) ;
MyExtendedOverlayColorMap = NULL ;
}
}
Quantity_Color Xw_ColorMap::HighlightColor ( ) const {
float r,g,b ;
status = Xw_get_highlight_color (MyExtendedColorMap,&r,&g,&b);
Standard_Real Red = r;
Standard_Real Green = g;
Standard_Real Blue = b;
return Quantity_Color(Red,Green,Blue,Quantity_TOC_RGB) ;
}
Standard_Integer Xw_ColorMap::HighlightPixel ( ) const {
unsigned long pixel ;
status = Xw_get_highlight_pixel(MyExtendedColorMap,&pixel) ;
if( !status ) PrintError() ;
return (Standard_Integer(pixel)) ;
}
Standard_Integer Xw_ColorMap::PixelOfColor ( const Quantity_Color &aColor ) const {
Standard_Real Red,Green,Blue ;
unsigned long pixel ;
Standard_Integer isapproximate;
aColor.Values(Red,Green,Blue,Quantity_TOC_RGB) ;
#ifdef PRO7349
status = Xw_get_color_pixel(MyExtendedColorMap,
(float)Red,(float)Green,(float)Blue,&pixel,&isapproximate) ;
if( !status ) PrintError() ;
if( isapproximate ) return (-Standard_Integer(pixel));
else return (Standard_Integer(pixel)) ;
#else
status = Xw_get_color_pixel(MyExtendedColorMap,
(float)Red,(float)Green,(float)Blue,&pixel) ;
if( !status ) PrintError() ;
return (Standard_Integer(pixel)) ;
#endif
}
#ifdef PRO10676
Standard_Integer Xw_ColorMap::AllocatesPixelOfColor ( ) const {
unsigned long pixel;
if( Xw_alloc_pixel(MyExtendedColorMap,&pixel) )
return Standard_Integer(pixel);
else {
Xw_print_error();
return -1;
}
}
void Xw_ColorMap::FreePixelOfColor ( const Standard_Integer aPixel ) const {
unsigned long pixel = aPixel;
Xw_free_pixel(MyExtendedColorMap,pixel);
}
Standard_Boolean Xw_ColorMap::SetColorOfPixel ( const Standard_Integer aPixel,
const Quantity_Color &aColor ) const {
Standard_Real Red,Green,Blue ;
aColor.Values(Red,Green,Blue,Quantity_TOC_RGB) ;
Standard_ShortReal r = Red,g = Green,b = Blue;
unsigned long pixel = aPixel;
return Xw_set_pixel(MyExtendedColorMap,pixel,r,g,b);
}
#endif
Standard_Integer Xw_ColorMap::Entry ( const Standard_Integer Index, Standard_Real &Red, Standard_Real &Green, Standard_Real &Blue ) const {
unsigned long pixel = 0 ;
float red,green,blue ;
status = Xw_get_color(MyExtendedColorMap,Index,
&red,&green,&blue,&pixel) ;
if( !status ) PrintError() ;
Red = red; Green = green; Blue = blue;
return (Standard_Integer(pixel)) ;
}
Xw_TypeOfVisual Xw_ColorMap::VisualClass( ) const {
Xw_TypeOfVisual vclass ;
vclass = Xw_get_colormap_visual(MyExtendedColorMap) ;
if( vclass == Xw_TOV_DEFAULT ) PrintError() ;
return (vclass) ;
}
Xw_TypeOfVisual Xw_ColorMap::OverlayVisualClass( ) const {
Xw_TypeOfVisual vclass = Xw_TOV_DEFAULT;
if( MyExtendedOverlayColorMap ) {
vclass = Xw_get_colormap_visual(MyExtendedOverlayColorMap) ;
}
return (vclass) ;
}
Standard_Integer Xw_ColorMap::VisualID( ) const {
Aspect_Handle *VisualInfo ;
Xw_TypeOfVisual VisualClass ;
int MaxColor,BasePixel,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid = 0 ;
status = Xw_get_colormap_info(MyExtendedColorMap,&VisualInfo,
&VisualClass,&visualid,&MaxColor,&BasePixel,
&MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex) ;
if( !status ) Xw_print_error();
return (visualid) ;
}
Standard_Integer Xw_ColorMap::OverlayVisualID( ) const {
Aspect_Handle *VisualInfo ;
Xw_TypeOfVisual VisualClass ;
int MaxColor,BasePixel,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid = 0;
if( MyExtendedOverlayColorMap ) {
status = Xw_get_colormap_info(MyExtendedOverlayColorMap,&VisualInfo,
&VisualClass,&visualid,&MaxColor,&BasePixel,
&MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex) ;
if( !status ) Xw_print_error() ;
}
return (visualid) ;
}
Standard_Integer Xw_ColorMap::MaxColors( ) const {
Aspect_Handle *VisualInfo ;
Xw_TypeOfVisual VisualClass ;
int MaxColor,BasePixel,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid ;
status = Xw_get_colormap_info(MyExtendedColorMap,&VisualInfo,
&VisualClass,&visualid,&MaxColor,&BasePixel,
&MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex) ;
if( status ) {
if( VisualClass == Xw_TOV_TRUECOLOR ) return MaxColor ;
else return MaxUserColor;
} else {
Xw_print_error() ;
return 0 ;
}
}
Standard_Integer Xw_ColorMap::MaxOverlayColors( ) const {
Aspect_Handle *VisualInfo ;
Xw_TypeOfVisual VisualClass ;
int MaxColor,BasePixel,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid ;
status = XW_ERROR;
if( MyExtendedOverlayColorMap ) {
status = Xw_get_colormap_info(MyExtendedOverlayColorMap,&VisualInfo,
&VisualClass,&visualid,&MaxColor,&BasePixel,
&MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex) ;
if( !status ) Xw_print_error() ;
}
return (status) ? MaxUserColor : 0;
}
Standard_Address Xw_ColorMap::XVisual( ) const {
Aspect_Handle *VisualInfo ;
Xw_TypeOfVisual VisualClass ;
int MaxColor,BasePixel,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid ;
status = Xw_get_colormap_info(MyExtendedColorMap,&VisualInfo,
&VisualClass,&visualid,&MaxColor,&BasePixel,
&MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex) ;
if( !status ) PrintError() ;
return (VisualInfo) ;
}
Standard_Address Xw_ColorMap::XOverlayVisual( ) const {
Aspect_Handle *VisualInfo = NULL ;
Xw_TypeOfVisual VisualClass ;
int MaxColor,BasePixel,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid ;
status = XW_ERROR;
if( MyExtendedOverlayColorMap ) {
status = Xw_get_colormap_info(MyExtendedOverlayColorMap,&VisualInfo,
&VisualClass,&visualid,&MaxColor,&BasePixel,
&MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex) ;
if( !status ) Xw_print_error() ;
}
return (status) ? VisualInfo : NULL ;
}
Aspect_Handle Xw_ColorMap::XColorMap( ) const {
Aspect_Handle colormap ;
colormap = Xw_get_colormap_xid(MyExtendedColorMap) ;
if( !colormap ) PrintError() ;
return (colormap) ;
}
Aspect_Handle Xw_ColorMap::XOverlayColorMap( ) const {
Aspect_Handle colormap = 0;
if( MyExtendedOverlayColorMap ) {
colormap = Xw_get_colormap_xid(MyExtendedOverlayColorMap) ;
}
return (colormap);
}
Standard_Address Xw_ColorMap::ExtendedColorMap () const {
return (MyExtendedColorMap);
}
Standard_Address Xw_ColorMap::ExtendedOverlayColorMap () const {
return (MyExtendedOverlayColorMap);
}
Standard_Boolean Xw_ColorMap::XColorCube ( Aspect_Handle &ColormapID,
Standard_Integer &VisualID,
Standard_Integer &BasePixel,
Standard_Integer &RedMax,
Standard_Integer &RedMult,
Standard_Integer &GreenMax,
Standard_Integer &GreenMult,
Standard_Integer &BlueMax,
Standard_Integer &BlueMult ) const
{
status = Xw_get_colormap_colorcube(MyExtendedColorMap,
&ColormapID,&VisualID,&BasePixel,
&RedMax,&RedMult,&GreenMax,&GreenMult,&BlueMax,&BlueMult);
return status;
}
Standard_Boolean Xw_ColorMap::XGrayRamp ( Aspect_Handle &ColormapID,
Standard_Integer &VisualID,
Standard_Integer &BasePixel,
Standard_Integer &GrayMax,
Standard_Integer &GrayMult) const
{
status = Xw_get_colormap_grayramp(MyExtendedColorMap,
&ColormapID,&VisualID,&BasePixel,&GrayMax,&GrayMult);
return status;
}

843
src/Xw/Xw_Driver.cdl Executable file
View File

@@ -0,0 +1,843 @@
-- File: Xw_Driver.cdl
-- Created: Thu Jul 1 09:14:42 1993
-- Author: Gerard GRAS
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class Driver from Xw inherits WindowDriver from Aspect
---Version:
---Purpose: This class defines a X window Driver.
-- Warning: A Driver is associated with one window and lets you
-- draw any primitives with any attributes you choose
-- inside that window. All Values and coordinates are
-- defined in Device Window Unit (DWU) space, which is
-- the Normalized Floating Pixel space limited by the size
-- of the window. The Maps Driver must be initialized
-- with Aspect_Driver::SetXXXXMap(aMap) where XXXX
-- may correspond to Color, Mark, Type, Width and Font.
---References:
uses
ExtendedString from TCollection,
Length from Quantity,
Factor from Quantity,
Ratio from Quantity,
PlaneAngle from Quantity,
Array1OfShortReal from TShort,
TypeOfResize from Aspect,
TypeOfDrawMode from Aspect,
TypeOfText from Aspect,
TypeOfPrimitive from Aspect,
ColorMap from Aspect,
TypeMap from Aspect,
WidthMap from Aspect,
FontMap from Aspect,
MarkMap from Aspect,
TypeOfVisual from Xw,
Window from Xw,
HArray1OfInteger from TColStd,
HListOfMFTFonts from Xw,
HArray1OfShortReal from TShort,
TextManager from Xw
raises
DriverDefinitionError from Aspect,
DriverError from Aspect
is
-------------------------
-- Category: Constructors
-------------------------
Create (aWindow: Window from Xw)
returns mutable Driver from Xw
raises DriverDefinitionError from Aspect;
---Level: Public
---Purpose: Creates the X Window Driver associated to the X window
-- <aWindow>.
-- Default values :
-- - DrawMode : TODM_REPLACE
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
BeginDraw (me: mutable;
DoubleBuffer: Boolean = Standard_True;
aRetainBuffer: Integer = 0)
---Level: Public
---Purpose: Begin graphics and drawn directly to the Window or Pixmap if
--<aRetainBuffer> is 0 or in the retain buffer if > 0.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not open.
-- call BufferIsOpen() method before.
---Category: Methods to modify the class definition
EndDraw (me: mutable; Synchronize: Boolean = Standard_False) is virtual;
---Level: Public
---Purpose: Called by the method Graphic2d_View::Update, this
-- method manages the buffer flushing and Wait after up to date
-- display when Synchronize is TRUE.
---Category: Methods to modify the class definition
ResizeSpace (me : mutable)
returns TypeOfResize from Aspect
---Level: Public
---Purpose: Resizes the WorkSpace depending of the Window size
-- MUST be call after a Resize or Move WindowDriver Event
-- Returns the TypeOfResize gravity mode .
-- Trigger: Raises if the type of resizing is unknown.
raises DriverError from Aspect is virtual;
---Category: Methods to modify the class definition
---------------------------------------------
-- Category: Methods to define the attributes
---------------------------------------------
InitializeColorMap (me: mutable;
Colormap: ColorMap from Aspect)
---Level: Public
---Purpose: Defines the color map.
-- Level: Public
-- Trigger: Raises if the definition failed.
raises DriverError from Aspect is virtual protected;
---Category: Methods to define the color indices.
InitializeTypeMap (me: mutable;
Typemap: TypeMap from Aspect)
---Purpose: Defines the line type map.
-- Level: Public
-- Trigger: Raises if the definition failed.
raises DriverError from Aspect is virtual protected;
---Category: Methods to define the type of line indices.
InitializeWidthMap (me: mutable;
Widthmap: WidthMap from Aspect)
---Purpose: Defines the width line map.
-- Level: Public
-- Trigger: Raises if the definition failed.
raises DriverError from Aspect is virtual protected;
---Category: Methods to define the width of line indices.
InitializeFontMap (me: mutable;
Fontmap: FontMap from Aspect)
---Purpose: Defines the font map.
-- Level: Public
-- Trigger: Raises if the definition failed.
raises DriverError from Aspect is virtual protected;
---Category: Methods to define the font indices.
InitializeMarkMap (me: mutable;
Markmap: MarkMap from Aspect)
---Purpose: Defines the mark map.
-- Level: Public
-- Trigger: Raises if the definition failed.
raises DriverError from Aspect is virtual protected;
---Category: Methods to define the marker indices.
---------------------------------------------
-- Category: Methods to set the attributes
---------------------------------------------
SetDrawMode (me:mutable; aMode: TypeOfDrawMode from Aspect) is virtual;
---Level: Advanced
---Purpose: Defines the draw mode for all primitives drawing.
-- TypeOfDrawMode is
-- TODM_REPLACE
-- TODM_ERASE
-- TODM_XOR
-- TODM_XORLIGHT
SetLineAttrib (me: mutable;
ColorIndex: Integer from Standard;
TypeIndex: Integer from Standard;
WidthIndex: Integer from Standard)
---Level: Public
---Purpose: Sets the line attributes.
-- Category: Methods to set the line attributes
-- Trigger: Raises if one of the index is out of range.
raises DriverError from Aspect is virtual;
SetTextAttrib (me: mutable;
ColorIndex: Integer from Standard;
FontIndex: Integer from Standard)
---Level: Public
---Purpose: Sets the text attributes.
-- Category: Methods to set the text attributes
-- Trigger: Raises if one of the index is out of range.
raises DriverError from Aspect is virtual;
SetTextAttrib (me: mutable;
ColorIndex: Integer from Standard;
FontIndex: Integer from Standard;
aSlant: PlaneAngle from Quantity;
aHScale: Factor from Quantity;
aWScale: Factor from Quantity;
isUnderlined: Boolean from Standard = Standard_False)
---Level: Public
---Purpose: Sets the Extended text attributes.
-- Category: Methods to set the text attributes
-- Trigger: Raises if one of the index is out of range.
raises DriverError from Aspect is virtual;
SetPolyAttrib (me: mutable;
ColorIndex: Integer from Standard;
TileIndex: Integer from Standard;
DrawEdgeFlag: Boolean from Standard = Standard_False)
---Level: Public
---Purpose: Sets the polygon attributes.
-- Warning:
-- <ColorIndex> is the background poly color index.
-- <TileIndex> is the background poly fill rule index.
-- If <DrawEdgeFlag> is TRUE the edge of the poly is drawn with the
-- current line attributes.
-- Category: Methods to set the poly attributes
-- Trigger: Raises if one of the index is out of range.
raises DriverError from Aspect is virtual;
SetMarkerAttrib (me: mutable;
ColorIndex: Integer from Standard;
EdgeWidthIndex: Integer from Standard;
FillMarker: Boolean from Standard = Standard_False)
---Level: Public
---Purpose: Sets the marker attributes.
-- Warning:
-- <ColorIndex> is the edge or fill marker color index.
-- <EdgeWidthIndex> is the edge marker thickness index.
-- If <FillMarker> is TRUE the marker is filled on the first set
-- of consecutive drawn points.
-- Category: Methods to set the marker attributes
-- Trigger: Raises if one of the index is out of range.
raises DriverError from Aspect is virtual;
-----------------------------------------
-- Category: Methods to manage the images
-----------------------------------------
IsKnownImage (me: mutable; anImage: Transient from Standard)
returns Boolean from Standard is virtual;
---Level: Public
---Purpose: Returns Standard_True if the associated driver
-- have stored the image and Standard_False if not.
---Category: Methods to manage the images
SizeOfImageFile (me; anImageFile: CString from Standard;
aWidth,aHeight: out Integer from Standard)
returns Boolean from Standard is virtual;
---Level: Public
---Purpose: Returns Standard_True and the Image Size in PIXEL
-- if the image file exist and can be computed by the driver,
-- NOTE that only XWD image file type are recognized today.
---Category: Methods to manage the images
ClearImage (me: mutable; anImageId: Transient from Standard) is virtual;
---Level: Public
---Purpose: Clears the image in <me>.
---Category: Methods to manage the images
ClearImageFile (me: mutable; anImageFile: CString from Standard)
is virtual;
---Level: Public
---Purpose: Clears the image associated with the image file .
---Category: Methods to manage the images
DrawImage (me: mutable; anImageId: Transient from Standard;
aX, aY: ShortReal from Standard)
---Level: Public
---Purpose: Draws the image in <me>.
-- <aX>, <aY> is the center of the image.
-- Image center must be defined in DWU space.
raises DriverError from Aspect is virtual;
---Trigger: If the anImageId is not found
---Category: Methods to manage the images
DrawImageFile (me: mutable; anImageFile: CString from Standard;
aX, aY: ShortReal from Standard;
aScale: Factor from Quantity = 1.0)
---Level: Public
---Purpose: Draws the image file in <me>.
-- <aX>, <aY> is the center of the image.
-- <aScale> the scale factor which is apply on this image
-- Image center must be defined in DWU space.
-- anImageFile must be defined with the full pathname
-- of the form /..../xxxxx.ext or $DIR/xxxxxx.ext
-- with DIR defined in a setenv variable.
-- xxxxxx the image file name.
-- ext the image file extension.
raises DriverError from Aspect is virtual;
---Trigger: If the anImageFile is not found
-- or the Image type is not an XWD.
---Category: Methods to manage the images
FillAndDrawImage (me: mutable; anImageId: Transient from Standard;
aX, aY: ShortReal from Standard;
Width, Height: Integer from Standard;
anArrayOfPixels: Address from Standard)
---Level: Public
---Purpose: Stores a complete image and draws it in <me>.
-- Image size must be defined in DWU space>
-- Category: Methods to manage the images
-- Trigger: Raises if the creation of the image failed.
raises DriverError from Aspect is virtual;
FillAndDrawImage (me: mutable; anImageId: Transient from Standard;
aX, aY: ShortReal from Standard;
anIndexOfLine, Width, Height: Integer from Standard;
anArrayOfPixels: Address from Standard)
---Level: Advanced
---Purpose: Stores a line of an image and draws it in <me>.
-- Warning: 0<= anIndexOfLine < aHeight
-- anIndexOfLine = 0 must be the first call
-- Category: Methods to manage the images
-- Trigger: Raises if the creation of the image failed.
raises DriverError from Aspect is virtual;
---------------------------------------
-- Category: Methods to draw primitives
---------------------------------------
DrawPolyline (me : mutable;
ListX: Array1OfShortReal from TShort;
ListY: Array1OfShortReal from TShort)
---Level: Public
---Purpose: Draws the polyline depending of SetLineAttrib() attributes.
-- Warning: Coordinates must be defined in DWU space.
-- Trigger: Raises if Polyline has too many points (> 1024)
-- Raises if the length of <ListX> is not equal to
-- the length of <ListY>.
raises DriverError from Aspect is virtual;
---Category: Methods to draw primitives
DrawPolygon (me : mutable;
ListX: Array1OfShortReal from TShort;
ListY: Array1OfShortReal from TShort)
---Level: Public
---Purpose: Draws the polygone depending of SetPolyAttrib() attributes.
-- Warning: Coordinates must be defined in DWU space.
-- Trigger: Raises if Polygone has too many points (> 1024)
-- Raises if the length of <ListX> is not equal to
-- the length of <ListY>.
raises DriverError from Aspect is virtual;
---Category: Methods to draw primitives
DrawSegment (me : mutable;
X1, Y1: ShortReal from Standard;
X2, Y2: ShortReal from Standard)
---Level: Public
---Purpose: Draws the segment depending of SetLineAttrib() attributes.
-- Warning: Coordinates must be defined in DWU space.
raises DriverError from Aspect is virtual;
---Category: Methods to draw primitives
DrawText (me : mutable;
Text: ExtendedString from TCollection;
Xpos, Ypos: ShortReal from Standard;
anAngle: ShortReal from Standard = 0.0;
aType: TypeOfText from Aspect = Aspect_TOT_SOLID)
---Level: Public
---Purpose: Draws the text depending of SetTextAttrib() attributes.
-- Category: Methods to draw primitives
-- Warning: Coordinates must be defined in DWU space.
-- Trigger: Raises if Text has too many chars (> 1024)
raises DriverError from Aspect is virtual;
DrawText (me : mutable;
Text: CString from Standard;
Xpos, Ypos: ShortReal from Standard;
anAngle: ShortReal from Standard = 0.0;
aType: TypeOfText from Aspect = Aspect_TOT_SOLID)
---Level: Public
---Purpose: Draws the text depending of SetTextAttrib() attributes.
-- Category: Methods to draw primitives
-- Warning: Coordinates must be defined in DWU space.
-- Angle must be defined in RADIAN.
-- Trigger: Raises if Text has too many chars (> 1024)
raises DriverError from Aspect is virtual;
DrawPolyText (me : mutable;
aText: ExtendedString from TCollection;
Xpos: ShortReal from Standard;
Ypos: ShortReal from Standard;
aMarge: Ratio from Quantity = 0.1;
anAngle: ShortReal from Standard = 0.0;
aType: TypeOfText from Aspect = Aspect_TOT_SOLID)
---Level: Public
---Purpose: Draws an framed text depending of the
-- SetTextAttrib() and SetPolyAttrib() attributes.
-- Warning: Coordinates must be defined in DWU space.
-- <aMarge> defines the ratio of the space between the
-- polygon borders and the bounding box of the text and
-- depending of the height of the text.
raises DriverError from Aspect is virtual;
---Trigger: Raises if Text has too many chars (> 1024)
-- or <aMarge is < 0 or > 1.
---Category: Methods to draw primitives
DrawPolyText (me : mutable;
aText: CString from Standard;
Xpos: ShortReal from Standard;
Ypos: ShortReal from Standard;
aMarge: Ratio from Quantity = 0.1;
anAngle: ShortReal from Standard = 0.0;
aType: TypeOfText from Aspect = Aspect_TOT_SOLID)
---Level: Public
---Purpose: Draws an framed text depending of the
-- SetTextAttrib() and SetPolyAttrib() attributes.
-- Warning: Coordinates must be defined in DWU space.
-- <aMarge> defines the ratio of the space between the
-- polygon borders and the bounding box of the text and
-- depending of the height of the text.
raises DriverError from Aspect is virtual;
---Trigger: Raises if Text has too many chars (> 1024)
-- or <aMarge is < 0 or > 1.
---Category: Methods to draw primitives
DrawPoint (me : mutable; X, Y: ShortReal from Standard)
---Level: Public
---Purpose: Draws a 1 PIXEL point depending of the SetMarkerAttrib()
--color attribute or add a point depending of the incremental
--BeginXxxxxx() primitive used.
raises DriverError from Aspect is virtual;
---Category: Methods to draw primitives
DrawMarker (me : mutable;
aMarker: Integer from Standard;
Xpos, Ypos: ShortReal from Standard;
Width,Height: ShortReal from Standard;
Angle: ShortReal from Standard = 0.0)
---Level: Public
---Purpose: Draws the previously defined marker depending of
-- the SetMarkerAttrib() attributes.
-- Warning: Coordinates and sizes must be defined in DWU space.
-- Angle must be defined in RADIAN.
-- A one pixel marker is drawn when aMarker index is undefined.
raises DriverError from Aspect is virtual;
---Category: Methods to draw primitives
DrawArc (me : mutable; X,Y : ShortReal from Standard;
aXradius,aYradius : ShortReal from Standard;
aStartAngle: ShortReal from Standard = 0.0;
anOpenAngle: ShortReal from Standard = 6.283185)
returns Boolean
---Level: Public
---Purpose: Draws an Ellipsoid arc of center <X,Y> and Radius
-- <aXradius,aYradius> of relative angle <anOpenAngle> from
-- the base angle <aStartAngle>
-- Warning: Returns FALSE if the hardware can't drawing this
-- primitive properly,application must to simulate it.
raises DriverError from Aspect is virtual;
---Trigger: Raises if one of <aXradius,aYradius> is <= 0.
DrawPolyArc (me : mutable; X,Y : ShortReal from Standard;
anXradius,anYradius : ShortReal from Standard;
aStartAngle: ShortReal from Standard = 0.0;
anOpenAngle: ShortReal from Standard = 6.283185)
returns Boolean
---Level: Public
---Purpose: Draws an filled Ellipsoid arc of center <X,Y> and Radius
-- <anXradius,anYradius> of relative angle <anOpenAngle> from
-- the base angle <aStartAngle> and depending of the SetPolyAttrib()
-- attributes.
-- Warning: Returns FALSE if the hardware can't drawing this
-- primitive properly,application must to simulate it.
raises DriverError from Aspect is virtual;
---Trigger: Raises if one of <aXradius,aYradius> is <= 0.
BeginPolyline (me : mutable; aNumber : Integer) is virtual;
---Level: Public
---Purpose: Begin a polyline primitive of <aNumber> of points .
-- Warning: Points must be added by the DrawPoint() method.
BeginPolygon (me : mutable; aNumber : Integer) is virtual;
---Level: Public
---Purpose: Begin a polygon primitive of <aNumber> of points .
-- Warning: Points must be added by the DrawPoint() method.
BeginSegments (me : mutable) is virtual;
---Level: Public
---Purpose: Begin a set of segments .
-- Warning: Segments must be added by DrawSegment() method.
BeginArcs (me : mutable) is virtual;
---Level: Public
---Purpose: Begin a set of circles or ellips .
-- Warning: Arcs must be added by the DrawArc() method.
BeginPolyArcs (me : mutable) is virtual;
---Level: Public
---Purpose: Begin a set of polygon circles or ellips .
-- Warning: Arcs must be added by the DrawPolyArc() method.
BeginMarkers (me : mutable) is virtual;
---Level: Public
---Purpose: Begin a set of markers .
-- Warning: Markers must be added by the DrawMarker() method.
BeginPoints (me : mutable) is virtual;
---Level: Public
---Purpose: Begin a set of points .
-- Warning: Points must be added by the DrawPoint() method.
ClosePrimitive (me : mutable)
---Level: Public
---Purpose: Close the last Begining primitive
raises DriverError from Aspect is virtual;
---Trigger: Raises if no primitive have been opened by BeginXxxxxx().
---------------------------------------
-- Category: Methods to Manage buffers
---------------------------------------
OpenBuffer (me : mutable; aRetainBuffer: Integer;
aPivotX: ShortReal = 0.0;
aPivotY: ShortReal = 0.0;
aWidthIndex: Integer = 0;
aColorIndex: Integer = 0;
aFontIndex: Integer = 0;
aDrawMode: TypeOfDrawMode = Aspect_TODM_REPLACE)
returns Boolean is virtual;
---Purpose: Allocate the retain buffer <aRetainBuffer> ,
-- Defines the DWU coordinates of the pivot point for all primitives
-- contains inside.
-- Defines the buffer color, line width and font index :
-- the default color is the highlight color of the colormap.
-- the default font is the default system font of the fontmap.
-- The other attributes are fixed :
-- line type is Solid,
-- line width is 1 Pixel,
-- polygon fill mode is Solid,
-- Warning: The number of allocated buffers is limited,it's
-- recommended to close unused buffers some time!
-- The TypeOfDrawMode REPLACE is enabled only if the
-- background drawing has been drawn with the DoubleBuffer
-- flag set to ENABLE at the last BeginDraw time.
-- The TypeOfDrawMode XOR is enabled in any case.
-- The other TypeOfDrawMode are not authorized.
-- Returns TRUE if the buffer is allocated and enabled for drawing.
CloseBuffer (me; aRetainBuffer: Integer)
---Purpose: Clear & Deallocate the retain buffer <aRetainBuffer>.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
ClearBuffer (me; aRetainBuffer: Integer)
---Purpose: Erase & Clear ALL primitives retains in the buffer <aRetainBuffer>.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
DrawBuffer (me; aRetainBuffer: Integer)
---Purpose: Draw ALL primitives retains in the buffer <aRetainBuffer>.
-- Warning: Note that the aspect of a retain buffer drawing is mono-colored
-- with the current buffer attributes and
-- depending of the DoubleBuffer state flag at the BeginDraw() buffer time,
-- when DB is TRUE,an XOR method is use for drawing and erasing buffers in the
-- same way.In this case,some color side effect can occurs depending of the
-- traversal primitive colors and the supported hardware.
-- when DB is FALSE and the background drawing has been generated with
-- DB at TRUE,no color side effect occurs because the DB is used for restoring
-- the drawing context at EraseBuffer() time,this is more powerfull for the
-- drawing quality excepted for large buffers (flicking) .
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
EraseBuffer (me; aRetainBuffer: Integer)
---Purpose: Erase ALL primitives retains in the buffer <aRetainBuffer>.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
MoveBuffer (me; aRetainBuffer: Integer;
aPivotX: ShortReal = 0.0;
aPivotY: ShortReal = 0.0)
---Purpose: Erase , Translate and reDraw ALL primitives retains in the buffer
--<aRetainBuffer>.
--<aPivotX,aPivotY> are the new DWU attached point absolute coordinates
--of the buffer pivot point.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
ScaleBuffer (me; aRetainBuffer: Integer; aScaleX: Factor = 1.0;
aScaleY: Factor = 1.0)
---Purpose: Erase , Scale the buffer from the Pivot point and reDraw ALL primitives
--retains in the buffer <aRetainBuffer>.
-- The transformation is relative since the creation time of the buffer.
--<aScaleX,aScaleY> are the relative scale factors apply on the two axis.
-- Warning: Note that the scalling of some primitives can provided some bad
--smoothing side effect (i.e: Circles,...)
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened or
--one of <aScale> factor is <= 0.
-- call BufferIsOpen() method before.
RotateBuffer (me; aRetainBuffer: Integer; anAngle: PlaneAngle = 0.0)
---Purpose: Erase , Rotate the buffer from the Pivot point and reDraw ALL primitives
-- retains in the buffer <aRetainBuffer>.
-- The transformation is relative since the creation time of the buffer.
-- <anAngle> is the relative counter-clockwise rotation angle from the
-- Horizontal axis.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
----------------------------
-- Category: Inquire methods
----------------------------
WorkSpace (me; Width, Heigth: out Length from Quantity) is virtual;
---Level: Public
---Purpose: Returns the Available WorkSpace in DWU coordinates
-- Category: Inquire methods
TextSize (me; aText: ExtendedString from TCollection;
aWidth, aHeight: out ShortReal from Standard;
aFontIndex: Integer from Standard = -1)
raises DriverError from Aspect is virtual;
---Level: Public
---Purpose: Returns the TEXT size in DWU space depending
-- of the required FontIndex if aFontIndex is >= 0
-- or the current FontIndex if < 0 (default).
---Category: Inquire methods
TextSize (me; aText: ExtendedString from TCollection;
aWidth, aHeight, anXoffset, anYoffset: out ShortReal from Standard;
aFontIndex: Integer from Standard = -1)
raises DriverError from Aspect is virtual;
---Level: Public
---Purpose: Returns the extended TEXT size and offsets
-- in DWU space depending
-- of the required FontIndex if aFontIndex is >= 0
-- or the current FontIndex if < 0 (default).
-- NOTE that the text offsets defines the relative position of the
-- of the text string origin from the lower left corner of the text
-- boundary limits.
---Category: Inquire methods
TextSize (me; aText: CString from Standard;
aWidth, aHeight, anXoffset, anYoffset: out ShortReal from Standard;
aFontIndex: Integer from Standard = -1)
raises DriverError from Aspect is virtual;
---Level: Public
---Purpose: Returns the ascii TEXT size and offsets
-- in DWU space depending
-- of the required FontIndex if aFontIndex is >= 0
-- or the current FontIndex if < 0 (default).
-- NOTE that the text offsets defines the relative position of the
-- of the text string origin from the lower left corner of the text
-- boundary limits.
---Category: Inquire methods
FontSize (me; aSlant: out PlaneAngle from Quantity;
aSize,aBheight: out ShortReal from Standard;
aFontIndex: Integer from Standard = -1)
returns CString from Standard
---Trigger: Raises if font is not defined.
raises DriverError from Aspect is virtual;
---Level: Public
---Purpose: Returns the font string,slant,size and
-- baseline height in DWU space depending
-- of the required FontIndex if aFontIndex is >= 0
-- or the current FontIndex if < 0 (default).
---Category: Inquire methods
Convert (me; PV: Integer from Standard)
returns Length from Quantity is virtual;
---Level: Public
---Purpose: Returns the DWU value depending of
-- the PIXEL value.
---Category: Inquire methods
Convert (me; DV: Length from Quantity)
returns Integer from Standard is virtual;
---Level: Public
---Purpose: Returns the PIXEL value depending of
-- the DWU value.
---Category: Inquire methods
Convert (me; PX, PY: Integer from Standard;
DX, DY: out Length from Quantity) is virtual;
---Level: Public
---Purpose: Returns the DWU position depending of
-- the PIXEL position .
---Category: Inquire methods
Convert (me; DX, DY: Length from Quantity;
PX, PY: out Integer from Standard) is virtual;
---Level: Public
---Purpose: Returns the PIXEL position depending of
-- the DWU position .
---Category: Inquire methods
BufferIsOpen(me; aRetainBuffer : Integer) returns Boolean is virtual;
---Purpose: Returns TRUE if the retain buffer <aRetainBuffer> is enabled
--for drawing.
BufferIsEmpty(me; aRetainBuffer : Integer) returns Boolean is virtual;
---Purpose: Returns TRUE if the retain buffer has not been opened or empty.
--- Returns FALSE if a lot of primitives have been stored inside
-- because a BeginDraw(..,<aRetainBuffer>) has been done previously.
BufferIsDrawn(me; aRetainBuffer : Integer) returns Boolean is virtual;
---Purpose: Returns TRUE if the retain buffer s actually displayed at screen.
AngleOfBuffer(me; aRetainBuffer : Integer; anAngle: out PlaneAngle)
---Purpose: Returns the current buffer rotate angle from the X axis.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
ScaleOfBuffer(me; aRetainBuffer : Integer; aScaleX,aScaleY: out Factor)
---Purpose: Returns the current buffer scale factors.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
PositionOfBuffer(me; aRetainBuffer : Integer; aPivotX,aPivotY: out ShortReal )
---Purpose: Returns the current buffer position.
raises DriverError from Aspect is virtual;
---Trigger: Raises if the retain buffer is not opened.
-- call BufferIsOpen() method before.
ColorBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard)
is virtual;
---Level: Advanced
---Purpose:
-- Returns the min and max driver virtual color indexs.
---Category: Inquire methods
LocalColorIndex(me; anIndex : Integer from Standard)
returns Integer from Standard is virtual;
---Level: Advanced
---Purpose:
-- Returns the local colormap hardware index from a virtual driver color
-- index or returns -1 if the index is not defined.
---Category: Inquire methods
FontBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard)
is virtual;
---Level: Advanced
---Purpose:
-- Returns the min and max driver virtual font indexs.
---Category: Inquire methods
LocalFontIndex(me; anIndex : Integer from Standard)
returns Integer from Standard is virtual;
---Level: Advanced
---Purpose:
-- Returns the associated fontmap hardware index from a virtual driver font
-- index or returns -1 if the index is not defined.
---Category: Inquire methods
TypeBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard)
is virtual;
---Level: Advanced
---Purpose:
-- Returns the min and max driver virtual type indexs.
---Category: Inquire methods
LocalTypeIndex(me; anIndex : Integer from Standard)
returns Integer from Standard is virtual;
---Level: Advanced
---Purpose:
-- Returns the associated typemap hardware index from a virtual driver type
-- index or returns -1 if the index is not defined.
---Category: Inquire methods
WidthBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard)
is virtual;
---Level: Advanced
---Purpose:
-- Returns the min and max driver virtual width indexs.
---Category: Inquire methods
LocalWidthIndex(me; anIndex : Integer from Standard)
returns Integer from Standard is virtual;
---Level: Advanced
---Purpose:
-- Returns the associated widthmap hardware index from a virtual driver width
-- index or returns -1 if the index is not defined.
---Category: Inquire methods
MarkBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard)
is virtual;
---Level: Advanced
---Purpose:
-- Returns the min and max driver virtual marker indexs.
---Category: Inquire methods
LocalMarkIndex(me; anIndex : Integer from Standard)
returns Integer from Standard is virtual;
---Level: Advanced
---Purpose:
-- Returns the local markmap hardware index from a virtual driver marker -- index or returns -1 if the index is not defined.
---Category: Inquire methods
----------------------------
-- Category: Private methods
----------------------------
PrintError(myclass) is protected;
---Purpose: Print last error or raise depending of the error gravity.
DrawRectangle(me; Xpos,Ypos,Angle,Xoffset,Yoffset,Width,Height:
ShortReal from Standard) is private;
---Purpose: Draw an oriented rectangle
FillRectangle(me; Xpos,Ypos,Angle,Xoffset,Yoffset,Width,Height:
ShortReal from Standard) is private;
---Purpose: Draw an oriented fill rectangle
fields
MyVisualClass: TypeOfVisual from Xw is protected;
MyExtendedDrawable: Address from Standard is protected;
MyExtendedColorMap: Address from Standard is protected;
MyExtendedTypeMap: Address from Standard is protected;
MyExtendedWidthMap: Address from Standard is protected;
MyExtendedFontMap: Address from Standard is protected;
MyExtendedMarkMap: Address from Standard is protected;
MyImage: Address from Standard is protected;
MyLineColor: Integer from Standard is protected;
MyLineType: Integer from Standard is protected;
MyLineWidth: Integer from Standard is protected;
MyPolyColor: Integer from Standard is protected;
MyPolyType: Integer from Standard is protected;
MyPolyTile: Integer from Standard is protected;
MyTextColor: Integer from Standard is protected;
MyTextFont: Integer from Standard is protected;
MyTextType: Integer from Standard is protected;
MyTextHScale: Real from Standard is protected;
MyTextWScale: Real from Standard is protected;
MyTextHSize: Real from Standard is protected;
MyTextWSize: Real from Standard is protected;
MyTextSlant: Real from Standard is protected;
MyTextMinHeight: Real from Standard is protected;
MyTextIsUnderlined: Boolean from Standard is protected;
MyMarkerColor: Integer from Standard is protected;
MyMarkerType: Boolean from Standard is protected;
MyMarkerWidth: Integer from Standard is protected;
MyColorIndexs: HArray1OfInteger from TColStd is protected;
MyTypeIndexs: HArray1OfInteger from TColStd is protected;
MyWidthIndexs: HArray1OfInteger from TColStd is protected;
MyFontIndexs: HArray1OfInteger from TColStd is protected;
MyMarkerIndexs: HArray1OfInteger from TColStd is protected;
MyPrimitiveType: TypeOfPrimitive from Aspect is protected;
MyMFTFonts: HListOfMFTFonts from Xw is protected;
MyMFTSizes: HArray1OfShortReal from TShort is protected;
MyTextManager: TextManager from Xw is protected;
end Driver from Xw;

1890
src/Xw/Xw_Driver.cxx Executable file

File diff suppressed because it is too large Load Diff

939
src/Xw/Xw_Extension.h Executable file
View File

@@ -0,0 +1,939 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#ifndef TRACE
//#define TRACE
#endif
#include <Xw_Cextern.hxx>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/XWDFile.h>
#ifndef min
#define min(a,b) (a>b ? b : a)
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_X11_EXTENSIONS_TRANSOLV_H
#include <X11/extensions/transovl.h>
#endif
#ifndef max
#define max(a,b) (a<b ? b : a)
#endif
#ifndef PI
#define PI 3.14159
#endif
#define DRAD (PI/180.)
#define MAXLINES 256
#define MAXPOLYS 256
#define MAXPOINTS 1024
#define MAXSEGMENTS 1024
#define MAXARCS 1024
#define MAXLTEXTS 256
#define MAXPTEXTS 256
#define MAXCHARS 1024
#define MAXIMAGES 8
#define MAXLMARKERS 256
#define MAXPMARKERS 256
#define MAXBUFFERS 8
#define MAXQG 32
#define MAXTYPE 256
#define MAXCOLOR 512
#define MINCOLOR 32
#define FRECOLOR 14
#define MAXWIDTH 256
#define MAXFONT 256
#define MAXTILE 256
#define MAXMARKER 256
#define MAXEVENT XW_ALLEVENT+1
#define MAXCURSOR 200
#define MAXANGLE 23040
#define MINTEXTSIZE 8
#define _ATTRIBUTES pwindow->attributes
#define _WINDOW pwindow->window
#define _PIXMAP pwindow->pixmap
#define _NWBUFFER pwindow->nwbuffer
#define _FWBUFFER pwindow->wbuffers[0]
#define _BWBUFFER pwindow->wbuffers[1]
#define _DRAWABLE pwindow->drawable
#define _COLORMAP (pwindow->pcolormap)
#define _WIDTHMAP (pwindow->pwidthmap)
#define _TYPEMAP (pwindow->ptypemap)
#define _FONTMAP (pwindow->pfontmap)
#define _TILEMAP (pwindow->ptilemap)
#define _MARKMAP (pwindow->pmarkmap)
#define _ROOT (_ATTRIBUTES.root)
#define _SCREEN (_ATTRIBUTES.screen)
#define _VISUAL (_ATTRIBUTES.visual)
#if defined(__cplusplus) || defined(c_plusplus)
#define _CLASS (_VISUAL->c_class)
#else
#define _CLASS (_VISUAL->class)
#endif
#ifdef _X
#undef _X
#endif
#define _X (_ATTRIBUTES.x)
#ifdef _Y
#undef _Y
#endif
#define _Y (_ATTRIBUTES.y)
#define _WIDTH (_ATTRIBUTES.width)
#define _HEIGHT (_ATTRIBUTES.height)
#define _STATE (_ATTRIBUTES.map_state)
#define _DEPTH (_ATTRIBUTES.depth)
#define _EVENT_MASK (_ATTRIBUTES.your_event_mask)
#define QGCODE(color,type,width,mode) ((color<<20)|(type<<12)|(width<<4)|mode)
#define QGCOLOR(code) ((code>>20)&0xFFF)
#define QGSETCOLOR(code,color) ((code&0x000FFFFF)|(color<<20))
#define QGTYPE(code) ((code>>12)&0xFF)
#define QGSETTYPE(code,type) ((code&0xFFF00FFF)|(type<<12))
#define QGWIDTH(code) ((code>> 4)&0xFF)
#define QGSETWIDTH(code,width) ((code&0xFFFFF00F)|(width<<4))
#define QGTILE(code) ((code>> 4)&0xFF)
#define QGSETTILE(code,mark) ((code&0xFFFFF00F)|(mark<<4))
#define QGFONT(code) ((code>> 4)&0xFF)
#define QGSETFONT(code,font) ((code&0xFFFFF00F)|(font<<4))
#define QGMODE(code) (code&0xF)
#define QGSETMODE(code,mode) ((code&0xFFFFFFF0)|mode)
#define ROUND(v) ( ((v) > 0.) ? ((v) < (float)(INT_MAX-1)) ? \
(int)((v)+.5) : INT_MAX : ((v) > (float)(INT_MIN+1)) ? \
(int)((v)-.5) : INT_MIN )
#ifdef OLD /*S3593 OPTIMISATION*/
#define PXPOINT(x) (ROUND((x) / pwindow->xratio))
#define PYPOINT(y) (ROUND(_HEIGHT - ((y) / pwindow->yratio)))
#define PVALUE(v) (ROUND((v) / ((pwindow->xratio+pwindow->yratio)/2.)))
#define UVALUE(v) ((float)(v) * (pwindow->xratio+pwindow->yratio)/2.)
#else
#define PXPOINT(x) ((int)((x) / pwindow->xratio))
#define PYPOINT(y) ((int)(_HEIGHT - ((y) / pwindow->yratio)))
#define PVALUE(v) ((int)((v) / ((pwindow->xratio+pwindow->yratio)/2.)))
#define UVALUE(v) ((float)(v) * (pwindow->xratio+pwindow->yratio)/2.)
#endif
//OCC186
#undef PXPOINT
#undef PYPOINT
#undef PVALUE
//OCC186
#define UXPOINT(x) ((float)(x) * pwindow->xratio)
#define UYPOINT(y) ((float)(_HEIGHT - (y)) * pwindow->yratio)
/* DISPLAY */
#define DISPLAY_TYPE 0
#ifdef XW_EXT_DISPLAY
#undef XW_EXT_DISPLAY
#endif
#define _DDISPLAY pdisplay->display
#define _DSCREEN (pdisplay->screen)
#define _DVISUAL (pdisplay->visual)
#if defined(__cplusplus) || defined(c_plusplus)
#define _DCLASS (pdisplay->visual->c_class)
#else
#define _DCLASS (pdisplay->visual->class)
#endif
#define _DCOLORMAP pdisplay->colormap
#define _DGC pdisplay->gc
#define _DROOT pdisplay->rootwindow
#define _DGRAB pdisplay->grabwindow
#define _DWIDTH pdisplay->width
#define _DHEIGHT pdisplay->height
#define MMPXVALUE(v) ((float)((v)*WidthMMOfScreen(_DSCREEN))/(float)_DWIDTH)
#define MMPYVALUE(v) ((float)((v)*HeightMMOfScreen(_DSCREEN))/(float)_DHEIGHT)
#define PMMXVALUE(v) ((int)((v)*_DWIDTH/(float)WidthMMOfScreen(_DSCREEN)))
#define PMMYVALUE(v) ((int)((v)*_DHEIGHT/(float)HeightMMOfScreen(_DSCREEN)))
typedef enum {
XW_SERVER_IS_UNKNOWN,XW_SERVER_IS_DEC,XW_SERVER_IS_SUN,
XW_SERVER_IS_SGI,XW_SERVER_IS_NEC,XW_SERVER_IS_HP
} XW_SERVER_TYPE ;
typedef struct {
/* Avoid 64-bit portability problems by being careful to use
longs due to the way XGetWindowProperty is specified. Note
that these parameters are passed as CARD32s over X
protocol. */
long overlay_visual;
long transparent_type;
long value;
long layer;
} XOverlayVisualInfo ;
typedef struct {
void *link ;
int type ; /* DISPLAY_TYPE */
XW_SERVER_TYPE server ;
Display *display ;
Screen *screen ;
Visual *visual ;
GC gc ;
int width ;
int height ;
Colormap colormap ;
Window rootwindow ;
Window grabwindow ;
float gamma ;
char* gname ;
} XW_EXT_DISPLAY;
/* COLORMAP */
#ifdef XW_EXT_COLORMAP
#undef XW_EXT_COLORMAP
#endif
#define COLORMAP_TYPE 2
#define _CDISPLAY (pcolormap->connexion->display)
#define _CSCREEN (pcolormap->connexion->screen)
#define _CCOLORMAP (pcolormap->connexion->colormap)
#define _CROOT (pcolormap->connexion->rootwindow)
#define _CVISUAL (pcolormap->visual)
#if defined(__cplusplus) || defined(c_plusplus)
#define _CCLASS (pcolormap->visual->c_class)
#else
#define _CCLASS (pcolormap->visual->class)
#endif
#define _CINFO (pcolormap->info)
#define _CGINFO (pcolormap->ginfo)
#define FREECOLOR 0 /* Free color Index if define[] = 0 */
#define USERCOLOR 1 /* User color Index if define[] = 1 */
#define IMAGECOLOR 2 /* Image color Index if define[] = 2 */
#define HIGHCOLOR 3 /* HighLight color Index if define[] = 3 */
#define BACKCOLOR 4 /* Background color Index if define[] = 4 */
#define SYSTEMCOLOR 5 /* System color Index if define[] = 5 */
typedef struct {
void *link ;
int type ; /* COLORMAP_TYPE */
XW_EXT_DISPLAY* connexion ;
Visual *visual ;
XStandardColormap info,ginfo ;
int maxhcolor ; /* Colormap Hard Length */
int maxucolor ; /* Colormap User Length */
int maxcolor ; /* Colormap Length */
int maxwindow ; /* Number of reference Window*/
Xw_TypeOfMapping mapping ; /* Colormap mapping */
unsigned char define[MAXCOLOR] ; /* 0 if FREE color */
unsigned long highpixel ; /* HighLightPixel Value */
unsigned long backpixel ; /* TransparentPixel Value */
unsigned long pixels[MAXCOLOR] ;
} XW_EXT_COLORMAP ;
/* WIDTHMAP */
#define WIDTHMAP_TYPE 3
#ifdef XW_EXT_WIDTHMAP
#undef XW_EXT_WIDTHMAP
#endif
#define _WDISPLAY (pwidthmap->connexion->display)
typedef struct {
void *link ;
int type ; /* WIDTHMAP_TYPE */
XW_EXT_DISPLAY* connexion ;
int maxwidth ; /* Widthmap Length */
int maxwindow ; /* Number of reference Window */
unsigned char widths[MAXWIDTH] ; /* Pixel width > 0 if defined*/
} XW_EXT_WIDTHMAP ;
/* TYPEMAP */
#define TYPEMAP_TYPE 4
#ifdef XW_EXT_TYPEMAP
#undef XW_EXT_TYPEMAP
#endif
#define _TDISPLAY (ptypemap->connexion->display)
typedef struct {
void *link ;
int type ; /* TYPEMAP_TYPE */
XW_EXT_DISPLAY* connexion ;
int maxtype ; /* Typemap Length */
int maxwindow ; /* Number of reference Window */
unsigned char *types[MAXTYPE] ; /* Line Type Pixel lengths */
/* NULL if type is not defined*/
} XW_EXT_TYPEMAP ;
/* FONTMAP */
#define FONTMAP_TYPE 5
#ifdef XW_EXT_FONTMAP
#undef XW_EXT_FONTMAP
#endif
#define _FDISPLAY (pfontmap->connexion->display)
typedef struct {
void* link ;
int type ; /* FONTMAP_TYPE */
XW_EXT_DISPLAY* connexion ;
int maxfont ; /* Fontmap Length */
int maxwindow ; /* Number of reference Window */
float gsizes[MAXFONT] ; /* Generic Font size in MM */
float fsizes[MAXFONT] ; /* Font size in MM */
float fratios[MAXFONT] ; /* Font baseline ratio */
float ssizex[MAXFONT] ; /* Selected X Font size in MM */
float ssizey[MAXFONT] ; /* Selected Y Font size in MM */
float gslants[MAXFONT] ; /* Generic Font slant in RAD */
float sslants[MAXFONT] ; /* Selected Font slant in RAD */
char* gnames[MAXFONT] ; /* Generic font name */
char* snames[MAXFONT] ; /* Selected font name */
XFontStruct* fonts[MAXFONT] ;/* Selected Font structure */
/* NULL if font is not defined*/
} XW_EXT_FONTMAP ;
/* TILEMAP */
#define TILEMAP_TYPE 6
#ifdef XW_EXT_TILEMAP
#undef XW_EXT_TILEMAP
#endif
#define _PDISPLAY (ptilemap->connexion->display)
typedef struct {
void *link ;
int type ; /* TILEMAP_TYPE */
XW_EXT_DISPLAY* connexion ;
int maxtile ; /* Tilemap Length */
int maxwindow ; /* Number of reference Window */
Pixmap tiles[MAXTILE] ; /* Tile pixmap */
/* 0 if tile is not defined */
} XW_EXT_TILEMAP ;
/* MARKMAP */
#define MARKMAP_TYPE 7
#ifdef XW_EXT_MARKMAP
#undef XW_EXT_MARKMAP
#endif
#define _MDISPLAY (pmarkmap->connexion->display)
typedef struct {
void *link ;
int type ; /* MARKMAP_TYPE */
XW_EXT_DISPLAY* connexion ;
int maxmarker ; /* Markmap Length */
int maxwindow ; /* Number of reference Window */
unsigned int width[MAXMARKER] ; /* Pmarker Size in pixels */
unsigned int height[MAXMARKER] ; /* Pmarker Size in pixels */
Pixmap marks[MAXMARKER] ; /* Pmarker pixmap */
int npoint[MAXMARKER] ; /* Lmarker length */
int* spoint[MAXMARKER] ; /* Lmarker status */
float* xpoint[MAXMARKER] ; /* Lmarker x coords */
float* ypoint[MAXMARKER] ; /* Lmarker y coords */
} XW_EXT_MARKMAP ;
/* IMAGEDATA*/
#define IMAGE_TYPE 8
#ifdef XW_EXT_IMAGEDATA
#undef XW_EXT_IMAGEDATA
#endif
#define _ICOLORMAP (pimage->pcolormap)
#define _IVISUAL (_ICOLORMAP->visual)
#define _IIMAGE (pimage->pximage)
#define _ZIMAGE (pimage->zximage)
#define _IINFO (pimage->pimageinfo)
typedef struct {
void *link ;
int type ; /* IMAGE_TYPE */
XW_EXT_COLORMAP *pcolormap ;
int maxwindow ; /* Number of reference Window*/
float zoom; /* Zoom factor */
XImage *pximage ; /* Ref image */
XImage *zximage ; /* Zoomed image */
XW_USERDATA *pimageinfo ; /* external IMAGE Infos*/
} XW_EXT_IMAGEDATA ;
typedef struct {
void* link ;
int isupdated ;
int npoint ;
XPoint rpoints[MAXPOINTS] ;
XPoint upoints[MAXPOINTS] ;
} XW_EXT_POINT ;
typedef struct {
void* link ;
int nchar ;
char chars[MAXCHARS] ;
} XW_EXT_CHAR ;
typedef struct {
void* link ;
int isupdated ;
int nseg ;
XSegment rsegments[MAXSEGMENTS] ;
XSegment usegments[MAXSEGMENTS] ;
} XW_EXT_SEGMENT ;
typedef struct {
void* link ;
int isupdated ;
int nmark ;
int nseg ;
int marks[MAXLMARKERS] ; /* seg numbers */
XPoint rcenters[MAXLMARKERS] ; /* marker center */
XPoint ucenters[MAXLMARKERS] ; /* marker center */
XSegment rsegments[MAXSEGMENTS] ;
XSegment usegments[MAXSEGMENTS] ;
} XW_EXT_LMARKER ;
typedef struct {
void* link ;
int isupdated ;
int nmark ;
int npoint ;
int marks[MAXPMARKERS] ; /* point numbers */
XPoint rcenters[MAXPMARKERS] ; /* marker center */
XPoint ucenters[MAXPMARKERS] ; /* marker center */
XPoint rpoints[MAXPOINTS] ;
XPoint upoints[MAXPOINTS] ;
} XW_EXT_PMARKER ;
typedef struct {
void* link ;
int isupdated ;
int nline ;
int lines[MAXLINES] ; /* line point numbers */
XPoint *plines[MAXLINES] ; /* LINE descriptor */
} XW_EXT_LINE ;
typedef struct {
void* link ;
int isupdated ;
int npoly ;
int polys[MAXPOLYS] ; /* poly point numbers */
int paths[MAXPOLYS] ; /* path point numbers */
XPoint *ppolys[MAXPOLYS] ; /* POLY descriptor */
} XW_EXT_POLY ;
typedef struct {
void* link ;
int isupdated ;
int narc ;
XArc rarcs[MAXARCS] ;
XArc uarcs[MAXARCS] ;
} XW_EXT_ARC ;
typedef struct {
void* link ;
int isupdated ;
int ntext ;
int modes[MAXLTEXTS] ; /* TEXT draw mode */
int texts[MAXLTEXTS] ;
char *ptexts[MAXLTEXTS] ; /* TEXT descriptor */
XPoint rpoints[MAXLTEXTS] ;
XPoint upoints[MAXLTEXTS] ;
float rangles[MAXLTEXTS] ; /* rotated string angle */
float uangles[MAXLTEXTS] ;
float rscalex[MAXLTEXTS] ; /* rotated string scale */
float uscalex[MAXLTEXTS] ;
float rscaley[MAXLTEXTS] ; /* rotated string scale */
float uscaley[MAXLTEXTS] ;
float slants[MAXLTEXTS] ; /* TEXT slant */
} XW_EXT_LTEXT ;
typedef struct {
void* link ;
int isupdated ;
int ntext ;
int modes[MAXLTEXTS] ; /* TEXT draw mode */
int texts[MAXPTEXTS] ;
char *ptexts[MAXPTEXTS] ; /* TEXT descriptor */
XPoint rpoints[MAXPTEXTS] ;
XPoint upoints[MAXPTEXTS] ;
float rangles[MAXPTEXTS] ; /* rotated string angle */
float uangles[MAXPTEXTS] ;
float marges[MAXPTEXTS] ; /* polygon margins */
float rscalex[MAXLTEXTS] ; /* rotated string scale */
float uscalex[MAXLTEXTS] ;
float rscaley[MAXLTEXTS] ; /* rotated string scale */
float uscaley[MAXLTEXTS] ;
float slants[MAXLTEXTS] ; /* TEXT slant */
} XW_EXT_PTEXT ;
typedef struct {
void *link ;
int isupdated ;
int nimage ; /* Image number to drawn */
XPoint rpoints[MAXIMAGES] ;
XPoint upoints[MAXIMAGES] ;
XW_EXT_IMAGEDATA *pimagdata[MAXIMAGES] ;
} XW_EXT_IMAGE ;
typedef struct {
int bufferid ; /* Identification */
GC gcf,gcb ; /* Graphic context */
XW_ATTRIB code ; /* QG code as C,T,F,M*/
int isdrawn; /* True if visible at screen */
int isempty; /* True if empty */
int isretain; /* True if retain drawing*/
int isupdated; /* True if has been updated*/
int rxmin,rymin,rxmax,rymax; /* Min Max ref. buffer */
int uxmin,uymin,uxmax,uymax; /* Min Max upt. buffer */
int xpivot,ypivot ; /* Buffer ref. pivot point */
int dxpivot,dypivot ; /* Current Buffer transl. vector */
float xscale,yscale; /* Buffer ref. drawing scale */
float dxscale,dyscale; /* Current Buffer drawing scale */
float angle; /* Buffer ref. drawing angle */
float dangle; /* Current Buffer drawing angle */
XW_EXT_CHAR *ptextdesc ; /* Retain desc. texts list */
XW_EXT_POINT *plinedesc ; /* Retain desc. lines list */
XW_EXT_POINT *ppntlist ; /* Retain Points list */
XW_EXT_SEGMENT *pseglist ; /* Retain Segments list */
XW_EXT_LINE *plinelist ; /* Retain Polylines list */
XW_EXT_POLY *ppolylist ; /* Retain Polygones list */
XW_EXT_ARC *plarclist ; /* Retain Arcs list */
XW_EXT_ARC *pparclist ; /* Retain poly Arcs list */
XW_EXT_LTEXT *pltextlist ; /* Retain Texts list */
XW_EXT_PTEXT *pptextlist ; /* Retain poly Texts list */
XW_EXT_LMARKER *plmarklist ; /* Retain Markers list */
XW_EXT_PMARKER *ppmarklist ; /* Retain poly Markers list */
XW_EXT_IMAGE *pimaglist ; /* Retain Image list */
} XW_EXT_BUFFER ;
typedef struct { /* Line GC */
GC gc ; /* Graphic context */
unsigned int count ; /* Used count info */
XW_ATTRIB code ; /* QG code as C,T,W,M*/
} XW_QGL ;
typedef struct { /* Polygon GC */
GC gc ; /* Graphic context */
unsigned int count ; /* Used count info */
XW_ATTRIB code ; /* QG code as C,T,T,M*/
} XW_QGP ;
typedef struct { /* Text GC */
GC gc ; /* Graphic context */
unsigned int count ; /* Used count info */
XW_ATTRIB code ; /* QG code as C,T,F,M*/
} XW_QGT ;
typedef struct { /* Marker GC */
GC gc ; /* Graphic context */
unsigned int count ; /* Used count info */
XW_ATTRIB code ; /* QG code as C,T,T,M*/
} XW_QGM ;
#define _BIMAGE pwindow->qgwind.pimage
#define _BMETHOD pwindow->qgwind.method
#define _BPIXMAP pwindow->qgwind.pixmap
#define _BINDEX pwindow->qgwind.cbufindex
#define _BUFFER(index) pwindow->qgwind.pbuflist[index]
typedef struct { /* Window GC */
GC gc ; /* Graphic context */
GC gcclear ; /* Graphic context */
GC gccopy ; /* Graphic context */
GC gchigh ; /* Graphic context */
XW_ATTRIB code ; /* QG code as C,T,T,M*/
XW_EXT_IMAGEDATA *pimage ; /* Back image data's */
Aspect_FillMethod method ; /* Back fill method */
Pixmap pixmap ; /* Back Pixmap or 0 */
int cbufindex ; /* Current buffer index */
XW_EXT_BUFFER pbuflist[MAXBUFFERS]; /* Retain primitives list*/
} XW_QGW ;
/* CALLBACK */
typedef struct {
XW_CALLBACK function ; /* CallBack Address */
void *userdata ; /* CallBack UserData*/
} XW_ECBK ;
#ifdef XW_PROTOTYPE
typedef XW_STATUS (*XW_ICALLBACK)(XW_EVENT* anyevent) ;
#else
typedef XW_STATUS (*XW_ICALLBACK)() ;
#endif /*XW_PROTOTYPE*/
typedef struct {
XW_ICALLBACK function ; /* CallBack Address */
} XW_ICBK ;
/* WINDOW */
#define WINDOW_TYPE 1
#ifdef XW_EXT_WINDOW
#undef XW_EXT_WINDOW
#endif
#define _DISPLAY (pwindow->connexion->display)
typedef struct {
void *link ;
int type ; /* WINDOW_TYPE */
XWindowAttributes attributes ; /* Window Attributes */
int axleft ; /* Actual Window position */
int aytop ; /* Actual Window position */
int axright ; /* Actual Window position */
int aybottom ; /* Actual Window position */
int rwidth ; /* Requested Window width*/
int rheight ; /* Requested Window height*/
float xratio ; /* Window User/Pixel Ratio*/
float yratio ; /* Window User/Pixel Ratio*/
XW_EXT_DISPLAY* connexion ;
Window window ; /* Window ID */
Pixmap pixmap ; /* Associated Window Pixmap*/
int nwbuffer ; /* MultiBuffers number if any */
XID wbuffers[2] ; /* Associated Window Buffers*/
Drawable drawable ; /* Can be Window or Pixmap */
int backindex ; /* Colormap background Index */
int clipflag ; /* Unable internal clipping*/
XW_EXT_COLORMAP *pcolormap ; /* Colormap Extension */
XW_EXT_WIDTHMAP *pwidthmap ; /* Widthmap Extension */
XW_EXT_TYPEMAP *ptypemap ; /* Widthmap Extension */
XW_EXT_FONTMAP *pfontmap ; /* Fontmap Extension */
XW_EXT_TILEMAP *ptilemap ; /* Tilemap Extension */
XW_EXT_MARKMAP *pmarkmap ; /* Markmap Extension */
int lineindex ; /* Current QG line index used */
XW_QGL qgline[MAXQG] ; /* QG Line Bundle indexs */
int polyindex ; /* Current QG poly index used */
XW_QGP qgpoly[MAXQG] ; /* QG poly Bundle indexs */
int textindex ; /* Current QG text index used */
XW_QGT qgtext[MAXQG] ; /* QG text Bundle indexs */
int markindex ; /* Current QG markerindex used*/
XW_QGM qgmark[MAXQG] ; /* QG marker Bundle indexs */
XW_QGW qgwind ; /* QG Window Bundle */
XW_ECBK ecbk[MAXEVENT] ; /* External CallBack EventList*/
XW_ICBK icbk[MAXEVENT] ; /* Internal CallBack EventList*/
void *other ; /* Other data extension */
} XW_EXT_WINDOW;
/* ICONS */
#define ICON_TYPE 10
typedef struct {
void *link ;
int type ; /* ICON_TYPE */
char *pname ;
char *pfile ;
XW_EXT_IMAGEDATA *pimage ; /* Associated Image data's */
Pixmap pixmap ; /* Associated Pixmap if any */
int update;
} XW_EXT_ICON ;
/*
Internal Functions
*/
#define Xw_malloc malloc
#define Xw_calloc calloc
#define Xw_free free
#ifdef XW_PROTOTYPE
#ifdef __cplusplus
extern "C" {
#endif
void _XInitImageFuncPtrs(XImage* pximage);
#ifdef __cplusplus
}
#endif
XVisualInfo* Xw_get_visual_info(XW_EXT_DISPLAY* display,Xw_TypeOfVisual tclass);
XVisualInfo* Xw_get_overlay_visual_info(XW_EXT_DISPLAY* display,Xw_TypeOfVisual tclass,unsigned long* backpixel) ;
XW_EXT_DISPLAY* Xw_get_display_structure(Display* display) ;
XW_EXT_DISPLAY* Xw_add_display_structure(int size) ;
XW_STATUS Xw_del_display_structure(XW_EXT_DISPLAY* adisplay) ;
XW_EXT_WINDOW* Xw_get_window_structure(Window window) ;
XW_EXT_WINDOW* Xw_add_window_structure(int size) ;
XW_STATUS Xw_del_window_structure(XW_EXT_WINDOW* awindow) ;
XW_STATUS Xw_reset_attrib(XW_EXT_WINDOW* awindow) ;
XW_STATUS Xw_redraw_buffer(XW_EXT_WINDOW *pwindow,XW_EXT_BUFFER *pbuffer) ;
XW_STATUS Xw_update_buffer(XW_EXT_WINDOW *pwindow,XW_EXT_BUFFER *pbuffer) ;
XW_EXT_BUFFER* Xw_get_buffer_structure(XW_EXT_WINDOW *pwindow,int bufferid) ;
XW_EXT_CHAR* Xw_add_text_desc_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_text_desc_structure(XW_EXT_BUFFER *pbuflist) ;
XW_EXT_POINT* Xw_add_line_desc_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_line_desc_structure(XW_EXT_BUFFER *pbuflist) ;
XW_EXT_POINT* Xw_add_point_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_point_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_points(XW_EXT_WINDOW* pwindow,XW_EXT_POINT* ppntlist,GC gc) ;
XW_EXT_SEGMENT* Xw_add_segment_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_segment_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_segments(XW_EXT_WINDOW* pwindow,XW_EXT_SEGMENT* pseglist,GC gc) ;
XW_EXT_LINE* Xw_add_polyline_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_polyline_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_lines(XW_EXT_WINDOW* pwindow,XW_EXT_LINE* plinelist,GC gc) ;
XW_EXT_ARC* Xw_add_arc_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_arc_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_arcs(XW_EXT_WINDOW* pwindow,XW_EXT_ARC* parclist,GC gc) ;
XW_EXT_ARC* Xw_add_polyarc_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_polyarc_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_polyarcs(XW_EXT_WINDOW* pwindow,XW_EXT_ARC* parclist,
GC gcpoly,GC gcline) ;
XW_EXT_POLY* Xw_add_polygone_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_polygone_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_polys(XW_EXT_WINDOW* pwindow,XW_EXT_POLY* ppolylist,
GC gcpoly,GC gcline) ;
XW_EXT_LTEXT* Xw_add_text_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_text_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_texts(XW_EXT_WINDOW* pwindow,XW_EXT_LTEXT* ptextlist,
GC gc,XW_ATTRIB code) ;
XW_EXT_PTEXT* Xw_add_polytext_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_polytext_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_polytexts(XW_EXT_WINDOW* pwindow,XW_EXT_PTEXT* ptextlist,
GC gctext,GC gcpoly,GC gcline,XW_ATTRIB code) ;
XW_STATUS Xw_isdefine_markerindex(XW_EXT_MARKMAP* amarkmap,int index) ;
XW_EXT_LMARKER* Xw_add_lmarker_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_lmarker_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_lmarkers(XW_EXT_WINDOW* pwindow,XW_EXT_LMARKER* pmarklist,GC gc) ;
XW_EXT_PMARKER* Xw_add_pmarker_structure(XW_EXT_BUFFER *pbuflist) ;
XW_STATUS Xw_del_pmarker_structure(XW_EXT_BUFFER *pbuflist) ;
void Xw_draw_pixel_pmarkers(XW_EXT_WINDOW* pwindow,XW_EXT_PMARKER* pmarklist,GC gc) ;
Colormap Xw_create_colormap(XW_EXT_COLORMAP *pcolormap) ;
XW_EXT_COLORMAP* Xw_add_colormap_structure(int size) ;
XW_EXT_COLORMAP* Xw_get_colormap_structure(XW_EXT_COLORMAP* acolormap) ;
XW_STATUS Xw_del_colormap_structure(XW_EXT_COLORMAP* acolormap) ;
XW_STATUS Xw_get_color_attrib(XW_EXT_WINDOW* awindow,
XW_DRAWMODE mode,int color,unsigned long* hcolor,
int* function,unsigned long* planemask) ;
XW_STATUS Xw_isdefine_colorindex(XW_EXT_COLORMAP* acolormap,int index) ;
XW_STATUS Xw_ifsystem_colorindex(XW_EXT_COLORMAP* acolormap,int index) ;
XW_STATUS Xw_ifimage_colorindex(XW_EXT_COLORMAP* acolormap,int index) ;
XW_STATUS Xw_ifbackground_colorindex(XW_EXT_COLORMAP* acolormap,int index) ;
XW_STATUS Xw_ifhighlight_colorindex(XW_EXT_COLORMAP* acolormap,int index) ;
char* Xw_get_filename(char* filename,const char *extension) ;
XW_EXT_WIDTHMAP* Xw_add_widthmap_structure(int size) ;
XW_STATUS Xw_del_widthmap_structure(XW_EXT_WIDTHMAP* awidthmap) ;
XW_STATUS Xw_isdefine_widthindex(XW_EXT_WIDTHMAP* awidthmap,int index) ;
XW_EXT_TYPEMAP* Xw_add_typemap_structure(int size) ;
XW_STATUS Xw_del_typemap_structure(XW_EXT_TYPEMAP* atypemap) ;
XW_STATUS Xw_isdefine_typeindex(XW_EXT_TYPEMAP* atypemap,int index) ;
XW_EXT_FONTMAP* Xw_add_fontmap_structure(int size) ;
XW_STATUS Xw_del_fontmap_structure(XW_EXT_FONTMAP* afontmap) ;
XW_STATUS Xw_isdefine_fontindex(XW_EXT_FONTMAP* afontmap,int index) ;
XW_EXT_TILEMAP* Xw_add_tilemap_structure(int size) ;
XW_STATUS Xw_del_tilemap_structure(XW_EXT_TILEMAP* atilemap) ;
XW_STATUS Xw_isdefine_tileindex(XW_EXT_TILEMAP* atilemap,int index) ;
XW_EXT_MARKMAP* Xw_add_markmap_structure(int size) ;
XW_STATUS Xw_del_markmap_structure(XW_EXT_MARKMAP* amarkmap) ;
XW_EXT_IMAGEDATA* Xw_add_imagedata_structure(int size) ;
XW_STATUS Xw_del_imagedata_structure(XW_EXT_IMAGEDATA* aimagedata) ;
XW_EXT_IMAGE* Xw_add_image_structure(XW_EXT_BUFFER* pbuflist) ;
XW_STATUS Xw_del_image_structure(XW_EXT_BUFFER* pbuflist) ;
void Xw_draw_pixel_images(XW_EXT_WINDOW* pwindow,XW_EXT_IMAGE *pimaglist,
GC gcimag,GC gcline) ;
XW_STATUS Xw_set_internal_event(XW_EXT_WINDOW* awindow,
XW_EVENTTYPE type,XW_ICALLBACK call_back) ;
XW_STATUS Xw_alloc_color(XW_EXT_COLORMAP* acolormap,float r,float g,float b,unsigned long *pixel,int *isapproximate);
int Xw_clip_segment(XW_EXT_WINDOW* pwindow,int x1,int y1,int x2,int y2,
XSegment* segment);
int Xw_get_trace() ;
int Xw_test(unsigned long mask) ;
void Xw_set_error(int code,const char* message,void* pvalue) ;
int Xw_error_handler(Display* display,XErrorEvent* event) ;
void Xw_set_synchronize(Display* display,int state) ;
void Xw_longcopy(register long* from,register long* to,register unsigned n) ;
void Xw_shortcopy(register short* from,register short* to,register unsigned n) ;
void Xw_bytecopy(register char* from,register char* to,register unsigned n) ;
#ifndef Xw_malloc
void* Xw_malloc(int size) ;
#endif
#ifndef Xw_calloc
void* Xw_calloc(int length,int size) ;
#endif
#ifndef Xw_free
void Xw_free(void* address) ;
#endif
//OCC186
int PXPOINT( double x, double ratio );
int PYPOINT( double y, double height, double ratio );
int PVALUE( double v, double xratio, double yratio );
//OCC186
#else /*XW_PROTOTYPE*/
extern "C" {
void _XInitImageFuncPtrs();
}
XVisualInfo* Xw_get_visual_info() ;
XVisualInfo* Xw_get_overlay_visual_info() ;
XW_EXT_DISPLAY* Xw_get_display_structure() ;
XW_EXT_DISPLAY* Xw_add_display_structure() ;
XW_STATUS Xw_del_display_structure() ;
XW_EXT_WINDOW* Xw_get_window_structure() ;
XW_EXT_WINDOW* Xw_add_window_structure() ;
XW_STATUS Xw_del_window_structure() ;
XW_STATUS Xw_reset_attrib() ;
XW_STATUS Xw_redraw_buffer() ;
XW_STATUS Xw_update_buffer() ;
XW_EXT_BUFFER* Xw_get_buffer_structure() ;
XW_EXT_CHAR* Xw_add_text_desc_structure() ;
XW_STATUS Xw_del_text_desc_structure() ;
XW_EXT_POINT* Xw_add_line_desc_structure() ;
XW_STATUS Xw_del_line_desc_structure() ;
XW_EXT_POINT* Xw_add_point_structure() ;
XW_STATUS Xw_del_point_structure() ;
void Xw_draw_pixel_points() ;
XW_EXT_SEGMENT* Xw_add_segment_structure() ;
XW_STATUS Xw_del_segment_structure() ;
void Xw_draw_pixel_segments() ;
XW_EXT_LINE* Xw_add_polyline_structure() ;
XW_STATUS Xw_del_polyline_structure() ;
void Xw_draw_pixel_lines() ;
XW_EXT_ARC* Xw_add_arc_structure() ;
XW_STATUS Xw_del_arc_structure() ;
void Xw_draw_pixel_arcs() ;
XW_EXT_ARC* Xw_add_polyarc_structure() ;
XW_STATUS Xw_del_polyarc_structure() ;
void Xw_draw_pixel_polyarcs() ;
XW_EXT_POLY* Xw_add_polygone_structure() ;
XW_STATUS Xw_del_polygone_structure() ;
void Xw_draw_pixel_polys() ;
XW_EXT_LTEXT* Xw_add_text_structure() ;
XW_STATUS Xw_del_text_structure() ;
void Xw_draw_pixel_texts() ;
XW_EXT_PTEXT* Xw_add_polytext_structure() ;
XW_STATUS Xw_del_polytext_structure() ;
void Xw_draw_pixel_polytexts() ;
XW_STATUS Xw_isdefine_markerindex() ;
XW_EXT_LMARKER* Xw_add_lmarker_structure() ;
XW_STATUS Xw_del_lmarker_structure() ;
void Xw_draw_pixel_lmarkers() ;
XW_EXT_PMARKER* Xw_add_pmarker_structure() ;
XW_STATUS Xw_del_pmarker_structure() ;
void Xw_draw_pixel_pmarkers() ;
Colormap Xw_create_colormap() ;
XW_EXT_COLORMAP* Xw_add_colormap_structure() ;
XW_EXT_COLORMAP* Xw_get_colormap_structure() ;
XW_STATUS Xw_del_colormap_structure() ;
XW_STATUS Xw_get_color_attrib() ;
XW_STATUS Xw_isdefine_colorindex() ;
XW_STATUS Xw_ifsystem_colorindex() ;
XW_STATUS Xw_ifimage_colorindex() ;
XW_STATUS Xw_ifbackground_colorindex() ;
XW_STATUS Xw_ifhighlight_colorindex() ;
char* Xw_get_filename() ;
XW_EXT_WIDTHMAP* Xw_add_widthmap_structure() ;
XW_STATUS Xw_del_widthmap_structure() ;
XW_STATUS Xw_isdefine_widthindex() ;
XW_EXT_TYPEMAP* Xw_add_typemap_structure() ;
XW_STATUS Xw_del_typemap_structure() ;
XW_STATUS Xw_isdefine_typeindex() ;
XW_EXT_FONTMAP* Xw_add_fontmap_structure() ;
XW_STATUS Xw_del_fontmap_structure() ;
XW_STATUS Xw_isdefine_fontindex() ;
XW_EXT_TILEMAP* Xw_add_tilemap_structure() ;
XW_STATUS Xw_del_tilemap_structure() ;
XW_STATUS Xw_isdefine_tileindex() ;
XW_EXT_MARKMAP* Xw_add_markmap_structure() ;
XW_STATUS Xw_del_markmap_structure() ;
XW_EXT_IMAGEDATA* Xw_add_imagedata_structure() ;
XW_STATUS Xw_del_imagedata_structure() ;
XW_EXT_IMAGE* Xw_add_image_structure() ;
XW_STATUS Xw_del_image_structure() ;
void Xw_draw_pixel_images() ;
XW_STATUS Xw_set_internal_event() ;
XW_STATUS Xw_alloc_color();
int Xw_clip_segment();
int Xw_test() ;
int Xw_get_trace() ;
void Xw_set_error() ;
int Xw_error_handler() ;
void Xw_set_synchronize() ;
void Xw_longcopy() ;
void Xw_shortcopy() ;
void Xw_bytecopy() ;
#ifndef Xw_malloc
void* Xw_malloc() ;
#endif
#ifndef Xw_calloc
void* Xw_calloc() ;
#endif
#ifndef Xw_free
void Xw_free() ;
#endif
//OCC186
int PXPOINT();
int PYPOINT();
int PVALUE();
//OCC186
#endif /*XW_PROTOTYPE*/

99
src/Xw/Xw_FontMap.cdl Executable file
View File

@@ -0,0 +1,99 @@
--
-- File: Xw_FontMap.cdl
-- Created: 24/08/93
-- Author: GG
--
---Copyright: MatraDatavision 1993
--
class FontMap from Xw inherits Transient
---Version: 0.0
---Purpose: This class defines a FontMap object.
---Keywords:
---Warning:
---References:
uses
FontMap from Aspect,
FontMapEntry from Aspect
raises
FontMapDefinitionError from Aspect,
BadAccess from Aspect
is
Create
returns mutable FontMap from Xw
is protected;
---Level: Internal
Create (Connexion : CString from Standard)
returns mutable FontMap from Xw
---Level: Public
---Purpose: Creates a FontMap with an unallocated FontMapEntry.
raises FontMapDefinitionError from Aspect;
---Error if FontMap creation failed according
-- to the supported hardware
SetEntry (me : mutable;
Entry : FontMapEntry from Aspect)
---Level: Public
---Purpose: Modifies an entry already defined or adds <Entry>
-- in the font map <me> if it don't exist.
raises BadAccess from Aspect is virtual;
---Purpose: Warning if FontMap size is exceeded.
-- or FontMap is not defined properly
-- or FontMapEntry Index is out of range according
-- to the supported hardware
SetEntries (me : mutable;
Fontmap : FontMap from Aspect)
---Level: Public
---Purpose: Modifies all entries of <me> from the new Fontmap.
raises BadAccess from Aspect is virtual;
---Purpose: Warning if FontMap size is exceeded.
-- or FontMap is not defined properly
-- or One of new FontMapEntry Index is out of range according
-- to the supported hardware
Destroy (me : mutable) is virtual;
---Level: Public
---Purpose: Destroies the Fontmap
---C++: alias ~
----------------------------
-- Category: Inquire methods
----------------------------
FreeFonts (me)
returns Integer from Standard
---Level: Public
---Purpose: Returns the number of Free Fonts in the Fontmap
-- depending of the HardWare
raises BadAccess from Aspect is static;
---Error If FontMap is not defined properly
ExtendedFontMap (me)
returns Address from Standard
is static protected;
---Level: Public
---Purpose: Returns extended data fontmap structure pointer.
---Category: Inquire methods
fields
MyExtendedDisplay : Address from Standard;
MyExtendedFontMap : Address from Standard;
friends
class GraphicDevice from Xw
end FontMap;

109
src/Xw/Xw_FontMap.cxx Executable file
View File

@@ -0,0 +1,109 @@
#include <Xw_FontMap.ixx>
#include <Aspect_TypeOfFont.hxx>
#include <Aspect_FontStyle.hxx>
#include <Standard_ShortReal.hxx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Static data definitions
static char *ErrorMessag ;
static int ErrorNumber ;
static int ErrorGravity ;
static XW_STATUS status ;
Xw_FontMap::Xw_FontMap () {
}
Xw_FontMap::Xw_FontMap (const Standard_CString Connexion) {
MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ;
if( !MyExtendedDisplay ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_FontMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
MyExtendedFontMap = Xw_def_fontmap(MyExtendedDisplay,(int)0) ;
if( !Xw_isdefine_fontmap(MyExtendedFontMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_FontMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
void Xw_FontMap::SetEntry (const Aspect_FontMapEntry& Entry) {
Aspect_FontStyle style = Entry.Type() ;
int ffont = (int) Entry.Index() ;
Standard_CString value = style.FullName() ;
float csize = TOMILLIMETER(style.Size()) ;
if( ffont ) { /* Don't modify Index 0,Default font */
status = Xw_def_font(MyExtendedFontMap,ffont,csize,(char*)value);
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
}
void Xw_FontMap::SetEntries (const Handle(Aspect_FontMap)& Fontmap) {
Standard_Integer size = Fontmap->Size() ;
Standard_Integer i ;
if( !Xw_isdefine_fontmap(MyExtendedFontMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_FontMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
for( i=1 ; i<=size ; i++ ) {
SetEntry(Fontmap->Entry(i)) ;
}
}
void Xw_FontMap::Destroy() {
if( MyExtendedFontMap ) {
Xw_close_fontmap(MyExtendedFontMap) ;
MyExtendedFontMap = NULL ;
}
}
Standard_Integer Xw_FontMap::FreeFonts( ) const {
Standard_Integer nfont ;
int mfont,ufont,dfont,ffont ;
status = Xw_get_fontmap_info(MyExtendedFontMap,
&mfont,&ufont,&dfont,&ffont) ;
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
nfont = ufont - dfont ;
return (nfont) ;
}
Standard_Address Xw_FontMap::ExtendedFontMap () const {
return (MyExtendedFontMap);
}

293
src/Xw/Xw_GraphicDevice.cdl Executable file
View File

@@ -0,0 +1,293 @@
--
-- File: Xw_GraphicDevice.cdl
-- Created: Tue Oct 19 15:33:10 1993
-- Author: Gerard GRAS
-- corrections MFA 21 Oct 94
---Copyright: Matra Datavision 1993
--
class GraphicDevice from Xw inherits GraphicDevice from Aspect
---Purpose: This class defines an X11 Graphic Device
-- Warning: An Graphic Device is defined by :
-- - a connection "host:server.screen"
-- - a colormap mapping of type Xw_TOM_xxxxx
-- - a "UseDefault" flag which permits the use of the
-- DefaultColormap if possible.
-- The connection can be specified directly
-- or extracted from an existing Window.
-- All Xw_Windows may share the same Graphic Device if
-- you don't want to have any side effects on the stations
-- which have only one hardware pseudo-colormap .
-- Four kind of mapping are possible :
-- 1) Xw_TOM_SIMPLERAMP
-- Allocates the number of required colors in the
-- colormap.
-- The number of user colors depends directly on
-- the hardware colormap size if UseDefault is False,
-- or on the remainding free colors in the hardware colormap
-- if UseDefault is True.
-- 2) Xw_TOM_BESTRAMP
-- Allocates the number of required colors in the
-- colormap but leaves the Odd color indexes free
-- if possible for highlight color management.
-- (plane 0 is reserved for this usage)
-- The number of user colors depends directly on
-- the hardware colormap size if UseDefault is False,
-- or on the remainding free colors in the hardware colormap
-- if UseDefault is True.
-- 3) Xw_TOM_COLORCUBE (the default)
-- Allocates the maximum available colors in the colormap
-- and builds a colorcube at this place.
-- Any user color will be approximate and will be chosen as
-- the nearest of the set of available colorcube colors.
-- In this case the number of user colors can be unlimited.
-- 4) Xw_TOM_HARDWARE
-- May do serious damage to the color system.
-- Must be used for maintenance only.
-- 5) Xw_TOM_READONLY
-- Allocates the number of required read only colors in the
-- default colormap.
-- The number of user colors depends directly on
-- the hardware colormap size.
---References:
uses
AsciiString from TCollection,
Length from Quantity,
GraphicDriver from Aspect,
ColorMap from Xw,
TypeMap from Xw,
WidthMap from Xw,
FontMap from Xw,
MarkMap from Xw,
TypeOfVisual from Xw,
TypeOfMapping from Xw,
Handle from Aspect
raises
GraphicDeviceDefinitionError from Aspect,
BadAccess from Aspect
is
Create
returns mutable GraphicDevice from Xw is protected ;
Create (Connection : CString from Standard ;
Mapping : TypeOfMapping from Xw = Xw_TOM_COLORCUBE ;
Ncolors : Integer from Standard = 0 ;
UseDefault : Boolean from Standard = Standard_True )
returns mutable GraphicDevice from Xw
---Level: Public
---Purpose: Create an Graphic Device on the specified Connection
-- by using ALL screen defaults if possible
-- (i.e:Default Colormap)
-- Warning: Raises if the Device is Badly defined
raises GraphicDeviceDefinitionError from Aspect ;
---------------------------------------------------
-- Category: methods to modify the class definition
---------------------------------------------------
Destroy ( me : mutable )
---Level: Public
---Purpose: Destroies all ressources attached to the GraphicDevice
-- (Windows, Colormaps, ....)
-- Warning: Raises if the Device is Badly defined
raises BadAccess from Aspect is virtual;
---C++: alias ~
---Category: methods to modify the class definition
InitMaps ( me : mutable ; Connection : CString from Standard ;
Mapping : TypeOfMapping from Xw ;
Ncolors : Integer from Standard ;
UseDefault: Boolean from Standard )
---Level: Public
---Purpose: Initializes all ressources attached to the GraphicDevice
-- Category: methods to modify the class definition
-- Warning: Raises if the Device is Badly defined
raises GraphicDeviceDefinitionError from Aspect
is static protected ;
----------------------------
-- Category: Inquire methods
----------------------------
ColorMap2D ( me )
returns ColorMap from Xw is static;
---Level: Internal
---Purpose: Returns the 2D oriented Device color map.
---Category: Inquire methods
VisualClass2D ( me )
returns TypeOfVisual from Xw is static;
---Level: Internal
---Purpose: Returns the 2D oriented Visual Class.
---Category: Inquire methods
OverlayVisualClass2D ( me )
returns TypeOfVisual from Xw is static;
---Level: Internal
---Purpose: Returns the 2D oriented overlay Visual Class.
---Category: Inquire methods
ExtendedColorMap2D ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data colormap 2D structure pointer.
---Category: Inquire methods
ExtendedOverlayColorMap2D ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data overlay colormap 2D structure pointer.
---Category: Inquire methods
ColorMap3D ( me )
returns ColorMap from Xw is static;
---Level: Internal
---Purpose: Returns the 3D oriented Device color map.
---Category: Inquire methods
VisualClass3D ( me )
returns TypeOfVisual from Xw is static;
---Level: Internal
---Purpose: Returns the 3D oriented Visual Class.
---Category: Inquire methods
OverlayVisualClass3D ( me )
returns TypeOfVisual from Xw is static;
---Level: Internal
---Purpose: Returns the 3D oriented overlay Visual Class.
---Category: Inquire methods
ExtendedColorMap3D ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data colormap 3D structure pointer.
---Category: Inquire methods
ExtendedOverlayColorMap3D ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data overlay colormap 3D structure pointer.
---Category: Inquire methods
TypeMap ( me )
returns TypeMap from Xw is static;
---Level: Internal
---Purpose: Returns the Device Type map.
---Category: Inquire methods
ExtendedTypeMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data typemap structure pointer.
---Category: Inquire methods
WidthMap ( me )
returns WidthMap from Xw is static;
---Level: Internal
---Purpose: Returns the Device Width map.
---Category: Inquire methods
ExtendedWidthMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data widthmap structure pointer.
---Category: Inquire methods
FontMap ( me )
returns FontMap from Xw is static;
---Level: Internal
---Purpose: Returns the Device Font map.
---Category: Inquire methods
ExtendedFontMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data fontmap structure pointer.
---Category: Inquire methods
MarkMap ( me )
returns MarkMap from Xw is static;
---Level: Internal
---Purpose: Returns the Device Mark map.
---Category: Inquire methods
ExtendedMarkMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data markmap structure pointer.
---Category: Inquire methods
Display ( me )
returns CString from Standard is static;
---Level: Internal
---Purpose: Returns the Device connection string.
---Category: Inquire methods
XDisplay ( me )
returns Address from Standard is static;
---Level: Internal
---Purpose: Returns the Device Display Address.
---Category: Inquire methods
ExtendedDisplay ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data display structure pointer.
---Category: Inquire methods
DisplaySize ( me ; Width, Height : out Integer from Standard )
---Level: Public
---Purpose: Returns the Display size in PIXEL
-- Warning: Raises if the connection is not defined properly
raises BadAccess from Aspect is static;
DisplaySize ( me ; Width, Height : out Length from Quantity )
---Level: Public
---Purpose: Returns the Display size in METER
-- Warning: Raises if the connection is not defined properly
raises BadAccess from Aspect is static;
PlaneLayer ( me ; aVisualID : Integer from Standard )
returns Integer from Standard
---Level: Public
---Purpose: Returns the plane layer ID from a visual ID
-- Warning: Raises if the connection is not defined properly
raises BadAccess from Aspect is static;
GraphicDriver ( me )
returns GraphicDriver from Aspect
is redefined;
fields
MyDisplay : AsciiString from TCollection ;
MyColorMap2D : ColorMap from Xw ;
MyColorMap3D : ColorMap from Xw ;
MyTypeMap : TypeMap from Xw ;
MyWidthMap : WidthMap from Xw ;
MyFontMap : FontMap from Xw ;
MyMarkMap : MarkMap from Xw ;
MyExtendedDisplay : Address from Standard is protected ;
friends
class Window from Xw
end GraphicDevice from Xw ;

284
src/Xw/Xw_GraphicDevice.cxx Executable file
View File

@@ -0,0 +1,284 @@
#define GG001 //GG_300197
// Preferer utiliser le visual de la root window en mode
// 2D plutot que de prendre un visual PseudoColor alors que la root
// est TrueColor.
// Ceci corrige notamment les pb de colormap non intallees sur DEC
// lorsque la station est bootee en TrueColor.
// File Xw_GraphicDevice.cxx
// Created Octobre 1993
// Author GG
//-Copyright MatraDatavision 1991,1992,1993
//-Version
//-Design Creation d'une unite graphique
//-Warning
//-References
//-Language C++ 2.0
//-Declarations
// for the class
#include <stdio.h>
#include <Xw.hxx>
#include <Xw_GraphicDevice.ixx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Static data definitions
//static char *ErrorMessag,LocalMessag[80] ;
static char LocalMessag[80] ;
//static int ErrorNumber ;
//static int ErrorGravity ;
static XW_STATUS status ;
//-Aliases
//-Global data definitions
//-Constructors
Xw_GraphicDevice::Xw_GraphicDevice () : Aspect_GraphicDevice() {
MyExtendedDisplay = NULL;
}
Xw_GraphicDevice::Xw_GraphicDevice (const Standard_CString Connexion, const Xw_TypeOfMapping Mapping, const Standard_Integer Ncolors, const Standard_Boolean UseDefault) : Aspect_GraphicDevice() {
InitMaps(Connexion,Mapping,Ncolors,UseDefault) ;
}
void Xw_GraphicDevice::Destroy () {
if( MyColorMap2D != MyColorMap3D ) {
MyColorMap3D.Nullify();
MyColorMap2D.Nullify();
} else {
MyColorMap2D.Nullify();
}
MyTypeMap.Nullify();
MyWidthMap.Nullify();
MyFontMap.Nullify();
MyMarkMap.Nullify();
if( MyExtendedDisplay ) {
status = Xw_close_display(MyExtendedDisplay) ;
MyExtendedDisplay = NULL;
}
}
void Xw_GraphicDevice::InitMaps (const Standard_CString Connexion,const Xw_TypeOfMapping Mapping,const Standard_Integer Ncolors,const Standard_Boolean UseDefault) {
#ifdef GG001
Xw_TypeOfVisual v2d = Xw_TOV_DEFAULT ;
#else
Xw_TypeOfVisual v2d = Xw_TOV_PREFERRED_PSEUDOCOLOR ;
#endif
Xw_TypeOfVisual v3d = Xw_TOV_PREFERRED_TRUECOLOR ;
Xw_set_trace(Xw::TraceLevel(),Xw::ErrorLevel()) ;
if( Connexion ) {
MyDisplay = TCollection_AsciiString(Connexion) ;
} else {
MyDisplay = TCollection_AsciiString("") ;
}
MyExtendedDisplay = Xw_open_display((Standard_PCharacter)MyDisplay.ToCString()) ;
if( !MyExtendedDisplay ) {
sprintf(LocalMessag,"Cannot connect to server '%s'",
MyDisplay.ToCString());
Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
}
v2d = Xw_get_display_visual(MyExtendedDisplay,v2d) ;
MyColorMap2D = new Xw_ColorMap(MyDisplay.ToCString(),
v2d,Mapping,Ncolors,UseDefault) ;
v3d = Xw_get_display_visual(MyExtendedDisplay,v3d) ;
if( v2d != v3d ) {
MyColorMap3D = new Xw_ColorMap(MyDisplay.ToCString(),
v3d,Mapping,Ncolors,UseDefault) ;
} else {
MyColorMap3D = MyColorMap2D ;
}
MyTypeMap = new Xw_TypeMap(MyDisplay.ToCString()) ;
MyWidthMap = new Xw_WidthMap(MyDisplay.ToCString()) ;
MyFontMap = new Xw_FontMap(MyDisplay.ToCString()) ;
MyMarkMap = new Xw_MarkMap(MyDisplay.ToCString()) ;
Standard_Address Bof;
Bof = ExtendedColorMap2D();
Bof = ExtendedColorMap3D();
Bof = ExtendedTypeMap();
Bof = ExtendedWidthMap();
Bof = ExtendedFontMap();
Bof = ExtendedMarkMap();
if( !ExtendedColorMap2D() ||
!ExtendedColorMap3D() ||
!ExtendedTypeMap() ||
!ExtendedWidthMap() ||
!ExtendedFontMap() ||
!ExtendedMarkMap() ) {
sprintf(LocalMessag,"Bad Graphic Device Attributs on '%s'",
Connexion);
Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
}
}
Handle(Xw_ColorMap) Xw_GraphicDevice::ColorMap2D () const {
return (MyColorMap2D) ;
}
Xw_TypeOfVisual Xw_GraphicDevice::VisualClass2D () const {
return (MyColorMap2D->VisualClass()) ;
}
Xw_TypeOfVisual Xw_GraphicDevice::OverlayVisualClass2D () const {
return (MyColorMap2D->OverlayVisualClass()) ;
}
Standard_Address Xw_GraphicDevice::ExtendedColorMap2D () const {
return (MyColorMap2D->ExtendedColorMap());
}
Standard_Address Xw_GraphicDevice::ExtendedOverlayColorMap2D () const {
return (MyColorMap2D->ExtendedOverlayColorMap());
}
Handle(Xw_ColorMap) Xw_GraphicDevice::ColorMap3D () const {
return (MyColorMap3D) ;
}
Xw_TypeOfVisual Xw_GraphicDevice::VisualClass3D () const {
return (MyColorMap3D->VisualClass()) ;
}
Xw_TypeOfVisual Xw_GraphicDevice::OverlayVisualClass3D () const {
return (MyColorMap3D->OverlayVisualClass()) ;
}
Standard_Address Xw_GraphicDevice::ExtendedColorMap3D () const {
return (MyColorMap3D->ExtendedColorMap());
}
Standard_Address Xw_GraphicDevice::ExtendedOverlayColorMap3D () const {
return (MyColorMap3D->ExtendedOverlayColorMap());
}
Handle(Xw_TypeMap) Xw_GraphicDevice::TypeMap () const {
return (MyTypeMap) ;
}
Standard_Address Xw_GraphicDevice::ExtendedTypeMap () const {
return (MyTypeMap->ExtendedTypeMap());
}
Handle(Xw_WidthMap) Xw_GraphicDevice::WidthMap () const {
return (MyWidthMap) ;
}
Standard_Address Xw_GraphicDevice::ExtendedWidthMap () const {
return (MyWidthMap->ExtendedWidthMap());
}
Handle(Xw_FontMap) Xw_GraphicDevice::FontMap () const {
return (MyFontMap) ;
}
Standard_Address Xw_GraphicDevice::ExtendedFontMap () const {
return (MyFontMap->ExtendedFontMap());
}
Handle(Xw_MarkMap) Xw_GraphicDevice::MarkMap () const {
return (MyMarkMap) ;
}
Standard_Address Xw_GraphicDevice::ExtendedMarkMap () const {
return (MyMarkMap->ExtendedMarkMap());
}
Standard_CString Xw_GraphicDevice::Display () const {
return (MyDisplay.ToCString());
}
Standard_Address Xw_GraphicDevice::XDisplay () const {
Aspect_Handle *display ;
Aspect_Handle root,colormap ;
Xw_TypeOfVisual pclass ;
int depth ;
status = Xw_get_display_info(MyExtendedDisplay,&display,
&root,&colormap,&pclass,&depth) ;
return (display);
}
Standard_Address Xw_GraphicDevice::ExtendedDisplay () const {
return (MyExtendedDisplay);
}
void Xw_GraphicDevice::DisplaySize (Standard_Integer &Width,Standard_Integer &Height) const {
int width,height ;
status = Xw_get_screen_size(MyExtendedDisplay,&width,&height) ;
Width = width ;
Height = height ;
}
void Xw_GraphicDevice::DisplaySize (Quantity_Length &Width,Quantity_Length &Height) const {
float width,height ;
status = Xw_get_mmscreen_size(MyExtendedDisplay,&width,&height) ;
Width = FROMMILLIMETER(width) ;
Height = FROMMILLIMETER(height) ;
}
Standard_Integer Xw_GraphicDevice::PlaneLayer (const Standard_Integer aVisualID) const {
return Xw_get_plane_layer(MyExtendedDisplay,aVisualID);
}
Handle(Aspect_GraphicDriver) Xw_GraphicDevice::GraphicDriver () const {
static Handle(Aspect_GraphicDriver) foo;
cout << "Xw_GraphicDevice::GraphicDriver returns foo\n" << flush;
return foo;
}

147
src/Xw/Xw_IconBox.cdl Executable file
View File

@@ -0,0 +1,147 @@
--
-- File: Xw_IconBox.cdl
-- Created: 2 Mars 1994
-- Author: GG
--
---Copyright: MatraDatavision 1991,1992,1993
class IconBox from Xw inherits Window from Xw
---Version:
---Purpose: This class defines a X11 IconBox
-- Warning: The IconBox is not visible at the creation time .
-- To show the Icon Box use the method Show () .
-- In this case the Icon Box appears at the DSU position
-- specified given in [0,1] space .
-- The size of the Icon Box grows depending of the number
-- of the Icons loaded inside .
---References:
uses
NameOfColor from Quantity,
GraphicDevice from Xw,
TypeOfVisual from Xw,
Handle from Aspect,
WindowQuality from Xw
raises
WindowDefinitionError from Aspect,
WindowError from Aspect
is
Create ( Device : GraphicDevice from Xw ;
Name : CString from Standard ;
Xc : Real from Standard = 0.5 ;
Yc : Real from Standard = 0.5 ;
BackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY;
aQuality : WindowQuality from Xw = Xw_WQ_SAMEQUALITY)
returns mutable IconBox from Xw
---Level: Public
---Purpose: Creates a IconBox n Preferred PseudoColor Visual
-- defined by his Center in DSU and connects it to the
-- X server at the first call depending of the GraphicDevice
-- connexion .
-- ALL Icons are loaded from the Icon File Directory Name :
-- "[$SYMBOL]xxxxxxx[.ifd]"
-- Warning: Raises if the Position is out of the Screen Space
-- or the Icon File Directory Name don't exist
raises WindowDefinitionError from Aspect ;
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
LoadIcons ( me : mutable ; Name : CString from Standard )
returns Integer from Standard is static;
---Level: Public
---Purpose: Loads Icon Box from an Other Icon File Directory Name
-- and returns the loaded icons number.
-- Warning: The Icons previously loaded are NOT cleared .
---Category: Methods to modify the class definition
Show ( me ) is static;
---Level: Public
---Purpose: Shows Icon Box to the screen
-- Warning: The Icon Box is displayed at the centered position
-- specified at the creation time and the size depend
-- of the Icon number really loaded inside .
UnloadIcons ( me : mutable ; Name : CString from Standard )
returns Integer from Standard is static;
---Level: Public
---Purpose: Unloads All previously loaded Icons in the IconBox
-- and returns the unloaded icons number.
---Category: methods to modify the class definition
Destroy ( me : mutable) is redefined ;
---Level: Public
---Purpose: Destroies the IconBox
---C++: alias ~
---Category: Methods to modify the class definition
AddIcon ( me : mutable ; W : Window from Xw ;
Name : CString from Standard;
aWidth : Integer from Standard = 0;
aHeight : Integer from Standard = 0) is static;
---Level: Public
---Purpose: Adds an Icon of Size aWidth,aHeight given in PIXEL
-- to the Icon Box from a FULL Existing Window
-- NOTE that if aWidth or aHeight is 0 the default icon size is taken.
---Category: methods to modify the class definition
SaveIcons ( me ) returns Integer from Standard is static;
---Level: Public
---Purpose: Saves all new created Icons as iconname.xwd file in the user
-- directory and returns the saved icons number.
----------------------------
-- Category: Inquire methods
----------------------------
IconNumber ( me )
returns Integer from Standard is static;
---Level: Public
---Purpose: Returns the Number of Icons loaded in the Icon Box .
IconName ( me ; Index : Integer from Standard )
returns CString from Standard
---Level: Public
---Purpose: Returns the Name of the N ime Icon
-- Warning: Raises if Index if out of range depending of the
-- Number of Loaded Icons .
raises WindowError from Aspect is static;
IconSize ( me ; Name : CString from Standard ;
Width, Height : out Integer from Standard )
returns Boolean from Standard is static;
---Level: Public
---Purpose: Returns the Pixmap Size attached to the Icon Name
-- Warning: May return FALSE if Icon doesn't exist in the IconBox .
---Category: Inquire methods
IconPixmap ( me ; Name : CString from Standard )
returns Handle from Aspect is static;
---Level: Public
---Purpose: Returns the Pixmap attached to the Icon Name
-- Warning: May return 0 if Icon doesn't exist in the IconBox .
---Category: Inquire methods
IconPixmap ( me ; Name : CString from Standard ;
Width, Height : Integer from Standard )
returns Handle from Aspect is static;
---Level: Public
---Purpose: Returns the Centered part of the Pixmap of required Size
-- attached to the Icon Name
-- Warning: May return 0 if Icon doesn't exist in the IconBox .
---Category: Inquire methods
fields
MyNumberOfIcons : Integer from Standard ;
end IconBox ;

159
src/Xw/Xw_IconBox.cxx Executable file
View File

@@ -0,0 +1,159 @@
#define PURIFY //GG_180297
// Liberation memoire allouee par les icones.
// File Xw_IconBox.cxx
// Created Mars 1994
// Author GG
//-Copyright MatraDatavision 1991,1992,1993
//-Version
//-Design Creation d'une Icon Box
//-Warning
//-References
//-Language C++ 2.0
//-Declarations
// for the class
#include <Xw_IconBox.ixx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Static data definitions
static XW_STATUS status ;
//-Aliases
//-Global data definitions
//-Constructors
Xw_IconBox::Xw_IconBox (const Handle(Xw_GraphicDevice)& Device, const Standard_CString Name, const Standard_Real Xc, const Standard_Real Yc, const Quantity_NameOfColor BackColor,const Xw_WindowQuality aQuality) :
Xw_Window(Device,Name,Xc,Yc,0.1,0.1,aQuality,BackColor,0) {
MyNumberOfIcons = Xw_load_icons(MyExtendedWindow,(Standard_PCharacter)Name) ;
if( !MyNumberOfIcons ) {
PrintError() ;
}
}
void Xw_IconBox::Destroy () {
MyNumberOfIcons = 0 ;
#ifdef PURIFY
if( MyExtendedWindow ) Xw_clear_icons(MyExtendedWindow,NULL);
#endif
}
Standard_Integer Xw_IconBox::UnloadIcons ( const Standard_CString Name) {
Standard_Integer nicons = 0;
nicons = Xw_clear_icons (MyExtendedWindow,(Standard_PCharacter)Name);
if( !nicons ) Xw_print_error() ;
MyNumberOfIcons -= nicons ;
return nicons;
}
void Xw_IconBox::Show () const {
status = Xw_show_icons (MyExtendedWindow);
if( !status ) Xw_print_error() ;
}
Standard_Integer Xw_IconBox::LoadIcons ( const Standard_CString Name ) {
int nicons ;
nicons = Xw_load_icons(MyExtendedWindow,(Standard_PCharacter)Name) ;
if( nicons > 0 ) MyNumberOfIcons += nicons ;
else Xw_print_error() ;
return nicons;
}
void Xw_IconBox::AddIcon ( const Handle(Xw_Window)& W,const Standard_CString Name,
const Standard_Integer aWidth,const Standard_Integer aHeight ) {
status = Xw_put_window_icon(MyExtendedWindow,W->ExtendedWindow(),
(Standard_PCharacter)Name,aWidth,aHeight) ;
if( status ) MyNumberOfIcons++ ;
else Xw_print_error() ;
}
Standard_Integer Xw_IconBox::SaveIcons () const {
Standard_Integer nicons = 0;
nicons = Xw_save_icons(MyExtendedWindow) ;
return nicons;
}
Standard_Integer Xw_IconBox::IconNumber () const {
return (MyNumberOfIcons);
}
Standard_CString Xw_IconBox::IconName ( const Standard_Integer Index) const {
char *Name = NULL ;
if( Index < 0 || Index > MyNumberOfIcons ) {
PrintError() ;
}
Name = Xw_get_icon_name(MyExtendedWindow,(int)Index) ;
if( !Name ) Xw_print_error() ;
return (Name);
}
Standard_Boolean Xw_IconBox::IconSize ( const Standard_CString Name, Standard_Integer& Width, Standard_Integer& Height ) const {
int width,height ;
status = Xw_get_icon_size( MyExtendedWindow,(Standard_PCharacter)Name,&width,&height) ;
if( status ) {
Width = width ;
Height = height ;
} else {
Xw_print_error() ;
}
return Standard_Boolean(status);
}
Aspect_Handle Xw_IconBox::IconPixmap ( const Standard_CString Name ) const {
Aspect_Handle pixmap = 0 ;
pixmap = Xw_get_icon_pixmap( MyExtendedWindow,0,0,(Standard_PCharacter)Name) ;
if( !pixmap ) Xw_print_error() ;
return (pixmap);
}
Aspect_Handle Xw_IconBox::IconPixmap ( const Standard_CString Name, const Standard_Integer Width,const Standard_Integer Height ) const {
Aspect_Handle pixmap = 0 ;
pixmap = Xw_get_icon_pixmap( MyExtendedWindow,
(int)Width,(int)Height,
(Standard_PCharacter)Name) ;
if( !pixmap ) Xw_print_error() ;
return (pixmap);
}

100
src/Xw/Xw_MarkMap.cdl Executable file
View File

@@ -0,0 +1,100 @@
--
-- File: Xw_MarkMap.cdl
-- Created: 17/01/95
-- Author: GG
--
---Copyright: MatraDatavision 1993
--
class MarkMap from Xw inherits Transient
---Version: 0.0
---Purpose: This class defines a MarkMap object.
---Keywords:
---Warning:
---References:
uses
MarkMap from Aspect,
MarkMapEntry from Aspect,
MarkerStyle from Aspect
raises
MarkMapDefinitionError from Aspect,
BadAccess from Aspect
is
Create
returns mutable MarkMap from Xw
is protected ;
---Level: Internal
Create ( Connexion : CString from Standard )
returns mutable MarkMap from Xw
---Level: Public
---Purpose: Creates a MarkMap with unallocated MarkMapEntry.
-- Warning: Raises if MarkMap creation failed according
-- to the supported hardware
raises MarkMapDefinitionError from Aspect ;
SetEntry ( me : mutable ;
anEntry : MarkMapEntry from Aspect )
---Level: Public
---Purpose: Modifies an entry already defined or Add the Entry
-- in the marker map <me> if it don't exist.
-- Warning: Raises if MarkMap size is exceeded,
-- or MarkMap is not defined properly,
-- or MarkMapEntry Index is out of range according
-- to the supported hardware
raises BadAccess from Aspect is virtual;
SetEntries ( me : mutable ;
aMarkmap : MarkMap from Aspect )
---Level: Public
---Purpose: Modifies all entries from a new Markmap
-- Warning: Raises if MarkMap size is exceeded,
-- or MarkMap is not defined properly,
-- or One of new MarkMapEntry Index is out of range according
-- to the supported hardware
raises BadAccess from Aspect is virtual;
Destroy ( me : mutable ) is virtual;
---Level: Public
---Purpose: Destroies the Markmap
---C++: alias ~
----------------------------
-- Category: Inquire methods
----------------------------
FreeMarkers ( me )
returns Integer from Standard
---Level: Public
---Purpose: Returns the Number of Free Marks in the Typemap
-- depending of the HardWare
-- Warning: Raises if MarkMap is not defined properly
raises BadAccess from Aspect is static;
ExtendedMarkMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data markermap structure pointer.
---Category: Inquire methods
fields
MyExtendedDisplay : Address from Standard ;
MyExtendedMarkMap : Address from Standard ;
friends
class GraphicDevice from Xw
end MarkMap ;

121
src/Xw/Xw_MarkMap.cxx Executable file
View File

@@ -0,0 +1,121 @@
#include <Xw_MarkMap.ixx>
#include <Aspect_TypeOfMarker.hxx>
#include <Aspect_MarkerStyle.hxx>
#include <Standard_ShortReal.hxx>
#include <TShort_Array1OfShortReal.hxx>
#include <TColStd_Array1OfBoolean.hxx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Static data definitions
static char *ErrorMessag ;
static int ErrorNumber ;
static int ErrorGravity ;
static XW_STATUS status ;
Xw_MarkMap::Xw_MarkMap () {
}
Xw_MarkMap::Xw_MarkMap (const Standard_CString Connexion) {
MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ;
if( !MyExtendedDisplay ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_MarkMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
MyExtendedMarkMap = Xw_def_markmap(MyExtendedDisplay,(int)0) ;
if( !Xw_isdefine_markmap(MyExtendedMarkMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_MarkMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
void Xw_MarkMap::SetEntry (const Aspect_MarkMapEntry& anEntry) {
Aspect_MarkerStyle style = anEntry.Style() ;
int length = (int) style.Length() ;
int index = (int) anEntry.Index() ;
const TShort_Array1OfShortReal& xvalues(style.XValues()) ;
const TShort_Array1OfShortReal& yvalues(style.YValues()) ;
const TColStd_Array1OfBoolean& svalues(style.SValues()) ;
float *X = (float*) &xvalues.Value(xvalues.Lower());
float *Y = (float*) &yvalues.Value(yvalues.Lower());
int *S = (int*) &svalues.Value(svalues.Lower());
Standard_Integer i;
for( i=1 ; i<=length ; i++ ) {
// Standard_Real xcoord,ycoord;
// Standard_Boolean state = style.Values(i,xcoord,ycoord);
}
if( index ) { /* Index 0 is default POINT Marker ,cann't be changed */
status = Xw_def_marker(MyExtendedMarkMap,index,length,S,X,Y) ;
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
}
void Xw_MarkMap::SetEntries (const Handle(Aspect_MarkMap)& Markmap) {
Standard_Integer size = Markmap->Size() ;
Standard_Integer i ;
if( !Xw_isdefine_markmap(MyExtendedMarkMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_MarkMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
for( i=1 ; i<=size ; i++ ) {
SetEntry(Markmap->Entry(i)) ;
}
}
void Xw_MarkMap::Destroy() {
if( MyExtendedMarkMap ) {
Xw_close_markmap(MyExtendedMarkMap) ;
MyExtendedMarkMap = NULL ;
}
}
Standard_Integer Xw_MarkMap::FreeMarkers( ) const {
Standard_Integer ntype ;
int mtype,utype,dtype,ftype ;
status = Xw_get_markmap_info(MyExtendedMarkMap,
&mtype,&utype,&dtype,&ftype) ;
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
ntype = utype - dtype ;
return (ntype) ;
}
Standard_Address Xw_MarkMap::ExtendedMarkMap () const {
return (MyExtendedMarkMap);
}

86
src/Xw/Xw_PixMap.cdl Executable file
View File

@@ -0,0 +1,86 @@
--
-- File: Xw_PixMap.cdl
-- Created: 14 October 1999
-- Author: VKH
-- Updated: GG IMP100701 Add the "depth" field and method
-- to the pixmap object.
--
---Copyright: MatraDatavision 1999
class PixMap from Xw
---Version:
---Purpose: This class defines a X11 pixmap
---Keywords: Bitmap, Pixmap, X11
inherits
PixMap from Aspect
uses
Handle from Aspect,
Color from Quantity,
Window from Aspect,
Window from Xw
raises
PixmapDefinitionError from Aspect,
PixmapError from Aspect
is
Create ( aWindow : Window from Aspect;
aWidth, anHeight : Integer from Standard;
aDepth : Integer from Standard = 0 )
returns mutable PixMap from Xw
raises PixmapDefinitionError from Aspect;
---Level: Public
---Purpose: Warning! When <aDepth> is NULL , the pixmap is created
-- with the SAME depth than the window <aWindow>
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
Destroy ( me : mutable )
---Level: Advanced
---Purpose: Destroies the Pixmap
-- Trigger: Raises if Pixmap is not defined properly
raises PixmapError from Aspect is virtual;
Dump ( me ; aFilename : CString from Standard;
aGammaValue: Real from Standard = 1.0 )
returns Boolean
is virtual;
---Level: Advanced
---Purpose:
-- Dumps the Bitmap to an image file with
-- an optional gamma correction value
-- and returns TRUE if the dump occurs normaly.
---Category: Methods to modify the class definition
PixelColor ( me : in;
theX, theY : in Integer from Standard )
returns Color from Quantity
is virtual;
---Purpose:
-- Returns the pixel color.
----------------------------
-- Category: Inquire methods
----------------------------
PixmapID ( me ) returns Handle from Aspect is virtual;
---Level: Advanced
---Purpose: Returns the ID of the just created pixmap
---Category: Inquire methods
----------------------------
-- Category: Private methods
----------------------------
PreferedDepth( me ; aWindow : Window from Aspect;
aDepth : Integer from Standard)
returns Integer from Standard is private;
fields
myPixmap : Handle from Aspect is protected;
myWindow : Window from Xw;
end PixMap;

161
src/Xw/Xw_PixMap.cxx Executable file
View File

@@ -0,0 +1,161 @@
// File Xw_PixMap.cxx
// Created 14 October 1999
// Author VKH
// Updated GG 06/03/00 Xw_PixMap MUST creates a Pixmap and no more an Image !!!
// GG IMP100701 Add the "depth" field and method
// to the pixmap object.
//-Copyright MatraDatavision 1999
//-Version
#define xTRACE 1
//
#include <errno.h>
#include <stdio.h>
#include <Xw_PixMap.ixx>
#include <Xw_Window.hxx>
#include <Xw_Extension.h>
#include <TCollection_AsciiString.hxx>
#include <Image_PixMap.hxx>
XW_STATUS Xw_save_xwd_image ( void*, void*, char* );
XW_STATUS Xw_save_bmp_image ( void*, void*, char* );
XW_STATUS Xw_save_gif_image ( void*, void*, char* );
Standard_Integer Xw_PixMap::PreferedDepth(
const Handle(Aspect_Window)& aWindow,
const Standard_Integer aDepth) const {
Handle(Xw_Window) hwindow = Handle(Xw_Window)::DownCast(aWindow);
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) hwindow->ExtendedWindow();
if( aDepth <= 0 ) return _DEPTH;
// Gets the nearest depth from possible screen depths
Standard_Integer i,j;
Screen *scr = DefaultScreenOfDisplay(_DISPLAY);
for( i=j=0 ; i<scr->ndepths ; i++ ) {
if( Abs(aDepth - scr->depths[i].depth) <
Abs(aDepth - scr->depths[j].depth) ) {
j = i;
}
}
return scr->depths[j].depth;
}
//////////////////////////////////////////////////////////////////////////////////////////
Xw_PixMap::Xw_PixMap ( const Handle(Aspect_Window)& aWindow,
const Standard_Integer aWidth,
const Standard_Integer anHeight,
const Standard_Integer aDepth ) :
Aspect_PixMap(aWidth, anHeight, PreferedDepth(aWindow, aDepth))
{
myWindow = Handle(Xw_Window)::DownCast(aWindow);
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) myWindow->ExtendedWindow();
Xw_print_error();
if( !Xw_get_trace() ) Xw_set_synchronize(_DISPLAY,True);
myPixmap = XCreatePixmap( _DISPLAY, _WINDOW, myWidth, myHeight, myDepth);
if( !Xw_get_trace() ) Xw_set_synchronize(_DISPLAY,False);
if ( !myPixmap || Xw_print_error() ) {
char errstring[256];
sprintf(errstring," *** Xw_PixMap : Cann't allocates pixmap of size %d x %d, request failed with errno : '%s'",myWidth, myHeight,strerror(errno));
Aspect_PixmapDefinitionError::Raise ( errstring );
}
}
///////////////////////////////
void
Xw_PixMap::Destroy ()
{
if( myPixmap ) {
#ifdef TRACE
printf(" $$$ Xw_PixMap::Destroy() %x\n",myPixmap);
#endif
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) myWindow->ExtendedWindow();
XFreePixmap(_DISPLAY,myPixmap);
}
}
////////////////////////////////////////////////////////////
Standard_Boolean Xw_PixMap::Dump (const Standard_CString theFilename,
const Standard_Real theGammaValue) const
{
// the attributes
XWindowAttributes winAttr;
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) myWindow->ExtendedWindow();
XGetWindowAttributes (_DISPLAY, _WINDOW, &winAttr);
// find the image
XImage* pximage = XGetImage (_DISPLAY, myPixmap,
0, 0, myWidth, myHeight,
AllPlanes, ZPixmap);
if (pximage == NULL)
{
return Standard_False;
}
if (winAttr.visual->c_class == TrueColor)
{
Standard_Byte* aDataPtr = (Standard_Byte* )pximage->data;
Handle(Image_PixMap) anImagePixMap = new Image_PixMap (aDataPtr,
pximage->width, pximage->height,
pximage->bytes_per_line,
pximage->bits_per_pixel,
Standard_True);
// destroy the image
XDestroyImage (pximage);
// save the image
return anImagePixMap->Dump (theFilename, theGammaValue);
}
else
{
std::cerr << "Visual Type not supported!";
// destroy the image
XDestroyImage (pximage);
return Standard_False;
}
}
////////////////////////////////////////////////////////////
Aspect_Handle Xw_PixMap::PixmapID() const
{
return myPixmap;
}
Quantity_Color Xw_PixMap::PixelColor (const Standard_Integer theX,
const Standard_Integer theY) const
{
// the attributes
XWindowAttributes winAttr;
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) myWindow->ExtendedWindow();
XGetWindowAttributes (_DISPLAY, _WINDOW, &winAttr);
// find the image
XImage* pximage = XGetImage (_DISPLAY, myPixmap,
0, 0, myWidth, myHeight,
AllPlanes, ZPixmap);
if (pximage == NULL)
{
return Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB);
}
XColor aColor;
aColor.pixel = XGetPixel (pximage, theX, theY);
XDestroyImage (pximage);
XQueryColor (_DISPLAY, myWindow->XColorMap(), &aColor);
return Quantity_Color (Quantity_Parameter (aColor.red) / 65535.0,
Quantity_Parameter (aColor.green) / 65535.0,
Quantity_Parameter (aColor.blue) / 65535.0,
Quantity_TOC_RGB);
}

128
src/Xw/Xw_TextManager.cdl Executable file
View File

@@ -0,0 +1,128 @@
-- File: Xw_TextManager.cdl
-- Created: Tue Apr 29 09:14:42 1993
-- Author: Gerard GRAS
-- <gg@photox>
---Copyright: Matra Datavision 1993
class TextManager from Xw inherits TextManager from MFT
---Purpose: defines the common behaviour of the Xw output driver.
-- Warning: Permits to receives draw primitives from the FontManager
-- at DrawText(...) time.
-- This class must be redefined by the user as an application class.
uses
Length from Quantity,
PlaneAngle from Quantity,
TypeOfText from Aspect
is
-------------------------
-- Category: Constructors
-------------------------
Create (aDrawable : Address from Standard;
aWidthMap : Address from Standard)
returns mutable TextManager from Xw;
---Purpose: Does NOTHING
-------------------------
-- Category: Draw methods
-------------------------
BeginString (me: mutable;
X,Y: Length from Quantity;
anOrientation: PlaneAngle from Quantity;
aWidth,aHeight: Length from Quantity;
aSlant: PlaneAngle from Quantity;
aPaintType: Integer from Standard) is redefined;
---Purpose: Calls when string drawing is started.
-- with a string aspect <aPaintType> :
-- 0 for filled string
-- 1 for stroke string
-- 2 for outline string
-- The origine of the string <X>,<Y>,
-- The orientation of the string <anOrientation>,
-- The medium size of the char <aWidth,aHeight>,
-- The Slant of the char <aSlant>,
BeginChar (me: mutable;
aCharCode: Integer from Standard;
X,Y: Length from Quantity)
returns Boolean from Standard is redefined;
---Purpose: Calls when a char drawing is started
-- and give the current string position for this char.
-- and give the relative char position from the beginning
-- of the string.
-- The application can returns FALSE for skipping the char drawing.
SetCharBoundingBox (me: mutable;
X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity)
returns Boolean from Standard is redefined;
---Purpose: Calls to defines the current char bounding-box.
-- The application can returns FALSE for ending the char drawing.
SetCharEncoding (me: mutable;
anEncoding: CString from Standard)
returns Boolean from Standard is redefined;
---Purpose: Calls to defines the current char encoding.
-- Warning: The application can returns FALSE for skipping the char drawing.
Moveto (me: mutable;
X,Y: Length from Quantity)
returns Boolean from Standard is redefined;
---Purpose: Calls to sets the current string position.
-- The application can returns FALSE for ending the char drawing.
Lineto (me: mutable;
X,Y: Length from Quantity)
returns Boolean from Standard is redefined;
---Purpose: Calls to drawn to the current string position.
-- The application can returns FALSE for ending the char drawing.
Curveto (me: mutable;
X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity)
returns Boolean from Standard is redefined;
---Purpose: Calls to drawn to the current string position.
-- The application can drawn the curve defined by
-- his descriptor P1,P2,P3,P4 or
-- returns FALSE to let the interpretor compute the curve
-- vectors.
ClosePath (me: mutable) is redefined;
---Purpose: Calls when a char path drawing is ended
EndChar (me: mutable;
X,Y: Length from Quantity)
returns Boolean from Standard is redefined;
---Purpose: Calls when a char drawing is ended
-- and give the relative char ending position from the
-- beginning of the string.
-- The application can returns FALSE for skipping the string
-- drawing.
EndString (me: mutable ) is redefined;
---Purpose: Calls when string drawing is ended (Normally the last call).
-------------------------
-- Category: Private methods
-------------------------
SetTextAttribs (me: mutable ;
aTextColor: Integer from Standard;
aTypeOfText: TypeOfText from Aspect;
anUnderlinePosition: Length from Quantity = 0.0)
is private;
---Purpose: Sets the current attribs of the text.
fields
myDrawable: Address from Standard;
myWidthMap: Address from Standard;
friends
class Driver from Xw
end TextManager from Xw;

295
src/Xw/Xw_TextManager.cxx Executable file
View File

@@ -0,0 +1,295 @@
#define S3593 //GG_130398
// OPTIMISATION MFT
//
#define PRO14351//GG_180698
// OPTIMISATION MFT
//
#include <Xw_TextManager.ixx>
#include <Aspect_Units.hxx>
#define TRACE 0
#define MAXCHARPOINTS 512
#define MAXCHARPATHS 8
#define TRANSFORM(X,Y) \
{ Standard_Real x = X,y = Y; \
X = x*theCosAngle - y*theSinAngle; \
Y = x*theSinAngle + y*theCosAngle; \
}
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
static XW_ATTRIB thePolyCode,theLineCode;
static Standard_Integer thePaintType,theNchar,theNpoly,theNpath;
static Standard_Integer theTextColor,theLineColor,theLineType,theLineWidth;
static Standard_Integer thePolyColor,thePolyType,thePolyTile;
static XW_DRAWMODE theLineMode,thePolyMode;
static Aspect_TypeOfText theTypeOfText;
static Standard_ShortReal theUnderlinePosition;
static Standard_ShortReal theX,theY,thePX,thePY;
static Standard_ShortReal theXmin,theXmax,theSinAngle,theCosAngle;
static Standard_ShortReal theSlant,theWidth,theHeight;
static Standard_Real theOrientation;
static Standard_Boolean theClippingFlag;
Xw_TextManager::Xw_TextManager(const Standard_Address aDrawable, const Standard_Address aWidthMap) : myDrawable(aDrawable),myWidthMap(aWidthMap) {
}
void Xw_TextManager::BeginString( const Quantity_Length X, const Quantity_Length Y, const Quantity_PlaneAngle anOrientation, const Quantity_Length aWidth, const Quantity_Length aHeight, const Quantity_PlaneAngle aSlant, const Standard_Integer aPaintType) {
#if TRACE > 0
cout << " Xw_TextManager::BeginString(" <<
X << "," << Y << "," << anOrientation << ","
<< aWidth << "," << aHeight << "," aSlant << ","
<< aPaintType << ")" << endl;
#endif
thePaintType = aPaintType;
theOrientation = anOrientation;
theX = X; theY = Y;
theXmin = theXmax = 0.;
theNchar = 0;
theSlant = aSlant;
theWidth = aWidth;
theHeight = aHeight;
theNpoly = theNpath = 0;
#ifdef S3593
// Set clipping off
theClippingFlag = Xw_get_clipping(myDrawable);
Xw_set_clipping(myDrawable,Standard_False);
#endif
// Save line attribs
thePolyCode = Xw_get_poly_attrib(myDrawable,
&thePolyColor,&thePolyType,&thePolyTile,&thePolyMode);
theLineCode = Xw_get_line_attrib(myDrawable,
&theLineColor,&theLineType,&theLineWidth,&theLineMode);
Standard_ShortReal thickness = theHeight/32.;
Standard_Integer windex;
Xw_get_width_index(myWidthMap,thickness,&windex) ;
// Force to OUTLINE if required
if( !thePaintType ) {
if( (theHeight < (4. MILLIMETER)) ||
(theTypeOfText == Aspect_TOT_OUTLINE) ) thePaintType = 2;
}
// Sets the MFT text attribs
switch (thePaintType) {
case 0:
Xw_set_poly_attrib(myDrawable,
theTextColor,Standard_False,0,XW_REPLACE);
Xw_set_line_attrib(myDrawable,
theTextColor,0,windex,XW_REPLACE);
break;
case 2:
Xw_set_poly_attrib(myDrawable,
theTextColor,Standard_True,-1,XW_REPLACE);
Xw_set_line_attrib(myDrawable,
theTextColor,0,windex,XW_REPLACE);
break;
case 1:
Xw_set_line_attrib(myDrawable,
theTextColor,0,windex,XW_REPLACE);
#ifndef PRO14351
Xw_begin_segments(myDrawable, 0);
#endif
break;
}
}
Standard_Boolean Xw_TextManager::BeginChar(const Standard_Integer aCharCode, const Standard_Real X, const Standard_Real Y) {
#if TRACE > 0
cout << " Xw_TextManager::BeginChar(" << aCharCode << "," <<
X << "," << Y << ")" << endl;
#endif
thePX = X; thePY = Y;
#ifndef PRO14351
if( thePaintType != 1 )
#endif
theNpoly = theNpath = 0;
return Standard_True;
}
Standard_Boolean Xw_TextManager::SetCharBoundingBox(const Quantity_Length X1, const Quantity_Length Y1, const Quantity_Length X2, const Quantity_Length Y2, const Quantity_Length X3, const Quantity_Length Y3, const Quantity_Length X4, const Quantity_Length Y4) {
#if TRACE > 0
cout << " Xw_TextManager::SetCharBoundingBox(" << X1 << "," << Y1 << "," <<
X2 << "," << Y2 << "," << X3 << "," << Y3 << "," <<
X4 << "," << Y4 << ")" << endl;
#endif
if( theUnderlinePosition > 0. ) {
if( !theNchar ) {
theXmin = Standard_ShortReal (X1);
}
theXmax = Sqrt(X2*X2 + Y2*Y2);
}
return Standard_True;
}
Standard_Boolean Xw_TextManager::SetCharEncoding(const Standard_CString anEncoding) {
#if TRACE > 0
cout << " Xw_TextManager::SetCharEncoding('" << anEncoding << "')" << endl;
#endif
return Standard_True;
}
Standard_Boolean Xw_TextManager::Moveto(const Standard_Real X, const Standard_Real Y) {
#if TRACE > 1
cout << " Xw_TextManager::Moveto(" << X << "," << Y << ")" << endl;
#endif
#ifndef PRO14351
if( thePaintType != 1 )
#endif
this->ClosePath();
thePX = X; thePY = Y;
return Standard_True;
}
Standard_Boolean Xw_TextManager::Lineto(const Standard_Real X, const Standard_Real Y) {
#if TRACE > 1
cout << " Xw_TextManager::Lineto(" << X << "," << Y << ")" << endl;
#endif
switch (thePaintType) {
case 0:
case 2:
if( theNpoly == 0 ) {
Xw_begin_poly(myDrawable,MAXCHARPOINTS,MAXCHARPATHS);
}
if( theNpath == 0 ) {
Xw_poly_point(myDrawable, theX+thePX, theY+thePY);
}
Xw_poly_point(myDrawable, theX+Standard_ShortReal(X),
theY+Standard_ShortReal(Y));
theNpath++; theNpoly++;
break;
case 1:
#ifndef PRO14351
Xw_draw_segment(myDrawable, theX+thePX, theY+thePY,
theX+Standard_ShortReal(X),
theY+Standard_ShortReal(Y));
#else
if( theNpoly == 0 ) {
Xw_begin_line(myDrawable,MAXCHARPOINTS);
Xw_line_point(myDrawable, theX+thePX, theY+thePY);
}
Xw_line_point(myDrawable, theX+Standard_ShortReal(X),
theY+Standard_ShortReal(Y));
#endif
thePX = X; thePY = Y;
theNpoly++;
}
return Standard_True;
}
Standard_Boolean Xw_TextManager::Curveto(const Quantity_Length X1, const Quantity_Length Y1, const Quantity_Length X2, const Quantity_Length Y2, const Quantity_Length X3, const Quantity_Length Y3, const Quantity_Length X4, const Quantity_Length Y4) {
#if TRACE > 0
cout << " Xw_TextManager::Curveto(" << X1 << "," << Y1 << "," <<
X2 << "," << Y2 << "," << X3 << "," << Y3 << "," <<
X4 << "," << Y4 << ")" << endl;
#endif
return Standard_False;
}
void Xw_TextManager::ClosePath() {
#if TRACE > 0
cout << " Xw_TextManager::ClosePath()" << endl;
#endif
switch (thePaintType) {
case 0:
case 2:
if( theNpath > 0 ) Xw_close_path(myDrawable);
theNpath = 0;
break;
case 1:
#ifdef PRO14351
if( theNpoly > 0 ) Xw_close_line(myDrawable);
theNpoly = 0;
#endif
break;
}
}
Standard_Boolean Xw_TextManager::EndChar(const Standard_Real X, const Standard_Real Y) {
#if TRACE > 0
cout << " Xw_TextManager::EndChar(" << X << "," << Y << ")" << endl;
#endif
switch (thePaintType) {
case 0:
case 2:
Xw_close_poly(myDrawable);
break;
case 1:
#ifdef PRO14351
Xw_close_line(myDrawable);
theNpoly = theNpath = 0;
#endif
break;
}
theNchar++;
return Standard_True;
}
void Xw_TextManager::EndString() {
#if TRACE > 0
cout << " Xw_TextManager::EndString()" << endl;
#endif
if( theUnderlinePosition > 0. ) {
Standard_ShortReal theX1 = theXmin;
Standard_ShortReal theY1 = -theUnderlinePosition;
Standard_ShortReal theX2 = theXmax;
Standard_ShortReal theY2 = theY1;
theSinAngle = Sin(theOrientation);
theCosAngle = Cos(theOrientation);
TRANSFORM(theX1,theY1);
TRANSFORM(theX2,theY2);
#ifndef PRO14351
Xw_draw_segment(myDrawable, theX+theX1, theY+theY1,
theX+theX2, theY+theY2);
#else
Xw_begin_line(myDrawable,2);
Xw_line_point(myDrawable, theX+theX1, theY+theY1);
Xw_line_point(myDrawable, theX+theX2, theY+theY2);
Xw_close_line(myDrawable);
#endif
}
// Restore line attribs
switch (thePaintType) {
case 0:
case 2:
if( thePolyCode != ~0 ) Xw_set_poly_attrib(myDrawable,
thePolyColor,thePolyType,thePolyTile,thePolyMode);
case 1:
#ifndef PRO14351
Xw_close_segments(myDrawable);
theNpoly = 0;
#endif
if( theLineCode != ~0 ) Xw_set_line_attrib(myDrawable,
theLineColor,theLineType,theLineWidth,theLineMode);
break;
}
#ifdef S3593
// Restore clipping
Xw_set_clipping(myDrawable,theClippingFlag);
#endif
}
void Xw_TextManager::SetTextAttribs( const Standard_Integer aTextColor, const Aspect_TypeOfText aTypeOfText, const Quantity_Length anUnderlinePosition) {
theTextColor = aTextColor;
theTypeOfText = aTypeOfText;
theUnderlinePosition = anUnderlinePosition;
}

100
src/Xw/Xw_TypeMap.cdl Executable file
View File

@@ -0,0 +1,100 @@
--
-- File: Xw_TypeMap.cdl
-- Created: 24/08/93
-- Author: GG
--
---Copyright: MatraDatavision 1993
--
class TypeMap from Xw inherits Transient
---Version: 0.0
---Purpose: This class defines a TypeMap object.
---Keywords:
---Warning:
---References:
uses
TypeMap from Aspect,
TypeMapEntry from Aspect,
LineStyle from Aspect
raises
TypeMapDefinitionError from Aspect,
BadAccess from Aspect
is
Create
returns mutable TypeMap from Xw
is protected ;
---Level: Internal
Create ( Connexion : CString from Standard )
returns mutable TypeMap from Xw
---Level: Public
---Purpose: Creates a TypeMap with unallocated TypeMapEntry.
-- Warning: Raises if TypeMap creation failed according
-- to the supported hardware
raises TypeMapDefinitionError from Aspect ;
SetEntry ( me : mutable ;
Entry : TypeMapEntry from Aspect )
---Level: Public
---Purpose: Modifies an entry already defined or Add the Entry
-- in the type map <me> if it don't exist.
-- Warning: Raises if TypeMap size is exceeded,
-- or TypeMap is not defined properly,
-- or TypeMapEntry Index is out of range according
-- to the supported hardware
raises BadAccess from Aspect is virtual;
SetEntries ( me : mutable ;
Typemap : TypeMap from Aspect )
---Level: Public
---Purpose: Modifies all entries from a new Typemap
-- Warning: Raises if TypeMap size is exceeded,
-- or TypeMap is not defined properly,
-- or One of new TypeMapEntry Index is out of range according
-- to the supported hardware
raises BadAccess from Aspect is virtual;
Destroy ( me : mutable ) is virtual;
---Level: Public
---Purpose: Destroies the Typemap
---C++: alias ~
----------------------------
-- Category: Inquire methods
----------------------------
FreeTypes ( me )
returns Integer from Standard
---Level: Public
---Purpose: Returns the Number of Free Types in the Typemap
-- depending of the HardWare
-- Warning: Raises if TypeMap is not defined properly
raises BadAccess from Aspect is static;
ExtendedTypeMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data typemap structure pointer.
---Category: Inquire methods
fields
MyExtendedDisplay : Address from Standard ;
MyExtendedTypeMap : Address from Standard ;
friends
class GraphicDevice from Xw
end TypeMap ;

116
src/Xw/Xw_TypeMap.cxx Executable file
View File

@@ -0,0 +1,116 @@
#include <Xw_TypeMap.ixx>
#include <Aspect_TypeOfLine.hxx>
#include <Aspect_LineStyle.hxx>
#include <Standard_ShortReal.hxx>
#include <TShort_Array1OfShortReal.hxx>
#include <TColQuantity_Array1OfLength.hxx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Static data definitions
static char *ErrorMessag ;
static int ErrorNumber ;
static int ErrorGravity ;
static XW_STATUS status ;
Xw_TypeMap::Xw_TypeMap () {
}
Xw_TypeMap::Xw_TypeMap (const Standard_CString Connexion) {
MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ;
if( !MyExtendedDisplay ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_TypeMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
MyExtendedTypeMap = Xw_def_typemap(MyExtendedDisplay,(int)0) ;
if( !Xw_isdefine_typemap(MyExtendedTypeMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_TypeMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
void Xw_TypeMap::SetEntry (const Aspect_TypeMapEntry& Entry) {
Aspect_LineStyle style = Entry.Type() ;
int length = (int) style.Length() ;
int ftype = (int) Entry.Index() ;
const TColQuantity_Array1OfLength& values(style.Values()) ;
TShort_Array1OfShortReal svalues(values.Lower(),values.Length()) ;
float *V = (float*) &svalues.Value(values.Lower()) ;
Standard_Integer i ;
if( ftype ) { /* Index 0 is default SOLID Line ,cann't be changed */
for( i=values.Lower() ; i<=values.Upper() ; i++)
svalues(i) = TOMILLIMETER(Standard_ShortReal(values(i))) ;
status = Xw_def_type(MyExtendedTypeMap,ftype,length,V) ;
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
}
void Xw_TypeMap::SetEntries (const Handle(Aspect_TypeMap)& Typemap) {
Standard_Integer size = Typemap->Size() ;
Standard_Integer i ;
if( !Xw_isdefine_typemap(MyExtendedTypeMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_TypeMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
for( i=1 ; i<=size ; i++ ) {
SetEntry(Typemap->Entry(i)) ;
}
}
void Xw_TypeMap::Destroy() {
if( MyExtendedTypeMap ) {
Xw_close_typemap(MyExtendedTypeMap) ;
MyExtendedTypeMap = NULL ;
}
}
Standard_Integer Xw_TypeMap::FreeTypes( ) const {
Standard_Integer ntype ;
int mtype,utype,dtype,ftype ;
status = Xw_get_typemap_info(MyExtendedTypeMap,
&mtype,&utype,&dtype,&ftype) ;
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
ntype = utype - dtype ;
return (ntype) ;
}
Standard_Address Xw_TypeMap::ExtendedTypeMap () const {
return (MyExtendedTypeMap);
}

21
src/Xw/Xw_WOKSteps.edl Executable file
View File

@@ -0,0 +1,21 @@
-- Author: Atelier CAS2000
-- History: Thu Jul 15 17:17:17 1999 Atelier CAS2000 Creation
-- Copyright: Matra Datavision 1999
@ifnotdefined ( %Xw_WOKSteps_EDL ) then
---@set %Xw_WOKSteps_EDL = "";
--- Insert your stuff Here
@if ( %Station == "wnt" ) then
-- Pas d'Xw sur Windows NT
@set %WOKSteps_ObjGroup = "";
@set %WOKSteps_DepGroup = "";
@set %WOKSteps_LibGroup = "";
@set %WOKSteps_ExecGroup = "";
@endif;
@endif;

14
src/Xw/Xw_WOKUMake.edl Executable file
View File

@@ -0,0 +1,14 @@
-- File: Xw_WOKUMake.edl
-- Author: Atelier CAS2000
-- History: Thu Jul 15 17:17:17 1999 Atelier CAS2000 Creation
-- Copyright: Matra Datavision 1999
sss
@ifnotdefined ( %Xw_WOKUMake_EDL ) then
@set %Xw_WOKUMake_EDL = "";
--- Insert your stuff Here
@if ( %Station == "wnt" ) then
@set %WOKUMake_Steps = "*src xcpp.fill(src) xcpp.src(xcpp.fill) xcpp.header(xcpp.fill) .xcpp.template(xcpp.fill) obj.inc";
@endif;
@endif;

98
src/Xw/Xw_WidthMap.cdl Executable file
View File

@@ -0,0 +1,98 @@
--
-- File: Xw_WidthMap.cdl
-- Created: 24/08/93
-- Author: GG
--
---Copyright: MatraDatavision 1993
--
class WidthMap from Xw inherits Transient
---Version: 0.0
---Purpose: This class defines a WidthMap object.
---Keywords:
---Warning:
---References:
uses
WidthMap from Aspect,
WidthMapEntry from Aspect
raises
WidthMapDefinitionError from Aspect,
BadAccess from Aspect
is
Create
returns mutable WidthMap from Xw
is protected ;
---Level: Public
Create ( Connexion : CString from Standard )
returns mutable WidthMap from Xw
---Level: Public
---Purpose: Creates a WidthMap with unallocated WidthMapEntry.
-- Warning: Raises if WidthMap creation failed according
-- to the supported hardware
raises WidthMapDefinitionError from Aspect ;
SetEntry ( me : mutable ;
Entry : WidthMapEntry from Aspect )
---Level: Public
---Purpose: Modifies an entry already defined or Add the Entry
-- in the type map <me> if it don't exist.
-- Warning: Raises if WidthMap size is exceeded,
-- or WidthMap is not defined properly,
-- or WidthMapEntry Index is out of range according
-- to the supported hardware
raises BadAccess from Aspect is virtual;
SetEntries ( me : mutable ;
Widthmap : WidthMap from Aspect )
---Level: Public
---Purpose: Modifies all entries from the New Widthmap
-- Warning: Raises if WidthMap size is exceeded,
-- or WidthMap is not defined properly,
-- or One of new WidthMapEntry Index is out of range according
-- to the supported hardware
raises BadAccess from Aspect is virtual;
Destroy( me : mutable ) is virtual;
---Level: Public
---Purpose: Destroies the Widthmap
---C++: alias ~
----------------------------
-- Category: Inquire methods
----------------------------
FreeWidths( me )
returns Integer from Standard
---Level: Internal
---Purpose: Returns the Number of Free Widths in the Widthmap
-- depending of the HardWare
-- Warning: Raises if WidthMap is not defined properly
raises BadAccess from Aspect is static;
ExtendedWidthMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns extended data typemap structure pointer.
---Category: Inquire methods
fields
MyExtendedDisplay : Address from Standard ;
MyExtendedWidthMap : Address from Standard ;
friends
class GraphicDevice from Xw
end WidthMap ;

105
src/Xw/Xw_WidthMap.cxx Executable file
View File

@@ -0,0 +1,105 @@
#include <Xw_WidthMap.ixx>
#include <Aspect_WidthOfLine.hxx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Static data definitions
static char *ErrorMessag ;
static int ErrorNumber ;
static int ErrorGravity ;
static XW_STATUS status ;
Xw_WidthMap::Xw_WidthMap () {
}
Xw_WidthMap::Xw_WidthMap (const Standard_CString Connexion) {
MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ;
if( !MyExtendedDisplay ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
MyExtendedWidthMap = Xw_def_widthmap(MyExtendedDisplay,(int)0) ;
if( !Xw_isdefine_widthmap(MyExtendedWidthMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
void Xw_WidthMap::SetEntry (const Aspect_WidthMapEntry& Entry) {
int fwidth = (int) Entry.Index() ;
float width = (float) TOMILLIMETER(Entry.Width()) ;
if( fwidth ) { /* Don't change Default index 0,One pixel Width */
status = Xw_def_width(MyExtendedWidthMap,fwidth,width) ;
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
}
void Xw_WidthMap::SetEntries (const Handle(Aspect_WidthMap)& Widthmap) {
Standard_Integer size = Widthmap->Size() ;
Standard_Integer i ;
if( !Xw_isdefine_widthmap(MyExtendedWidthMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
for( i=1 ; i<=size ; i++ ) {
SetEntry(Widthmap->Entry(i)) ;
}
}
void Xw_WidthMap::Destroy() {
if( MyExtendedWidthMap ) {
Xw_close_widthmap(MyExtendedWidthMap) ;
MyExtendedWidthMap = NULL ;
}
}
Standard_Integer Xw_WidthMap::FreeWidths( ) const {
Standard_Integer nwidth ;
int mwidth,uwidth,dwidth,fwidth ;
status = Xw_get_widthmap_info(MyExtendedWidthMap,
&mwidth,&uwidth,&dwidth,&fwidth) ;
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
nwidth = uwidth - dwidth ;
return (nwidth) ;
}
Standard_Address Xw_WidthMap::ExtendedWidthMap () const {
return (MyExtendedWidthMap);
}

669
src/Xw/Xw_Window.cdl Executable file
View File

@@ -0,0 +1,669 @@
--
-- File: Xw_Window.cdl
-- Created: 18 Novembre 1991
-- Author: NW,JPB,CAL,GG
-- Modified : GG 28/01/00 G004
-- Add gamma correction computation just before dumping an image.
-- GG 07/03/00 G004 Add MMSize() method
-- TCL 26/10/00 G002 SetBackground(aName: CString) method
-- SAV 24/11/01 SetBackground(Quantity_Color)
-- GG - RIC120302 Add NEW XParentWindow methods.
--
---Copyright: MatraDatavision 1991,1992,1993
class Window from Xw
---Version:
---Purpose: This class defines a X11 window
-- Warning: The position and size for the creation of the window
-- are defined in Device Screen Unit (DSU)
-- floating [0,1] space.
---References:
inherits
Window from Aspect
uses
AsciiString from TCollection,
Background from Aspect,
GradientBackground from Aspect,
TypeOfResize from Aspect,
Handle from Aspect,
FillMethod from Aspect,
GradientFillMethod from Aspect,
PixMap from Aspect,
NameOfColor from Quantity,
Parameter from Quantity,
Ratio from Quantity,
Color from Quantity,
ColorMap from Xw,
TypeMap from Xw,
WidthMap from Xw,
FontMap from Xw,
MarkMap from Xw,
GraphicDevice from Xw,
WindowQuality from Xw,
TypeOfVisual from Xw
raises
WindowDefinitionError from Aspect,
WindowError from Aspect
is
Create ( Device : GraphicDevice from Xw )
returns mutable Window from Xw
raises WindowDefinitionError from Aspect;
---Level: Public
Create ( Device : GraphicDevice from Xw ;
aPart1, aPart2 : Integer from Standard ;
aQuality : WindowQuality from Xw = Xw_WQ_SAMEQUALITY ;
BackColor : NameOfColor from Quantity =
Quantity_NOC_MATRAGRAY )
returns mutable Window from Xw
---Level: Public
---Purpose: Creates a Window from an X Window defined by his ID
-- This Xid equals (aPart1 << 16) + aPart2.
-- A child of this Window is created when the WindowQuality
-- isn't the same than the parent Window
-- Trigger: Raises WindowDefinitionError if the connection failed
-- or if the Position out of the Screen Space
raises WindowDefinitionError from Aspect ;
Create ( Device : GraphicDevice from Xw ;
aWindow : Handle from Aspect;
aQuality : WindowQuality from Xw = Xw_WQ_SAMEQUALITY ;
BackColor : NameOfColor from Quantity =
Quantity_NOC_MATRAGRAY )
returns mutable Window from Xw
---Level: Public
---Purpose: Creates a Window from an X Window defined by his Xid
-- A child of this Window is created when the WindowQuality
-- isn't the same than the parent Window
-- Trigger: Raises WindowDefinitionError if the connection failed
-- or if the Position out of the Screen Space
raises WindowDefinitionError from Aspect ;
Create ( Device : GraphicDevice from Xw ;
Title : CString from Standard ;
Xc : Parameter from Quantity = 0.5 ;
Yc : Parameter from Quantity = 0.5 ;
Width : Parameter from Quantity = 0.5 ;
Height : Parameter from Quantity = 0.5 ;
Quality : WindowQuality from Xw = Xw_WQ_DRAWINGQUALITY ;
BackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY ;
Parent : Handle from Aspect = 0 )
returns mutable Window from Xw
---Level: Public
---Purpose: Creates a Window defined by his Center and his Size
-- in DSU from the Parent Window.
-- NOTE than if Parent is 0 the window is created from the
-- ROOT Window.
-- Connects it to the X server at the first call
-- depending of the GraphicDevice Visual and
-- Display parameters.
-- Quality defined a 2D or 3D Graphics oriented Window and
-- must be one of :
-- Xw_WQ_DRAWINGQUALITY for 2D Wireframe.
-- Xw_WQ_PICTUREQUALITY for Picture.
-- Xw_WQ_3DQUALITY for 3D Shading, HiddenLines, Wireframe.
--
-- Creation of an Xw_Window automatically determines the
-- smaller dimension of the screen (usually the height)
-- and parametrises it as 1.0.
-- The smaller dimension of the window is limited to 1.0
-- We can give a value greater than 1.0 to the larger
-- dimension.
-- No matter how large the values passed in argument, the
-- window is automatically limited to the maximum size of
-- the screen.
-- The ratio of width to height of a conventional screen is
-- of the order of 1.3.
--
-- Trigger: Raises WindowDefinitionError if the connection failed
-- or if the Position out of the Screen Space
raises WindowDefinitionError from Aspect ;
Create ( theDevice : GraphicDevice from Xw ;
theTitle : CString from Standard ;
thePxLeft : Integer from Standard ;
thePxTop : Integer from Standard ;
thePxWidth : Integer from Standard ;
thePxHeight : Integer from Standard ;
theQuality : WindowQuality from Xw = Xw_WQ_DRAWINGQUALITY ;
theBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY ;
theParent : Handle from Aspect = 0 )
returns mutable Window from Xw
---Level: Public
---Purpose: Creates a Window defined by his position and size
-- in pixels from the Parent Window.
-- Trigger: Raises WindowDefinitionError if the connection failed
-- or if the Position out of the Screen Space
raises WindowDefinitionError from Aspect ;
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
SetBackground ( me : mutable ;
Background : Background from Aspect ) is virtual;
---Level: Public
---Purpose: Modifies the window background.
-- Warning: the background color is ignored when the quality
-- of this window is TRANSPARENT.
---Category: Methods to modify the class definition
SetBackground ( me : mutable ;
BackColor : NameOfColor from Quantity ) is virtual;
---Level: Public
---Purpose: Modifies the window background from a Named Color.
-- Warning: the background color is ignored when the quality
-- of this window is TRANSPARENT.
---Category: Methods to modify the class definition
SetBackground ( me : mutable; color : Color from Quantity ) is virtual;
---Level: Public
---Purpose: Modifies the window background from a Named Color.
-- Warning: the background color is ignored when the quality
-- of this window is TRANSPARENT.
---Category: Methods to modify the class definition
SetBackground( me: mutable;
aPixmap: Handle from Aspect);
---Level: Advanced
---Purpose: Defines the window background directly from a bitmap.
-- Warning: the bitmap and window must have the same depth.
---Category: Methods to modify the class definition
SetBackground( me: mutable;
aName: CString from Standard;
aMethod : FillMethod from Aspect = Aspect_FM_CENTERED)
returns Boolean from Standard;
---Level: Public
---Purpose: Loads the window background from an image file <aName>
-- defined with a supported format XWD,GIF or BMP
-- and returns TRUE if the operation is successfull.
---Category: Methods to modify the class definition
SetBackground ( me : mutable ;
Background : GradientBackground from Aspect ) is virtual;
---Level: Public
---Purpose: Modifies the window gradient background.
-- Warning: the gradient background colours are ignored when the quality
-- of this window is TRANSPARENT.
---Category: Methods to modify the class definition
SetBackground( me : mutable;
aCol1 : Color from Quantity;
aCol2 : Color from Quantity;
aMethod : GradientFillMethod from Aspect = Aspect_GFM_HOR);
---Level: Public
---Purpose: Modifies the window gradient background.
-- Warning: the gradient background colours are ignored when the quality
-- of this window is TRANSPARENT.
---Category: Methods to modify the class definition
SetDoubleBuffer ( me : mutable ;
DBmode : Boolean from Standard )
---Level: Advanced
---Purpose: Activates/Deactivates the Double Buffering capability
-- for this window.
-- Warning: Double Buffering is always DISABLE by default
-- If there is not enought ressources to activate the
-- double-buffering the DB mode flag can be set to FALSE.
---Category: Methods to modify the class definition
is virtual;
Flush ( me )
---Level: Advanced
---Purpose: Flushs all graphics to the screen and Swap the Double
-- buffer if Enable
-- Category: Methods to modify the class definition
-- Trigger: Raises if Something is WRONG at Drawing Time.
raises WindowError from Aspect is virtual;
Map ( me ) is virtual;
---Level: Public
---Purpose: Opens the window <me>.
---Category: Methods to modify the class definition
Unmap ( me ) is virtual;
---Level: Public
---Purpose: Closes the window <me>.
---Category: Methods to modify the class definition
DoResize ( me )
returns TypeOfResize from Aspect
---Level: Advanced
---Purpose: Applies the resizing to the window <me>.
---Category: Methods to modify the class definition
raises WindowError from Aspect is virtual;
DoMapping ( me ) returns Boolean from Standard
raises WindowError from Aspect is virtual;
---Level: Advanced
---Purpose: Apply the mapping change to the window <me>
-- and returns TRUE if the window is mapped at screen.
---Category: Methods to modify the class definition
Destroy ( me : mutable )
---Level: Advanced
---Purpose: Destroies the Window
-- C++: alias ~
-- Category: Methods to modify the class definition
-- Trigger: Raises if Window is not defined properly
raises WindowError from Aspect is virtual;
Clear ( me ) is virtual;
---Level: Public
---Purpose: Clears the Window in the Background color
---Category: Methods to modify the class definition
ClearArea ( me ;
Xc, Yc : Integer from Standard ;
Width, Height : Integer from Standard )
---Level: Public
---Purpose: Clears the Window Area defined by his center and PIXEL size
-- in the Background color
-- Category: Methods to modify the class definition
-- Trigger: Raises if Window is not defined properly
raises WindowError from Aspect is virtual;
Restore ( me )
---Level: Public
---Purpose: Restores The Window from the BackingStored Window
-- See BackingStore () method.
---Category: Methods to modify the class definition
raises WindowError from Aspect is virtual;
RestoreArea ( me ;
Xc, Yc : Integer from Standard ;
Width, Height : Integer from Standard )
---Level: Public
---Purpose: Restores The Window Area defined by his center
-- and PIXEL size from the BackingStored Window
-- See BackingStore () method.
---Category: Methods to modify the class definition
raises WindowError from Aspect is virtual;
Dump ( me ; aFilename : CString from Standard;
aGammaValue: Real from Standard = 1.0 ) returns Boolean
---Level: Advanced
---Purpose: Dumps the Window to an XWD,GIF or BMP file with
-- an optional gamma correction value according to the graphic system.
-- and returns TRUE if the dump occurs normaly.
-- Category: Methods to modify the class definition
-- Trigger: Raises if Window is not defined properly
raises WindowError from Aspect is virtual;
DumpArea ( me ; aFilename : CString from Standard ;
Xc, Yc : Integer from Standard ;
Width, Height : Integer from Standard ;
aGammaValue: Real from Standard = 1.0 ) returns Boolean
---Level: Advanced
---Purpose: Dumps the Window Area defined by his center and PIXEL size
-- to an XWD,GIF or BMP file with
-- an optional gamma correction value according to the graphic system.
-- and returns TRUE if the dump occurs normaly.
-- Category: Methods to modify the class definition
-- Trigger: Raises if Window is not defined properly
-- or the area is out of the Window.
raises WindowError from Aspect is virtual;
ToPixMap ( me )
returns PixMap from Aspect
---Level : Public
---Purpose : dump the full contents of the window to a pixmap.
is virtual;
Load ( me ; aFilename : CString from Standard) returns Boolean
---Level: Advanced
---Purpose: Loads the XWD file to this Window.
-- Returns TRUE if the loading occurs normaly.
-- Warning: Note that the Window is enlarged automatically
-- when the image size is too large for this window.
-- Category: Methods to modify the class definition
-- Trigger: Raises if Window is not defined properly
raises WindowError from Aspect is virtual;
LoadArea ( me ; aFilename : CString from Standard ;
Xc, Yc : Integer from Standard ;
Width, Height : Integer from Standard ) returns Boolean
---Level: Advanced
---Purpose: Loads the XWD file to Window Area defined by his center
-- and PIXEL size.
-- Returns TRUE if the loading occurs normaly.
-- Warning: Note that the Image is zoomed automatically
-- when the image size is too large for this window area.
-- Category: Methods to modify the class definition
-- Trigger: Raises if Window is not defined properly
-- or the area is out of the Window.
raises WindowError from Aspect is virtual;
SetCursor ( me ; anId : Integer from Standard ;
aColor : NameOfColor from Quantity
= Quantity_NOC_YELLOW ) is virtual ;
---Level: Advanced
---Purpose: Changes the current window cursor by anId cursor
-- in the specified color.
-- NOTE than anId must be one of /usr/include/X11/cursorfont.h
-- or 0 for Deactivate the cursor
---Category: Methods to modify the class definition
----------------------------
-- Category: Inquire methods
----------------------------
BackingStore ( me )
returns Boolean from Standard is virtual;
---Level: Advanced
---Purpose: Returns the BackingStore capability for this Window.
-- If Answer is True Exposure can be recovered by
-- Restore RestoreArea methods.
-- If Answer is False, Application must Redraw the
-- exposed area.
---Category: Inquire methods
DoubleBuffer ( me )
returns Boolean from Standard is virtual;
---Level: Advanced
---Purpose: Returns the DoubleBuffer state.
---Category: Inquire methods
IsMapped ( me )
returns Boolean from Standard is virtual;
---Level: Public
---Purpose: Returns True if the window <me> is opened
-- and False if the window is closed.
---Category: Inquire methods
Ratio ( me )
returns Ratio from Quantity is virtual;
---Level: Public
---Purpose: Returns The Window RATIO equal to the physical
-- WIDTH/HEIGHT dimensions
---Category: Inquire methods
Position ( me ;
X1, Y1, X2, Y2 : out Parameter from Quantity ) is virtual;
---Level: Public
---Purpose: Returns The Window POSITION in DSU
---Category: Inquire methods
Position ( me ;
X1, Y1, X2, Y2 : out Integer from Standard ) is virtual;
---Level: Public
---Purpose: Returns The Window POSITION in PIXEL
---Category: Inquire methods
Size ( me ;
Width, Height : out Parameter from Quantity ) is virtual;
---Level: Public
---Purpose: Returns The Window SIZE in DSU
---Category: Inquire methods
Size ( me ;
Width, Height : out Integer from Standard ) is virtual;
---Level: Public
---Purpose: Returns The Window SIZE in PIXEL
---Category: Inquire methods
MMSize ( me ;
Width, Height : out Real from Standard ) is virtual;
---Level: Public
---Purpose: Returns The Window SIZE in MM
---Category: Inquire methods
Convert ( me ; PV : Integer from Standard )
returns Parameter from Quantity is virtual;
---Level: Public
---Purpose: Returns the DSU value depending of the PIXEL value.
---Category: Inquire methods
Convert ( me ; DV : Parameter from Quantity )
returns Integer from Standard is virtual;
---Level: Public
---Purpose: Returns the PIXEL value depending of the DSU value.
---Category: Inquire methods
Convert ( me ;
PX, PY : Integer from Standard ;
DX, DY : out Parameter from Quantity ) is virtual;
---Level: Public
---Purpose: Returns the DSU position depending of the PIXEL position.
---Category: Inquire methods
Convert ( me ;
DX, DY : Parameter from Quantity ;
PX, PY : out Integer from Standard ) is virtual;
---Level: Public
---Purpose: Returns the PIXEL position depending of the DSU position.
---Category: Inquire methods
XWindow ( me )
returns Handle from Aspect is static;
---Level: Public
---Purpose: Returns the X window ID of the created window <me>.
---Category: Inquire methods
XWindow ( me ; aPart1, aPart2 : out Integer from Standard ) is static;
---Level: Public
---Purpose: Returns the X window ID of the created window <me>.
-- This Xid equals (aPart1 << 16) + aPart2.
XParentWindow ( me )
returns Handle from Aspect is static;
---Level: Public
---Purpose: Returns the X window ID parent of the created window <me>.
---Category: Inquire methods
XParentWindow ( me ; aPart1, aPart2 : out Integer from Standard ) is static;
---Level: Public
---Purpose: Returns the X window ID parent of the created window <me>.
-- This Xid equals (aPart1 << 16) + aPart2.
XPixmap ( me )
returns Handle from Aspect is static;
---Level: Internal
---Purpose: Returns the X pixmap ID of the created window <me>.
-- If BackingStore () is permitted.
---Category: Inquire methods
PointerPosition ( me ; X, Y : out Integer from Standard )
returns Boolean from Standard is virtual;
---Level: Advanced
---Purpose: Returns the Pointer position relatively to the Window <me>
-- and FALSE if the pointer is outside of the window
---Category: Inquire methods
ColorMap ( me )
returns ColorMap from Xw is static;
---Level: Public
---Purpose: Returns the Colormap attached to this Window
TypeMap ( me )
returns TypeMap from Xw is static;
---Level: Public
---Purpose: Returns the Typemap attached to this Window
WidthMap ( me )
returns WidthMap from Xw is static;
---Level: Public
---Purpose: Returns the Widthmap attached to this Window
FontMap ( me )
returns FontMap from Xw is static;
---Level: Public
---Purpose: Returns the Fontmap attached to this Window
MarkMap ( me )
returns MarkMap from Xw is static;
---Level: Public
---Purpose: Returns the Markmap attached to this Window
XColorMap ( me )
returns Handle from Aspect
---Level: Internal
---Purpose: Returns the Colormap XId attached to this Window
-- depending of the HardWare and Visual class
-- Trigger: Raises if Window is not defined properly
raises WindowError from Aspect is static;
XVisual ( me )
returns Address from Standard
---Level: Internal
---Purpose: Returns the Visual address attached to this Window
-- depending of the HardWare
-- Trigger: Raises if Window is not defined properly
raises WindowError from Aspect is static;
VisualClass ( me )
returns TypeOfVisual from Xw is static;
---Level: Public
---Purpose: Returns the X window Visual class of the created window <me>
---Category: Inquire methods
VisualDepth ( me )
returns Integer from Standard is static;
---Level: Public
---Purpose: Returns the X window Visual depth of the created window <me>
---Category: Inquire methods
VisualID ( me )
returns Integer from Standard is static;
---Level: Public
---Purpose: Returns the Visual ID of the Window
---Category: Inquire methods
Quality ( me )
returns WindowQuality from Xw is static;
---Level: Public
---Purpose: Returns the Quality of this window
---Category: Inquire methods
PixelOfColor ( me ;aColor : NameOfColor from Quantity;
aPixel : out Integer from Standard )
returns Boolean from Standard is static;
---Level: Public
---Purpose: Returns FALSE when the returned pixel value <aPixel>
-- of an RGB color <aColor> is exact or TRUE
-- when the pixel value is approximated.
PixelOfColor ( me ;aColor : Color from Quantity;
aPixel : out Integer from Standard )
returns Boolean from Standard is static;
---Level: Advanced
---Purpose: Returns FALSE when the returned pixel value <aPixel>
-- of an RGB color <aColor> is exact or TRUE
-- when the pixel value is approximated.
-- Warning:
-- make becarefull about the number of different pixel
-- of colors reserved in the colormap in PseudoColor mode !!!
BackgroundPixel ( me ; aPixel : out Integer from Standard )
returns Boolean from Standard is static;
---Level: Public
---Purpose: Returns FALSE when the returned background pixel
-- value <aPixel> is not defined
ExtendedWindow ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns the ExtendedWindow address of the created window.
---Category: Inquire methods
ExtendedColorMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns the ExtendedColorMap address of the created window.
---Category: Inquire methods
ExtendedTypeMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns the ExtendedTypeMap address of the created window.
---Category: Inquire methods
ExtendedWidthMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns the ExtendedWidthMap address of the created window.
---Category: Inquire methods
ExtendedFontMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns the ExtendedFontMap address of the created window.
---Category: Inquire methods
ExtendedMarkMap ( me )
returns Address from Standard
is static protected ;
---Level: Internal
---Purpose: Returns the ExtendedMarkMap address of the created window.
---Category: Inquire methods
SetWindow ( me: mutable ; aWindow : Handle from Aspect ;
aQuality: WindowQuality from Xw ;
BackColor : NameOfColor from Quantity )
---Level: Internal
---Trigger: Raises if Window is not defined properly
raises WindowError from Aspect
is static private ;
SetWindow ( me: mutable ; Title : CString from Standard ;
Xc, Yc, Width, Height: Parameter from Quantity ;
Quality : WindowQuality from Xw ;
BackColor : NameOfColor from Quantity ;
Parent : Handle from Aspect )
---Level: Internal
---Trigger: Raises if Window is not defined properly
raises WindowError from Aspect
is static private ;
PrintError(myclass) is protected;
---Purpose: Print last error or raise depending of the error gravity.
Init( me: mutable ) is private;
---Purpose: Initialise the fileds of class
fields
MyQuality : WindowQuality from Xw is protected ;
MyColorMap : ColorMap from Xw is protected ;
MyTypeMap : TypeMap from Xw is protected ;
MyWidthMap : WidthMap from Xw is protected ;
MyFontMap : FontMap from Xw is protected ;
MyMarkMap : MarkMap from Xw is protected ;
MyXWindow : Handle from Aspect is protected ;
MyXParentWindow : Handle from Aspect is protected ;
MyXPixmap : Handle from Aspect is protected ;
MyVisualClass : TypeOfVisual from Xw is protected ;
MyDepth : Integer from Standard is protected ;
MyBackgroundIndex : Integer from Standard is protected ;
MyExtendedDisplay : Address from Standard is protected ;
MyExtendedWindow : Address from Standard is protected ;
MyExtendedColorMap : Address from Standard is protected ;
MyExtendedTypeMap : Address from Standard is protected ;
MyExtendedWidthMap : Address from Standard is protected ;
MyExtendedFontMap : Address from Standard is protected ;
MyExtendedMarkMap : Address from Standard is protected ;
friends
class Driver from Xw,
class IconBox from Xw,
class PixMap from Xw
end Window ;

1380
src/Xw/Xw_Window.cxx Executable file

File diff suppressed because it is too large Load Diff

183
src/Xw/Xw_alloc_color.cxx Executable file
View File

@@ -0,0 +1,183 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_ALLOC_COLOR
#endif
/*
XW_STATUS Xw_alloc_color(pcolormap,r,g,b,pixel,isapproximate):
XW_EXT_COLORMAP *pcolormap
float r,g,b ; Red,Green,Blue color value 0. >= x <= 1.
unsigned long pixel ;Returned Color pixel value
bool isapproximate
Get the color pixel value from an {r,g,b} color definition.
Returned the existing color pixel or create an other if it don't exist.
Returns ERROR if Bad Color pixel
Returns SUCCESS if Successful
*/
#define OCC38 /* SAV 30/11/01 correcred: gamma correction formula */
static double theGammaCorrection = 1.0;
static Colormap theColormap;
static XColor theColors[MAXCOLOR];
static unsigned char theFilters[MAXCOLOR];
#ifdef XW_PROTOTYPE
XW_STATUS Xw_alloc_color (XW_EXT_COLORMAP* pcolormap,
float r,float g,float b,unsigned long *pixel,int *isapproximate)
#else
XW_STATUS Xw_alloc_color (pcolormap,r,g,b,pixel,isapproximate)
XW_EXT_COLORMAP *pcolormap;
float r,g,b ;
unsigned long *pixel;
int *isapproximate;
#endif /*XW_PROTOTYPE*/
{
int status = False;
int drmin = 65536;
int dgmin = 65536;
int dbmin = 65536;
XColor color;
unsigned char filter='\0';
char svalue[6];
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_alloc_color",pcolormap) ;
return (XW_ERROR) ;
}
*isapproximate = False;
if( _CCLASS == TrueColor ) {
if( theColormap != _CINFO.colormap ) {
theColormap = _CINFO.colormap;
if( Xw_get_env("Xw_SET_GAMMA_CORRECTION",svalue,sizeof(svalue)) ) {
if( strlen(svalue) > 0 ) {
float gamma;
sscanf(svalue,"%f",&gamma);
#ifdef OCC38
if( gamma > 0. )
theGammaCorrection = 1. / gamma;
#else
if( gamma > 0. ) theGammaCorrection = gamma;
#endif
}
printf(" Xw_SET_GAMMA_CORRECTION is %f\n",theGammaCorrection) ;
}
}
color.pixel = 0;
if( theGammaCorrection != 1.0 ) {
color.red = (unsigned short) (pow((double)r,theGammaCorrection)*65535.);
color.green = (unsigned short) (pow((double)g,theGammaCorrection)*65535.);
color.blue = (unsigned short) (pow((double)b,theGammaCorrection)*65535.);
} else {
color.red = (unsigned short) (r*65535.);
color.green = (unsigned short) (g*65535.);
color.blue = (unsigned short) (b*65535.);
}
status = XAllocColor(_CDISPLAY,_CINFO.colormap,&color) ;
if( !status ) {
unsigned long mask = _CVISUAL->map_entries-1 ;
unsigned long red = (unsigned long) (r * mask) ;
unsigned long green = (unsigned long) (g * mask) ;
unsigned long blue = (unsigned long) (b * mask) ;
mask = _CVISUAL->red_mask;
while ( !(mask & 0x01) ) { mask >>= 1; red <<= 1; }
mask = _CVISUAL->green_mask;
while ( !(mask & 0x01) ) { mask >>= 1; green <<= 1; }
mask = _CVISUAL->blue_mask;
while ( !(mask & 0x01) ) { mask >>= 1; blue <<= 1; }
color.pixel = red|green|blue ;
}
} else {
color.pixel = 0;
color.red = (unsigned short) (r*65535.);
color.green = (unsigned short) (g*65535.);
color.blue = (unsigned short) (b*65535.);
status = XAllocColor(_CDISPLAY,_CINFO.colormap,&color) ;
if( !status ) {
int i,j,ncolor = min(MAXCOLOR,_CVISUAL->map_entries);
int dr,dg,db;
if( theColormap != _CINFO.colormap ) {
theColormap = _CINFO.colormap;
for( i=0 ; i<ncolor ; i++ ) {
theColors[i].pixel = i;
theFilters[i] = 0;
}
XQueryColors(_CDISPLAY,_CINFO.colormap,theColors,ncolor);
for( i=0 ; i<ncolor ; i++ ) {
filter = 0;
if( theColors[i].red > theColors[i].blue ) filter |= 1;
else if( theColors[i].blue > theColors[i].red ) filter |= 4;
if( theColors[i].red > theColors[i].green ) filter |= 2;
else if( theColors[i].green > theColors[i].red ) filter |= 4;
if( theColors[i].blue > theColors[i].green ) filter |= 2;
else if( theColors[i].green > theColors[i].blue ) filter |= 1;
theFilters[i] = filter;
}
}
filter = 0;
if( color.red > color.blue ) filter |= 1;
else if( color.blue > color.red ) filter |= 4;
if( color.red > color.green ) filter |= 2;
else if( color.green > color.red ) filter |= 4;
if( color.blue > color.green ) filter |= 2;
else if( color.green > color.blue ) filter |= 1;
for( i=j=0 ; i<ncolor ; i++ ) {
if( filter == theFilters[i] ) {
if( filter ) { /* This is a color */
dr = abs( color.red - theColors[i].red ) >> 8;
dg = abs( color.green - theColors[i].green ) >> 8;
db = abs( color.blue - theColors[i].blue ) >> 8;
if( (dr <= drmin) && (dg <= dgmin) && (db <= dbmin) ) {
j = i; drmin = dr; dgmin = dg; dbmin = db;
}
} else { /* This is a gray */
dr = abs( color.red - theColors[i].red ) >> 8;
if( dr <= drmin ) {
j = i; drmin = dr;
}
}
}
}
if( filter ) {
if( (drmin > 0) || (dgmin > 0) || (dbmin > 0) ) *isapproximate = True;
} else {
if( drmin > 0 ) *isapproximate = True;
}
color.pixel = theColors[j].pixel;
}
}
*pixel = color.pixel;
status = XW_SUCCESS;
#ifdef TRACE_ALLOC_COLOR
if( Xw_get_trace() ) {
printf(" %d = Xw_alloc_color(%lx,%f,%f,%f,%ld,%d)\n",
status,(long ) pcolormap,r,g,b,*pixel,*isapproximate) ;
if( *isapproximate ) {
if( !filter ) {
printf(" Is an approximate color of delta-GRAY (%f)\n",(float)drmin/65535.);
} else {
printf(" Is an approximate color of delta-COLOR (%f,%f,%f)\n",
(float)drmin/65535.,
(float)dgmin/65535.,
(float)dbmin/65535.);
}
}
}
#endif
return (XW_STATUS)status;
}

154
src/Xw/Xw_alloc_pixel.cxx Executable file
View File

@@ -0,0 +1,154 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_ALLOC_PIXEL
#define TRACE_SET_PIXEL
#define TRACE_FREE_PIXEL
#endif
/*
XW_STATUS Xw_alloc_pixel(pcolormap,*pixel):
XW_EXT_COLORMAP *pcolormap
unsigned long *pixel;
Allocates a pixel in the colormap and
returns SUCCESS for a valid pixel value according of the free space of
the colormap,
or ERROR if no more room exist in the colormap.
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_alloc_pixel (void* acolormap, unsigned long *pixel)
#else
XW_STATUS Xw_alloc_pixel (acolormap,pixel)
void *acolormap;
unsigned long *pixel;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*) acolormap;
XW_STATUS status = XW_ERROR;
*pixel = 0;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_alloc_pixel",pcolormap) ;
return (XW_ERROR) ;
}
if( _CCLASS == PseudoColor ) {
if( XAllocColorCells(_CDISPLAY,
_CINFO.colormap,False,NULL,0,pixel,1) ) {
status = XW_SUCCESS;
}
}
#ifdef TRACE_ALLOC_PIXEL
if( Xw_get_trace() ) {
printf(" %d = Xw_alloc_pixel(%lx,%ld)\n",status,(long ) pcolormap,*pixel) ;
}
#endif
return (status);
}
/*
XW_STATUS Xw_set_pixel(pcolormap,pixel,r,g,b):
XW_EXT_COLORMAP *pcolormap
unsigned long pixel;
float r,g,b;
Updates a pixel with the color {r,g,b} defined in [0-1] space
returns SUCCESS for a valid PseudoColor pixel
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_set_pixel (void* acolormap, unsigned long pixel, float r, float g, float b)
#else
XW_STATUS Xw_set_pixel (acolormap,pixel,r,g,b)
void *acolormap;
unsigned long pixel;
float r,g,b;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*) acolormap;
XW_STATUS status = XW_ERROR;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_set_pixel",pcolormap) ;
return (XW_ERROR) ;
}
if( _CCLASS == PseudoColor ) {
XColor color;
int error,gravity;
char *serror;
color.pixel = pixel;
color.red = (unsigned short) (r*65535.);
color.green = (unsigned short) (g*65535.);
color.blue = (unsigned short) (b*65535.);
color.flags = DoRed | DoGreen | DoBlue;
Xw_print_error();
if( !Xw_get_trace() ) Xw_set_synchronize(_CDISPLAY,True);
XStoreColor(_CDISPLAY,_CINFO.colormap,&color);
if( !Xw_get_trace() ) Xw_set_synchronize(_CDISPLAY,False);
serror = Xw_get_error(&error,&gravity);
if( error < 1000 ) status = XW_SUCCESS;
}
#ifdef TRACE_SET_PIXEL
if( Xw_get_trace() ) {
printf(" %d = Xw_set_pixel(%lx,%ld,%f,%f,%f)\n",status,(long ) pcolormap,pixel,r,g,b) ;
}
#endif
return (status);
}
/*
XW_STATUS Xw_free_pixel(pcolormap,pixel):
XW_EXT_COLORMAP *pcolormap
unsigned long pixel;
Free a pixel from the colormap
returns SUCCESS for a valid PseudoColor pixel
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_free_pixel (void* acolormap, unsigned long pixel)
#else
XW_STATUS Xw_free_pixel (acolormap,pixel)
void *acolormap;
unsigned long pixel;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*) acolormap;
XW_STATUS status = XW_ERROR;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_free_pixel",pcolormap) ;
return (XW_ERROR) ;
}
if( _CCLASS == PseudoColor ) {
int error,gravity;
char *serror;
Xw_print_error();
if( !Xw_get_trace() ) Xw_set_synchronize(_CDISPLAY,True);
XFreeColors(_CDISPLAY,_CINFO.colormap,&pixel,1,0);
if( !Xw_get_trace() ) Xw_set_synchronize(_CDISPLAY,False);
serror = Xw_get_error(&error,&gravity);
if( error < 1000 ) status = XW_SUCCESS;
}
#ifdef TRACE_FREE_PIXEL
if( Xw_get_trace() ) {
printf(" %d = Xw_free_pixel(%lx,%ld)\n",status,(long ) pcolormap,pixel) ;
}
#endif
return (status);
}

67
src/Xw/Xw_calc_points.cxx Executable file
View File

@@ -0,0 +1,67 @@
// File: Xw_points.cxx
// Created: Wed Feb 20 17:50:06 2002
// Author: Sergey ALTUKHOV
// <sav@vovox>
#include <Standard_Integer.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Xw_Extension.h>
#ifdef XW_PROTOTYPE
int PXPOINT( double x, double ratio )
#else
int PXPOINT( x, ratio )
double x, ratio;
#endif /*XW_PROTOTYPE*/
{
int result = 0;
try {
OCC_CATCH_SIGNALS
result = (int) ( x / ratio );
}
catch (Standard_Failure) {
result = ROUND( x / ratio );
}
return result;
}
#ifdef XW_PROTOTYPE
int PYPOINT( double y, double height, double ratio )
#else
int PYPOINT( y, height, ratio )
double y, height, ratio;
#endif /*XW_PROTOTYPE*/
{
int result = 0;
try {
OCC_CATCH_SIGNALS
result = (int)( height - ( y / ratio ) );
}
catch (Standard_Failure) {
result = ROUND( height - ( y / ratio ) );
}
return result;
}
#ifdef XW_PROTOTYPE
int PVALUE( double v, double xratio, double yratio )
#else
int PVALUE( v, xratio, yratio )
double v, xratio, yratio;
#endif /*XW_PROTOTYPE*/
{
int result = 0;
try {
OCC_CATCH_SIGNALS
result = (int)( v / ( ( xratio + yratio ) / 2. ) );
}
catch (Standard_Failure) {
result = ROUND( v / ( ( xratio + yratio ) / 2. ) );
}
return result;
}

564
src/Xw/Xw_convert_image.cxx Executable file
View File

@@ -0,0 +1,564 @@
/*
C<
C***********************************************************************
C
C FONCTION :
C ----------
C
C
C$ HISTORIQUE DES MODIFICATIONS :
C --------------------------------
C 21-02-97 : GG ; G1334-PERF
C Ameliorer les performances de traduction
C des images XWD.
C >> Rempacer XGetPixel et XputPixel par des
C directes dans le buffer image.
C 07-05-97 : GG ; PRO7909
C Eviter de detruire l'image convertie lorsqu'il n'y a pas
C de conversion a faire !
*/
#define PRO7909
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_CONVERT_IMAGE
#endif
/*
XW_STATUS Xw_convert_image (awindow,aimage,acolors,ncolors):
XW_EXT_WINDOW *awindow
XW_EXT_IMAGEDATA *aimage
XW_EXT_COLOR *acolors (can be NULL)
int ncolors
Convert an image depending of the window class
returns ERROR if image can't be converted.
returns SUCCESS if successfull
*/
#define CREATE_IMAGE(_fun,_out,_nbp) \
/* Allocate the new pixel buffer */ \
if( !(_out = (unsigned char*) Xw_calloc(piimage->width * piimage->height,_nbp)) ) {\
/*ERROR*Bad Image allocation*/ \
Xw_set_error(60,_fun,0) ; \
return NULL ; \
} \
/* Create the new Image structure */ \
if( !(poimage = XCreateImage(_DISPLAY,_VISUAL,_DEPTH,ZPixmap,\
0,(char*)_out,piimage->width,piimage->height,_nbp*8,0)) ) {\
/* ERROR*XImage Creation failed */ \
Xw_set_error(62,_fun,0) ; \
Xw_free((char*)_out) ; \
return NULL ; \
}
#define COPY_PSEUDO_TO_PSEUDO(_fun,_in,_out) \
for( y=0 ; y<piimage->height ; y++ ) { \
for( x=0 ; x<piimage->width ; x++ ) { \
ipixel = *_in++; \
if( ipixel != lipixel ) { \
lipixel = ipixel; \
if( ipixel >= MAXCOLOR ) ipixel = 0 ; \
opixel = mapping[ipixel] ; \
if( !opixel ) { \
for( i=0,j=ipixel ; i<ncolors ; i++,j++) { \
if( j >= ncolors ) j = 0 ; \
if( ipixel == pcolors[j].pixel ) break; \
} \
red = (float)pcolors[j].red/0xFFFF ; \
green = (float)pcolors[j].green/0xFFFF ; \
blue = (float)pcolors[j].blue/0xFFFF ; \
if( !Xw_get_color_pixel(_COLORMAP,red,green,blue,&opixel,&isapproximate)) {\
/*ERROR*XImage Creation failed*/ \
Xw_set_error(63,_fun,&_COLORMAP->info.colormap) ;\
} \
mapping[ipixel] = opixel ; \
} \
} \
*_out++ = opixel; \
} \
if( ipad > 0 ) pidata.cdata += ipad; \
}
#define COPY_PSEUDO_TO_TRUE(_fun,_in,_out) \
for( y=0 ; y<piimage->height ; y++ ) { \
for( x=0 ; x<piimage->width ; x++ ) { \
ipixel = *_in++; \
if( ipixel != lipixel ) { \
lipixel = ipixel; \
if( ipixel >= MAXCOLOR ) ipixel = 0 ; \
opixel = mapping[ipixel] ; \
if( !opixel ) { \
for( i=0,j=ipixel ; i<ncolors ; i++,j++) { \
if( j >= ncolors ) j = 0 ; \
if( ipixel == pcolors[j].pixel ) break; \
} \
red = (float)pcolors[j].red/0xFFFF ; \
green = (float)pcolors[j].green/0xFFFF ; \
blue = (float)pcolors[j].blue/0xFFFF ; \
if( !Xw_get_color_pixel(_COLORMAP,red,green,blue,&opixel,&isapproximate)) {\
/*ERROR*XImage Creation failed*/ \
Xw_set_error(63,_fun,&_COLORMAP->info.colormap) ;\
} \
mapping[ipixel] = opixel ; \
} \
} \
*_out++ = opixel; \
} \
if( ipad > 0 ) pidata.cdata += ipad; \
}
#define COPY_TRUE_TO_PSEUDO(_fun,_in,_out) \
for( y=0 ; y<piimage->height ; y++ ) { \
for( x=0 ; x<piimage->width ; x++ ) { \
ipixel = *_in++; \
if( ipixel != lipixel ) { \
lipixel = ipixel; \
red = (float)((ipixel >> sred) & cmask)/(float)cmask; \
green = (float)((ipixel >> sgreen) & cmask)/(float)cmask; \
blue = (float)((ipixel >> sblue) & cmask)/(float)cmask; \
if( !Xw_get_color_pixel(_COLORMAP,red,green,blue,&opixel,&isapproximate)) {\
/*ERROR*XImage Creation failed*/ \
Xw_set_error(63,_fun,&_COLORMAP->info.colormap) ; \
} \
} \
*_out++ = opixel; \
} \
if( ipad > 0 ) pidata.cdata += ipad; \
}
#define COPY_TRUE_TO_TRUE(_fun,_in,_out) \
for( y=0 ; y<piimage->height ; y++ ) { \
for( x=0 ; x<piimage->width ; x++ ) { \
ipixel = *_in++; \
if( ipixel != lipixel ) { \
lipixel = ipixel; \
red = (float)((ipixel >> sred) & cmask)/(float)cmask; \
green = (float)((ipixel >> sgreen) & cmask)/(float)cmask; \
blue = (float)((ipixel >> sblue) & cmask)/(float)cmask; \
if( !Xw_get_color_pixel(_COLORMAP,red,green,blue,&opixel,&isapproximate)) {\
/*ERROR*XImage Creation failed*/ \
Xw_set_error(63,_fun,&_COLORMAP->info.colormap) ; \
} \
} \
*_out++ = opixel; \
} \
if( ipad > 0 ) pidata.cdata += ipad; \
}
#ifdef XW_PROTOTYPE
static XImage* ConvertPseudoToPseudo(XW_EXT_WINDOW *pwindow,XImage *piimage,XColor *pcolors,int ncolors) ;
static XImage* ConvertPseudoToTrue(XW_EXT_WINDOW *pwindow,XImage *piimage,XColor *pcolors,int ncolors) ;
static XImage* ConvertTrueToPseudo(XW_EXT_WINDOW *pwindow,XImage *piimage) ;
static XImage* ConvertTrueToTrue(XW_EXT_WINDOW *pwindow,XImage *piimage) ;
#else
static XImage* ConvertPseudoToPseudo() ;
static XImage* ConvertPseudoToTrue() ;
static XImage* ConvertTrueToPseudo() ;
static XImage* ConvertTrueToTrue() ;
#endif /*XW_PROTOTYPE*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_convert_image (void *awindow,void *aimage,void *acolors,int ncolors)
#else
XW_STATUS Xw_convert_image (awindow,aimage,acolors,ncolors)
void *awindow;
void *aimage;
void *acolors;
int ncolors;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_IMAGEDATA *pimage = (XW_EXT_IMAGEDATA*)aimage;
XColor *pcolors = (XColor*)acolors;
XImage *piimage,*poimage = NULL;
XW_STATUS status = XW_ERROR;
int i,iclass = 0;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_convert_image",pwindow) ;
return (XW_ERROR) ;
}
if( !Xw_isdefine_image(pimage) ) {
/*ERROR*Bad EXT_IMAGEDATA Address*/
Xw_set_error(25,"Xw_convert_image",pimage) ;
return (XW_ERROR) ;
}
piimage = (_ZIMAGE) ? _ZIMAGE : _IIMAGE;
if( !pcolors && piimage->red_mask &&
piimage->green_mask && piimage->blue_mask ) iclass = TrueColor;
else iclass = PseudoColor;
switch ( iclass ) {
case PseudoColor :
if( !pcolors ) {
if( !_ICOLORMAP ) _ICOLORMAP = _COLORMAP;
ncolors = min(_IVISUAL->map_entries,MAXCOLOR);
pcolors = (XColor*) Xw_calloc(sizeof(XColor),ncolors);
for( i=0 ; i<ncolors ; i++ ) pcolors[i].pixel = i;
XQueryColors(_DISPLAY,_ICOLORMAP->info.colormap,pcolors,ncolors) ;
}
if( pcolors ) switch (_CLASS ) {
case PseudoColor : /* Convert Pseudo to PseudoColor */
if( acolors || (_ICOLORMAP != _COLORMAP) ) {
poimage = ConvertPseudoToPseudo(pwindow,piimage,pcolors,ncolors) ;
} else {
poimage = piimage;
}
break ;
case TrueColor : /* Convert Pseudo to TrueColor */
poimage = ConvertPseudoToTrue(pwindow,piimage,pcolors,ncolors) ;
break ;
default:
/*ERROR*Unimplemented Visual class*/
Xw_set_error(5,"Xw_convert_image",&_CLASS) ;
}
#ifdef BUG /* Cette memoire est liberee par Xw_load_image !! */
if( pcolors && !acolors ) Xw_free(pcolors);
#endif
break ;
case TrueColor :
switch (_CLASS ) {
case PseudoColor : /* Convert True to PseudoColor */
poimage = ConvertTrueToPseudo(pwindow,piimage) ;
break ;
case TrueColor : /* Convert True to TrueColor */
poimage = ConvertTrueToTrue(pwindow,piimage) ;
break ;
default:
/*ERROR*Unimplemented Visual class*/
Xw_set_error(5,"Xw_convert_image",&_CLASS) ;
}
break ;
default:
/*ERROR*Unimplemented Visual class*/
Xw_set_error(5,"Xw_convert_image",&iclass) ;
}
_ICOLORMAP = _COLORMAP;
if( poimage ) {
status = XW_SUCCESS;
/* Destroy the old image */
if( _ZIMAGE && (_ZIMAGE != _IIMAGE) ) {
XDestroyImage(_ZIMAGE);
_ZIMAGE = NULL;
}
/* Initialize the output image */
#ifdef PRO7909
if( _IIMAGE != poimage ) {
XDestroyImage(_IIMAGE);
_IIMAGE = poimage;
}
#else
XDestroyImage(_IIMAGE);
_IIMAGE = poimage;
#endif
pimage->zoom = 1.;
}
#ifdef TRACE_CONVERT_IMAGE
if( Xw_get_trace() ) {
printf (" %d = Xw_convert_image(%lx,%lx,%lx,%d)\n",
status,(long ) pwindow,(long ) pimage,(long ) pcolors,ncolors);
}
#endif
return (status);
}
#ifdef XW_PROTOTYPE
static XImage* ConvertTrueToPseudo(XW_EXT_WINDOW *pwindow,XImage *piimage)
#else
static XImage* ConvertTrueToPseudo(pwindow,piimage)
XW_EXT_WINDOW *pwindow ;
XImage *piimage ;
#endif /*XW_PROTOTYPE*/
/*
Convert TrueColor to PseudoColor Image
*/
{
unsigned long ipixel,opixel,cmask ;
unsigned long lipixel = 0xFFFFFFFF ;
//int i,j,ipad,isapproximate ;
int ipad,isapproximate ;
int sred,sgreen,sblue ;
float red,green,blue ;
register union {
unsigned char *cdata ;
unsigned short *sdata ;
unsigned int *idata ;
} pidata,podata;
register int x,y;
XImage *poimage = NULL ;
#ifdef TRACE_CONVERT_IMAGE
if( Xw_get_trace() ) {
printf(" Xw_convert_image.TrueToPseudo()\n") ;
}
#endif
ipad = piimage->bytes_per_line -
piimage->width * piimage->bits_per_pixel/8 ;
pidata.cdata = (unsigned char*)piimage->data + piimage->xoffset;
sred = sgreen = sblue = 0 ;
cmask = piimage->red_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sred++ ; }
cmask = piimage->green_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sgreen++ ; }
cmask = piimage->blue_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sblue++ ; }
CREATE_IMAGE("ConvertTrueToPseudo",podata.cdata,1)
switch (piimage->bits_per_pixel) {
case 8 :
COPY_TRUE_TO_PSEUDO("ConvertTrueToPseudo",pidata.cdata,podata.cdata);
break;
case 16 :
COPY_TRUE_TO_PSEUDO("ConvertTrueToPseudo",pidata.sdata,podata.cdata);
break;
case 32 :
COPY_TRUE_TO_PSEUDO("ConvertTrueToPseudo",pidata.idata,podata.cdata);
break;
default:
/*ERROR*Unimplemented Image Visual depth*/
Xw_set_error(64,"ConvertTrueToPseudo",&piimage->bits_per_pixel);
}
return (poimage) ;
}
#ifdef XW_PROTOTYPE
static XImage* ConvertPseudoToTrue(XW_EXT_WINDOW *pwindow,XImage *piimage,XColor *pcolors,int ncolors)
#else
static XImage* ConvertPseudoToTrue(pwindow,piimage,pcolors,ncolors)
XW_EXT_WINDOW *pwindow ;
XImage *piimage ;
XColor *pcolors;
int ncolors;
#endif /*XW_PROTOTYPE*/
/*
Convert PseudoColor to TrueColor Image
*/
{
unsigned long ipixel,opixel ;
unsigned long lipixel = 0xFFFFFFFF ;
unsigned long mapping[MAXCOLOR];
int i,j,ipad,isapproximate ;
float red,green,blue ;
register union {
unsigned char *cdata ;
unsigned short *sdata ;
unsigned int *idata ;
} pidata,podata;
register int x,y;
XImage *poimage = NULL ;
#ifdef TRACE_CONVERT_IMAGE
if( Xw_get_trace() ) {
printf(" Xw_convert_image.PseudoToTrue()\n") ;
}
#endif
for( i=0 ; i<MAXCOLOR ; i++ ) mapping[i] = 0;
ipad = piimage->bytes_per_line -
piimage->width * piimage->bits_per_pixel/8 ;
pidata.cdata = (unsigned char*)piimage->data + piimage->xoffset;
switch (_DEPTH) {
case 4 :
case 8 :
CREATE_IMAGE("ConvertPseudoToTrue",podata.cdata,1)
COPY_PSEUDO_TO_TRUE("ConvertPseudoToTrue",pidata.cdata,podata.cdata);
break;
case 12 :
CREATE_IMAGE("ConvertPseudoToTrue",podata.cdata,2)
COPY_PSEUDO_TO_TRUE("ConvertPseudoToTrue",pidata.cdata,podata.sdata);
break;
case 24 :
CREATE_IMAGE("ConvertPseudoToTrue",podata.cdata,4)
COPY_PSEUDO_TO_TRUE("ConvertPseudoToTrue",pidata.cdata,podata.idata);
break;
default:
/*ERROR*Unimplemented Image Visual depth*/
Xw_set_error(64,"ConvertPseudoToTrue",&_DEPTH);
}
return (poimage) ;
}
#ifdef XW_PROTOTYPE
static XImage* ConvertPseudoToPseudo(XW_EXT_WINDOW *pwindow,XImage *piimage,XColor *pcolors,int ncolors)
#else
static XImage* ConvertPseudoToPseudo(pwindow,piimage,pcolors,ncolors)
XW_EXT_WINDOW *pwindow ;
XImage *piimage ;
XColor *pcolors;
int ncolors;
#endif /*XW_PROTOTYPE*/
/*
Convert PseudoColor to PseudoColor Image
*/
{
unsigned long ipixel,opixel ;
unsigned long lipixel = 0xFFFFFFFF ;
unsigned long mapping[MAXCOLOR];
int i,j,ipad,isapproximate ;
float red,green,blue ;
register union {
unsigned char *cdata ;
unsigned short *sdata ;
unsigned int *idata ;
} pidata,podata;
register int x,y;
XImage *poimage = NULL ;
#ifdef TRACE_CONVERT_IMAGE
if( Xw_get_trace() ) {
printf(" Xw_convert_image.PseudoToPseudo()\n") ;
}
#endif
for( i=0 ; i<MAXCOLOR ; i++ ) mapping[i] = 0;
ipad = piimage->bytes_per_line -
piimage->width * piimage->bits_per_pixel/8 ;
pidata.cdata = (unsigned char*)piimage->data + piimage->xoffset;
switch (_DEPTH) {
case 4 :
case 8 :
CREATE_IMAGE("ConvertPseudoToPseudo",podata.cdata,1)
COPY_PSEUDO_TO_PSEUDO("ConvertPseudoToPseudo",pidata.cdata,podata.cdata);
break;
default:
/*ERROR*Unimplemented Image Visual depth*/
Xw_set_error(64,"ConvertPseudoToPseudo",&_DEPTH);
}
return (poimage) ;
}
#ifdef XW_PROTOTYPE
static XImage* ConvertTrueToTrue(XW_EXT_WINDOW *pwindow,XImage *piimage)
#else
static XImage* ConvertTrueToTrue(pwindow,piimage)
XW_EXT_WINDOW *pwindow ;
XImage *piimage ;
#endif /*XW_PROTOTYPE*/
/*
Convert TrueColor to TrueColor Image
*/
{
unsigned long ipixel,opixel,cmask ;
unsigned long lipixel = 0xFFFFFFFF ;
//int i,j,ipad,isapproximate ;
int ipad,isapproximate ;
int sred,sgreen,sblue ;
float red,green,blue ;
register union {
unsigned char *cdata ;
unsigned short *sdata ;
unsigned int *idata ;
} pidata,podata;
register int x,y;
XImage *poimage = NULL ;
#ifdef TRACE_CONVERT_IMAGE
if( Xw_get_trace() ) {
printf(" Xw_convert_image.TrueToTrue()\n") ;
}
#endif
if( (_DEPTH == piimage->depth) &&
(_VISUAL->red_mask == piimage->red_mask) &&
(_VISUAL->green_mask == piimage->green_mask) &&
(_VISUAL->blue_mask == piimage->blue_mask) ) return piimage;
ipad = piimage->bytes_per_line -
piimage->width * piimage->bits_per_pixel/8 ;
pidata.cdata = (unsigned char*)piimage->data + piimage->xoffset;
sred = sgreen = sblue = 0 ;
cmask = piimage->red_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sred++ ; }
cmask = piimage->green_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sgreen++ ; }
cmask = piimage->blue_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sblue++ ; }
switch (_DEPTH) {
case 4 :
case 8 :
CREATE_IMAGE("ConvertTrueToTrue",podata.cdata,1)
switch (piimage->bits_per_pixel) {
case 8 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.cdata,podata.cdata);
break;
case 16 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.sdata,podata.cdata);
break;
case 32 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.idata,podata.cdata);
break;
default:
/*ERROR*Unimplemented Image Visual depth*/
Xw_set_error(64,"ConvertTrueToTrue",&piimage->bits_per_pixel);
}
break;
case 12 :
CREATE_IMAGE("ConvertTrueToTrue",podata.cdata,2)
switch (piimage->bits_per_pixel) {
case 8 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.cdata,podata.sdata);
break;
case 16 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.sdata,podata.sdata);
break;
case 32 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.idata,podata.sdata);
break;
default:
/*ERROR*Unimplemented Image Visual depth*/
Xw_set_error(64,"ConvertTrueToTrue",&piimage->bits_per_pixel);
}
break;
case 24 :
CREATE_IMAGE("ConvertTrueToTrue",podata.cdata,4)
switch (piimage->bits_per_pixel) {
case 8 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.cdata,podata.idata);
break;
case 16 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.sdata,podata.idata);
break;
case 32 :
COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.idata,podata.idata);
break;
default:
/*ERROR*Unimplemented Image Visual depth*/
Xw_set_error(64,"ConvertTrueToTrue",&piimage->bits_per_pixel);
}
break;
default:
/*ERROR*Unimplemented Image Visual depth*/
Xw_set_error(64,"ConvertTrueToTrue",&_DEPTH);
}
return (poimage) ;
}

View File

@@ -0,0 +1,140 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_BACKGROUND_COLOR
#endif
/*
XW_STATUS Xw_def_background_color(awindow,r,g,b):
XW_EXT_WINDOW *awindow
float r,g,b ; Red,Green,Blue color value 0. >= x <= 1.
Update Background Color index with the specified R,G,B values .
Returns ERROR if Extended Window or Colormap is wrong
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_background_color (void* awindow,
float r,float g,float b)
#else
XW_STATUS Xw_def_background_color (awindow,r,g,b)
void *awindow;
float r,g,b ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
XW_EXT_COLORMAP *pcolormap ;
unsigned long backpixel,highpixel ;
XColor color ;
int i,index,cclass,isapproximate ;
XW_STATUS status = XW_SUCCESS;
if ( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_def_background_color",pwindow) ;
return (XW_ERROR) ;
}
if ( !Xw_isdefine_colormap(_COLORMAP) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_def_background_color",_COLORMAP) ;
return (XW_ERROR) ;
}
pcolormap = _COLORMAP ;
index = pwindow->backindex ;
if( index >= 0 ) {
if( pcolormap->define[index] != BACKCOLOR ) {
for( i=0 ; i<pcolormap->maxcolor ; i++ ) {
if( pcolormap->define[i] == FREECOLOR ) break;
}
if( i < pcolormap->maxcolor ) {
index = i ;
pcolormap->define[i] = BACKCOLOR;
}
}
if( pcolormap->mapping == Xw_TOM_READONLY ) {
cclass = StaticColor;
} else {
cclass = _CCLASS;
}
switch ( cclass ) {
case TrueColor :
Xw_get_color_pixel(pcolormap,r,g,b,&backpixel,&isapproximate) ;
break ;
case PseudoColor :
if( pcolormap->mapping == Xw_TOM_COLORCUBE ) {
if( (_CGINFO.red_mult > 0) && (fabs(r-g) < 0.01) && (fabs(r-b) < 0.01) ) {
index = (int)(0.5+r*_CGINFO.red_max)*_CGINFO.red_mult;
if( _CINFO.red_max > 0 )
index += (_CINFO.red_max+1)*(_CINFO.green_max+1)*(_CINFO.blue_max+1);
} else if( _CINFO.red_mult > 0 ) {
index = ((int)(0.5+r*_CINFO.red_max))*_CINFO.red_mult+
((int)(0.5+g*_CINFO.green_max))*_CINFO.green_mult+
((int)(0.5+b*_CINFO.blue_max))*_CINFO.blue_mult;
} else if( _CGINFO.red_mult > 0 ) {
float l = (r+g+b)/3.;
index = (int)(0.5+l*_CGINFO.red_max)*_CGINFO.red_mult;
} else {
index = 0;
}
backpixel = _CINFO.base_pixel = index;
} else if( pcolormap->define[index] == BACKCOLOR ) {
color.pixel = backpixel = pcolormap->pixels[index] ;
color.red = (unsigned short) (r * 0xFFFF) ;
color.green = (unsigned short) (g * 0xFFFF) ;
color.blue = (unsigned short) (b * 0xFFFF) ;
color.flags = DoRed|DoGreen|DoBlue ;
XStoreColor(_DISPLAY,_CINFO.colormap,&color) ;
}
break ;
case StaticColor :
status = Xw_alloc_color(pcolormap,r,g,b,&backpixel,&isapproximate) ;
break ;
}
if( status ) {
pwindow->backindex = index ;
pcolormap->pixels[index] = backpixel ;
}
} else {
backpixel = pcolormap->backpixel ; /* Transparent window */
}
if( status ) {
highpixel = pcolormap->highpixel ^ backpixel ;
XSetWindowBackground (_DISPLAY, _WINDOW, backpixel) ;
XSetBackground(_DISPLAY, pwindow->qgwind.gc, backpixel) ;
XSetBackground(_DISPLAY, pwindow->qgwind.gccopy, backpixel) ;
XSetBackground(_DISPLAY, pwindow->qgwind.gcclear, backpixel) ;
XSetBackground(_DISPLAY, pwindow->qgwind.gchigh, backpixel) ;
XSetForeground(_DISPLAY, pwindow->qgwind.gcclear, backpixel) ;
XSetForeground(_DISPLAY, pwindow->qgwind.gchigh, highpixel) ;
for( i=0 ; i<MAXQG ; i++ ) {
XSetBackground(_DISPLAY, pwindow->qgline[i].gc, backpixel);
XSetBackground(_DISPLAY, pwindow->qgpoly[i].gc, backpixel);
XSetBackground(_DISPLAY, pwindow->qgtext[i].gc, backpixel);
XSetBackground(_DISPLAY, pwindow->qgmark[i].gc, backpixel);
}
}
#ifdef TRACE_DEF_BACKGROUND_COLOR
if( Xw_get_trace() ) {
printf(" %d = Xw_def_background_color(%lx,%f,%f,%f)\n",status,(long ) pwindow,r,g,b) ;
}
#endif
return (status);
}

100
src/Xw/Xw_def_color.cxx Executable file
View File

@@ -0,0 +1,100 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_COLOR
#endif
/*
XW_STATUS Xw_def_color(acolormap,index,r,g,b):
XW_EXT_COLORMAP *acolormap
int index ; Color index 0 >= x < MAXCOLOR
float r,g,b ; Red,Green,Blue color value 0. >= x <= 1.
Update Color Extended colormap index with the specified R,G,B values .
Returns ERROR if BadColor Index
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_color (void* acolormap,
int index,float r,float g,float b)
#else
XW_STATUS Xw_def_color (acolormap,index,r,g,b)
void *acolormap;
int index ;
float r,g,b ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ;
XColor color ;
int cclass,isapproximate;
unsigned long pixel;
XW_STATUS status = XW_SUCCESS;
if ( !Xw_isdefine_colorindex(pcolormap,index) ) {
/*ERROR*Bad Color Index*/
Xw_set_error(1,"Xw_def_color",&index) ;
return (XW_ERROR) ;
}
if( pcolormap->mapping == Xw_TOM_READONLY ) {
cclass = StaticColor;
} else {
cclass = _CCLASS;
}
switch (cclass) {
case TrueColor :
Xw_get_color_pixel(pcolormap,r,g,b,&pixel,&isapproximate) ;
break ;
case PseudoColor :
if( pcolormap->mapping == Xw_TOM_COLORCUBE ) {
int kindex;
if( (_CGINFO.red_mult > 0) && (fabs(r-g) < 0.01) && (fabs(r-b) < 0.01) ) {
kindex = (int)(0.5+r*_CGINFO.red_max)*_CGINFO.red_mult;
if( _CINFO.red_max > 0 )
kindex += (_CINFO.red_max+1)*(_CINFO.green_max+1)*(_CINFO.blue_max+1);
} else if( _CINFO.red_mult > 0 ) {
kindex = ((int)(0.5+r*_CINFO.red_max))*_CINFO.red_mult+
((int)(0.5+g*_CINFO.green_max))*_CINFO.green_mult+
((int)(0.5+b*_CINFO.blue_max))*_CINFO.blue_mult;
} else if( _CGINFO.red_mult > 0 ) {
float l = (r+g+b)/3.;
kindex = (int)(0.5+l*_CGINFO.red_max)*_CGINFO.red_mult;
} else {
kindex = 0;
}
pixel = _CINFO.base_pixel + kindex;
} else {
color.pixel = pixel = pcolormap->pixels[index] ;
color.red = (unsigned short) (r * 0xFFFF) ;
color.green = (unsigned short) (g * 0xFFFF) ;
color.blue = (unsigned short) (b * 0xFFFF) ;
color.flags = DoRed|DoGreen|DoBlue ;
XStoreColor(_CDISPLAY,_CINFO.colormap,&color) ;
}
break ;
case StaticColor :
status = Xw_alloc_color(pcolormap,r,g,b,&pixel,&isapproximate) ;
break ;
}
if( status ) {
pcolormap->define[index] = USERCOLOR ;
pcolormap->pixels[index] = pixel ;
}
#ifdef TRACE_DEF_COLOR
if( Xw_get_trace() ) {
printf(" %d = Xw_def_color(%lx,%d,%f,%f,%f)\n",status,(long ) pcolormap,index,r,g,b) ;
}
#endif
return (status);
}

1644
src/Xw/Xw_def_colormap.cxx Executable file

File diff suppressed because it is too large Load Diff

189
src/Xw/Xw_def_font.cxx Executable file
View File

@@ -0,0 +1,189 @@
#define PRO5676 /*GG_231296
// Calculer la hauteur exacte de la police de caracteres
// par rapport a la partie du texte situee au dessus de la
// ligne de base.
*/
#define TEST
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_FONT
#endif
#define MAXNAMES 32
/*
STATUS Xw_def_font (afontmap,index,size,fontname):
XW_EXT_FONTMAP *afontmap
int index Font index
float size Font size in MM
char fontname[] Font description
Update Text Font Extended fontmap index with the specified
FONT size and description
NOTE than font index 0 is the default font and cann't be REDEFINED .
NOTE than fontname can be defined in three forms :
1) Simple form is "fmly" Ex: "helvetica"
2) More complex form is "fmly-wght" Ex: "helvetica-bold"
3) Full form is "-fndry-fmly-wght-slant-swdth-adstyl-pxlsz
-ptSz-resx-resy-spc-avgWdth-rgstry-encdn"
where each field must be replaced by an "*"
See Xlib User Guide for more information or /usr/bin/X11/xfontsel"
utility .
Returns ERROR if BadFont Index or name
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_font (void* afontmap,
int index,float size,char* fontname)
#else
XW_STATUS Xw_def_font (afontmap,index,size,fontname)
void *afontmap;
int index ;
float size ;
char *fontname ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_FONTMAP *pfontmap = (XW_EXT_FONTMAP*)afontmap ;
Screen *screen ;
int i,j,n,prefered_size,count,psize,qsize,retry = True;
char **fontlist,*prefered_name ;
XFontStruct *tmpfont,*selected_font,*prefered_font ;
//char **fontdir ;
float rsize = fabs(size);
if ( !Xw_isdefine_fontindex(pfontmap,index) ) {
/*ERROR*Bad Font Index*/
Xw_set_error(7,"Xw_def_font",&index) ;
return (XW_ERROR) ;
}
if( !fontname || !strlen(fontname) ) {
/*ERROR*Bad Font Name*/
Xw_set_error(8,"Xw_def_font",fontname) ;
return (XW_ERROR) ;
}
screen = ScreenOfDisplay(_FDISPLAY,DefaultScreen(_FDISPLAY)) ;
fontlist = XListFonts(_FDISPLAY,fontname,MAXNAMES,&count) ;
RETRY:
prefered_size =
(unsigned int) (rsize*(float)WidthOfScreen(screen)/
(float)WidthMMOfScreen(screen)) ;
prefered_font = NULL;
prefered_name = NULL;
if( count ) {
char *psub,*pfont,scalable_font[128];
qsize = 0;
for( i=0 ; i<count ; i++ ) {
pfont = fontlist[i];
#ifdef TEST
if(( psub = strstr(pfont,"-0-0-") )) {
int l = psub - pfont + 1;
pfont = scalable_font;
strncpy(pfont,fontlist[i],l);
sprintf(&pfont[l],"%d",prefered_size);
strcat(pfont,&fontlist[i][l+1]);
selected_font = XLoadQueryFont(_FDISPLAY,pfont) ;
} else {
selected_font = XLoadQueryFont(_FDISPLAY,pfont) ;
}
#else
selected_font = XLoadQueryFont(_FDISPLAY,fontlist[i]) ;
#endif
if( !selected_font ) break;
psize = selected_font->max_bounds.ascent +
selected_font->max_bounds.descent ;
if( !prefered_font ||
(abs(psize - prefered_size) < abs(qsize - prefered_size)) ) {
tmpfont = prefered_font ;
prefered_font = selected_font ;
selected_font = tmpfont ;
qsize = psize;
#ifdef TEST
prefered_name = pfont ;
#else
prefered_name = fontlist[i] ;
#endif
}
if( selected_font && (prefered_font != selected_font) ) {
for( j=1,n=0 ; j<pfontmap->maxfont ; j++ ) {
if( pfontmap->fonts[j] && (selected_font->fid ==
pfontmap->fonts[j]->fid) ) n++ ;
}
if( !n ) {
XFreeFont(_FDISPLAY,selected_font);
}
}
}
}
if( pfontmap->gnames[index] ) Xw_free(pfontmap->gnames[index]) ;
if( pfontmap->snames[index] ) Xw_free(pfontmap->snames[index]) ;
pfontmap->gnames[index] = (char*) Xw_malloc(strlen(fontname)+1) ;
strcpy(pfontmap->gnames[index],fontname) ;
if( strstr(fontname,"Defaultfont") ) {
pfontmap->snames[index] =
(char*) Xw_malloc(strlen(pfontmap->snames[0])+1) ;
strcpy(pfontmap->snames[index],pfontmap->snames[0]) ;
pfontmap->fonts[index] = pfontmap->fonts[0] ;
} else if( prefered_font && prefered_name ) {
pfontmap->snames[index] =
(char*) Xw_malloc(strlen(prefered_name)+1) ;
strcpy(pfontmap->snames[index],prefered_name) ;
pfontmap->fonts[index] = prefered_font ;
} else {
pfontmap->snames[index] =
(char*) Xw_malloc(strlen(pfontmap->snames[0])+1) ;
strcpy(pfontmap->snames[index],pfontmap->snames[0]) ;
pfontmap->fonts[index] = pfontmap->fonts[0] ;
/*ERROR*Bad Font Name*/
Xw_set_error(8,"Xw_def_font",fontname) ;
return (XW_ERROR) ;
}
#ifdef PRO5676
if( size < 0. && retry ) {
float ratio,tsize;
psize = (pfontmap->fonts[index])->max_bounds.ascent;
tsize = (float)psize*HeightMMOfScreen(screen)/
(float)HeightOfScreen(screen) ;
ratio = rsize/tsize;
rsize *= ratio;
retry = False;
if( fabs(ratio - 1.) > 0.001 ) goto RETRY;
}
#endif
psize = (pfontmap->fonts[index])->max_bounds.ascent +
(pfontmap->fonts[index])->max_bounds.descent ;
rsize = (float)psize*HeightMMOfScreen(screen)/
(float)HeightOfScreen(screen) ;
pfontmap->gsizes[index] = size ;
pfontmap->fsizes[index] = rsize ;
pfontmap->fratios[index] =
(float)(pfontmap->fonts[index])->max_bounds.descent/
(pfontmap->fonts[index])->max_bounds.ascent;
pfontmap->ssizey[index] =
pfontmap->ssizex[index] = pfontmap->ssizey[index] = rsize;
pfontmap->gslants[index] = pfontmap->sslants[index] = 0. ;
if( fontlist ) XFreeFontNames(fontlist) ;
#ifdef TRACE_DEF_FONT
if( Xw_get_trace() ) {
printf (" Xw_def_font(%lx,%d,%f,'%s')\n",(long ) pfontmap,index,size,fontname) ;
}
#endif
return (XW_SUCCESS);
}

215
src/Xw/Xw_def_fontmap.cxx Executable file
View File

@@ -0,0 +1,215 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_FONTMAP
#endif
/*
XW_EXT_FONTMAP* Xw_def_fontmap(adisplay,nfont):
XW_EXT_DISPLAY *adisplay Extended Display structure
int nfont Number of font cells to be allocated
Create a fontmap extension
allocate the font cells in the fontmap as if possible
depending of the MAXFONT define .
Returns Fontmap extension address if successuful
or NULL if ERROR
STATUS = Xw_close_fontmap(afontmap)
XW_EXT_FONTMAP* afontmap Extended fontmap
Destroy The Extended TypeMap
Returns ERROR if Bad Extended TypeMap Address
SUCCESS if successfull
*/
#ifdef XW_PROTOTYPE
void* Xw_def_fontmap (void* adisplay,int nfont)
#else
void* Xw_def_fontmap (adisplay,nfont)
void *adisplay ;
int nfont ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_FONTMAP *pfontmap = NULL ;
XFontStruct *dfstruct ;
XGCValues values ;
GC gc ;
//int i,font,psize ;
int i,psize ;
char *dfstring = NULL ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_def_fontmap",pdisplay) ;
return (NULL) ;
}
gc = DefaultGCOfScreen(_DSCREEN) ;
XGetGCValues(_DDISPLAY,gc,GCFont,&values) ;
dfstruct = XQueryFont(_DDISPLAY,XGContextFromGC(gc)) ;
for( i=0 ; i<dfstruct->n_properties ; i++ ) {
if( dfstruct->properties[i].name == XA_FONT ) {
dfstring = XGetAtomName(_DDISPLAY,dfstruct->properties[i].card32) ;
break ;
}
}
if( !(pfontmap = Xw_add_fontmap_structure(sizeof(XW_EXT_FONTMAP))) )
return (NULL) ;
if( nfont <= 0 ) nfont = MAXFONT ;
pfontmap->connexion = pdisplay ;
pfontmap->maxfont = min(nfont,MAXFONT) ;
pfontmap->gnames[0] = (char*) "Defaultfont";
pfontmap->snames[0] = dfstring ;
pfontmap->fonts[0] = dfstruct ;
pfontmap->fonts[0]->fid = values.font ;
psize = (pfontmap->fonts[0])->max_bounds.ascent +
(pfontmap->fonts[0])->max_bounds.descent ;
pfontmap->gsizes[0] = (float)psize*HeightMMOfScreen(_DSCREEN)/
(float)HeightOfScreen(_DSCREEN) ;
pfontmap->fsizes[0] = pfontmap->gsizes[0];
pfontmap->fratios[0] = 0.;
pfontmap->ssizex[0] = pfontmap->ssizey[0] = pfontmap->fsizes[0] ;
pfontmap->gslants[0] = pfontmap->sslants[0] = 0. ;
#ifdef TRACE_DEF_FONTMAP
if( Xw_get_trace() ) {
printf(" %lx = Xw_def_fontmap(%lx,%d)\n", (long ) pfontmap,(long ) adisplay,nfont) ;
}
#endif
return (pfontmap);
}
static XW_EXT_FONTMAP *PfontmapList =NULL ;
#ifdef XW_PROTOTYPE
XW_EXT_FONTMAP* Xw_add_fontmap_structure(int size)
#else
XW_EXT_FONTMAP* Xw_add_fontmap_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended fontmap structure in the
EXtended fontmap List
returns Extended fontmap address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_FONTMAP *pfontmap = (XW_EXT_FONTMAP*) Xw_malloc(size) ;
int i ;
if( pfontmap ) {
pfontmap->type = FONTMAP_TYPE ;
pfontmap->link = PfontmapList ;
PfontmapList = pfontmap ;
pfontmap->connexion = NULL ;
pfontmap->maxfont = 0 ;
pfontmap->maxwindow = 0 ;
for( i=0 ; i<MAXFONT ; i++ ) {
pfontmap->gnames[i] = NULL ;
pfontmap->snames[i] = NULL ;
pfontmap->fonts[i] = NULL ;
pfontmap->gsizes[i] = 0. ;
pfontmap->fsizes[i] = 0. ;
pfontmap->ssizex[i] = 0. ;
pfontmap->ssizey[i] = 0. ;
pfontmap->gslants[i] = 0. ;
pfontmap->sslants[i] = 0. ;
pfontmap->fratios[i] = 0. ;
}
} else {
/*EXT_FONTMAP allocation failed*/
Xw_set_error(9,"Xw_add_fontmap_structure",NULL) ;
}
return (pfontmap) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_fontmap(void* afontmap)
#else
XW_STATUS Xw_close_fontmap(afontmap)
void* afontmap ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_FONTMAP* pfontmap = (XW_EXT_FONTMAP*) afontmap ;
XW_STATUS status ;
if( !Xw_isdefine_fontmap(pfontmap) ) {
/*Bad EXT_FONTMAP Address*/
Xw_set_error(51,"Xw_close_fontmap",pfontmap) ;
return (XW_ERROR) ;
}
status = Xw_del_fontmap_structure(pfontmap) ;
#ifdef TRACE_DEF_FONTMAP
if( Xw_get_trace() ) {
printf(" %d = Xw_close_fontmap(%lx)\n",status,(long ) pfontmap) ;
}
#endif
return (status) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_fontmap_structure(XW_EXT_FONTMAP* afontmap)
#else
XW_STATUS Xw_del_fontmap_structure(afontmap)
XW_EXT_FONTMAP *afontmap;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended fontmap address from the Extended List
returns ERROR if the fontmap address is not Found in the list
returns SUCCESS if successful
*/
{
XW_EXT_FONTMAP *pfontmap = PfontmapList ;
int i ;
if( !afontmap ) return (XW_ERROR) ;
if( afontmap->maxwindow ) {
return (XW_ERROR) ;
} else {
for( i=1 ; i<MAXFONT ; i++) {
if( afontmap->fonts[i] ) {
if( afontmap->gnames[i] ) Xw_free(afontmap->gnames[i]) ;
if( afontmap->snames[i] ) Xw_free(afontmap->snames[i]) ;
if( afontmap->fonts[i]->fid != afontmap->fonts[0]->fid )
XFreeFont(_FDISPLAY,afontmap->fonts[i]) ;
}
}
if( afontmap == pfontmap ) {
PfontmapList = (XW_EXT_FONTMAP*) afontmap->link ;
} else {
for( ; pfontmap ; pfontmap = (XW_EXT_FONTMAP*) pfontmap->link ) {
if( pfontmap->link == afontmap ) {
pfontmap->link = afontmap->link ;
break ;
}
}
}
Xw_free(afontmap) ;
}
return (XW_SUCCESS) ;
}

114
src/Xw/Xw_def_highlight_color.cxx Executable file
View File

@@ -0,0 +1,114 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_HIGHLIGHT_COLOR
#endif
/*
STATUS Xw_def_highlight_color(acolormap,r,g,b):
XW_EXT_COLORMAP *acolormap
float r,g,b ; Red,Green,Blue color value 0. >= x <= 1.
Update Highlight Color index with the specified R,G,B values .
NOTE than highlight color is shared between all Windows
Returns ERROR if Extended Colormap is not properly defined
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_highlight_color (void* acolormap,
float r,float g,float b)
#else
XW_STATUS Xw_def_highlight_color (acolormap,r,g,b)
void *acolormap;
float r,g,b ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ;
XColor color ;
int i,cclass,index = -1,isapproximate ;
XW_STATUS status = XW_SUCCESS;
unsigned long highpixel;
if ( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_def_highlight_color",pcolormap) ;
return (XW_ERROR) ;
}
if( pcolormap->mapping == Xw_TOM_READONLY ) {
cclass = StaticColor;
} else {
cclass = _CCLASS;
}
switch ( cclass ) {
case TrueColor :
Xw_get_color_pixel(pcolormap,r,g,b,&highpixel,&isapproximate) ;
break ;
case PseudoColor :
if( pcolormap->mapping == Xw_TOM_COLORCUBE ) {
if( (_CGINFO.red_mult > 0) && (fabs(r-g) < 0.01) && (fabs(r-b) < 0.01) ) {
index = (int)(0.5+r*_CGINFO.red_max)*_CGINFO.red_mult;
if( _CINFO.red_max > 0 )
index += (_CINFO.red_max+1)*(_CINFO.green_max+1)*(_CINFO.blue_max+1);
} else if( _CINFO.red_mult > 0 ) {
index = ((int)(0.5+r*_CINFO.red_max))*_CINFO.red_mult+
((int)(0.5+g*_CINFO.green_max))*_CINFO.green_mult+
((int)(0.5+b*_CINFO.blue_max))*_CINFO.blue_mult;
} else if( _CGINFO.red_mult > 0 ) {
float l = (r+g+b)/3.;
index = (int)(0.5+l*_CGINFO.red_max)*_CGINFO.red_mult;
} else {
index = 0;
}
highpixel = _CINFO.base_pixel + index ;
} else if( pcolormap->mapping == Xw_TOM_BESTRAMP ) {
color.red = (unsigned short) (r * 0xFFFF) ;
color.green = (unsigned short) (g * 0xFFFF) ;
color.blue = (unsigned short) (b * 0xFFFF) ;
color.flags = DoRed|DoGreen|DoBlue ;
for( i=0 ; i<pcolormap->maxcolor ; i++ ) {
if( (pcolormap->pixels[i] & 1) &&
((pcolormap->define[i] == FREECOLOR) ||
(pcolormap->define[i] == HIGHCOLOR)) ) {
pcolormap->define[i] = HIGHCOLOR ;
color.pixel = pcolormap->pixels[i] ;
XStoreColor(_CDISPLAY,_CINFO.colormap,&color) ;
}
}
highpixel = pcolormap->pixels[1];
} else if( pcolormap->mapping == Xw_TOM_SIMPLERAMP ) {
Xw_get_color_index(pcolormap,r,g,b,&index) ;
highpixel = _CINFO.base_pixel + index ;
}
break ;
case StaticColor :
status = Xw_alloc_color(pcolormap,r,g,b,&highpixel,&isapproximate) ;
break ;
}
if( status ) {
if( index >= 0 ) {
pcolormap->define[index] = HIGHCOLOR ;
}
pcolormap->highpixel = highpixel ;
#ifdef BUG_PRO3709
Xw_reset_attrib(NULL) ;
#endif
}
#ifdef TRACE_DEF_HIGHLIGHT_COLOR
if( Xw_get_trace() ) {
printf(" %d = Xw_def_highlight_color(%lx,%f,%f,%f)\n",status,(long ) pcolormap,r,g,b) ;
}
#endif
return (status);
}

93
src/Xw/Xw_def_marker.cxx Executable file
View File

@@ -0,0 +1,93 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_MARKER
#endif
/*
STATUS Xw_def_marker (amarkmap,index,npoint,spoint,xpoint,ypoint):
XW_EXT_MARKMAP *amarkmap
int index Marker index 0 > x < MAXMARKER
int npoint Marker length
int *spoint Marker status point (move-draw boolean)
float *xpoint Marker X coords in space -1,+1
float *ypoint Marker Y coords in space -1,+1
Update Marker Extended markmap index with the specified line marker
descriptor .
Marker point must be defined in the float space -1,+1
NOTE that marker index 0 is the default marker (.)
and cann't be REDEFINED .
NOTE that the marker size in Meter is decide at the draw_marker time.
Returns ERROR if BadMarker Index or Bad marker coords
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_marker (void* amarkmap,
int index,int npoint,int* spoint,float *xpoint,float *ypoint)
#else
XW_STATUS Xw_def_marker (amarkmap,index,npoint,spoint,xpoint,ypoint)
void *amarkmap;
int index,npoint,*spoint;
float *xpoint,*ypoint;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_MARKMAP *pmarkmap = (XW_EXT_MARKMAP*) amarkmap ;
int i ;
if ( !Xw_isdefine_markerindex(pmarkmap,index) ) {
/*Bad Marker Index*/
Xw_set_error(10,"Xw_def_marker",&index) ;
return (XW_ERROR) ;
}
if( pmarkmap->npoint[index] ) {
pmarkmap->npoint[index] = 0;
Xw_free(pmarkmap->spoint[index]);
pmarkmap->spoint[index] = NULL;
Xw_free(pmarkmap->xpoint[index]);
pmarkmap->xpoint[index] = NULL;
Xw_free(pmarkmap->ypoint[index]);
pmarkmap->ypoint[index] = NULL;
}
if( npoint > 0 ) {
int *s = pmarkmap->spoint[index] =
(int*) Xw_malloc(npoint*sizeof(int));
float *x = pmarkmap->xpoint[index] =
(float*) Xw_malloc(npoint*sizeof(float));
float *y = pmarkmap->ypoint[index] =
(float*) Xw_malloc(npoint*sizeof(float));
if( s && x && y ) {
pmarkmap->npoint[index] = npoint;
for( i=0 ; i<npoint ; i++ ) {
*s++ = spoint[i];
*x++ = xpoint[i];
*y++ = ypoint[i];
}
} else {
/*Marker Allocation failed*/
Xw_set_error(11,"Xw_def_marker",NULL) ;
return (XW_ERROR) ;
}
}
#ifdef TRACE_DEF_MARKER
if( Xw_get_trace() ) {
printf(" Xw_def_marker(%lx,%d,%d)\n",(long ) pmarkmap,index,npoint);
if( Xw_get_trace() > 1 ) {
for( i=0 ; i<npoint ; i++ ) {
printf(" point(%d) = {%d,%f,%f}\n",i,spoint[i],xpoint[i],ypoint[i]);
}
}
}
#endif
return (XW_SUCCESS);
}

174
src/Xw/Xw_def_markmap.cxx Executable file
View File

@@ -0,0 +1,174 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_MARKMAP
#endif
/*
XW_EXT_MARKMAP* Xw_def_markmap(adisplay,nmark):
XW_EXT_DISPLAY *adisplay Extended Display structure
int nmark Number of marker cells to be allocated
Create a markmap extension
allocate the marker cells in the markmap as if possible
depending of the MAXMARKER define .
Returns Markmap extension address if successuful
or NULL if ERROR
*/
#ifdef XW_PROTOTYPE
void* Xw_def_markmap (void* adisplay,int nmark)
#else
void* Xw_def_markmap (adisplay,nmark)
void *adisplay ;
int nmark ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_MARKMAP *pmarkmap = NULL ;
//int i ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_def_markmap",pdisplay) ;
return (NULL) ;
}
if( !(pmarkmap = Xw_add_markmap_structure(sizeof(XW_EXT_MARKMAP))) )
return (NULL) ;
if( nmark <= 0 ) nmark = MAXMARKER ;
pmarkmap->connexion = pdisplay ;
pmarkmap->maxmarker = min(nmark,MAXMARKER) ;
#ifdef TRACE_DEF_MARKMAP
if( Xw_get_trace() ) {
printf(" %lx = Xw_def_markmap(%lx,%d)\n", (long ) pmarkmap,(long ) adisplay,nmark) ;
}
#endif
return (pmarkmap);
}
static XW_EXT_MARKMAP *PmarkmapList =NULL ;
#ifdef XW_PROTOTYPE
XW_EXT_MARKMAP* Xw_add_markmap_structure(int size)
#else
XW_EXT_MARKMAP* Xw_add_markmap_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended markmap structure in the
EXtended markmap List
returns Extended markmap address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_MARKMAP *pmarkmap = (XW_EXT_MARKMAP*) Xw_malloc(size) ;
int i ;
if( pmarkmap ) {
pmarkmap->type = MARKMAP_TYPE ;
pmarkmap->link = PmarkmapList ;
PmarkmapList = pmarkmap ;
pmarkmap->connexion = NULL ;
pmarkmap->maxmarker = 0 ;
pmarkmap->maxwindow = 0 ;
for( i=0 ; i<MAXMARKER ; i++ ) {
pmarkmap->marks[i] = 0 ;
pmarkmap->npoint[i] = 0 ;
pmarkmap->width[i] = 0 ;
pmarkmap->height[i] = 0 ;
}
} else {
/*EXT_MARKMAP Allocation failed*/
Xw_set_error(12,"Xw_add_markmap_structure",0) ;
}
return (pmarkmap) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_markmap(void* amarkmap)
#else
XW_STATUS Xw_close_markmap(amarkmap)
void* amarkmap ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_MARKMAP *pmarkmap = (XW_EXT_MARKMAP*) amarkmap ;
XW_STATUS status ;
if( !Xw_isdefine_markmap(pmarkmap) ) {
/*Bad EXT_MARKMAP Address*/
Xw_set_error(46,"Xw_close_markmap",pmarkmap) ;
return (XW_ERROR) ;
}
status = Xw_del_markmap_structure(pmarkmap) ;
#ifdef TRACE_DEF_MARKMAP
if( Xw_get_trace() ) {
printf(" %d = Xw_close_markmap(%lx)\n",status,(long ) pmarkmap) ;
}
#endif
return (status) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_markmap_structure(XW_EXT_MARKMAP* amarkmap)
#else
XW_STATUS Xw_del_markmap_structure(amarkmap)
XW_EXT_MARKMAP *amarkmap;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended markmap address from the Extended List
returns ERROR if the markmap address is not Found in the list
returns SUCCESS if successful
*/
{
XW_EXT_MARKMAP *pmarkmap = PmarkmapList ;
int i ;
if( !amarkmap ) return (XW_ERROR) ;
if( amarkmap->maxwindow ) {
return (XW_ERROR) ;
} else {
for( i=0 ; i<MAXMARKER ; i++) {
if( amarkmap->marks[i] ) {
XFreePixmap(_MDISPLAY,amarkmap->marks[i]) ;
// amarkmap->marks[i] = NULL;
amarkmap->marks[i] = 0;
}
if( amarkmap->npoint[i] > 0 ) {
Xw_free(amarkmap->spoint[i]);
Xw_free(amarkmap->xpoint[i]);
Xw_free(amarkmap->ypoint[i]);
amarkmap->npoint[i] = 0;
}
}
if( amarkmap == pmarkmap ) {
PmarkmapList = (XW_EXT_MARKMAP*) amarkmap->link ;
} else {
for( ; pmarkmap ; pmarkmap = (XW_EXT_MARKMAP*) pmarkmap->link ) {
if( pmarkmap->link == amarkmap ) {
pmarkmap->link = amarkmap->link ;
break ;
}
}
}
Xw_free(amarkmap) ;
}
return (XW_SUCCESS) ;
}

103
src/Xw/Xw_def_tile.cxx Executable file
View File

@@ -0,0 +1,103 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_TILE
#endif
/*
STATUS Xw_def_tile (atilemap,index,width,height,cdata):
XW_EXT_TILEMAP *atilemap
int index Tile index 0 >= x < MAXTILE
int width Width of tile in pixels
int height Height of tile in pixels
char *cdata Tile description
Update Polygon tile Extended tilemap index with the specified
bitmap cdata .
Datas must be defined as one char by bit cdata with value 0 or 1
so,cdata array must be defined as char cdata[width][height]
NOTE than tile index 0 is the default Tile (SOLID)
and cann't be REDEFINED .
Returns ERROR if BadTile Index or Bad tile datas
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_tile (void* atilemap,
int index,int width,int height,char* cdata)
#else
XW_STATUS Xw_def_tile (atilemap,index,width,height,cdata)
void *atilemap;
int index ;
int width,height ;
char *cdata ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_TILEMAP *ptilemap = (XW_EXT_TILEMAP*)atilemap ;
Window root ;
Screen *screen ;
unsigned char *pattern ;
int i,j,l,m,n ;
if ( !Xw_isdefine_tileindex(ptilemap,index) ) {
/*Bad Tile Index*/
Xw_set_error(13,"Xw_def_tile",&index) ;
return (XW_ERROR) ;
}
if( width <= 0 || height <= 0 ) {
/*Bad Tile size*/
Xw_set_error(14,"Xw_def_tile",&index) ;
return (XW_ERROR) ;
}
if( !cdata ) {
/*Bad Tile data address*/
Xw_set_error(15,"Xw_def_tile",&index) ;
return (XW_ERROR) ;
}
if( ptilemap->tiles[index] )
XFreePixmap(_PDISPLAY,ptilemap->tiles[index]) ;
ptilemap->tiles[index] = 0 ;
screen = ScreenOfDisplay(_PDISPLAY,DefaultScreen(_PDISPLAY)) ;
root = RootWindowOfScreen(screen) ;
pattern = (unsigned char*) Xw_malloc(width*height/8) ;
pattern[0] = 0x00 ;
for( i=n=0,l=8 ; i<width ; i++ ) {
for( j=0 ; j<height ; j++ ) {
m = i*width + j ;
pattern[n] |= (cdata[m] & 1) << --l ;
if( !l ) {
l = 8 ;
n++ ;
pattern[n] = 0x00 ;
}
}
}
ptilemap->tiles[index] = XCreateBitmapFromData(_PDISPLAY,root,
(char*)pattern,width,height) ;
Xw_free(pattern) ;
if( !ptilemap->tiles[index] ) {
/*Tile Bitmap Allocation failed*/
Xw_set_error(16,"Xw_def_tile",&index) ;
return (XW_ERROR) ;
}
#ifdef TRACE_DEF_TILE
if( Xw_get_trace() ) {
printf (" Xw_def_tile(%lx,%d,%d,%d,%lx)\n",(long ) ptilemap,index,width,height,(long ) cdata);
}
#endif
return (XW_SUCCESS);
}

168
src/Xw/Xw_def_tilemap.cxx Executable file
View File

@@ -0,0 +1,168 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_TILEMAP
#endif
/*
XW_EXT_TILEMAP* Xw_def_tilemap(adisplay,ntile):
XW_EXT_DISPLAY *adisplay Extended Display structure
int ntile Number of tile cells to be allocated
Create a tilemap extension
allocate the tile cells in the tilemap as if possible
depending of the MAXTILE define .
Returns Tilemap extension address if successuful
or NULL if ERROR
*/
#ifdef XW_PROTOTYPE
void* Xw_def_tilemap (void* adisplay,int ntile)
#else
void* Xw_def_tilemap (adisplay,ntile)
void *adisplay ;
int ntile ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_TILEMAP *ptilemap = NULL ;
//int i,tile ;
int i ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_def_tilemap",pdisplay) ;
return (NULL) ;
}
if( !(ptilemap = Xw_add_tilemap_structure(sizeof(XW_EXT_TILEMAP))) )
return (NULL) ;
if( ntile <= 0 ) ntile = MAXTILE ;
ptilemap->connexion = pdisplay ;
ptilemap->maxtile = min(ntile,MAXTILE) ;
for( i=0 ; i<ptilemap->maxtile ; i++ ) {
ptilemap->tiles[i] = 0 ;
}
#ifdef TRACE_DEF_TILEMAP
if( Xw_get_trace() ) {
printf(" %lx = Xw_def_tilemap(%lx,%d)\n", (long ) ptilemap,(long ) adisplay,ntile) ;
}
#endif
return (ptilemap);
}
static XW_EXT_TILEMAP *PtilemapList =NULL ;
#ifdef XW_PROTOTYPE
XW_EXT_TILEMAP* Xw_add_tilemap_structure(int size)
#else
XW_EXT_TILEMAP* Xw_add_tilemap_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended tilemap structure in the
EXtended tilemap List
returns Extended tilemap address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_TILEMAP *ptilemap = (XW_EXT_TILEMAP*) Xw_malloc(size) ;
int i ;
if( ptilemap ) {
ptilemap->type = TILEMAP_TYPE ;
ptilemap->link = PtilemapList ;
PtilemapList = ptilemap ;
ptilemap->connexion = NULL ;
ptilemap->maxtile = 0 ;
ptilemap->maxwindow = 0 ;
for( i=0 ; i<MAXTILE ; i++ ) {
ptilemap->tiles[i] = 0 ;
}
} else {
/*EXT_TILEMAP allocation failed*/
Xw_set_error(17,"Xw_add_tilemap_structure",0) ;
}
return (ptilemap) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_tilemap(void* atilemap)
#else
XW_STATUS Xw_close_tilemap(atilemap)
void* atilemap ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_TILEMAP *ptilemap = (XW_EXT_TILEMAP*)atilemap ;
XW_STATUS status ;
if( !Xw_isdefine_tilemap(ptilemap) ) {
/*Bad EXT_TILEMAP Address*/
Xw_set_error(49,"Xw_close_tilemap",ptilemap) ;
return (XW_ERROR) ;
}
status = Xw_del_tilemap_structure(ptilemap) ;
#ifdef TRACE_DEF_TILEMAP
if( Xw_get_trace() ) {
printf(" %d = Xw_close_tilemap(%lx)\n",status,(long ) ptilemap) ;
}
#endif
return (status) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_tilemap_structure(XW_EXT_TILEMAP* atilemap)
#else
XW_STATUS Xw_del_tilemap_structure(atilemap)
XW_EXT_TILEMAP *atilemap;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended tilemap address from the Extended List
returns ERROR if the tilemap address is not Found in the list
returns SUCCESS if successful
*/
{
XW_EXT_TILEMAP *ptilemap = PtilemapList ;
int i ;
if( !atilemap ) return (XW_ERROR) ;
if( atilemap->maxwindow ) --atilemap->maxwindow ;
if( atilemap->maxwindow ) {
return (XW_ERROR) ;
} else {
for( i=0 ; i<MAXTILE ; i++) {
if( atilemap->tiles[i] ) XFreePixmap(_PDISPLAY,atilemap->tiles[i]) ;
}
if( atilemap == ptilemap ) {
PtilemapList = (XW_EXT_TILEMAP*) atilemap->link ;
} else {
for( ; ptilemap ; ptilemap = (XW_EXT_TILEMAP*) ptilemap->link ) {
if( ptilemap->link == atilemap ) {
ptilemap->link = atilemap->link ;
break ;
}
}
}
Xw_free(atilemap) ;
}
return (XW_SUCCESS) ;
}

86
src/Xw/Xw_def_type.cxx Executable file
View File

@@ -0,0 +1,86 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_TYPE
#endif
/*
STATUS Xw_def_type (atypemap,index,length,desc):
XW_EXT_TYPEMAP *atypemap
int index Line type index
int length Descriptor length
float *desc Type Descriptor
Update Line Type Extended typemap index with the specified TYPE values . Descriptor is an array of float.Each value give the subline length
in MM .First subline is the draw part,Second the hidden part,
Thirst the drawn part ...
NOTE than type index 0 is the Default Type (SOLID)
and cann't be REDEFINED
Returns ERROR if BadType Index
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_type (void* atypemap,
int index,int length,float* desc)
#else
XW_STATUS Xw_def_type (atypemap,index,length,desc)
void *atypemap;
int index ;
int length ;
float *desc ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_TYPEMAP *ptypemap = (XW_EXT_TYPEMAP*)atypemap ;
Screen *screen ;
unsigned char *pdesc ;
int i,ptype ;
if ( !Xw_isdefine_typeindex(ptypemap,index) ) {
/*Bad Type index*/
Xw_set_error(18,"Xw_def_type",&index) ;
return (XW_ERROR) ;
}
if( !desc || length < 0 ) {
/*Bad Type descriptor data*/
Xw_set_error(19,"Xw_def_type",&index) ;
return (XW_ERROR) ;
}
if( ptypemap->types[index] ) Xw_free(ptypemap->types[index]) ;
ptypemap->types[index] = NULL ;
if( length ) {
ptypemap->types[index] = pdesc = (unsigned char*) Xw_malloc(length+1) ;
screen = ScreenOfDisplay(_TDISPLAY,DefaultScreen(_TDISPLAY)) ;
for( i=0 ; i<length ; i++ ) {
pdesc[i] = 1 ;
ptype = (int) (0.5 + (desc[i] * (float)WidthOfScreen(screen)/
(float)WidthMMOfScreen(screen))) ;
if( desc[i] == 0. || ptype < 0 || ptype > 255 ) {
/*Bad Type descriptor data*/
Xw_set_error(19,"Xw_def_type",&index) ;
}
pdesc[i] = (unsigned char) (ptype) ? ptype : 1 ;
}
pdesc[length] ='\0' ;
}
#ifdef TRACE_DEF_TYPE
if( Xw_get_trace() ) {
printf (" Xw_def_type(%lx,%d,%d,{",(long ) ptypemap,index,length);
for ( i=0 ; i<length-1 ; i++ ) printf("%f,",desc[i]) ;
printf("%f})\n",desc[length-1]) ;
}
#endif
return (XW_SUCCESS);
}

169
src/Xw/Xw_def_typemap.cxx Executable file
View File

@@ -0,0 +1,169 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_TYPEMAP
#endif
/*
XW_EXT_TYPEMAP* Xw_def_typemap(adisplay,ntype):
XW_EXT_DISPLAY *adisplay Extended Display structure
int ntype Number of type cells to be allocated
Create a typemap extension
allocate the type cells in the typemap as if possible
depending of the MAXTYPE define .
Returns Typemap extension address if successuful
or NULL if ERROR
STATUS = Xw_close_typemap(atypemap)
XW_EXT_TYPEMAP* atypemap Extended typemap
Destroy The Extended TypeMap
Returns ERROR if Bad Extended TypeMap Address
SUCCESS if successfull
*/
#ifdef XW_PROTOTYPE
void* Xw_def_typemap (void* adisplay,int ntype)
#else
void* Xw_def_typemap (adisplay,ntype)
void *adisplay ;
int ntype ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_TYPEMAP *ptypemap = NULL ;
//int i,type ;
int i ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_def_typemap",pdisplay) ;
return (NULL) ;
}
if( !(ptypemap = Xw_add_typemap_structure(sizeof(XW_EXT_TYPEMAP))) )
return (NULL) ;
if( ntype <= 0 ) ntype = MAXTYPE ;
ptypemap->connexion = pdisplay ;
ptypemap->maxtype = min(ntype,MAXTYPE) ;
for( i=0 ; i<ptypemap->maxtype ; i++ ) {
ptypemap->types[i] = NULL ;
}
#ifdef TRACE_DEF_TYPEMAP
if( Xw_get_trace() ) {
printf(" %lx = Xw_def_typemap(%lx,%d)\n", (long ) ptypemap,(long ) adisplay,ntype) ;
}
#endif
return (ptypemap);
}
static XW_EXT_TYPEMAP *PtypemapList =NULL ;
#ifdef XW_PROTOTYPE
XW_EXT_TYPEMAP* Xw_add_typemap_structure(int size)
#else
XW_EXT_TYPEMAP* Xw_add_typemap_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended typemap structure in the
EXtended typemap List
returns Extended typemap address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_TYPEMAP *ptypemap = (XW_EXT_TYPEMAP*) Xw_malloc(size) ;
int i ;
if( ptypemap ) {
ptypemap->type = TYPEMAP_TYPE ;
ptypemap->link = PtypemapList ;
PtypemapList = ptypemap ;
ptypemap->connexion = NULL ;
ptypemap->maxtype = 0 ;
ptypemap->maxwindow = 0 ;
for( i=0 ; i<MAXTYPE ; i++ ) ptypemap->types[i] = NULL ;
} else {
/*EXT_TYPEMAP Allocation failed*/
Xw_set_error(20,"Xw_add_typemap_structure",0) ;
}
return (ptypemap) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_typemap(void* atypemap)
#else
XW_STATUS Xw_close_typemap(atypemap)
void *atypemap ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_TYPEMAP* ptypemap = (XW_EXT_TYPEMAP*) atypemap ;
XW_STATUS status ;
if( !Xw_isdefine_typemap(ptypemap) ) {
/*Bad EXT_TYPEMAP Address*/
Xw_set_error(51,"Xw_close_typemap",ptypemap) ;
return (XW_ERROR) ;
}
status = Xw_del_typemap_structure(ptypemap) ;
#ifdef TRACE_DEF_TYPEMAP
if( Xw_get_trace() ) {
printf(" %d = Xw_close_typemap(%lx)\n",status,(long ) ptypemap) ;
}
#endif
return (status) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_typemap_structure(XW_EXT_TYPEMAP* atypemap)
#else
XW_STATUS Xw_del_typemap_structure(atypemap)
XW_EXT_TYPEMAP *atypemap;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended typemap address from the Extended List
returns ERROR if the typemap address is not Found in the list
returns SUCCESS if successful
*/
{
XW_EXT_TYPEMAP *ptypemap = PtypemapList ;
//int i ;
if( !atypemap ) return (XW_ERROR) ;
if( atypemap->maxwindow ) {
return (XW_ERROR) ;
} else {
if( atypemap == ptypemap ) {
PtypemapList = (XW_EXT_TYPEMAP*) atypemap->link ;
} else {
for( ; ptypemap ; ptypemap = (XW_EXT_TYPEMAP*) ptypemap->link ) {
if( ptypemap->link == atypemap ) {
ptypemap->link = atypemap->link ;
break ;
}
}
}
Xw_free(atypemap) ;
}
return (XW_SUCCESS) ;
}

64
src/Xw/Xw_def_width.cxx Executable file
View File

@@ -0,0 +1,64 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_WIDTH
#endif
/*
STATUS Xw_def_width (awidthmap,index,width):
XW_EXT_WIDTHMAP *awidthmap
int index Line width index
float width width in MM
Update Line Width Extended widthmap index
with the specified WIDTH value .
NOTE than width index 0 is the default width (1 pixel)
and cann't be redefined .
Returns ERROR if BadWidth Index
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_width (void* awidthmap,int index,float width)
#else
XW_STATUS Xw_def_width (awidthmap,index,width)
void *awidthmap ;
int index ;
float width ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WIDTHMAP *pwidthmap = (XW_EXT_WIDTHMAP*)awidthmap ;
Screen *screen ;
int pwidth ;
if ( !Xw_isdefine_widthindex(pwidthmap,index) ) {
/*Bad Width Index*/
Xw_set_error(21,"Xw_def_width",&index) ;
return (XW_ERROR) ;
}
screen = ScreenOfDisplay(_WDISPLAY,DefaultScreen(_WDISPLAY)) ;
width = width * (float)HeightOfScreen(screen)/
(float)HeightMMOfScreen(screen) ;
pwidth = (int) (0.5 + width) ;
pwidthmap->widths[index] = 1 ;
if( width == 0. || pwidth < 0 || pwidth > 255 ) {
/*Bad Width Thickness*/
Xw_set_error(22,"Xw_def_width",&width) ;
}
pwidthmap->widths[index] = (unsigned char) (pwidth) ? pwidth : 1 ;
#ifdef TRACE_DEF_WIDTH
if( Xw_get_trace() ) {
printf (" Xw_def_width(%lx,%d,%f)\n",(long ) pwidthmap,index,width) ;
}
#endif
return (XW_SUCCESS);
}

168
src/Xw/Xw_def_widthmap.cxx Executable file
View File

@@ -0,0 +1,168 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_WIDTHMAP
#endif
/*
XW_EXT_WIDTHMAP* Xw_def_widthmap(adisplay,nwidth):
XW_EXT_DISPLAY *adisplay Extended Display structure
int nwidth Number of width cells to be allocated
Create a widthmap extension
allocate the width cells in the widthmap as if possible
depending of the MAXWIDTH define .
Returns Widthmap extension address if successful
or NULL if ERROR
STATUS Xw_close_widthmap(awidthmap):
XW_EXT_WIDTHMAP* awidthmap Extended Widthmap address
Destroy The specified Extended Widthmap
Returns SUCCESS if successuful
Returns ERROR if Bad Extended Widthmap
*/
#ifdef XW_PROTOTYPE
void* Xw_def_widthmap (void* adisplay,int nwidth)
#else
void* Xw_def_widthmap (adisplay,nwidth)
void *adisplay ;
int nwidth ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_WIDTHMAP *pwidthmap = NULL ;
//int i ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_def_widthmap",pdisplay) ;
return (NULL) ;
}
if( !(pwidthmap = Xw_add_widthmap_structure(sizeof(XW_EXT_WIDTHMAP))) )
return (NULL) ;
if( nwidth <= 0 ) nwidth = MAXWIDTH ;
pwidthmap->connexion = pdisplay ;
pwidthmap->maxwidth = min(nwidth,MAXWIDTH) ;
#ifdef TRACE_DEF_WIDTHMAP
if( Xw_get_trace() ) {
printf(" %lx = Xw_def_widthmap(%lx,%d)\n",
(long ) pwidthmap,(long ) adisplay,nwidth) ;
}
#endif
return (pwidthmap);
}
static XW_EXT_WIDTHMAP *PwidthmapList =NULL ;
#ifdef XW_PROTOTYPE
XW_EXT_WIDTHMAP* Xw_add_widthmap_structure(int size)
#else
XW_EXT_WIDTHMAP* Xw_add_widthmap_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended widthmap structure in the
EXtended widthmap List
returns Extended widthmap address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_WIDTHMAP *pwidthmap = (XW_EXT_WIDTHMAP*) Xw_malloc(size) ;
int i ;
if( pwidthmap ) {
pwidthmap->type = WIDTHMAP_TYPE ;
pwidthmap->link = PwidthmapList ;
PwidthmapList = pwidthmap ;
pwidthmap->connexion = NULL ;
pwidthmap->maxwidth = 0 ;
pwidthmap->maxwindow = 0 ;
for( i=0 ; i<MAXWIDTH ; i++ ) {
pwidthmap->widths[i] = 0 ;
}
} else {
/*EXT_WIDTHMAP Allocation Failed*/
Xw_set_error(23,"Xw_add_widthmap_structure",0) ;
}
return (pwidthmap) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_widthmap(void* awidthmap)
#else
XW_STATUS Xw_close_widthmap(awidthmap)
void* awidthmap ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WIDTHMAP *pwidthmap = (XW_EXT_WIDTHMAP*)awidthmap ;
XW_STATUS status ;
if( !Xw_isdefine_widthmap(pwidthmap) ) {
/*Bad EXT_WIDTHMAP Address*/
Xw_set_error(53,"Xw_close_widthmap",pwidthmap) ;
return (XW_ERROR) ;
}
status = Xw_del_widthmap_structure(pwidthmap) ;
#ifdef TRACE_DEF_WIDTHMAP
if( Xw_get_trace() ) {
printf(" %d = Xw_close_widthmap(%lx)\n",status,(long ) pwidthmap) ;
}
#endif
return (status) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_widthmap_structure(XW_EXT_WIDTHMAP* awidthmap)
#else
XW_STATUS Xw_del_widthmap_structure(awidthmap)
XW_EXT_WIDTHMAP *awidthmap;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended widthmap address from the Extended List
returns ERROR if the widthmap address is not Found in the list
returns SUCCESS if successful
*/
{
XW_EXT_WIDTHMAP *pwidthmap = PwidthmapList ;
//int i ;
if( !awidthmap ) return (XW_ERROR) ;
if( awidthmap->maxwindow ) {
return (XW_ERROR) ;
} else {
if( awidthmap == pwidthmap ) {
PwidthmapList = (XW_EXT_WIDTHMAP*) awidthmap->link ;
} else {
for( ; pwidthmap ; pwidthmap = (XW_EXT_WIDTHMAP*) pwidthmap->link ) {
if( pwidthmap->link == awidthmap ) {
pwidthmap->link = awidthmap->link ;
break ;
}
}
}
Xw_free(awidthmap) ;
}
return (XW_SUCCESS) ;
}

601
src/Xw/Xw_def_window.cxx Executable file
View File

@@ -0,0 +1,601 @@
#define PURIFY /*GG_220596
Liberation memoire lors de la destruction d'une fenetre*/
#define S3593 /*GG130398
OPTIMISATION MFT -> Desactiver temporairement le clipping
*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_WINDOW
#define TRACE_CLOSE_WINDOW
#endif
/*
XW_EXT_WINDOW* Xw_def_window (adisplay,window,istransparent);
XW_EXT_DISPLAY *adisplay ;
Aspect_Handle window XWindow ID
int istransparent
Create the Window Extension info
and save Window attributes
Returns ERROR if the connection failed.
Returns extended data window structure pointer
if the connection done.
XW_STATUS Xw_close_window (awindow,destroy):
XW_EXT_WINDOW *awindow
int destroy
Close the window(s) and free all structures attached to
NOTE than this Close all windows if awindow is NULL
Destroy the XWindow if destroy is TRUE;
returns ERROR NO Extended Window address has been defined
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
void* Xw_def_window (void *adisplay,Aspect_Handle window,int istransparent)
#else
void* Xw_def_window (adisplay,window,istransparent)
void *adisplay ;
Aspect_Handle window ;
int istransparent ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_WINDOW *pwindow = NULL ;
XW_WINDOWSTATE state ;
//XWindowAttributes attributes ;
XGCValues gc_values;
int mask,maskext ;
//XEvent event ;
//int i,j,status,xc,yc,width,height ;
int i,xc,yc,width,height ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_def_window",pdisplay) ;
return (NULL) ;
}
if( !(pwindow = Xw_add_window_structure(sizeof(XW_EXT_WINDOW))) )
return (NULL) ;
_DRAWABLE = _WINDOW = window ;
_PIXMAP = 0 ;
_NWBUFFER = 0 ;
_FWBUFFER = 0 ;
_BWBUFFER = 0 ;
_COLORMAP = NULL ;
_WIDTHMAP = NULL ;
_TYPEMAP = NULL ;
_FONTMAP = NULL ;
_TILEMAP = NULL ;
_MARKMAP = NULL ;
pwindow->connexion = pdisplay ;
state = Xw_get_window_position(pwindow,&xc,&yc,&width,&height) ;
if( state == XW_WS_UNKNOWN ) {
/*ERROR*Bad Window Attributes*/
Xw_del_window_structure(pwindow) ;
Xw_set_error(54,"Xw_def_window",&window) ;
return (NULL) ;
}
pwindow->axleft = xc - width/2 ;
pwindow->axright = xc + width/2 ;
pwindow->aytop = yc - height/2 ;
pwindow->aybottom = yc + height/2 ;
pwindow->rwidth = 0 ;
pwindow->rheight = 0 ;
pwindow->lineindex = 0 ;
pwindow->polyindex = 0 ;
pwindow->textindex = 0 ;
pwindow->markindex = 0 ;
if( istransparent ) {
pwindow->backindex = -1 ;
} else {
pwindow->backindex = 0 ;
}
pwindow->clipflag = True;
for( i=0 ; i<MAXEVENT ; i++ ) {
pwindow->ecbk[i].function = NULL ;
pwindow->ecbk[i].userdata = NULL ;
pwindow->icbk[i].function = NULL ;
}
gc_values.function = GXcopy ; mask = GCFunction ;
gc_values.plane_mask = AllPlanes ; mask |= GCPlaneMask ;
gc_values.background = BlackPixelOfScreen(_SCREEN) ;
mask |= GCBackground ;
gc_values.foreground = WhitePixelOfScreen(_SCREEN) ;
mask |= GCForeground ;
pwindow->qgwind.gc = XCreateGC(_DISPLAY,_WINDOW, mask, &gc_values) ;
gc_values.foreground = BlackPixelOfScreen(_SCREEN) ;
pwindow->qgwind.gcclear = XCreateGC(_DISPLAY,_WINDOW, mask, &gc_values);
gc_values.graphics_exposures = False ; mask |= GCGraphicsExposures ;
gc_values.foreground = WhitePixelOfScreen(_SCREEN) ;
pwindow->qgwind.gccopy = XCreateGC(_DISPLAY,_WINDOW, mask, &gc_values) ;
gc_values.function = GXxor ;
gc_values.graphics_exposures = True ;
pwindow->qgwind.gchigh = XCreateGC(_DISPLAY,_WINDOW, mask, &gc_values) ;
gc_values.function = GXcopy ;
pwindow->qgwind.code = ~0 ;
pwindow->qgwind.pimage = NULL ;
pwindow->qgwind.method = Aspect_FM_NONE ;
pwindow->qgwind.pixmap = 0 ;
_BINDEX = 0 ;
for( i=0 ; i<MAXBUFFERS ; i++ ) {
_BUFFER(i).bufferid = 0 ;
_BUFFER(i).gcf = NULL ;
_BUFFER(i).gcb = NULL ;
_BUFFER(i).code = 0 ;
_BUFFER(i).isdrawn = False ;
_BUFFER(i).isempty = True ;
_BUFFER(i).isretain = False ;
_BUFFER(i).isupdated = False ;
_BUFFER(i).rxmin = _WIDTH ;
_BUFFER(i).rymin = _HEIGHT ;
_BUFFER(i).rxmax = 0 ;
_BUFFER(i).rymax = 0 ;
_BUFFER(i).xpivot = 0 ;
_BUFFER(i).ypivot = 0 ;
_BUFFER(i).dxpivot = 0 ;
_BUFFER(i).dypivot = 0 ;
_BUFFER(i).xscale = 1. ;
_BUFFER(i).yscale = 1. ;
_BUFFER(i).dxscale = 1. ;
_BUFFER(i).dyscale = 1. ;
_BUFFER(i).angle = 0. ;
_BUFFER(i).dangle = 0. ;
_BUFFER(i).ptextdesc = NULL ;
_BUFFER(i).plinedesc = NULL ;
_BUFFER(i).ppntlist = NULL ;
_BUFFER(i).pseglist = NULL ;
_BUFFER(i).plinelist = NULL ;
_BUFFER(i).ppolylist = NULL ;
_BUFFER(i).plarclist = NULL ;
_BUFFER(i).pparclist = NULL ;
_BUFFER(i).pltextlist = NULL ;
_BUFFER(i).pptextlist = NULL ;
_BUFFER(i).plmarklist = NULL ;
_BUFFER(i).ppmarklist = NULL ;
_BUFFER(i).pimaglist = NULL ;
}
for( i=0 ; i<MAXQG ; i++ ) {
gc_values.line_width = 0 ; maskext = GCLineWidth ;
gc_values.line_style = LineSolid ; maskext |= GCLineStyle ;
gc_values.dash_offset = 0 ; maskext |= GCDashOffset ;
gc_values.join_style = JoinRound ; maskext |= GCJoinStyle ;
pwindow->qgline[i].code = ~0 ;
pwindow->qgline[i].count = 0 ;
pwindow->qgline[i].gc = XCreateGC(_DISPLAY,_WINDOW,
mask | maskext, &gc_values) ;
pwindow->qgmark[i].code = ~0;
pwindow->qgmark[i].count = 0 ;
pwindow->qgmark[i].gc = XCreateGC(_DISPLAY,_WINDOW,
mask | maskext, &gc_values) ;
gc_values.fill_style = FillSolid ; maskext = GCFillStyle ;
gc_values.fill_rule = EvenOddRule ; maskext |= GCFillRule ;
pwindow->qgpoly[i].code = ~0 ;
pwindow->qgpoly[i].count = 0 ;
pwindow->qgpoly[i].gc = XCreateGC(_DISPLAY,_WINDOW,
mask | maskext, &gc_values) ;
maskext = 0 ;
pwindow->qgtext[i].code = ~0;
pwindow->qgtext[i].count = 0 ;
pwindow->qgtext[i].gc = XCreateGC(_DISPLAY,_WINDOW,
mask | maskext, &gc_values) ;
}
XFlush(_DISPLAY) ;
Xw_set_window_ratio(pwindow,0.001 METER) ;
#ifdef TRACE_DEF_WINDOW
if( Xw_get_trace() ) {
printf (" Xw_def_window(%lx,%lx,%d)\n",(long ) pdisplay,(long ) window,istransparent) ;
}
#endif
return (pwindow);
}
static XW_EXT_WINDOW *PwindowList =NULL ;
#ifdef XW_PROTOTYPE
XW_EXT_WINDOW* Xw_add_window_structure(int size)
#else
XW_EXT_WINDOW* Xw_add_window_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended window structure in the
EXtended Window List
returns Extended window address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) Xw_malloc(size) ;
if( pwindow ) {
pwindow->type = WINDOW_TYPE ;
pwindow->link = PwindowList ;
pwindow->other = NULL ;
PwindowList = pwindow ;
} else {
/*ERROR*EXT_WINDOW allocation failed*/
Xw_set_error(69,"Xw_add_window_structure",0) ;
}
return (pwindow) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_WINDOW* Xw_get_window_structure(Window window)
#else
XW_EXT_WINDOW* Xw_get_window_structure(window)
Window window ;
#endif /*XW_PROTOTYPE*/
/*
Return the Extended window address corresponding to the required
Window Id or NULL if not found
*/
{
XW_EXT_WINDOW *pwindow = PwindowList ;
while (pwindow) {
if( pwindow->window == window ) {
break ;
}
pwindow = (XW_EXT_WINDOW*) pwindow->link ;
}
return (pwindow) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_window (void* awindow,int destroy)
#else
XW_STATUS Xw_close_window (awindow,destroy)
void *awindow;
int destroy;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
int i ;
if( !pwindow ) {
while( Xw_del_window_structure(NULL) ) ;
} else {
if( destroy ) {
#ifdef PURIFY
XFreeGC(_DISPLAY,pwindow->qgwind.gc);
XFreeGC(_DISPLAY,pwindow->qgwind.gcclear);
XFreeGC(_DISPLAY,pwindow->qgwind.gccopy);
XFreeGC(_DISPLAY,pwindow->qgwind.gchigh);
for( i=0 ; i<MAXQG ; i++ ) {
XFreeGC(_DISPLAY,pwindow->qgline[i].gc);
XFreeGC(_DISPLAY,pwindow->qgmark[i].gc);
XFreeGC(_DISPLAY,pwindow->qgpoly[i].gc);
XFreeGC(_DISPLAY,pwindow->qgtext[i].gc);
}
#endif
XDestroyWindow(_DISPLAY,_WINDOW) ;
}
Xw_del_window_structure(pwindow) ;
}
#ifdef TRACE_CLOSE_WINDOW
if( Xw_get_trace() ) {
printf (" Xw_close_window(%lx,%d)\n",(long ) pwindow,destroy) ;
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_window_structure(XW_EXT_WINDOW* pwindow)
#else
XW_STATUS Xw_del_window_structure(pwindow)
XW_EXT_WINDOW *pwindow;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended window address or the next from the Extended List
and Free the Extended Window
returns ERROR if the window address is not Found in the list
or NO more Window exist
returns SUCCESS if successful
*/
{
XW_EXT_WINDOW *qwindow = PwindowList ;
int i ;
if( !qwindow ) return (XW_ERROR) ;
if( pwindow == qwindow ) {
PwindowList = (XW_EXT_WINDOW*) pwindow->link ;
} else if( !pwindow ) {
if( !PwindowList ) return (XW_ERROR) ;
pwindow = PwindowList ;
PwindowList = (XW_EXT_WINDOW*) PwindowList->link ;
} else {
for( ; qwindow ; qwindow = (XW_EXT_WINDOW*) qwindow->link ) {
if( qwindow->link == pwindow ) {
qwindow->link = pwindow->link ;
break ;
}
}
}
if( _PIXMAP ) {
Xw_close_pixmap(pwindow) ;
}
if( _BIMAGE ) {
Xw_close_image(_BIMAGE) ;
_BIMAGE = NULL;
}
if( _BPIXMAP ) {
Xw_close_background_pixmap(pwindow) ;
_BPIXMAP = 0;
}
Xw_close_buffer(pwindow,0) ;
for( i=1 ; i<MAXBUFFERS ; i++ ) {
Xw_close_buffer(pwindow,-i) ;
}
if( pwindow->other ) Xw_free(pwindow->other) ;
if( _COLORMAP && (_COLORMAP->maxwindow > 0) ) {
_COLORMAP->maxwindow -= 1;
}
Xw_free(pwindow) ;
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_reset_attrib(XW_EXT_WINDOW* awindow)
#else
XW_STATUS Xw_reset_attrib(awindow)
XW_EXT_WINDOW *awindow ;
#endif /*XW_PROTOTYPE*/
/*
Reset ALL Window attributes of a particular Window or ALL Windows
if NULL
*/
{
XW_EXT_WINDOW *pwindow ;
unsigned long highpixel,backpixel ;
int i ;
if( !(pwindow = PwindowList) ) return (XW_ERROR) ;
while (pwindow) {
if( !awindow || (pwindow == awindow) ) {
for( i=0 ; i<MAXQG ; i++ ) {
pwindow->qgline[i].code = ~0 ;
pwindow->qgpoly[i].code = ~0 ;
pwindow->qgtext[i].code = ~0 ;
pwindow->qgmark[i].code = ~0 ;
}
if( _COLORMAP ) {
highpixel = _COLORMAP->highpixel ;
if( pwindow->backindex < 0 ) {
backpixel = _COLORMAP->backpixel ;
} else {
backpixel = _COLORMAP->pixels[pwindow->backindex] ;
}
XSetForeground(_DISPLAY, pwindow->qgwind.gccopy, highpixel) ;
highpixel ^= backpixel ;
XSetForeground(_DISPLAY, pwindow->qgwind.gchigh, highpixel) ;
}
}
pwindow = (XW_EXT_WINDOW*) pwindow->link ;
}
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_color_attrib(XW_EXT_WINDOW* awindow,
XW_DRAWMODE mode,int color,unsigned long* hcolor,
int* function,unsigned long* planemask)
#else
XW_STATUS Xw_get_color_attrib(awindow,mode,color,hcolor,function,planemask)
XW_EXT_WINDOW *awindow ;
XW_DRAWMODE mode ;
int color ;
int *function ;
unsigned long *planemask ;
unsigned long *hcolor ;
#endif /*XW_PROTOTYPE*/
/*
Returns the best drawing attributs color,function and planemask
depending of write mode and colormap visual class attached to this
window .
returns ERROR if the Visual class is not authorized
returns SUCCESS if successfull
*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
switch ( _CLASS ) {
case TrueColor :
switch (mode) {
case XW_ERASE :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex] ;
else *hcolor = _COLORMAP->backpixel;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_REPLACE :
*hcolor = _COLORMAP->pixels[color] ;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_XORBACK :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex]
^ _COLORMAP->pixels[color] ;
else *hcolor = _COLORMAP->backpixel
^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
case XW_XORLIGHT :
case XW_HIGHLIGHT :
case XW_UNHIGHLIGHT :
*hcolor = _COLORMAP->highpixel ^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
}
break ;
case PseudoColor :
switch (mode) {
case XW_ERASE :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex] ;
else *hcolor = _COLORMAP->backpixel;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_REPLACE :
*hcolor = _COLORMAP->pixels[color] ;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_XORBACK :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex]
^ _COLORMAP->pixels[color] ;
else *hcolor = _COLORMAP->backpixel
^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
case XW_XORLIGHT :
case XW_HIGHLIGHT :
case XW_UNHIGHLIGHT :
*hcolor = _COLORMAP->highpixel ^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
}
break ;
case StaticColor :
switch (mode) {
case XW_ERASE :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex] ;
else *hcolor = _COLORMAP->backpixel;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_REPLACE :
*hcolor = _COLORMAP->pixels[color] ;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_XORBACK :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex]
^ _COLORMAP->pixels[color] ;
else *hcolor = _COLORMAP->backpixel
^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
case XW_XORLIGHT :
case XW_HIGHLIGHT :
case XW_UNHIGHLIGHT :
*hcolor = _COLORMAP->highpixel ^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
}
break ;
case StaticGray :
case GrayScale :
case DirectColor :
/*ERROR*Unimplemented Visual class*/
Xw_set_error(5,"Xw_get_color_attrib",&_CLASS) ;
return (XW_ERROR) ;
}
return (XW_SUCCESS) ;
}
#ifdef S3593
#ifdef XW_PROTOTYPE
void Xw_set_clipping(void* awindow, int flag)
#else
void Xw_set_clipping(awindow,flag)
void* awindow;
int flag;
#endif
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) awindow;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_set_clipping",pwindow) ;
return;
}
pwindow->clipflag = flag;
}
#ifdef XW_PROTOTYPE
int Xw_get_clipping(void* awindow)
#else
int Xw_get_clipping(awindow)
void* awindow;
#endif
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) awindow;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_get_clipping",pwindow) ;
return (True) ;
}
return pwindow->clipflag;
}
#endif /*S3593*/

297
src/Xw/Xw_draw_arc.cxx Executable file
View File

@@ -0,0 +1,297 @@
#include <Standard_Integer.hxx>
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_ARC
#endif
/*
STATUS Xw_draw_arc (awindow,xc,yc,xradius,yradius,start,angle):
XW_EXT_WINDOW *awindow
float xc,yc Arc center defined in User Space
float xradius Horizontal arc radius defined in User Space
float xradius Vertical Arc radius defined in User Space
float start Start angle defined in RADIAN
float angle Arc angle defined in RADIAN
Display arc in current QG set by set_line_attrib .
or retain arc in buffer.
return ERROR if bad parameter
returns SUCCESS if successful
*/
#define MAXCOORD 32767
#define MINCOORD -32768
static int BeginArcs = False;
static XW_EXT_ARC *parclist ;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_arc (void* awindow,float xc,float yc,
float xradius,float yradius,float start,float angle)
#else
XW_STATUS Xw_draw_arc (awindow,xc,yc,xradius,yradius,start,angle)
void *awindow;
float xc,yc,xradius,yradius,start,angle ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) awindow ;
XW_EXT_BUFFER *pbuffer ;
int narc,bindex,angle1,angle2,x,y,width,height ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_arc",pwindow) ;
return (XW_ERROR) ;
}
if( xradius <= 0. ) {
/*ERROR*Bad arc radius*/
Xw_set_error(115,"Xw_draw_arc",&xradius) ;
return (XW_ERROR) ;
}
if( yradius <= 0. ) {
/*ERROR*Bad arc radius*/
Xw_set_error(115,"Xw_draw_arc",&yradius) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( parclist = pbuffer->plarclist ; parclist ;
parclist = (XW_EXT_ARC*) parclist->link ) {
if( parclist->narc < MAXARCS ) break ;
}
if( !parclist ) {
parclist = Xw_add_arc_structure(pbuffer) ;
}
if( !parclist ) return XW_ERROR ;
angle1 = (Standard_Integer )( start*64./DRAD );
if( angle1 > 0 ) {
while( angle1 > MAXANGLE ) angle1 -= MAXANGLE ;
} else if( angle1 < 0 ) {
while( angle1 < -MAXANGLE ) angle1 += MAXANGLE ;
}
angle2 = (Standard_Integer ) ( angle*64./DRAD );
if( angle2 > 0 ) {
while( angle2 > MAXANGLE ) angle2 -= MAXANGLE ;
} else if( angle2 < 0 ) {
while( angle2 < -MAXANGLE ) angle2 += MAXANGLE ;
}
//OCC186
width = 2*PVALUE(xradius, pwindow->xratio, pwindow->yratio);
height = 2*PVALUE(yradius, pwindow->xratio, pwindow->yratio);
x = PXPOINT(xc, pwindow->xratio);
y = PYPOINT(yc, pwindow->attributes.height, pwindow->yratio);
//OCC186
x = max(min(x,MAXCOORD),MINCOORD);
y = max(min(y,MAXCOORD),MINCOORD);
if( width < 0xFFFF && height < 0xFFFF ) {
narc = parclist->narc ;
parclist->rarcs[narc].width = width ;
parclist->rarcs[narc].height = height ;
parclist->rarcs[narc].x = x - width/2 ;
parclist->rarcs[narc].y = y - height/2 ;
parclist->rarcs[narc].angle1 = angle1 ;
parclist->rarcs[narc].angle2 = angle2 ;
parclist->narc++ ;
if( bindex > 0 ) {
pbuffer->isempty = False ;
width = (width+1)/2 ;
height = (height+1)/2 ;
pbuffer->rxmin = min(pbuffer->rxmin,x-width) ;
pbuffer->rymin = min(pbuffer->rymin,y-height) ;
pbuffer->rxmax = max(pbuffer->rxmax,x+width) ;
pbuffer->rymax = max(pbuffer->rymax,y+height) ;
} else if( !BeginArcs ) {
int index = pwindow->lineindex ;
Xw_draw_pixel_arcs(pwindow,parclist,pwindow->qgline[index].gc) ;
parclist->narc = 0 ;
}
} else {
/*ERROR*Too big arc radius*/
Xw_set_error(116,"Xw_draw_arc",0) ;
return (XW_ERROR) ;
}
#ifdef TRACE_DRAW_ARC
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_arc(%lx,%f,%f,%f,%f,%f,%f\n",
(long ) pwindow,xc,yc,xradius,yradius,start,angle);
}
#endif
return (XW_SUCCESS);
}
/*
STATUS Xw_begin_arcs (awindow,narc):
XW_EXT_WINDOW *awindow
int narc Not used
Begin a set of arcs which must be filled by Xw_draw_arc and
closed by Xw_close_arcs
returns ERROR if bad extended window address
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_begin_arcs(void* awindow,int narc)
#else
XW_STATUS Xw_begin_arcs(awindow,narc)
void *awindow ;
int narc ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_begin_arcs",pwindow) ;
return (XW_ERROR) ;
}
if( BeginArcs ) Xw_close_arcs(pwindow);
BeginArcs = True;
#ifdef TRACE_DRAW_ARC
if( Xw_get_trace() > 2 ) {
printf(" Xw_begin_arcs(%lx,%d)\n",(long ) pwindow,narc) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_close_arcs (awindow):
XW_EXT_WINDOW *awindow
Close the set of arcs
returns ERROR if bad extended window address
returns SUCCESS successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_arcs(void* awindow)
#else
XW_STATUS Xw_close_arcs(awindow)
void *awindow ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
int bindex ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_close_arcs",pwindow) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
if( BeginArcs && !bindex ) {
int index = pwindow->lineindex ;
for( parclist = _BUFFER(bindex).plarclist ; parclist ;
parclist = (XW_EXT_ARC*) parclist->link ) {
if( parclist->narc > 0 ) {
Xw_draw_pixel_arcs(pwindow,parclist,pwindow->qgline[index].gc) ;
parclist->narc = 0 ;
} else break ;
}
}
BeginArcs = False;
#ifdef TRACE_DRAW_ARC
if( Xw_get_trace() > 2 ) {
printf(" Xw_close_arcs(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_arcs (XW_EXT_WINDOW* pwindow,XW_EXT_ARC* parclist,GC gc)
#else
void Xw_draw_pixel_arcs (pwindow,parclist,gc)
XW_EXT_WINDOW *pwindow;
XW_EXT_ARC *parclist;
GC gc;
#endif /*XW_PROTOTYPE*/
{
if( parclist->isupdated ) {
XDrawArcs(_DISPLAY,_DRAWABLE,gc,parclist->uarcs,parclist->narc) ;
} else {
XDrawArcs(_DISPLAY,_DRAWABLE,gc,parclist->rarcs,parclist->narc) ;
}
}
#ifdef XW_PROTOTYPE
XW_EXT_ARC* Xw_add_arc_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_ARC* Xw_add_arc_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended arc structure in the
arc List
returns Extended arc address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_ARC *parc ;
parc = (XW_EXT_ARC*) Xw_malloc(sizeof(XW_EXT_ARC)) ;
if( parc ) {
parc->link = pbuflist->plarclist ;
parc->isupdated = False ;
parc->narc = 0 ;
pbuflist->plarclist = parc ;
} else {
/*ERROR*EXT_ARC Allocation failed*/
Xw_set_error(35,"Xw_add_arc_structure",NULL) ;
}
return (parc) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_arc_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_arc_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended arc structure in the
arc List
SUCCESS always
*/
{
XW_EXT_ARC *parc,*qarc ;
for( parc = pbuflist->plarclist ; parc ; parc = qarc ) {
qarc = (XW_EXT_ARC*)parc->link ;
Xw_free(parc) ;
}
pbuflist->plarclist = NULL ;
return (XW_SUCCESS) ;
}

2172
src/Xw/Xw_draw_buffer.cxx Executable file

File diff suppressed because it is too large Load Diff

206
src/Xw/Xw_draw_image.cxx Executable file
View File

@@ -0,0 +1,206 @@
#define BUC0056 /*GG_300496
Protection contre zoom trop grand*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_IMAGE
#endif
/*
STATUS Xw_draw_image (awindow,aimage,xc,yc):
XW_EXT_WINDOW *awindow
XW_EXT_IMAGEDATA *aimage Image structure
float xc,yc Image center location in user space
Draw an image to the window at the required Center location
NOTE than current Window position and Size is taken
returns ERROR if NO Image is defined or Image is outside of the window
returns SUCCESS if successful
*/
#ifdef BUC0056
#define MAXCOORD 32767
#define MINCOORD -32768
#endif
static XW_EXT_IMAGE *pimaglist ;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_image (void* awindow,void* aimage,float xc,float yc)
#else
XW_STATUS Xw_draw_image (awindow,aimage,xc,yc)
void *awindow;
void *aimage ;
float xc,yc ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_IMAGEDATA *pimage = (XW_EXT_IMAGEDATA*)aimage ;
XW_EXT_BUFFER *pbuffer ;
//int color,nimage,bindex,x,y,width,height ;
int nimage,bindex,x,y,width,height ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_image",pwindow) ;
return (XW_ERROR) ;
}
if( !Xw_isdefine_image(pimage) ) {
/*ERROR*Bad EXT_IMAGEDATA Address*/
Xw_set_error(25,"Xw_draw_image",pimage) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( pimaglist = pbuffer->pimaglist ; pimaglist ;
pimaglist = (XW_EXT_IMAGE*) pimaglist->link ) {
if( pimaglist->nimage < MAXIMAGES ) break ;
}
if( !pimaglist ) {
pimaglist = Xw_add_image_structure(pbuffer) ;
}
//OCC186
x = PXPOINT(xc, pwindow->xratio) ;
y = PYPOINT(yc, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
#ifdef BUC0056
x = max(min(x,MAXCOORD),MINCOORD);
y = max(min(y,MAXCOORD),MINCOORD);
#endif
width = (_ZIMAGE) ? _ZIMAGE->width : _IIMAGE->width ;
height = (_ZIMAGE) ? _ZIMAGE->height : _IIMAGE->height ;
nimage = pimaglist->nimage ;
pimaglist->pimagdata[nimage] = pimage ;
pimaglist->rpoints[nimage].x = x ;
pimaglist->rpoints[nimage].y = y ;
pimaglist->nimage++ ;
if( bindex ) {
pbuffer->isempty = False ;
width = (width+3)/2 ;
height = (height+3)/2 ;
pbuffer->rxmin = min(pbuffer->rxmin,x-width) ;
pbuffer->rymin = min(pbuffer->rymin,y-height) ;
pbuffer->rxmax = max(pbuffer->rxmax,x+width) ;
pbuffer->rymax = max(pbuffer->rymax,y+height) ;
} else {
Xw_draw_pixel_images(pwindow,pimaglist,pwindow->qgwind.gccopy,NULL);
pimaglist->nimage = 0 ;
}
#ifdef TRACE_DRAW_IMAGE
if( Xw_get_trace() ) {
printf (" Xw_draw_image(%lx,%lx,%f,%f)\n",(long ) pwindow,(long ) pimage,xc,yc) ;
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_images (XW_EXT_WINDOW* pwindow,XW_EXT_IMAGE* pimaglist,
GC gcimag,GC gcline)
#else
void Xw_draw_pixel_images (pwindow,pimaglist,gcimag,gcline)
XW_EXT_WINDOW *pwindow;
XW_EXT_IMAGE *pimaglist ;
GC gcimag,gcline ;
#endif
{
XW_EXT_IMAGEDATA *pimage;
unsigned int width,height;
XImage *pximage;
int i,x,y;
for( i=0 ; i<pimaglist->nimage ; i++ ) {
pimage = pimaglist->pimagdata[i] ;
pximage = (_ZIMAGE) ? _ZIMAGE : _IIMAGE;
width = pximage->width;
height = pximage->height;
if( pimaglist->isupdated ) {
x = pimaglist->upoints[i].x - width/2 ;
y = pimaglist->upoints[i].y - height/2 ;
} else {
x = pimaglist->rpoints[i].x - width/2 ;
y = pimaglist->rpoints[i].y - height/2 ;
}
if( gcimag ) {
XPutImage(_DISPLAY,_DRAWABLE,gcimag,pximage,0,0,x,y,width,height) ;
}
if( gcline ) {
XDrawRectangle(_DISPLAY,_DRAWABLE,gcline,x-1,y-1,width+2,height+2) ;
}
}
}
#ifdef XW_PROTOTYPE
XW_EXT_IMAGE* Xw_add_image_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_IMAGE* Xw_add_image_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended image structure in the
image List
returns Extended image address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_IMAGE *pimage ;
int i ;
pimage = (XW_EXT_IMAGE*) Xw_malloc(sizeof(XW_EXT_IMAGE)) ;
if( pimage ) {
pimage->link = pbuflist->pimaglist ;
pimage->isupdated = False ;
pimage->nimage = 0 ;
for( i=0 ; i<MAXIMAGES ; i++ ) {
pimage->pimagdata[i] = NULL ;
}
pbuflist->pimaglist = pimage ;
} else {
/*ERROR*EXT_IMAGE Allocation failed*/
Xw_set_error(27,"Xw_add_image_structure",NULL) ;
}
return (pimage) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_image_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_image_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended image structure in the
image List
SUCCESS always
*/
{
XW_EXT_IMAGE *pimag,*qimag ;
int i ;
for( pimag = pbuflist->pimaglist ; pimag ; pimag = qimag ) {
qimag = (XW_EXT_IMAGE*)pimag->link ;
for( i=0 ; i<pimag->nimage ; i++ ) {
if( pimag->pimagdata[i] )
Xw_del_imagedata_structure(pimag->pimagdata[i]) ;
}
Xw_free(pimag) ;
}
pbuflist->pimaglist = NULL ;
return (XW_SUCCESS) ;
}

518
src/Xw/Xw_draw_line.cxx Executable file
View File

@@ -0,0 +1,518 @@
#define S3593 /*GG_130398
OPTIMISATION MFT
Activer le clipping de maniere optionnelle
*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_LINE
#endif
/*
STATUS Xw_draw_line (awindow,npoint,x,y):
XW_EXT_WINDOW *awindow
int npoint Polyline point number
float *x,*y Points Arrays
Display continuous line in current QG set by set_line_attrib .
Note that lines can be buffered depending of the DisplayMode context
and Flush at Xw_flush time .
returns ERROR if npoint > MAXPOINTS
returns SUCCESS always
*/
static int BeginLine = -1 ;
static XW_EXT_LINE *plinelist ;
static XW_EXT_POINT *plinedesc ;
static XSegment segment;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_line (void* awindow,int npoint,float* px,float* py)
#else
XW_STATUS Xw_draw_line (awindow,npoint,px,py)
void *awindow;
int npoint ;
float *px,*py ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) awindow ;
XW_EXT_BUFFER *pbuffer ;
int i,nline,ldesc,bindex;
int x,y,lx=0,ly=0 ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_line",pwindow) ;
return (XW_ERROR) ;
}
if( npoint > MAXPOINTS ) {
npoint = MAXPOINTS;
/*ERROR*Too many points in LINE*/
Xw_set_error(28,"Xw_draw_line",&npoint) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( plinelist = pbuffer->plinelist ; plinelist ;
plinelist = (XW_EXT_LINE*)plinelist->link ) {
if( plinelist->nline < MAXLINES ) break ;
}
if( !plinelist ) {
plinelist = Xw_add_polyline_structure(pbuffer) ;
}
if( !plinelist ) return XW_ERROR ;
for( plinedesc = pbuffer->plinedesc ; plinedesc ;
plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
if( plinedesc->npoint + npoint <= MAXPOINTS ) break ;
}
if( !plinedesc ) {
plinedesc = Xw_add_line_desc_structure(pbuffer) ;
}
if( !plinedesc ) return XW_ERROR ;
nline = plinelist->nline ;
ldesc = plinedesc->npoint ;
plinelist->plines[nline] = &plinedesc->rpoints[ldesc] ;
for( i=0 ; i<npoint ; i++ ) {
//OCC186
x = PXPOINT(px[i], pwindow->xratio) ;
y = PYPOINT(py[i], pwindow->attributes.height, pwindow->yratio) ;
//OCC186
#ifdef S3593
if( pwindow->clipflag ) {
#endif
if( i > 0 ) {
int status;
status = Xw_clip_segment(pwindow,lx,ly,x,y,&segment);
if( status >= 0 ) {
if( (i < 2) || (status & 0xF ) ) {
plinedesc->rpoints[ldesc].x = segment.x1 ;
plinedesc->rpoints[ldesc].y = segment.y1 ;
ldesc++;
if( bindex > 0 ) {
int xx = segment.x1,yy = segment.y1;
pbuffer->rxmin = min(pbuffer->rxmin,xx) ;
pbuffer->rymin = min(pbuffer->rymin,yy) ;
pbuffer->rxmax = max(pbuffer->rxmax,xx) ;
pbuffer->rymax = max(pbuffer->rymax,yy) ;
}
}
plinedesc->rpoints[ldesc].x = segment.x2 ;
plinedesc->rpoints[ldesc].y = segment.y2 ;
ldesc++;
if( bindex > 0 ) {
int xx = segment.x2,yy = segment.y2;
pbuffer->rxmin = min(pbuffer->rxmin,xx) ;
pbuffer->rymin = min(pbuffer->rymin,yy) ;
pbuffer->rxmax = max(pbuffer->rxmax,xx) ;
pbuffer->rymax = max(pbuffer->rymax,yy) ;
}
}
}
lx = x; ly = y;
#ifdef S3593
} else {
plinedesc->rpoints[ldesc].x = x ;
plinedesc->rpoints[ldesc].y = y ;
ldesc++ ;
if( bindex > 0 ) {
pbuffer->rxmin = min(pbuffer->rxmin,x) ;
pbuffer->rymin = min(pbuffer->rymin,y) ;
pbuffer->rxmax = max(pbuffer->rxmax,x) ;
pbuffer->rymax = max(pbuffer->rymax,y) ;
}
}
#endif
}
plinelist->lines[nline] = ldesc - plinedesc->npoint ;
if( plinelist->lines[nline] > 1 ) {
plinedesc->npoint = ldesc ;
plinelist->nline++ ;
if( bindex > 0 ) {
pbuffer->isempty = False ;
} else if( BeginLine < 0 ) {
int index = pwindow->lineindex ;
Xw_draw_pixel_lines(pwindow,plinelist,pwindow->qgline[index].gc);
plinelist->nline = 0 ;
plinedesc->npoint = 0 ;
}
}
#ifdef TRACE_DRAW_LINE
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_line(%lx,%d)\n",(long ) pwindow,npoint) ;
for( i=0 ; i<npoint ; i++ ) {
printf(" Point(%d) = {%f,%f}\n",i,px[i],py[i]) ;
}
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_lines (XW_EXT_WINDOW* pwindow,XW_EXT_LINE *plinelist,GC gc)
#else
void Xw_draw_pixel_lines (pwindow,plinelist,gc)
XW_EXT_WINDOW *pwindow;
XW_EXT_LINE *plinelist;
GC gc ;
#endif /*XW_PROTOTYPE*/
{
int i,npoint;
XPoint *ppoint ;
for( i=0 ; i<plinelist->nline ; i++ ) {
npoint = plinelist->lines[i] ;
ppoint = plinelist->plines[i] ;
if( plinelist->isupdated ) {
ppoint += MAXPOINTS ;
}
if( ppoint && npoint > 1 ) {
XDrawLines(_DISPLAY,_DRAWABLE,gc,ppoint,npoint,CoordModeOrigin) ;
}
}
}
/*
STATUS Xw_begin_line (awindow,npoint):
XW_EXT_WINDOW *awindow
int npoint Polyline point number
Begin Polyline which must be filled by Xw_line_point and
closed by Xw_close_line
returns ERROR if npoint > MAXPOINTS
returns SUCCESS if successful
*/
static int Npoint = 0;
static int Lx,Ly;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_begin_line(void* awindow,int npoint)
#else
XW_STATUS Xw_begin_line(awindow,npoint)
void *awindow ;
int npoint ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
XW_EXT_BUFFER *pbuffer ;
int nline,ldesc,bindex ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_begin_line",pwindow) ;
return (XW_ERROR) ;
}
if( npoint > MAXPOINTS ) {
npoint = MAXPOINTS ;
/*ERROR*Too many points in LINE*/
Xw_set_error(28,"Xw_begin_line",&npoint) ;
return (XW_ERROR) ;
}
if( BeginLine >= 0 ) Xw_close_line(pwindow);
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( plinelist = pbuffer->plinelist ; plinelist ;
plinelist = (XW_EXT_LINE*)plinelist->link ) {
if( plinelist->nline < MAXLINES ) break ;
}
if( !plinelist ) {
plinelist = Xw_add_polyline_structure(pbuffer) ;
}
if( !plinelist ) return XW_ERROR ;
for( plinedesc = pbuffer->plinedesc ; plinedesc ;
plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
if( plinedesc->npoint + npoint <= MAXPOINTS ) break ;
}
if( !plinedesc ) {
plinedesc = Xw_add_line_desc_structure(pbuffer) ;
}
if( !plinedesc ) return XW_ERROR ;
nline = plinelist->nline ;
ldesc = plinedesc->npoint ;
plinelist->lines[nline] = Npoint = 0 ;
plinelist->plines[nline] = &plinedesc->rpoints[ldesc] ;
BeginLine = ldesc ;
#ifdef TRACE_DRAW_LINE
if( Xw_get_trace() > 2 ) {
printf(" Xw_begin_line(%lx,%d)\n",(long ) pwindow,npoint) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_line_point (awindow,x,y):
XW_EXT_WINDOW *awindow
float x,y New point to add in polyline in user-space coordinates
Fill Polyline with one point more
returns ERROR if Too Many Points in polylines
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_line_point(void* awindow,float x,float y)
#else
XW_STATUS Xw_line_point(awindow,x,y)
void *awindow ;
float x,y ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
XW_EXT_BUFFER *pbuffer ;
int bindex,xi,yi ;
if( BeginLine >= 0 ) {
int ldesc = plinedesc->npoint ;
if( ldesc >= MAXPOINTS ) {
/*ERROR*Too many points in LINE*/
Xw_set_error(28,"Xw_line_point",&ldesc) ;
Xw_close_line(pwindow) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
//OCC186
xi = PXPOINT(x, pwindow->xratio) ;
yi = PYPOINT(y, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
#ifdef S3593
if( pwindow->clipflag ) {
#endif
if( Npoint > 0 ) {
int status;
status = Xw_clip_segment(pwindow,Lx,Ly,xi,yi,&segment);
if( status >= 0 ) {
if( (Npoint < 2) || (status & 0xF ) ) {
plinedesc->rpoints[ldesc].x = segment.x1 ;
plinedesc->rpoints[ldesc].y = segment.y1 ;
ldesc++;
if( bindex > 0 ) {
int xx = segment.x1,yy = segment.y1;
pbuffer->isempty = False ;
pbuffer->rxmin = min(pbuffer->rxmin,xx) ;
pbuffer->rymin = min(pbuffer->rymin,yy) ;
pbuffer->rxmax = max(pbuffer->rxmax,xx) ;
pbuffer->rymax = max(pbuffer->rymax,yy) ;
}
}
plinedesc->rpoints[ldesc].x = segment.x2 ;
plinedesc->rpoints[ldesc].y = segment.y2 ;
ldesc++;
if( bindex > 0 ) {
int xx = segment.x2,yy = segment.y2;
pbuffer->isempty = False ;
pbuffer->rxmin = min(pbuffer->rxmin,xx) ;
pbuffer->rymin = min(pbuffer->rymin,yy) ;
pbuffer->rxmax = max(pbuffer->rxmax,xx) ;
pbuffer->rymax = max(pbuffer->rymax,yy) ;
}
}
}
Lx = xi; Ly = yi;
#ifdef S3593
} else {
plinedesc->rpoints[ldesc].x = xi ;
plinedesc->rpoints[ldesc].y = yi ;
ldesc++;
if( bindex > 0 ) {
pbuffer->isempty = False ;
pbuffer->rxmin = min(pbuffer->rxmin,xi) ;
pbuffer->rymin = min(pbuffer->rymin,yi) ;
pbuffer->rxmax = max(pbuffer->rxmax,xi) ;
pbuffer->rymax = max(pbuffer->rymax,yi) ;
}
}
#endif
Npoint++;
plinedesc->npoint = ldesc ;
}
#ifdef TRACE_DRAW_LINE
if( Xw_get_trace() > 3 ) {
printf(" Xw_line_point(%lx,%f,%f)\n",(long ) pwindow,x,y) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_close_line (awindow):
XW_EXT_WINDOW *awindow
Close the Polyline
returns ERROR if Polyline is empty
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_line(void* awindow)
#else
XW_STATUS Xw_close_line(awindow)
void *awindow ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
if( BeginLine >= 0 ) {
int nline = plinelist->nline ;
int ldesc = plinedesc->npoint ;
int bindex = _BINDEX ;
plinelist->lines[nline] = ldesc - BeginLine ;
plinelist->nline++ ;
if( !bindex ) {
int index = pwindow->lineindex ;
Xw_draw_pixel_lines(pwindow,plinelist,pwindow->qgline[index].gc) ;
plinelist->nline = 0 ;
plinedesc->npoint = 0 ;
}
BeginLine = -1 ;
}
#ifdef TRACE_DRAW_LINE
if( Xw_get_trace() > 2 ) {
printf(" Xw_close_line(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_LINE* Xw_add_polyline_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_LINE* Xw_add_polyline_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended polyline structure in the
polyline List
returns Extended polyline address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_LINE *pline ;
pline = (XW_EXT_LINE*) Xw_malloc(sizeof(XW_EXT_LINE)) ;
if( pline ) {
pline->link = pbuflist->plinelist ;
pline->isupdated = False ;
pline->nline = 0 ;
pbuflist->plinelist = pline ;
} else {
/*ERROR*EXT_LINE allocation failed*/
Xw_set_error(30,"Xw_add_polyline_structure",NULL) ;
}
return (pline) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_polyline_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_polyline_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended polyline structure in the
polyline List
SUCCESS always
*/
{
XW_EXT_LINE *pline,*qline ;
for( pline = pbuflist->plinelist ; pline ; pline = qline ) {
qline = (XW_EXT_LINE*)pline->link ;
Xw_free(pline) ;
}
pbuflist->plinelist = NULL ;
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_POINT* Xw_add_line_desc_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_POINT* Xw_add_line_desc_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended line_desc structure in the
line_desc List
returns Extended line_desc address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_POINT *pdesc ;
pdesc = (XW_EXT_POINT*) Xw_malloc(sizeof(XW_EXT_POINT)) ;
if( pdesc ) {
pdesc->link = pbuflist->plinedesc ;
pdesc->npoint = 0 ;
pbuflist->plinedesc = pdesc ;
} else {
/*ERROR*EXT_POINT allocation failed*/
Xw_set_error(117,"Xw_add_line_desc_structure",NULL) ;
}
return (pdesc) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_line_desc_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_line_desc_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended line_desc structure in the
line_desc List
SUCCESS always
*/
{
XW_EXT_POINT *pdesc,*qdesc ;
for( pdesc = pbuflist->plinedesc ; pdesc ; pdesc = qdesc ) {
qdesc = (XW_EXT_POINT*)pdesc->link ;
Xw_free(pdesc) ;
}
pbuflist->plinedesc = NULL ;
return (XW_SUCCESS) ;
}

477
src/Xw/Xw_draw_marker.cxx Executable file
View File

@@ -0,0 +1,477 @@
#define BUC0056 /*GG_300496
Protection contre zoom trop grand*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_MARKER
#endif
/*
STATUS Xw_draw_marker (awindow,index,x,y,width,height,angle):
XW_EXT_WINDOW *awindow
int index Marker index
float x,y Marker position in user space
float width,height Marker size in MM.
float angle Marker orientation in RAD
Display polyline & polygones marker in current QG set
by set_marker_attrib .
Note that markers can be buffered depending of the DisplayMode context
and Flush at Xw_flush time .
returns SUCCESS always
*/
#ifdef BUC0056
#define MAXCOORD 32767
#define MINCOORD -32768
#endif
static int BeginMarkers = False ;
static XW_EXT_LMARKER *plmarklist ;
static XW_EXT_PMARKER *ppmarklist ;
#define XROTATE(x,y) (x*cosa - y*sina)
#define YROTATE(x,y) (x*sina + y*cosa)
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_marker (void* awindow,int index,
float x,float y,float width,float height,float angle)
#else
XW_STATUS Xw_draw_marker (awindow,index,x,y,width,height,angle)
void *awindow;
int index;
float x,y ;
float width,height;
float angle;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_DISPLAY *pdisplay = pwindow->connexion;
XW_EXT_BUFFER *pbuffer ;
int i,np,type,bindex,rotate = False ;
int ix,iy,ix1,iy1,ix2,iy2,sm,*ps;
int npoint,nseg,nmark ;
float xm,ym,cosa=0,sina=0,*px,*py;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_marker",pwindow) ;
return (XW_ERROR) ;
}
if( !Xw_isdefine_marker(_MARKMAP,index) ) {
/*ERROR*Bad Defined Marker*/
Xw_set_error(77,"Xw_draw_marker",&index) ;
return (XW_ERROR) ;
}
type = QGTYPE(pwindow->qgmark[pwindow->markindex].code);
np = _MARKMAP->npoint[index] ;
//OCC186
ix = PXPOINT(x, pwindow->xratio) ;
iy = PYPOINT(y, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
#ifdef BUC0056
if( ix < MINCOORD || ix > MAXCOORD ) return XW_SUCCESS;
if( iy < MINCOORD || iy > MAXCOORD ) return XW_SUCCESS;
#endif
if( angle != 0. ) {
rotate = True;
cosa = cos((double)angle);
sina = sin((double)angle);
}
if( np >= MAXPOINTS ) {
np = MAXPOINTS-1;
/*ERROR*Too many points in MARKER*/
Xw_set_error(112,"Xw_draw_marker",&np) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
if( bindex > 0 ) type = 0 ; /* Poly markers will be disable */
ppmarklist = NULL ;
if( type > 0 ) {
for( ppmarklist = pbuffer->ppmarklist ; ppmarklist ;
ppmarklist = (XW_EXT_PMARKER*) ppmarklist->link ) {
if( (ppmarklist->nmark < MAXPMARKERS) &&
(ppmarklist->npoint + np < MAXPOINTS) ) break ;
}
if( !ppmarklist ) {
ppmarklist = Xw_add_pmarker_structure(pbuffer) ;
}
if( !ppmarklist ) return XW_ERROR ;
npoint = ppmarklist->npoint ;
nmark = ppmarklist->nmark ;
ix1 = ix ; iy1 = iy ;
ps = _MARKMAP->spoint[index];
px = _MARKMAP->xpoint[index];
py = _MARKMAP->ypoint[index];
for( i=0 ; i<np ; i++,ps++,px++,py++ ) {
sm = *ps; xm = *px * width/2. ; ym = *py * height/2.;
if( rotate ) {
float xr,yr;
xr = XROTATE(xm,ym);
yr = YROTATE(xm,ym);
ix2 = ix + PMMXVALUE(xr); iy2 = iy - PMMYVALUE(yr);
} else {
ix2 = ix + PMMXVALUE(xm); iy2 = iy - PMMYVALUE(ym);
}
ppmarklist->rpoints[npoint].x = ix2 ;
ppmarklist->rpoints[npoint].y = iy2 ;
if( sm || !i ) npoint++;
else break;
ix1 = ix2; iy1 = iy2;
}
ppmarklist->marks[nmark] = npoint - ppmarklist->npoint;
ppmarklist->npoint = npoint ;
ppmarklist->rcenters[nmark].x = ix ;
ppmarklist->rcenters[nmark].y = iy ;
ppmarklist->nmark++ ;
}
for( plmarklist = pbuffer->plmarklist ; plmarklist ;
plmarklist = (XW_EXT_LMARKER*) plmarklist->link ) {
if( (plmarklist->nmark < MAXLMARKERS) &&
(plmarklist->nseg + np < MAXPOINTS) ) break ;
}
if( !plmarklist ) {
plmarklist = Xw_add_lmarker_structure(pbuffer) ;
}
if( !plmarklist ) return XW_ERROR ;
nseg = plmarklist->nseg ;
nmark = plmarklist->nmark ;
ix1 = ix ; iy1 = iy ;
ps = _MARKMAP->spoint[index];
px = _MARKMAP->xpoint[index];
py = _MARKMAP->ypoint[index];
for( i=0 ; i<np ; i++,ps++,px++,py++ ) {
sm = *ps; xm = *px * width/2. ; ym = *py * height/2.;
if( rotate ) {
float xr,yr;
xr = xm*cosa - ym*sina;
yr = xm*sina + ym*cosa;
ix2 = ix + PMMXVALUE(xr); iy2 = iy - PMMYVALUE(yr);
} else {
ix2 = ix + PMMXVALUE(xm); iy2 = iy - PMMYVALUE(ym);
}
if( sm ) {
plmarklist->rsegments[nseg].x1 = ix1 ;
plmarklist->rsegments[nseg].y1 = iy1 ;
plmarklist->rsegments[nseg].x2 = ix2 ;
plmarklist->rsegments[nseg].y2 = iy2 ;
nseg++;
}
ix1 = ix2; iy1 = iy2;
}
plmarklist->marks[nmark] = nseg - plmarklist->nseg;
plmarklist->nseg = nseg ;
plmarklist->rcenters[nmark].x = ix ;
plmarklist->rcenters[nmark].y = iy ;
plmarklist->nmark++ ;
if( bindex > 0 ) {
int w = (PMMXVALUE(width)+1)/2 ;
int h = (PMMYVALUE(height)+1)/2 ;
pbuffer->isempty = False ;
pbuffer->rxmin = min(pbuffer->rxmin,ix-w) ;
pbuffer->rymin = min(pbuffer->rymin,iy-h) ;
pbuffer->rxmax = max(pbuffer->rxmax,ix+w) ;
pbuffer->rymax = max(pbuffer->rymax,iy+h) ;
} else if( !BeginMarkers ) {
if( ppmarklist ) {
int index = pwindow->polyindex ;
Xw_draw_pixel_pmarkers(pwindow,ppmarklist,
pwindow->qgpoly[index].gc);
ppmarklist->nmark = 0 ;
ppmarklist->npoint = 0 ;
}
if( plmarklist ) {
int index = pwindow->markindex ;
Xw_draw_pixel_lmarkers(pwindow,plmarklist,
pwindow->qgmark[index].gc);
plmarklist->nmark = 0 ;
plmarklist->nseg = 0 ;
}
}
#ifdef TRACE_DRAW_MARKER
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_marker(%lx,%d,%f,%f,%f,%f,%f)\n",
(long ) pwindow,index,x,y,width,height,angle) ;
}
#endif
return (XW_SUCCESS);
}
/*
STATUS Xw_begin_markers (awindow,nmarker):
XW_EXT_WINDOW *awindow
int nmarker Not used
Begin a set of markers which must be filled by Xw_draw_marker and
closed by Xw_close_markers
returns ERROR if bad extended window address
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_begin_markers(void* awindow,int nmarker)
#else
XW_STATUS Xw_begin_markers(awindow,nmarker)
void *awindow ;
int nmarker ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_begin_markers",pwindow) ;
return (XW_ERROR) ;
}
if( BeginMarkers ) Xw_close_markers(pwindow);
BeginMarkers = True;
#ifdef TRACE_DRAW_MARKER
if( Xw_get_trace() > 2 ) {
printf(" Xw_begin_markers(%lx,%d)\n",(long ) pwindow,nmarker) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_close_markers (awindow):
XW_EXT_WINDOW *awindow
Close the set of markers
returns ERROR if bad extended window address
returns SUCCESS successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_markers(void* awindow)
#else
XW_STATUS Xw_close_markers(awindow)
void *awindow ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
XW_EXT_BUFFER *pbuffer ;
int bindex ;
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
if( BeginMarkers && !bindex ) {
int index = pwindow->polyindex ;
for( ppmarklist = pbuffer->ppmarklist ; ppmarklist ;
ppmarklist = (XW_EXT_PMARKER*) ppmarklist->link ) {
if( ppmarklist->nmark > 0 ) {
Xw_draw_pixel_pmarkers(pwindow,ppmarklist,
pwindow->qgpoly[index].gc) ;
ppmarklist->nmark = 0 ;
ppmarklist->npoint = 0 ;
} else break ;
}
index = pwindow->markindex ;
for( plmarklist = pbuffer->plmarklist ; plmarklist ;
plmarklist = (XW_EXT_LMARKER*) plmarklist->link ) {
if( plmarklist->nseg > 0 ) {
Xw_draw_pixel_lmarkers(pwindow,plmarklist,
pwindow->qgmark[index].gc) ;
plmarklist->nmark = 0 ;
plmarklist->nseg = 0 ;
} else break ;
}
}
BeginMarkers = False;
#ifdef TRACE_DRAW_MARKER
if( Xw_get_trace() > 2 ) {
printf(" Xw_close_markers(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_pmarkers (XW_EXT_WINDOW* pwindow,XW_EXT_PMARKER* pmarklist,GC gc)
#else
void Xw_draw_pixel_pmarkers (pwindow,pmarklist,gc)
XW_EXT_WINDOW *pwindow;
XW_EXT_PMARKER *pmarklist;
GC gc ;
#endif /*XW_PROTOTYPE*/
{
int i,j,npoint ;
XPoint *ppoint ;
for( i=j=0 ; i<pmarklist->nmark ; i++,j += npoint ) {
npoint = pmarklist->marks[i] ;
if( pmarklist->isupdated ) {
ppoint = &pmarklist->upoints[j] ;
} else {
ppoint = &pmarklist->rpoints[j] ;
}
if( npoint > 2 ) {
XFillPolygon(_DISPLAY,_DRAWABLE,gc,ppoint,npoint,
Nonconvex,CoordModeOrigin) ;
}
}
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_lmarkers (XW_EXT_WINDOW* pwindow,XW_EXT_LMARKER* pmarklist,GC gc)
#else
void Xw_draw_pixel_lmarkers (pwindow,pmarklist,gc)
XW_EXT_WINDOW *pwindow;
XW_EXT_LMARKER *pmarklist;
GC gc ;
#endif /*XW_PROTOTYPE*/
{
if( pmarklist->isupdated ) {
XDrawSegments(_DISPLAY,_DRAWABLE,gc,
pmarklist->usegments,pmarklist->nseg) ;
} else {
XDrawSegments(_DISPLAY,_DRAWABLE,gc,
pmarklist->rsegments,pmarklist->nseg) ;
}
}
#ifdef XW_PROTOTYPE
XW_EXT_LMARKER* Xw_add_lmarker_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_LMARKER* Xw_add_lmarker_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended marker structure in the
marker List
returns Extended marker address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_LMARKER *pmarker ;
pmarker = (XW_EXT_LMARKER*) Xw_malloc(sizeof(XW_EXT_LMARKER)) ;
if( pmarker ) {
pmarker->link = pbuflist->plmarklist ;
pmarker->isupdated = False ;
pmarker->nmark = 0 ;
pmarker->nseg = 0 ;
pbuflist->plmarklist = pmarker ;
} else {
/*ERROR*EXT_MARKER Allocation failed*/
Xw_set_error(31,"Xw_add_marker_structure",NULL) ;
}
return (pmarker) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_lmarker_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_lmarker_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended marker structure in the
marker List
SUCCESS always
*/
{
XW_EXT_LMARKER *pmarker,*qmarker ;
for( pmarker = pbuflist->plmarklist ; pmarker ; pmarker = qmarker ) {
qmarker = (XW_EXT_LMARKER*)pmarker->link ;
Xw_free(pmarker) ;
}
pbuflist->plmarklist = NULL ;
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_PMARKER* Xw_add_pmarker_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_PMARKER* Xw_add_pmarker_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended marker structure in the
marker List
returns Extended marker address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_PMARKER *pmarker ;
pmarker = (XW_EXT_PMARKER*) Xw_malloc(sizeof(XW_EXT_PMARKER)) ;
if( pmarker ) {
pmarker->link = pbuflist->ppmarklist ;
pmarker->isupdated = False ;
pmarker->nmark = 0 ;
pmarker->npoint = 0 ;
pbuflist->ppmarklist = pmarker ;
} else {
/*ERROR*EXT_MARKER Allocation failed*/
Xw_set_error(31,"Xw_add_marker_structure",NULL) ;
}
return (pmarker) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_pmarker_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_pmarker_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended marker structure in the
marker List
SUCCESS always
*/
{
XW_EXT_PMARKER *pmarker,*qmarker ;
for( pmarker = pbuflist->ppmarklist ; pmarker ; pmarker = qmarker ) {
qmarker = (XW_EXT_PMARKER*)pmarker->link ;
Xw_free(pmarker) ;
}
pbuflist->ppmarklist = NULL ;
return (XW_SUCCESS) ;
}

258
src/Xw/Xw_draw_point.cxx Executable file
View File

@@ -0,0 +1,258 @@
#define BUC0056 /*GG_300496
Protection contre zoom trop grand*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_POINT
#endif
/*
STATUS Xw_draw_point (awindow,x,y):
XW_EXT_WINDOW *awindow
float x,y Point position in user space
Display point in current QG set by set_marker_attrib .
Note that points can be buffered depending of the DisplayMode context
and Flush at Xw_flush time .
returns SUCCESS always
*/
#ifdef BUC0056
#define MAXCOORD 32767
#define MINCOORD -32768
#endif
static int BeginPoints = False ;
static XW_EXT_POINT *ppntlist = NULL ;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_point (void* awindow,float x,float y)
#else
XW_STATUS Xw_draw_point (awindow,x,y)
void *awindow;
float x,y ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_BUFFER *pbuffer ;
int npnt,bindex,ix,iy ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_point",pwindow) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( ppntlist = pbuffer->ppntlist ; ppntlist ;
ppntlist = (XW_EXT_POINT*) ppntlist->link ) {
if( ppntlist->npoint < MAXPOINTS ) break ;
}
if( !ppntlist ) {
ppntlist = Xw_add_point_structure(pbuffer) ;
}
if( !ppntlist ) return XW_ERROR ;
//OCC186
ix = PXPOINT(x, pwindow->xratio) ;
iy = PYPOINT(y, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
#ifdef BUC0056
if( ix < MINCOORD || ix > MAXCOORD ) return XW_SUCCESS;
if( iy < MINCOORD || iy > MAXCOORD ) return XW_SUCCESS;
#endif
npnt = ppntlist->npoint ;
ppntlist->rpoints[npnt].x = ix ;
ppntlist->rpoints[npnt].y = iy ;
ppntlist->npoint++ ;
if( bindex > 0 ) {
pbuffer->isempty = False ;
pbuffer->rxmin = min(pbuffer->rxmin,ix) ;
pbuffer->rymin = min(pbuffer->rymin,iy) ;
pbuffer->rxmax = max(pbuffer->rxmax,ix) ;
pbuffer->rymax = max(pbuffer->rymax,iy) ;
} else if( !BeginPoints ) {
int index = pwindow->markindex ;
Xw_draw_pixel_points(pwindow,ppntlist,pwindow->qgmark[index].gc) ;
ppntlist->npoint = 0 ;
}
#ifdef TRACE_DRAW_POINT
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_point(%lx,%f,%f)\n",(long ) pwindow,x,y) ;
}
#endif
return (XW_SUCCESS);
}
/*
STATUS Xw_begin_points (awindow,npoint):
XW_EXT_WINDOW *awindow
int npoint Not used
Begin a set of points which must be filled by Xw_draw_point and
closed by Xw_close_points
returns ERROR if bad extended window address
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_begin_points(void* awindow,int npoint)
#else
XW_STATUS Xw_begin_points(awindow,npoint)
void *awindow ;
int npoint ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_begin_points",pwindow) ;
return (XW_ERROR) ;
}
if( BeginPoints ) Xw_close_points(pwindow);
BeginPoints = True;
#ifdef TRACE_DRAW_POINT
if( Xw_get_trace() > 2 ) {
printf(" Xw_begin_points(%lx,%d)\n",(long ) pwindow,npoint) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_close_points (awindow):
XW_EXT_WINDOW *awindow
Close the set of points
returns ERROR if bad extended window address
returns SUCCESS successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_points(void* awindow)
#else
XW_STATUS Xw_close_points(awindow)
void *awindow ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
XW_EXT_BUFFER *pbuffer ;
int bindex ;
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
if( BeginPoints && !bindex ) {
int index = pwindow->lineindex ;
for( ppntlist = pbuffer->ppntlist ; ppntlist ;
ppntlist = (XW_EXT_POINT*) ppntlist->link ) {
if( ppntlist->npoint > 0 ) {
Xw_draw_pixel_points(pwindow,ppntlist,pwindow->qgmark[index].gc) ;
ppntlist->npoint = 0 ;
} else break ;
}
}
BeginPoints = False;
#ifdef TRACE_DRAW_POINT
if( Xw_get_trace() > 2 ) {
printf(" Xw_close_points(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_points(XW_EXT_WINDOW *pwindow,XW_EXT_POINT* ppntlist,GC gc)
#else
void Xw_draw_pixel_points(pwindow,ppntlist,gc)
XW_EXT_WINDOW *pwindow ;
XW_EXT_POINT *ppntlist ;
GC gc ;
#endif /*XW_PROTOTYPE*/
{
if( ppntlist->isupdated ) {
XDrawPoints(_DISPLAY,_DRAWABLE,gc,ppntlist->upoints,
ppntlist->npoint,CoordModeOrigin) ;
} else {
XDrawPoints(_DISPLAY,_DRAWABLE,gc,ppntlist->rpoints,
ppntlist->npoint,CoordModeOrigin) ;
}
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_point_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_point_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended point structure in the
point List
SUCCESS always
*/
{
XW_EXT_POINT *ppoint,*qpoint ;
for( ppoint = pbuflist->ppntlist ; ppoint ; ppoint = qpoint ) {
qpoint = (XW_EXT_POINT*)ppoint->link ;
Xw_free(ppoint) ;
}
pbuflist->ppntlist = NULL ;
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_POINT* Xw_add_point_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_POINT* Xw_add_point_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended point structure in the
point List
returns Extended point address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_POINT *ppoint ;
ppoint = (XW_EXT_POINT*) Xw_malloc(sizeof(XW_EXT_POINT)) ;
if( ppoint ) {
ppoint->link = pbuflist->ppntlist ;
ppoint->isupdated = False ;
ppoint->npoint = 0 ;
pbuflist->ppntlist = ppoint ;
} else {
/*ERROR*EXT_POINT Allocation failed*/
Xw_set_error(117,"Xw_add_point_structure",NULL) ;
}
return (ppoint) ;
}

583
src/Xw/Xw_draw_poly.cxx Executable file
View File

@@ -0,0 +1,583 @@
#define BUC40223 /*GG_070797
Protection contre zoom trop grand*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_POLY
#endif
/*
STATUS Xw_draw_poly (awindow,npoint,px,py):
XW_EXT_WINDOW *awindow
int npoint Polygone point number
float *px,*py Polygone points
Display continuous poly in current QG set by set_poly_attrib .
Note that polys can be buffered depending of the DisplayMode context
and Flush at Xw_flush time .
returns ERROR if npoint > MAXPOINTS
returns SUCCESS if successful
*/
static int FirstPolyPoint = -1 ;
static int FirstPolyLine = -1 ;
static int FirstPathPoint = -1 ;
static XW_EXT_POLY *ppolylist ;
static XW_EXT_POINT *plinedesc ;
static XSegment segment;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_poly (void* awindow,int npoint,float* px,float* py)
#else
XW_STATUS Xw_draw_poly (awindow,npoint,px,py)
void *awindow;
int npoint ;
float *px,*py ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_BUFFER *pbuffer ;
int i,npoly,ldesc,bindex;
int x=0,y=0,lx=0,ly=0 ;
XPoint *ppoint ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_poly",pwindow) ;
return (XW_ERROR) ;
}
if( npoint >= MAXPOINTS ) {
npoint = MAXPOINTS-1 ;
/*ERROR*Too many points in POLYGONE*/
Xw_set_error(28,"Xw_draw_poly",&npoint) ;
return (XW_ERROR) ;
}
if( npoint < 3 ) {
/*WARNING*POLYGONE is Empty !!!*/
Xw_set_error(33,"Xw_draw_poly",&npoint) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( ppolylist = pbuffer->ppolylist ; ppolylist ;
ppolylist = (XW_EXT_POLY*)ppolylist->link ) {
if( ppolylist->npoly < MAXPOLYS ) break ;
}
if( !ppolylist ) {
ppolylist = Xw_add_polygone_structure(pbuffer) ;
}
if( !ppolylist ) return XW_ERROR ;
for( plinedesc = pbuffer->plinedesc ; plinedesc ;
plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
if( plinedesc->npoint + npoint < MAXPOINTS ) break ;
}
if( !plinedesc ) {
plinedesc = Xw_add_line_desc_structure(pbuffer) ;
}
if( !plinedesc ) return XW_ERROR ;
npoly = ppolylist->npoly ;
ldesc = plinedesc->npoint ;
ppolylist->ppolys[npoly] = ppoint = &plinedesc->rpoints[ldesc] ;
for( i=0 ; i<npoint ; i++ ) {
//OCC186
x = PXPOINT(px[i], pwindow->xratio) ;
y = PYPOINT(py[i], pwindow->attributes.height, pwindow->yratio) ;
//OCC186
#ifdef BUC40223
if( i > 0 ) {
int status;
status = Xw_clip_segment(pwindow,lx,ly,x,y,&segment);
if( status >= 0 ) {
if( (i < 2) || (status & 0xF ) ) {
plinedesc->rpoints[ldesc].x = segment.x1 ;
plinedesc->rpoints[ldesc].y = segment.y1 ;
ldesc++;
if( bindex > 0 ) {
int xx = segment.x1,yy = segment.y1;
pbuffer->rxmin = min(pbuffer->rxmin,xx) ;
pbuffer->rymin = min(pbuffer->rymin,yy) ;
pbuffer->rxmax = max(pbuffer->rxmax,xx) ;
pbuffer->rymax = max(pbuffer->rymax,yy) ;
}
}
plinedesc->rpoints[ldesc].x = segment.x2 ;
plinedesc->rpoints[ldesc].y = segment.y2 ;
ldesc++;
if( bindex > 0 ) {
int xx = segment.x2,yy = segment.y2;
pbuffer->rxmin = min(pbuffer->rxmin,xx) ;
pbuffer->rymin = min(pbuffer->rymin,yy) ;
pbuffer->rxmax = max(pbuffer->rxmax,xx) ;
pbuffer->rymax = max(pbuffer->rymax,yy) ;
}
}
}
lx = x; ly = y;
#else
plinedesc->rpoints[ldesc].x = x ;
plinedesc->rpoints[ldesc].y = y ;
ldesc++ ;
if( bindex > 0 ) {
pbuffer->rxmin = min(pbuffer->rxmin,x) ;
pbuffer->rymin = min(pbuffer->rymin,y) ;
pbuffer->rxmax = max(pbuffer->rxmax,x) ;
pbuffer->rymax = max(pbuffer->rymax,y) ;
}
#endif
}
if( ppoint->x != x || ppoint->y != y ) {
plinedesc->rpoints[ldesc].x = ppoint->x ;
plinedesc->rpoints[ldesc].y = ppoint->y ;
ldesc++ ;
}
ppolylist->polys[npoly] = ldesc - plinedesc->npoint ;
ppolylist->paths[npoly] = ppolylist->polys[npoly] ;
if( ppolylist->polys[npoly] > 3 ) {
ppolylist->npoly++ ;
plinedesc->npoint = ldesc ;
if( bindex > 0 ) {
pbuffer->isempty = False ;
} else if( FirstPolyPoint < 0 ) {
int polyindex = pwindow->polyindex ;
int lineindex = pwindow->lineindex ;
GC gcpoly = (QGTILE(pwindow->qgpoly[polyindex].code)) ?
pwindow->qgpoly[polyindex].gc : NULL ;
GC gcline = (QGTYPE(pwindow->qgpoly[polyindex].code)) ?
pwindow->qgline[lineindex].gc : NULL ;
Xw_draw_pixel_polys(pwindow,ppolylist,gcpoly,gcline);
ppolylist->npoly = 0 ;
plinedesc->npoint = 0 ;
}
}
#ifdef TRACE_DRAW_POLY
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_poly(%lx,%d)\n",(long ) pwindow,npoint) ;
for( i=0 ; i<npoint ; i++ ) {
printf(" Point(%d) = {%f,%f}\n",i,px[i],py[i]) ;
}
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_polys(XW_EXT_WINDOW* pwindow,XW_EXT_POLY* ppolylist,
GC gcpoly,GC gcline)
#else
void Xw_draw_pixel_polys(pwindow,ppolylist,gcpoly,gcline)
XW_EXT_WINDOW *pwindow ;
XW_EXT_POLY *ppolylist ;
GC gcpoly,gcline ;
#endif
{
int i,npolypoint,npathpoint,shape,npoint=0,count=0;
Region chr_region=NULL;
XPoint *ppoint ;
for( i=0 ; i<ppolylist->npoly ; i++ ) {
npolypoint = ppolylist->polys[i] ;
npathpoint = ppolylist->paths[i] ;
ppoint = ppolylist->ppolys[i] ;
if( ppolylist->isupdated ) {
ppoint += MAXPOINTS ;
}
if( gcpoly ) {
if( npolypoint > 0 ) {
npoint = npolypoint; count = 0;
chr_region = 0;
}
if( npoint > npathpoint ) {
if( npathpoint > 3 ) {
if( chr_region == 0 ) {
chr_region =
XPolygonRegion(ppoint,npathpoint-1,EvenOddRule);
} else {
Region chr_pathreg =
XPolygonRegion(ppoint,npathpoint-1,EvenOddRule);
Region chr_xorreg = XCreateRegion ();
XXorRegion (chr_region, chr_pathreg, chr_xorreg);
XDestroyRegion (chr_region);
chr_region = chr_xorreg;
}
}
count += npathpoint;
if( count >= npoint && chr_region ) {
XRectangle rect;
XSetRegion(_DISPLAY,gcpoly,chr_region);
XClipBox(chr_region,&rect);
XFillRectangles(_DISPLAY,_DRAWABLE,gcpoly,&rect,1);
XDestroyRegion(chr_region);
XSetClipMask(_DISPLAY,gcpoly,None);
}
} else if( npoint > 3 ) {
shape = (npoint > 4) ? Nonconvex : Convex;
XFillPolygon(_DISPLAY,_DRAWABLE,gcpoly,ppoint,npoint-1,
shape,CoordModeOrigin) ;
}
}
if( gcline && (gcpoly != gcline) && (npathpoint > 3) ) {
XDrawLines(_DISPLAY,_DRAWABLE,gcline,
ppoint,npathpoint,CoordModeOrigin) ;
}
}
}
/*
STATUS Xw_begin_poly (awindow,npoint,npath):
XW_EXT_WINDOW *awindow
int npoint Estimated polygone point number
int npath Estimated polygone path number
Begin Polygone which must be filled by Xw_poly_point and
closed by Xw_close_poly
returns ERROR if npoint > MAXPOINTS
or npath > MAXPOLYS
returns SUCCESS if successful
*/
static int Npoint = 0;
static int Lx,Ly;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_begin_poly(void* awindow,int npoint,int npath)
#else
XW_STATUS Xw_begin_poly(awindow,npoint,npath)
void *awindow ;
int npoint,npath ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
int npoly,ldesc,bindex ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_begin_poly",pwindow) ;
return (XW_ERROR) ;
}
if( npoint >= MAXPOINTS ) {
npoint = MAXPOINTS-1 ;
/*ERROR*Too many points in POLYGONE*/
Xw_set_error(32,"Xw_begin_poly",&npoint) ;
return (XW_ERROR) ;
}
if( npath >= MAXPOLYS ) {
npath = MAXPOLYS-1 ;
/*ERROR*Too many paths in POLYGONE*/
Xw_set_error(32,"Xw_begin_poly",&npath) ;
return (XW_ERROR) ;
}
if( FirstPolyPoint >= 0 ) Xw_close_poly(pwindow) ;
bindex = _BINDEX ;
for( ppolylist = _BUFFER(bindex).ppolylist ; ppolylist ;
ppolylist = (XW_EXT_POLY*)ppolylist->link ) {
if( (ppolylist->npoly + npath) < MAXPOLYS ) break ;
}
if( !ppolylist ) {
ppolylist = Xw_add_polygone_structure(&_BUFFER(bindex)) ;
}
if( !ppolylist ) return XW_ERROR ;
for( plinedesc = _BUFFER(bindex).plinedesc ; plinedesc ;
plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
if( (plinedesc->npoint + npoint) < MAXPOINTS ) break ;
}
if( !plinedesc ) {
plinedesc = Xw_add_line_desc_structure(&_BUFFER(bindex)) ;
}
if( !plinedesc ) return XW_ERROR ;
npoly = ppolylist->npoly ;
ldesc = plinedesc->npoint ;
ppolylist->polys[npoly] = 0 ;
ppolylist->paths[npoly] = Npoint = 0 ;
ppolylist->ppolys[npoly] = &plinedesc->rpoints[ldesc] ;
FirstPolyPoint = FirstPathPoint = ldesc ;
FirstPolyLine = npoly;
#ifdef TRACE_DRAW_POLY
if( Xw_get_trace() > 2 ) {
printf(" Xw_begin_poly(%lx,%d,%d)\n",(long ) pwindow,npoint,npath) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_poly_point (awindow,x,y):
XW_EXT_WINDOW *awindow
float x,y New point to add in polygone in user-space coordinates
Fill Polygone with one point more
returns ERROR if Too Many Points in polygones
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_poly_point(void* awindow,float x,float y)
#else
XW_STATUS Xw_poly_point(awindow,x,y)
void *awindow ;
float x,y ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
XW_EXT_BUFFER *pbuffer ;
int bindex,xi,yi ;
if( FirstPolyPoint >= 0 ) {
int ldesc = plinedesc->npoint ;
if( ldesc >= MAXPOINTS ) {
/*ERROR*Too many points in POLYGONE*/
Xw_set_error(32,"Xw_poly_point",&ldesc) ;
Xw_close_poly(pwindow) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
//OCC186
xi = PXPOINT(x, pwindow->xratio) ;
yi = PYPOINT(y, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
#ifdef BUC40223
if( Npoint > 0 ) {
int status;
status = Xw_clip_segment(pwindow,Lx,Ly,xi,yi,&segment);
if( status >= 0 ) {
if( (Npoint < 2) || (status & 0xF ) ) {
plinedesc->rpoints[ldesc].x = segment.x1 ;
plinedesc->rpoints[ldesc].y = segment.y1 ;
ldesc++; plinedesc->npoint++ ;
if( bindex > 0 ) {
int xx = segment.x1,yy = segment.y1;
pbuffer = &_BUFFER(bindex) ;
pbuffer->isempty = False ;
pbuffer->rxmin = min(pbuffer->rxmin,xx) ;
pbuffer->rymin = min(pbuffer->rymin,yy) ;
pbuffer->rxmax = max(pbuffer->rxmax,xx) ;
pbuffer->rymax = max(pbuffer->rymax,yy) ;
}
}
plinedesc->rpoints[ldesc].x = segment.x2 ;
plinedesc->rpoints[ldesc].y = segment.y2 ;
plinedesc->npoint++ ;
if( bindex > 0 ) {
int xx = segment.x2,yy = segment.y2;
pbuffer = &_BUFFER(bindex) ;
pbuffer->isempty = False ;
pbuffer->rxmin = min(pbuffer->rxmin,xx) ;
pbuffer->rymin = min(pbuffer->rymin,yy) ;
pbuffer->rxmax = max(pbuffer->rxmax,xx) ;
pbuffer->rymax = max(pbuffer->rymax,yy) ;
}
}
}
Lx = xi; Ly = yi;
Npoint++;
#else
plinedesc->rpoints[ldesc].x = xi ;
plinedesc->rpoints[ldesc].y = yi ;
plinedesc->npoint++ ;
if( bindex > 0 ) {
pbuffer = &_BUFFER(bindex) ;
pbuffer->isempty = False ;
pbuffer->rxmin = min(pbuffer->rxmin,xi) ;
pbuffer->rymin = min(pbuffer->rymin,yi) ;
pbuffer->rxmax = max(pbuffer->rxmax,xi) ;
pbuffer->rymax = max(pbuffer->rymax,yi) ;
}
#endif
}
#ifdef TRACE_DRAW_POLY
if( Xw_get_trace() > 3 ) {
printf(" Xw_poly_point(%lx,%f,%f)\n",(long ) pwindow,x,y) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_close_path (awindow):
XW_EXT_WINDOW *awindow
Close the Polygone path
returns ERROR if TOO many path
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_path(void* awindow)
#else
XW_STATUS Xw_close_path(awindow)
void *awindow ;
#endif /*XW_PROTOTYPE*/
{
#ifdef TRACE_DRAW_POLY
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
#endif
if( FirstPolyPoint >= 0 ) {
int npoly = ppolylist->npoly ;
int ldesc = plinedesc->npoint ;
if( plinedesc->rpoints[FirstPathPoint].x != plinedesc->rpoints[ldesc-1].x ||
plinedesc->rpoints[FirstPathPoint].y != plinedesc->rpoints[ldesc-1].y ) {
plinedesc->rpoints[ldesc].x = plinedesc->rpoints[FirstPathPoint].x ;
plinedesc->rpoints[ldesc].y = plinedesc->rpoints[FirstPathPoint].y ;
plinedesc->npoint++ ; ldesc++ ;
}
ppolylist->polys[FirstPolyLine] = ldesc - FirstPolyPoint ;
ppolylist->paths[npoly] = ldesc - FirstPathPoint ;
FirstPathPoint = ldesc;
if( ppolylist->npoly < MAXPOLYS ) {
ppolylist->npoly = ++npoly ;
ppolylist->polys[npoly] = 0 ;
ppolylist->paths[npoly] = Npoint = 0 ;
ppolylist->ppolys[npoly] = &plinedesc->rpoints[ldesc] ;
} else {
/*ERROR*Too many paths in POLYGONE*/
Xw_set_error(32,"Xw_close_path",&ppolylist->npoly) ;
return (XW_ERROR) ;
}
}
#ifdef TRACE_DRAW_POLY
if( Xw_get_trace() > 2 ) {
printf(" Xw_close_path(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_close_poly (awindow):
XW_EXT_WINDOW *awindow
Close the Polygone
returns ERROR if Polygone is empty
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_poly(void* awindow)
#else
XW_STATUS Xw_close_poly(awindow)
void *awindow ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
if( FirstPolyPoint >= 0 ) {
if( plinedesc->npoint > FirstPathPoint ) Xw_close_path(pwindow);
if( !_BINDEX ) {
int polyindex = pwindow->polyindex ;
int lineindex = pwindow->lineindex ;
GC gcpoly = (QGTILE(pwindow->qgpoly[polyindex].code)) ?
pwindow->qgpoly[polyindex].gc : NULL ;
GC gcline = (QGTYPE(pwindow->qgpoly[polyindex].code)) ?
pwindow->qgline[lineindex].gc : NULL ;
Xw_draw_pixel_polys(pwindow,ppolylist,gcpoly,gcline);
ppolylist->npoly = 0 ;
plinedesc->npoint = 0 ;
}
FirstPolyPoint = -1 ;
}
#ifdef TRACE_DRAW_POLY
if( Xw_get_trace() > 2 ) {
printf(" Xw_close_poly(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_POLY* Xw_add_polygone_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_POLY* Xw_add_polygone_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended polygone structure in the
polygone List
returns Extended polygone address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_POLY *ppoly ;
ppoly = (XW_EXT_POLY*) Xw_malloc(sizeof(XW_EXT_POLY)) ;
if( ppoly ) {
ppoly->link = pbuflist->ppolylist ;
ppoly->isupdated = False ;
ppoly->npoly = 0 ;
pbuflist->ppolylist = ppoly ;
} else {
/*ERROR*EXT_POLYGONE allocation failed*/
Xw_set_error(34,"Xw_add_polygone_structure",NULL) ;
}
return (ppoly) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_polygone_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_polygone_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended polygone structure in the
polygone List
SUCCESS always
*/
{
XW_EXT_POLY *ppoly,*qpoly ;
for( ppoly = pbuflist->ppolylist ; ppoly ; ppoly = qpoly ) {
qpoly = (XW_EXT_POLY*)ppoly->link ;
Xw_free(ppoly) ;
}
pbuflist->ppolylist = NULL ;
return (XW_SUCCESS) ;
}

309
src/Xw/Xw_draw_polyarc.cxx Executable file
View File

@@ -0,0 +1,309 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_POLYARC
#endif
/*
STATUS Xw_draw_polyarc (awindow,xc,yc,xradius,yradius,start,angle):
XW_EXT_WINDOW *awindow
float xc,yc Arc center defined in User Space
float xradius Horizontal arc radius defined in User Space
float xradius Vertical Arc radius defined in User Space
float start Start angle defined in RADIAN
float angle Arc angle defined in RADIAN
Display arc in current QG set by set_poly_attrib .
or retain arcs in buffer.
returns ERROR if bad parameter
returns SUCCESS if successfull
*/
#define MAXCOORD 32767
#define MINCOORD -32768
static int BeginArcs = False;
static XW_EXT_ARC *parclist ;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_polyarc (void* awindow,float xc,float yc,
float xradius,float yradius,float start,float angle)
#else
XW_STATUS Xw_draw_polyarc (awindow,xc,yc,xradius,yradius,start,angle)
void *awindow;
float xc,yc,xradius,yradius,start,angle ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) awindow ;
XW_EXT_BUFFER *pbuffer ;
int narc,bindex,angle1,angle2,x,y,width,height ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_polyarc",pwindow) ;
return (XW_ERROR) ;
}
if( xradius <= 0. ) {
/*ERROR*Bad arc radius*/
Xw_set_error(115,"Xw_draw_polyarc",&xradius) ;
return (XW_ERROR) ;
}
if( yradius <= 0. ) {
/*ERROR*Bad arc radius*/
Xw_set_error(115,"Xw_draw_polyarc",&yradius) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( parclist = pbuffer->pparclist ; parclist ;
parclist = (XW_EXT_ARC*) parclist->link ) {
if( parclist->narc < MAXARCS ) break ;
}
if( !parclist ) {
parclist = Xw_add_polyarc_structure(pbuffer) ;
}
if( !parclist ) return XW_ERROR ;
angle1 = (int )( start*64./DRAD );
if( angle1 > 0 ) {
while( angle1 > MAXANGLE ) angle1 -= MAXANGLE ;
} else if( angle1 < 0 ) {
while( angle1 < -MAXANGLE ) angle1 += MAXANGLE ;
}
angle2 = (int )( angle*64./DRAD );
if( angle2 > 0 ) {
while( angle2 > MAXANGLE ) angle2 -= MAXANGLE ;
} else if( angle2 < 0 ) {
while( angle2 < -MAXANGLE ) angle2 += MAXANGLE ;
}
//OCC186
width = 2*PVALUE(xradius, pwindow->xratio, pwindow->yratio) ;
height = 2*PVALUE(yradius, pwindow->xratio, pwindow->yratio) ;
x = PXPOINT(xc, pwindow->xratio) ;
y = PYPOINT(yc, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
x = max(min(x,MAXCOORD),MINCOORD);
y = max(min(y,MAXCOORD),MINCOORD);
if( width < 0xFFFF && height < 0xFFFF ) {
narc = parclist->narc ;
parclist->rarcs[narc].width = width ;
parclist->rarcs[narc].height = height ;
parclist->rarcs[narc].x = x - width/2 ;
parclist->rarcs[narc].y = y - height/2 ;
parclist->rarcs[narc].angle1 = angle1 ;
parclist->rarcs[narc].angle2 = angle2 ;
parclist->narc++ ;
if( bindex > 0 ) {
pbuffer->isempty = False ;
width = (width+1)/2 ;
height = (height+1)/2 ;
pbuffer->rxmin = min(pbuffer->rxmin,x-width) ;
pbuffer->rymin = min(pbuffer->rymin,y-height) ;
pbuffer->rxmax = max(pbuffer->rxmax,x+width) ;
pbuffer->rymax = max(pbuffer->rymax,y+height) ;
} else if( !BeginArcs ) {
int polyindex = pwindow->polyindex ;
int lineindex = pwindow->lineindex ;
GC gcpoly = pwindow->qgpoly[polyindex].gc ;
GC gcline = (QGTYPE(pwindow->qgpoly[polyindex].code)) ?
pwindow->qgline[lineindex].gc : NULL ;
Xw_draw_pixel_polyarcs(pwindow,parclist,gcpoly,gcline);
parclist->narc = 0 ;
}
} else {
/*ERROR*Too big arc radius*/
Xw_set_error(116,"Xw_draw_polyarc",0) ;
return (XW_ERROR) ;
}
#ifdef TRACE_DRAW_POLYARC
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_polyarc(%lx,%f,%f,%f,%f,%f,%f\n",
(long ) pwindow,xc,yc,xradius,yradius,start,angle);
}
#endif
return (XW_SUCCESS);
}
/*
STATUS Xw_begin_polyarcs (awindow,narc):
XW_EXT_WINDOW *awindow
int narc Not used
Begin a set of arcs which must be filled by Xw_draw_polyarc and
closed by Xw_close_polyarcs
returns ERROR if bad extended window address
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_begin_polyarcs(void* awindow,int narc)
#else
XW_STATUS Xw_begin_polyarcs(awindow,narc)
void *awindow ;
int narc ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_begin_polyarcs",pwindow) ;
return (XW_ERROR) ;
}
if( BeginArcs ) Xw_close_polyarcs(pwindow);
BeginArcs = True;
#ifdef TRACE_DRAW_POLYARC
if( Xw_get_trace() > 2 ) {
printf(" Xw_begin_polyarcs(%lx,%d)\n",(long ) pwindow,narc) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_close_polyarcs (awindow):
XW_EXT_WINDOW *awindow
Close the set of arcs
returns ERROR if bad extended window address
returns SUCCESS successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_polyarcs(void* awindow)
#else
XW_STATUS Xw_close_polyarcs(awindow)
void *awindow ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
int bindex ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_close_polyarcs",pwindow) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
if( BeginArcs && !bindex ) {
int polyindex = pwindow->polyindex ;
int lineindex = pwindow->lineindex ;
GC gcpoly = pwindow->qgpoly[polyindex].gc ;
GC gcline = (QGTYPE(pwindow->qgpoly[polyindex].code)) ?
pwindow->qgline[lineindex].gc : NULL ;
for( parclist = _BUFFER(bindex).pparclist ; parclist ;
parclist = (XW_EXT_ARC*) parclist->link ) {
if( parclist->narc > 0 ) {
Xw_draw_pixel_polyarcs(pwindow,parclist,gcpoly,gcline);
parclist->narc = 0 ;
} else break ;
}
}
BeginArcs = False;
#ifdef TRACE_DRAW_POLYARC
if( Xw_get_trace() > 2 ) {
printf(" Xw_close_polyarcs(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_polyarcs (XW_EXT_WINDOW* pwindow,XW_EXT_ARC* parclist,
GC gcpoly,GC gcline)
#else
void Xw_draw_pixel_polyarcs (pwindow,parclist,gcpoly,gcline)
XW_EXT_WINDOW *pwindow;
XW_EXT_ARC *parclist;
GC gcpoly,gcline;
#endif /*XW_PROTOTYPE*/
{
if( parclist->isupdated ) {
XFillArcs(_DISPLAY,_DRAWABLE,gcpoly,parclist->uarcs,parclist->narc) ;
if( gcline && (gcpoly != gcline) ) {
XDrawArcs(_DISPLAY,_DRAWABLE,gcline,parclist->uarcs,parclist->narc) ;
}
} else {
XFillArcs(_DISPLAY,_DRAWABLE,gcpoly,parclist->rarcs,parclist->narc) ;
if( gcline && (gcpoly != gcline) ) {
XDrawArcs(_DISPLAY,_DRAWABLE,gcline,parclist->rarcs,parclist->narc) ;
}
}
}
#ifdef XW_PROTOTYPE
XW_EXT_ARC* Xw_add_polyarc_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_ARC* Xw_add_polyarc_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended arc structure in the
arc List
returns Extended arc address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_ARC *parc ;
parc = (XW_EXT_ARC*) Xw_malloc(sizeof(XW_EXT_ARC)) ;
if( parc ) {
parc->link = pbuflist->pparclist ;
parc->isupdated = 0 ;
parc->narc = 0 ;
pbuflist->pparclist = parc ;
} else {
/*ERROR*EXT_ARC Allocation failed*/
Xw_set_error(35,"Xw_add_polyarc_structure",NULL) ;
}
return (parc) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_polyarc_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_polyarc_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended arc structure in the
arc List
SUCCESS always
*/
{
XW_EXT_ARC *parc,*qarc ;
for( parc = pbuflist->pparclist ; parc ; parc = qarc ) {
qarc = (XW_EXT_ARC*)parc->link ;
Xw_free(parc) ;
}
pbuflist->pparclist = NULL ;
return (XW_SUCCESS) ;
}

442
src/Xw/Xw_draw_polytext.cxx Executable file
View File

@@ -0,0 +1,442 @@
#define GG002 /*GG_020197
Renvoyer la hauteur du texte et non de la font
*/
#define GG010 /*GG_150197
Ameliorer la conformiter de l'underline vis a vis de WORLD
*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_POLYTEXT
#endif
/*
STATUS Xw_draw_polytext (awindow,x,y,text,angle,marge,mode):
XW_EXT_WINDOW *awindow
float x,y Position of the beginning of text in world coordinate
char text[] String to display
float angle Rotated text angle
float marge Margin text ratio
int mode 1 si outline
Display text in current QG set by set_text_attrib .
returns ERROR if text length > MAXCHARS
returns SUCCESS if successful
*/
#define MAXCOORD 32767
#define MINCOORD -32768
#define XROTATE(x,y) (x*cosa + y*sina)
#define YROTATE(x,y) (y*cosa - x*sina)
static XW_EXT_PTEXT *ptextlist ;
static XW_EXT_CHAR *ptextdesc ;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_polytext (void* awindow,float x,float y,
char* text,float angle,float marge,int mode)
#else
XW_STATUS Xw_draw_polytext (awindow,x,y,text,angle,marge,mode)
void *awindow;
float x,y ;
float angle ;
float marge ;
char *text ;
int mode ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_BUFFER *pbuffer ;
int ntext,nchar,length,bindex,ix,iy,textindex,textfont,texttype ;
XW_ATTRIB textcode;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_polytext",pwindow) ;
return (XW_ERROR) ;
}
if( marge < 0. || marge > 1. ) {
/*ERROR*Bad poly text margin*/
Xw_set_error(124,"Xw_draw_polytext",&marge) ;
return (XW_ERROR) ;
}
length = strlen(text) ;
if( length+1 > MAXCHARS ) {
length = MAXCHARS-1 ;
/*ERROR*Too big text string*/
Xw_set_error(38,"Xw_draw_polytext",&length) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( ptextlist = pbuffer->pptextlist ; ptextlist ;
ptextlist = (XW_EXT_PTEXT*)ptextlist->link ) {
if( ptextlist->ntext < MAXPTEXTS ) break ;
}
if( !ptextlist ) {
ptextlist = Xw_add_polytext_structure(pbuffer) ;
}
if( !ptextlist ) return XW_ERROR ;
for( ptextdesc = pbuffer->ptextdesc ; ptextdesc ;
ptextdesc = (XW_EXT_CHAR*)ptextdesc->link ) {
if( ptextdesc->nchar + length < MAXCHARS ) break ;
}
if( !ptextdesc ) {
ptextdesc = Xw_add_text_desc_structure(pbuffer) ;
}
if( !ptextdesc ) return XW_ERROR ;
//OCC186
ix = PXPOINT(x, pwindow->xratio) ;
iy = PYPOINT(y, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
ix = max(min(ix,MAXCOORD),MINCOORD);
iy = max(min(iy,MAXCOORD),MINCOORD);
textindex = pwindow->textindex ;
textcode = pwindow->qgtext[textindex].code ;
textfont = QGFONT(textcode);
texttype = QGTYPE(textcode);
if( mode ) texttype |= XW_EXTENDEDTEXT_OUTLINE ;
ntext = ptextlist->ntext ;
nchar = ptextdesc->nchar ;
ptextlist->modes[ntext] = texttype ;
ptextlist->texts[ntext] = length ;
ptextlist->ptexts[ntext] = &ptextdesc->chars[nchar] ;
ptextlist->rpoints[ntext].x = ix ;
ptextlist->rpoints[ntext].y = iy ;
ptextlist->rscalex[ntext] = 1. ;
ptextlist->rscaley[ntext] = 1. ;
ptextlist->slants[ntext] = 0. ;
strcpy(ptextlist->ptexts[ntext],text) ;
if( angle > 0. ) {
while( angle > 2.*PI ) angle -= 2.*PI ;
} else if( angle < 0. ) {
while( angle < -2.*PI ) angle += 2.*PI ;
}
ptextlist->rangles[ntext] = angle ;
ptextlist->marges[ntext] = marge ;
nchar += length+1 ;
ptextlist->ntext++ ;
ptextdesc->nchar = nchar ;
if( bindex > 0 ) {
int dm ;
XFontStruct *pfontinfo = _FONTMAP->fonts[textfont] ;
#ifdef GG002
int xmin,ymin,xmax,ymax,dir,fascent,fdescent;
XCharStruct overall;
XTextExtents(pfontinfo,text,length,
&dir,&fascent,&fdescent,&overall);
xmin = overall.lbearing;
xmax = overall.width;
ymin = -overall.ascent;
ymax = overall.descent;
#else
int xmin = 0 ;
int xmax = XTextWidth(pfontinfo,text,length) ;
int ymin = -pfontinfo->ascent ;
int ymax = pfontinfo->descent ;
#endif
dm = (int )( marge*(ymax-ymin)+0.5 );
xmin -= dm ; ymin -= dm ; xmax += dm ; ymax += dm ;
pbuffer->isempty = False ;
if( texttype & XW_EXTENDEDTEXT_UNDERLINE ) {
#ifdef GG010
if( _FONTMAP->fratios[textfont] <= 0. )
#endif
ymax += 2*max(2,(ymax-ymin)/8) ;
}
// if( abs(angle) > 0. ) {
if( fabs(angle) > 0. ) {
float cosa = cos((double)angle) ;
float sina = sin((double)angle) ;
int tx,ty ;
tx = (int )( ix + XROTATE(xmin,ymin) );
ty = (int )( iy + YROTATE(xmin,ymin) );
pbuffer->rxmin = min(pbuffer->rxmin,tx) ;
pbuffer->rymin = min(pbuffer->rymin,ty) ;
pbuffer->rxmax = max(pbuffer->rxmax,tx) ;
pbuffer->rymax = max(pbuffer->rymax,ty) ;
tx = (int )( ix + XROTATE(xmax,ymax) );
ty = (int )( iy + YROTATE(xmax,ymax) );
pbuffer->rxmin = min(pbuffer->rxmin,tx) ;
pbuffer->rymin = min(pbuffer->rymin,ty) ;
pbuffer->rxmax = max(pbuffer->rxmax,tx) ;
pbuffer->rymax = max(pbuffer->rymax,ty) ;
tx = (int )( ix + XROTATE(xmax,ymin) );
ty = (int )( iy + YROTATE(xmax,ymin) );
pbuffer->rxmin = min(pbuffer->rxmin,tx) ;
pbuffer->rymin = min(pbuffer->rymin,ty) ;
pbuffer->rxmax = max(pbuffer->rxmax,tx) ;
pbuffer->rymax = max(pbuffer->rymax,ty) ;
tx = (int )( ix + XROTATE(xmin,ymax) );
ty = (int )( iy + YROTATE(xmin,ymax) );
pbuffer->rxmin = min(pbuffer->rxmin,tx) ;
pbuffer->rymin = min(pbuffer->rymin,ty) ;
pbuffer->rxmax = max(pbuffer->rxmax,tx) ;
pbuffer->rymax = max(pbuffer->rymax,ty) ;
} else {
pbuffer->rxmin = min(pbuffer->rxmin,ix+xmin) ;
pbuffer->rymin = min(pbuffer->rymin,iy+ymin) ;
pbuffer->rxmax = max(pbuffer->rxmax,ix+xmax) ;
pbuffer->rymax = max(pbuffer->rymax,iy+ymax) ;
}
} else {
int polyindex = pwindow->polyindex ;
int lineindex = pwindow->lineindex ;
GC gctext = pwindow->qgtext[textindex].gc ;
GC gcpoly = (QGTILE(pwindow->qgpoly[polyindex].code)) ?
pwindow->qgpoly[polyindex].gc : NULL ;
GC gcline = (QGTYPE(pwindow->qgpoly[polyindex].code)) ?
pwindow->qgline[lineindex].gc : NULL ;
Xw_draw_pixel_polytexts(pwindow,ptextlist,
gctext,gcpoly,gcline,textcode) ;
ptextlist->ntext = 0 ;
ptextdesc->nchar = 0 ;
}
#ifdef TRACE_DRAW_POLYTEXT
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_polytext(%lx,%f,%f,'%s',%f,%f)\n",
(long ) pwindow,x,y,text,angle,marge) ;
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_polytexts(XW_EXT_WINDOW* pwindow,XW_EXT_PTEXT* ptextlist,
GC gctext,GC gcpoly,GC gcline,XW_ATTRIB code)
#else
void Xw_draw_pixel_polytexts(pwindow,ptextlist,gctext,gcpoly,gcline,code)
XW_EXT_WINDOW *pwindow ;
XW_EXT_PTEXT *ptextlist ;
GC gctext,gcpoly,gcline ;
XW_ATTRIB code ;
#endif /*XW_PROTOTYPE*/
{
int i,ix,iy,mode,length,font = QGFONT(code),type = QGTYPE(code) ;
float angle,marge,cosa,sina ;
char *pchar ;
XPoint points[5] ;
for( i=0 ; i<ptextlist->ntext ; i++ ) {
length = ptextlist->texts[i] ;
if( length <= 0 ) continue ;
if( ptextlist->isupdated ) {
ix = ptextlist->upoints[i].x ;
iy = ptextlist->upoints[i].y ;
angle = ptextlist->uangles[i] ;
} else {
ix = ptextlist->rpoints[i].x ;
iy = ptextlist->rpoints[i].y ;
angle = ptextlist->rangles[i] ;
}
mode = ptextlist->modes[i] ;
marge = ptextlist->marges[i] ;
pchar = ptextlist->ptexts[i] ;
if( type & XW_EXTENDEDTEXT_MINHEIGHT ) {
//OCC186
int rcx = max(4,PVALUE(FROMMILLIMETER(_FONTMAP->ssizex[font]),
pwindow->xratio, pwindow->yratio)/3);
int rcy = max(4,PVALUE(FROMMILLIMETER(_FONTMAP->ssizey[font]),
pwindow->xratio, pwindow->yratio)/3);
//OCC186
if( angle == 0. ) {
XFillArc(_DISPLAY,_DRAWABLE,gctext,
ix-rcx,iy-rcy,2*rcx,2*rcy,0,360*64) ;
} else {
int dx,dy ;
cosa = cos((double)angle) ;
sina = sin((double)angle) ;
dx = (int )( XROTATE(0,rcx) );
dy = (int )( YROTATE(0,rcy) );
XFillArc(_DISPLAY,_DRAWABLE,gctext,
ix-dx,iy-dy,2*rcx,2*rcy,0,360*64) ;
}
} else {
XFontStruct *pfontinfo = _FONTMAP->fonts[font] ;
int dm,du = 0;
#ifdef GG002
int xmin,ymin,xmax,ymax,dir,fascent,fdescent;
XCharStruct overall;
XTextExtents(pfontinfo,pchar,length,
&dir,&fascent,&fdescent,&overall);
xmin = overall.lbearing;
xmax = overall.width;
ymin = -overall.ascent;
ymax = overall.descent;
#else
int xmin = 0 ;
int xmax = XTextWidth(pfontinfo,pchar,length) ;
int ymin = -pfontinfo->ascent ;
int ymax = pfontinfo->descent ;
#endif
if( type & XW_EXTENDEDTEXT_UNDERLINE ) {
#ifdef GG010
if( _FONTMAP->fratios[font] > 0. ) {
//OCC186
du = PVALUE(0.6*_FONTMAP->fratios[font]*
FROMMILLIMETER(_FONTMAP->ssizey[font]),
pwindow->xratio, pwindow->yratio);
//OCC186
} else {
du = max(2,(ymax-ymin)/8) ;
ymax += 2*du ;
}
#else
du = max(2,(ymax-ymin)/8) ;
ymax += 2*du ;
#endif
}
dm = (int )( marge*(ymax-ymin)+0.5 );
xmin -= dm ; ymin -= dm ; xmax += dm ; ymax += dm ;
if( angle == 0. ) {
if( gcpoly ) {
XFillRectangle(_DISPLAY,_DRAWABLE,gcpoly,
ix+xmin,iy+ymin,xmax-xmin,ymax-ymin) ;
}
if( gcline && (gcline != gcpoly) ) {
XDrawRectangle(_DISPLAY,_DRAWABLE,gcline,
ix+xmin,iy+ymin,xmax-xmin,ymax-ymin) ;
}
if( type & XW_EXTENDEDTEXT_UNDERLINE ) {
#ifdef GG010
xmin += dm ; xmax -= dm ; ymax = du ;
#else
xmin += dm ; xmax -= dm ; ymax -= dm + du ;
#endif
XDrawLine(_DISPLAY,_DRAWABLE,gctext,
ix+xmin,iy+ymax,ix+xmax,iy+ymax) ;
}
XDrawString(_DISPLAY,_DRAWABLE,gctext,ix,iy,pchar,length) ;
} else {
int j,tx,ty,w ;
float dx,dy ;
XFontStruct *pfontinfo = _FONTMAP->fonts[font] ;
cosa = cos((double)angle) ;
sina = sin((double)angle) ;
dx = XROTATE(xmin,ymin) ;
dy = YROTATE(xmin,ymin) ;
points[0].x = ix + ROUND(dx) ;
points[0].y = iy + ROUND(dy) ;
dx = XROTATE(xmax,ymin) ;
dy = YROTATE(xmax,ymin) ;
points[1].x = ix + ROUND(dx) ;
points[1].y = iy + ROUND(dy) ;
dx = XROTATE(xmax,ymax) ;
dy = YROTATE(xmax,ymax) ;
points[2].x = ix + ROUND(dx) ;
points[2].y = iy + ROUND(dy) ;
dx = XROTATE(xmin,ymax) ;
dy = YROTATE(xmin,ymax) ;
points[3].x = ix + ROUND(dx) ;
points[3].y = iy + ROUND(dy) ;
points[4].x = points[0].x ;
points[4].y = points[0].y ;
if( gcpoly ) {
XFillPolygon(_DISPLAY,_DRAWABLE,gcpoly,points,4,
Convex,CoordModeOrigin) ;
}
if( gcline && (gcline != gcpoly) ) {
XDrawLines(_DISPLAY,_DRAWABLE,gcline,points,5,
CoordModeOrigin) ;
}
if( type & XW_EXTENDEDTEXT_UNDERLINE ) {
int x1,y1,x2,y2 ;
#ifdef GG010
xmin += dm ; xmax -= dm ; ymax = du ;
#else
xmin += dm ; xmax -= dm ; ymax -= dm + du ;
#endif
x1 = (int )( XROTATE(xmin,ymax) );
y1 = (int )( YROTATE(xmin,ymax) );
x2 = (int )( XROTATE(xmax,ymax) );
y2 = (int )( YROTATE(xmax,ymax) );
XDrawLine(_DISPLAY,_DRAWABLE,gctext,ix+x1,iy+y1,ix+x2,iy+y2) ; }
for( j=tx=ty=0 ; j<length ; j++ ) {
XDrawString(_DISPLAY,_DRAWABLE,gctext,
ix+tx,iy-ty,&pchar[j],1) ;
w = XTextWidth(pfontinfo,pchar,j);
tx = ROUND(w*cosa) ;
ty = ROUND(w*sina) ;
}
}
}
}
}
#ifdef XW_PROTOTYPE
XW_EXT_PTEXT* Xw_add_polytext_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_PTEXT* Xw_add_polytext_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended polytext structure in the
text List
returns Extended text address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_PTEXT *ptext ;
ptext = (XW_EXT_PTEXT*) Xw_malloc(sizeof(XW_EXT_PTEXT)) ;
if( ptext ) {
ptext->link = pbuflist->pptextlist ;
ptext->isupdated = 0 ;
ptext->ntext = 0 ;
pbuflist->pptextlist = ptext ;
} else {
/*ERROR*EXT_TEXT Allocation failed*/
Xw_set_error(39,"Xw_add_polytext_structure",NULL) ;
}
return (ptext) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_polytext_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_polytext_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended polytext structure in the
text List
SUCCESS always
*/
{
XW_EXT_PTEXT *ptext,*qtext ;
for( ptext = pbuflist->pptextlist ; ptext ; ptext = qtext ) {
qtext = (XW_EXT_PTEXT*)ptext->link ;
Xw_free(ptext) ;
}
pbuflist->pptextlist = NULL ;
return (XW_SUCCESS) ;
}

382
src/Xw/Xw_draw_segment.cxx Executable file
View File

@@ -0,0 +1,382 @@
#define S3593 /*GG_130398
OPTIMISATION MFT
Activer le clipping de maniere optionnelle
*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_SEGMENT
#endif
static XW_EXT_SEGMENT *pseglist ;
static int BeginSegments = False ;
/*
STATUS Xw_draw_segment (awindow,x1,y1,x2,y2):
XW_EXT_WINDOW *awindow
float x1,y1 First point Coordinates defined in User Space
float x2,y2 Second point Coordinates defined in User Space
Display segment in current QG set by set_line_attrib .
Note that segments can be buffered depending of the DisplayMode context
and Flush at Xw_flush time .
returns SUCCESS always
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_segment (void* awindow,float x1,float y1,float x2,float y2)
#else
XW_STATUS Xw_draw_segment (awindow,x1,y1,x2,y2)
void *awindow;
float x1,y1,x2,y2 ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_BUFFER *pbuffer ;
int status ;
int nseg,bindex;
int ix1,iy1,ix2,iy2 ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_segment",pwindow) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( pseglist = pbuffer->pseglist ; pseglist ;
pseglist = (XW_EXT_SEGMENT*)pseglist->link ) {
if( pseglist->nseg < MAXSEGMENTS ) break ;
}
if( !pseglist ) {
pseglist = Xw_add_segment_structure(pbuffer) ;
}
if( !pseglist ) return XW_ERROR ;
//OCC186
ix1 = PXPOINT(x1, pwindow->xratio) ;
iy1 = PYPOINT(y1, pwindow->attributes.height, pwindow->yratio) ;
ix2 = PXPOINT(x2, pwindow->xratio) ;
iy2 = PYPOINT(y2, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
nseg = pseglist->nseg ;
#ifdef S3593
if( pwindow->clipflag ) {
#endif
status = Xw_clip_segment(pwindow,ix1,iy1,ix2,iy2,
&pseglist->rsegments[nseg]);
if( status < 0 ) return (XW_SUCCESS);
#ifdef S3593
} else {
pseglist->rsegments[nseg].x1 = ix1 ;
pseglist->rsegments[nseg].y1 = iy1 ;
pseglist->rsegments[nseg].x2 = ix2 ;
pseglist->rsegments[nseg].y2 = iy2 ;
}
#endif
pseglist->nseg++ ;
if( bindex > 0 ) {
pbuffer->isempty = False ;
if( ix1 < ix2 ) {
pbuffer->rxmin = min(pbuffer->rxmin,ix1) ;
pbuffer->rxmax = max(pbuffer->rxmax,ix2) ;
} else {
pbuffer->rxmin = min(pbuffer->rxmin,ix2) ;
pbuffer->rxmax = max(pbuffer->rxmax,ix1) ;
}
if( iy1 < iy2 ) {
pbuffer->rymin = min(pbuffer->rymin,iy1) ;
pbuffer->rymax = max(pbuffer->rymax,iy2) ;
} else {
pbuffer->rymin = min(pbuffer->rymin,iy2) ;
pbuffer->rymax = max(pbuffer->rymax,iy1) ;
}
} else if( !BeginSegments ) {
int index = pwindow->lineindex ;
Xw_draw_pixel_segments(pwindow,pseglist,pwindow->qgline[index].gc) ;
pseglist->nseg = 0 ;
}
#ifdef TRACE_DRAW_SEGMENT
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_segment(%lx,%f,%f,%f,%f\n",(long ) pwindow,x1,y1,x2,y2) ;
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_segments(XW_EXT_WINDOW* pwindow,XW_EXT_SEGMENT *pseglist,GC gc)
#else
void Xw_draw_pixel_segments(pwindow,pseglist,gc)
XW_EXT_WINDOW *pwindow;
XW_EXT_SEGMENT *pseglist;
GC gc ;
#endif /*XW_PROTOTYPE*/
{
if( pseglist->isupdated ) {
XDrawSegments(_DISPLAY,_DRAWABLE,gc,
pseglist->usegments,pseglist->nseg) ;
} else {
XDrawSegments(_DISPLAY,_DRAWABLE,gc,
pseglist->rsegments,pseglist->nseg) ;
}
#ifdef TRACE_DRAW_SEGMENT
if( Xw_get_trace() > 2 ) {
printf(" %d = Xw_draw_pixel_segments(%lx,%lx,%lx\n",pseglist->nseg,(long ) pwindow,(long ) pseglist,(long ) gc) ;
}
#endif
}
/*
STATUS Xw_begin_segments (awindow,nsegment):
XW_EXT_WINDOW *awindow
int nsegment Not used
Begin a set of segments which must be filled by Xw_draw_segment and
closed by Xw_close_segments
returns ERROR if bad extended window address
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_begin_segments(void* awindow,int nsegment)
#else
XW_STATUS Xw_begin_segments(awindow,nsegment)
void *awindow ;
int nsegment ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_begin_segments",pwindow) ;
return (XW_ERROR) ;
}
if( BeginSegments ) Xw_close_segments(pwindow);
BeginSegments = True;
#ifdef TRACE_DRAW_LINE
if( Xw_get_trace() > 2 ) {
printf(" Xw_begin_segments(%x,%d)\n",pwindow,nsegment) ;
}
#endif
return (XW_SUCCESS) ;
}
/*
STATUS Xw_close_segments (awindow):
XW_EXT_WINDOW *awindow
Close the set of segments
returns ERROR if bad extended window address
returns SUCCESS successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_segments(void* awindow)
#else
XW_STATUS Xw_close_segments(awindow)
void *awindow ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
XW_EXT_BUFFER *pbuffer ;
int bindex ;
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
if( BeginSegments && !bindex ) {
int index = pwindow->lineindex ;
for( pseglist = pbuffer->pseglist ; pseglist ;
pseglist = (XW_EXT_SEGMENT*)pseglist->link ) {
if( pseglist->nseg ) {
Xw_draw_pixel_segments(pwindow,pseglist,
pwindow->qgline[index].gc) ;
pseglist->nseg = 0 ;
} else break ;
}
}
BeginSegments = False;
#ifdef TRACE_DRAW_SEGMENT
if( Xw_get_trace() > 2 ) {
printf(" Xw_close_segments(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_SEGMENT* Xw_add_segment_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_SEGMENT* Xw_add_segment_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended segment structure in the
segment List
returns Extended segment address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_SEGMENT *pseg ;
pseg = (XW_EXT_SEGMENT*) Xw_malloc(sizeof(XW_EXT_SEGMENT)) ;
if( pseg ) {
pseg->link = pbuflist->pseglist ;
pseg->isupdated = False ;
pseg->nseg = 0 ;
pbuflist->pseglist = pseg ;
} else {
/*ERROR*EXT_SEGMENT Allocation failed*/
Xw_set_error(35,"Xw_add_segment_structure",NULL) ;
}
return (pseg) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_segment_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_segment_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended segment structure in the
segment List
SUCCESS always
*/
{
XW_EXT_SEGMENT *pseg,*qseg ;
for( pseg = pbuflist->pseglist ; pseg ; pseg = qseg ) {
qseg = (XW_EXT_SEGMENT*)pseg->link ;
Xw_free(pseg) ;
}
pbuflist->pseglist = NULL ;
return (XW_SUCCESS) ;
}
#define MINXCOORD -32768
#define MAXXCOORD 32767
#define MINYCOORD -32768
#define MAXYCOORD 32767
#ifdef XW_PROTOTYPE
int Xw_clip_segment (XW_EXT_WINDOW* pwindow,int x1,int y1,int x2,int y2,XSegment* pseg)
#else
int Xw_clip_segment (pwindow,x1,y1,x2,y2,pseg)
XW_EXT_WINDOW *pwindow;
int x1,y1,x2,y2;
XSegment *pseg;
#endif /*XW_PROTOTYPE*/
/*
Clip a segment when one coord is < MINCOORD or > MAXCOORD.
Returns the clipped segment and a clip bit-mask status :
0 Nothing is clipped
1 X first point is clipped on MAX
2 X first point is clipped on MIN
4 Y first point is clipped on MAX
8 Y first point is clipped on MIN
16 X second point is clipped on MAX
32 X second point is clipped on MIN
64 Y second point is clipped on MAX
128 Y second point is clipped on MIN
-1 segment is out of space.
*/
{
int xx1 = x1,yy1 = y1,xx2 = x2,yy2 = y2;
int status = 0;
if( xx1 > MAXXCOORD ) {
if( xx2 < MAXXCOORD ) {
float rap = (float)(yy2 - yy1)/(xx2 - xx1);
yy1 += (int)((MAXXCOORD - xx1) * rap);
xx1 = MAXXCOORD;
status |= 1;
} else return -1;
} else if( xx1 < MINXCOORD ) {
if( xx2 > MINXCOORD ) {
float rap = (float)(yy2 - yy1)/(xx2 - xx1);
yy1 += (int)((MINXCOORD - xx1) * rap);
xx1 = MINXCOORD;
status |= 2;
} else return -1;
}
if( yy1 > MAXYCOORD ) {
if( yy2 < MAXYCOORD ) {
float rap = (float)(xx2 - xx1)/(yy2 - yy1);
xx1 += (int)((MAXYCOORD - yy1) * rap);
yy1 = MAXYCOORD;
status |= 4;
} else return -1;
} else if( yy1 < MINYCOORD ) {
if( yy2 > MINYCOORD ) {
float rap = (float)(xx2 - xx1)/(yy2 - yy1);
xx1 += (int)((MINYCOORD - yy1) * rap);
yy1 = MINYCOORD;
status |= 8;
} else return -1;
}
if( xx2 > MAXXCOORD ) {
float rap = (float)(yy2 - yy1)/(xx2 - xx1);
yy2 = yy1 + (int)((MAXXCOORD - xx1) * rap);
xx2 = MAXXCOORD;
status |= 16;
} else if( xx2 < MINXCOORD ) {
float rap = (float)(yy2 - yy1)/(xx2 - xx1);
yy2 = yy1 + (int)((MINXCOORD - xx1) * rap);
xx2 = MINXCOORD;
status |= 32;
}
if( yy2 > MAXYCOORD ) {
float rap = (float)(xx2 - xx1)/(yy2 - yy1);
xx2 = xx1 + (int)((MAXYCOORD - yy1) * rap);
yy2 = MAXYCOORD;
status |= 64;
} else if( yy2 < MINYCOORD ) {
float rap = (float)(xx2 - xx1)/(yy2 - yy1);
xx2 = xx1 + (int)((MINYCOORD - yy1) * rap);
yy2 = MINYCOORD;
status |= 128;
}
pseg->x1 = xx1;
pseg->y1 = yy1;
pseg->x2 = xx2;
pseg->y2 = yy2;
return status;
}

452
src/Xw/Xw_draw_text.cxx Executable file
View File

@@ -0,0 +1,452 @@
#define GG002 /*GG_020197
Renvoyer la hauteur du texte et non de la font
*/
#define GG010 /*GG_150197
Ameliorer la conformiter de l'underline vis a vis de WORLD
*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DRAW_TEXT
#endif
/*
STATUS Xw_draw_text (awindow,x,y,text,angle,mode):
XW_EXT_WINDOW *awindow
float x,y Position of the beginning of text in world coordinate
char text[] String to display
float angle Rotated text angle
mode 1 si outline
Display text in current QG set by set_text_attrib .
returns ERROR if text length > MAXCHARS
returns SUCCESS if successful
*/
#define MAXCOORD 32767
#define MINCOORD -32768
#define XROTATE(x,y) (x*cosa + y*sina)
#define YROTATE(x,y) (y*cosa - x*sina)
static XW_EXT_LTEXT *ptextlist ;
static XW_EXT_CHAR *ptextdesc ;
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_text (void* awindow,float x,float y,char* text,float angle,int mode)
#else
XW_STATUS Xw_draw_text (awindow,x,y,text,angle,mode)
void *awindow;
float x,y ;
float angle ;
char *text ;
int mode ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_BUFFER *pbuffer ;
int ntext,nchar,length,bindex,ix,iy,textindex,textfont,texttype ;
XW_ATTRIB textcode;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_draw_text",pwindow) ;
return (XW_ERROR) ;
}
length = strlen(text) ;
if( length+1 > MAXCHARS ) {
length = MAXCHARS-1 ;
/*ERROR*Too big text string*/
Xw_set_error(38,"Xw_draw_text",&length) ;
return (XW_ERROR) ;
}
bindex = _BINDEX ;
pbuffer = &_BUFFER(bindex) ;
for( ptextlist = pbuffer->pltextlist ; ptextlist ;
ptextlist = (XW_EXT_LTEXT*)ptextlist->link ) {
if( ptextlist->ntext < MAXLTEXTS ) break ;
}
if( !ptextlist ) {
ptextlist = Xw_add_text_structure(pbuffer) ;
}
if( !ptextlist ) return XW_ERROR ;
for( ptextdesc = pbuffer->ptextdesc ; ptextdesc ;
ptextdesc = (XW_EXT_CHAR*)ptextdesc->link ) {
if( ptextdesc->nchar + length < MAXCHARS ) break ;
}
if( !ptextdesc ) {
ptextdesc = Xw_add_text_desc_structure(pbuffer) ;
}
if( !ptextdesc ) return XW_ERROR ;
//OCC186
ix = PXPOINT(x, pwindow->xratio) ;
iy = PYPOINT(y, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
ix = max(min(ix,MAXCOORD),MINCOORD);
iy = max(min(iy,MAXCOORD),MINCOORD);
textindex = pwindow->textindex ;
textcode = pwindow->qgtext[textindex].code ;
textfont = QGFONT(textcode);
texttype = QGTYPE(textcode);
if( mode ) texttype |= XW_EXTENDEDTEXT_OUTLINE ;
ntext = ptextlist->ntext ;
nchar = ptextdesc->nchar ;
ptextlist->modes[ntext] = texttype ;
ptextlist->texts[ntext] = length ;
ptextlist->ptexts[ntext] = &ptextdesc->chars[nchar] ;
ptextlist->rpoints[ntext].x = ix ;
ptextlist->rpoints[ntext].y = iy ;
ptextlist->rscalex[ntext] = 1. ;
ptextlist->rscaley[ntext] = 1. ;
ptextlist->slants[ntext] = 0. ;
strcpy(ptextlist->ptexts[ntext],text) ;
if( angle > 0. ) {
while( angle > 2.*PI ) angle -= 2.*PI ;
} else if( angle < 0. ) {
while( angle < -2.*PI ) angle += 2.*PI ;
}
ptextlist->rangles[ntext] = angle ;
nchar += length+1 ;
ptextlist->ntext++ ;
ptextdesc->nchar = nchar ;
if( bindex > 0 ) {
XFontStruct *pfontinfo = _FONTMAP->fonts[textfont] ;
#ifdef GG002
int xmin,ymin,xmax,ymax,dir,fascent,fdescent;
XCharStruct overall;
XTextExtents(pfontinfo,text,length,
&dir,&fascent,&fdescent,&overall);
xmin = overall.lbearing;
xmax = overall.width;
ymin = -overall.ascent;
ymax = overall.descent;
#else
int xmin = 0 ;
int xmax = XTextWidth(pfontinfo,text,length) ;
int ymin = -pfontinfo->ascent ;
int ymax = pfontinfo->descent ;
#endif
pbuffer->isempty = False ;
if( texttype & XW_EXTENDEDTEXT_UNDERLINE ) {
#ifdef GG010
if( _FONTMAP->fratios[textfont] <= 0. )
#endif
ymax += 2*max(2,(ymax-ymin)/8) ;
}
// if( abs(angle) > 0. ) {
if( fabs(angle) > 0. ) {
float cosa = cos((double)angle) ;
float sina = sin((double)angle) ;
int tx,ty ;
tx = (int )( ix + XROTATE(xmin,ymin) );
ty = (int )( iy + YROTATE(xmin,ymin) );
pbuffer->rxmin = min(pbuffer->rxmin,tx) ;
pbuffer->rymin = min(pbuffer->rymin,ty) ;
pbuffer->rxmax = max(pbuffer->rxmax,tx) ;
pbuffer->rymax = max(pbuffer->rymax,ty) ;
tx = (int )( ix + XROTATE(xmax,ymax) );
ty = (int )( iy + YROTATE(xmax,ymax) );
pbuffer->rxmin = min(pbuffer->rxmin,tx) ;
pbuffer->rymin = min(pbuffer->rymin,ty) ;
pbuffer->rxmax = max(pbuffer->rxmax,tx) ;
pbuffer->rymax = max(pbuffer->rymax,ty) ;
tx = (int )( ix + XROTATE(xmax,ymin) );
ty = (int )( iy + YROTATE(xmax,ymin) );
pbuffer->rxmin = min(pbuffer->rxmin,tx) ;
pbuffer->rymin = min(pbuffer->rymin,ty) ;
pbuffer->rxmax = max(pbuffer->rxmax,tx) ;
pbuffer->rymax = max(pbuffer->rymax,ty) ;
tx = (int )( ix + XROTATE(xmin,ymax) );
ty = (int )( iy + YROTATE(xmin,ymax) );
pbuffer->rxmin = min(pbuffer->rxmin,tx) ;
pbuffer->rymin = min(pbuffer->rymin,ty) ;
pbuffer->rxmax = max(pbuffer->rxmax,tx) ;
pbuffer->rymax = max(pbuffer->rymax,ty) ;
} else {
pbuffer->rxmin = min(pbuffer->rxmin,ix+xmin) ;
pbuffer->rymin = min(pbuffer->rymin,iy+ymin) ;
pbuffer->rxmax = max(pbuffer->rxmax,ix+xmax) ;
pbuffer->rymax = max(pbuffer->rymax,iy+ymax) ;
}
} else {
int index = pwindow->textindex ;
Xw_draw_pixel_texts(pwindow,ptextlist,
pwindow->qgtext[index].gc,
pwindow->qgtext[index].code) ;
ptextlist->ntext = 0 ;
ptextdesc->nchar = 0 ;
}
#ifdef TRACE_DRAW_TEXT
if( Xw_get_trace() > 2 ) {
printf(" Xw_draw_text(%lx,%f,%f,'%s',%f)\n",(long ) pwindow,x,y,text,angle) ;
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
void Xw_draw_pixel_texts(XW_EXT_WINDOW* pwindow,XW_EXT_LTEXT* ptextlist,
GC gctext,XW_ATTRIB code)
#else
void Xw_draw_pixel_texts(pwindow,ptextlist,gctext,code)
XW_EXT_WINDOW *pwindow ;
XW_EXT_LTEXT *ptextlist ;
GC gctext ;
XW_ATTRIB code ;
#endif /*XW_PROTOTYPE*/
{
int i,ix,iy,mode,length,font = QGFONT(code),type = QGTYPE(code) ;
float angle,cosa,sina ;
char *pchar ;
for( i=0 ; i<ptextlist->ntext ; i++ ) {
length = ptextlist->texts[i] ;
if( length <= 0 ) continue ;
if( ptextlist->isupdated ) {
ix = ptextlist->upoints[i].x ;
iy = ptextlist->upoints[i].y ;
angle = ptextlist->uangles[i] ;
} else {
ix = ptextlist->rpoints[i].x ;
iy = ptextlist->rpoints[i].y ;
angle = ptextlist->rangles[i] ;
}
mode = ptextlist->modes[i] ;
pchar = ptextlist->ptexts[i] ;
if( type & XW_EXTENDEDTEXT_MINHEIGHT ) {
//OCC186
int rcx = max(4,PVALUE(FROMMILLIMETER(_FONTMAP->ssizex[font]),
pwindow->xratio, pwindow->yratio)/3);
int rcy = max(4,PVALUE(FROMMILLIMETER(_FONTMAP->ssizey[font]),
pwindow->xratio, pwindow->yratio)/3);
//OCC186
if( angle == 0. ) {
XFillArc(_DISPLAY,_DRAWABLE,gctext,
ix-rcx,iy-rcy,2*rcx,2*rcy,0,360*64) ;
} else {
int dx,dy ;
cosa = cos((double)angle) ;
sina = sin((double)angle) ;
dx = (int )( XROTATE(0,rcx) );
dy = (int )( YROTATE(0,rcy) );
XFillArc(_DISPLAY,_DRAWABLE,gctext,
ix-dx,iy-dy,2*rcx,2*rcy,0,360*64) ;
}
} else {
XFontStruct *pfontinfo = _FONTMAP->fonts[font] ;
int xmin,ymin,xmax,ymax ;
if( angle == 0. ) {
if( type & XW_EXTENDEDTEXT_UNDERLINE ) {
#ifdef GG002
int dir,fascent,fdescent;
XCharStruct overall;
XTextExtents(pfontinfo,pchar,length,
&dir,&fascent,&fdescent,&overall);
xmin = overall.lbearing;
xmax = overall.width;
ymin = -overall.ascent;
ymax = overall.descent;
#else
xmin = 0 ;
xmax = XTextWidth(pfontinfo,pchar,length) ;
ymin = -pfontinfo->ascent ;
ymax = pfontinfo->descent ;
#endif
#ifdef GG010
if( _FONTMAP->fratios[font] > 0. ) {
//OCC186
ymax = PVALUE(0.6*_FONTMAP->fratios[font]*
FROMMILLIMETER(_FONTMAP->ssizey[font]),
pwindow->xratio, pwindow->yratio);
//OCC186
} else {
ymax = max(2,(ymax-ymin)/8) ;
}
#else
ymax += max(2,(ymax-ymin)/8) ;
#endif
XDrawLine(_DISPLAY,_DRAWABLE,gctext,
ix+xmin,iy+ymax,ix+xmax,iy+ymax) ;
}
XDrawString(_DISPLAY,_DRAWABLE,gctext,ix,iy,pchar,length) ;
} else {
int w,j,tx,ty ;
cosa = cos((double)angle) ;
sina = sin((double)angle) ;
if( type & XW_EXTENDEDTEXT_UNDERLINE ) {
int x1,y1,x2,y2 ;
#ifdef GG002
int dir,fascent,fdescent;
XCharStruct overall;
XTextExtents(pfontinfo,pchar,length,
&dir,&fascent,&fdescent,&overall);
xmin = overall.lbearing;
xmax = overall.width;
ymin = -overall.ascent;
ymax = overall.descent;
#else
xmin = 0 ;
xmax = XTextWidth(pfontinfo,pchar,length) ;
ymin = -pfontinfo->ascent ;
ymax = pfontinfo->descent ;
#endif
#ifdef GG010
if( _FONTMAP->fratios[font] > 0. ) {
//OCC186
ymax = PVALUE(0.6*_FONTMAP->fratios[font]*
FROMMILLIMETER(_FONTMAP->ssizey[font]),
pwindow->xratio, pwindow->yratio);
//OCC186
} else {
ymax = max(2,(ymax-ymin)/8) ;
}
#else
ymax += max(2,(ymax-ymin)/8) ;
#endif
x1 = (int )( XROTATE(xmin,ymax) );
y1 = (int )( YROTATE(xmin,ymax) );
x2 = (int )( XROTATE(xmax,ymax) );
y2 = (int )( YROTATE(xmax,ymax) );
XDrawLine(_DISPLAY,_DRAWABLE,gctext,
ix+x1,iy+y1,ix+x2,iy+y2) ;
}
for( j=tx=ty=0 ; j<length ; j++) {
XDrawString(_DISPLAY,_DRAWABLE,gctext,
ix+tx,iy-ty,&pchar[j],1) ;
w = XTextWidth(pfontinfo,pchar,j);
tx = ROUND(w*cosa) ;
ty = ROUND(w*sina) ;
}
}
}
}
}
#ifdef XW_PROTOTYPE
XW_EXT_LTEXT* Xw_add_text_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_LTEXT* Xw_add_text_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended text structure in the
text List
returns Extended text address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_LTEXT *ptext ;
ptext = (XW_EXT_LTEXT*) Xw_malloc(sizeof(XW_EXT_LTEXT)) ;
if( ptext ) {
ptext->link = pbuflist->pltextlist ;
ptext->isupdated = False ;
ptext->ntext = 0 ;
pbuflist->pltextlist = ptext ;
} else {
/*ERROR*EXT_TEXT Allocation failed*/
Xw_set_error(39,"Xw_add_text_structure",NULL) ;
}
return (ptext) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_text_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_text_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended text structure in the
text List
SUCCESS always
*/
{
XW_EXT_LTEXT *ptext,*qtext ;
for( ptext = pbuflist->pltextlist ; ptext ; ptext = qtext ) {
qtext = (XW_EXT_LTEXT*)ptext->link ;
Xw_free(ptext) ;
}
pbuflist->pltextlist = NULL ;
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_CHAR* Xw_add_text_desc_structure(XW_EXT_BUFFER* pbuflist )
#else
XW_EXT_CHAR* Xw_add_text_desc_structure(pbuflist )
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert at end one Extended char structure in the
char List
returns Extended char address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_CHAR *pchar ;
pchar = (XW_EXT_CHAR*) Xw_malloc(sizeof(XW_EXT_CHAR)) ;
if( pchar ) {
pchar->link = pbuflist->ptextdesc ;
pchar->nchar = 0 ;
pbuflist->ptextdesc = pchar ;
} else {
/*ERROR*EXT_CHAR Allocation failed*/
Xw_set_error(118,"Xw_add_text_desc_structure",NULL) ;
}
return (pchar) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_text_desc_structure(XW_EXT_BUFFER* pbuflist)
#else
XW_STATUS Xw_del_text_desc_structure(pbuflist)
XW_EXT_BUFFER *pbuflist ;
#endif /*XW_PROTOTYPE*/
/*
Remove ALL Extended char structure in the
char List
SUCCESS always
*/
{
XW_EXT_CHAR *pchar,*qchar ;
for( pchar = pbuflist->ptextdesc ; pchar ; pchar = qchar ) {
qchar = (XW_EXT_CHAR*)pchar->link ;
Xw_free(pchar) ;
}
pbuflist->ptextdesc = NULL ;
return (XW_SUCCESS) ;
}

185
src/Xw/Xw_draw_zoomed_image.cxx Executable file
View File

@@ -0,0 +1,185 @@
#include <Xw_Extension.h>
#ifdef TRACE
# define TRACE_DRAW_ZOOMED_IMAGE
#endif
/*
STATUS Xw_draw_zoomed_image (awindow,aimage,xc,yc,zoom):
XW_EXT_WINDOW *awindow Drawable
XW_EXT_IMAGEDATA *aimage Image structure
float xc,yc Image center location in user space
float zoom Image zoom factor
Draw an image to the window at the required Center location
with required zoom factor.
returns ERROR if NO Image is defined or Image is outside of the window
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_draw_zoomed_image (void* awindow, void* aimage, float xc, float yc, float zoom)
#else
XW_STATUS Xw_draw_zoomed_image (awindow, aimage, xc, yc, zoom)
void *awindow;
void *aimage;
float xc, yc, zoom;
#endif // XW_PROTOTYPE
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_IMAGEDATA *pimage = (XW_EXT_IMAGEDATA*)aimage;
// XW_EXT_BUFFER *pbuffer;
XImage *pximage, *qximage;
int wWidth, wHeight, xC, yC, wp, hp, dxp, dyp, isize;
int x, y, xp, yp, xn, yn, xq, yq, nxC, nyC;
unsigned long pixel;
float ratio;
#ifdef TRACE_DRAW_ZOOMED_IMAGE
if (Xw_get_trace ())
printf ("Xw_draw_zoomed_image(%lx, %lx, xc=%f, yc=%f, zoom=%f)\n",(long ) pwindow,(long ) pimage,xc,yc,zoom);
#endif // TRACE_DRAW_ZOOMED_IMAGE
if (!Xw_isdefine_window(pwindow)) {
// ERROR*Bad EXT_WINDOW Address
Xw_set_error(24,"Xw_draw_zoomed_image",pwindow);
return (XW_ERROR);
}
if (!Xw_isdefine_image(pimage)) {
// ERROR*Bad EXT_IMAGEDATA Address
Xw_set_error(25,"Xw_draw_zoomed_image",pimage);
return (XW_ERROR);
}
if (zoom <= 0.) {
// ERROR*Bad Image Zoom factor
Xw_set_error(113,"Xw_draw_zoomed_image",&zoom) ;
return (XW_ERROR);
}
if (Xw_get_window_size(pwindow, &wWidth, &wHeight) != XW_SUCCESS) {
// ERROR*Get Window Size
printf (" ***Xw_draw_zoomed_image : BAD call to Xw_get_window_size()\n");
return (XW_ERROR);
}
printf ("\nXw_draw_zoomed_image info -> window size (%d x %d)\n", wWidth, wHeight);
//OCC186
xC = PXPOINT (xc, pwindow->xratio);
yC = PYPOINT (yc, pwindow->attributes.height, pwindow->yratio);
//OCC186
printf ("Xw_draw_zoomed_image info -> image center (%d, %d)\n", xC, yC);
pximage = pimage->pximage ;
qximage = (XImage*) Xw_malloc(sizeof(XImage));
if (!qximage) {
// ERROR*XImage Allocation failed
Xw_set_error (60, "Xw_draw_zoomed_image",NULL);
return (XW_ERROR);
}
Xw_bytecopy ((char*)pximage, (char*)qximage, sizeof(XImage));
wp = pximage->width;
hp = pximage->height;
dxp = dyp = 0;
ratio = (float) wp/hp;
qximage->width = (int )( wp * zoom );
qximage->height = (int )( hp * zoom );
nxC = wWidth / 2;
nyC = wHeight / 2;
if (qximage->width > wWidth || qximage->height > wHeight) {
// int rw = qximage->width, rh = qximage->height;
// Set new image size
#ifdef DEBUG
printf (" ***Xw_draw_zoomed_image (%f). Image size is too big (%d x %d)\n",zoom,qximage->width,qximage->height);
#endif
if (qximage->width > wWidth ) qximage->width = wWidth;
if (qximage->height > wHeight) qximage->height = wHeight;
#ifdef DEBUG
printf ("Xw_draw_zoomed_image info -> image will be truncated to (%d x %d)\n",qximage->width,qximage->height);
#endif
// Part of an original image to be zoomed (size of it)
wp = (int )( qximage->width / zoom + 1);
hp = (int )( qximage->height / zoom + 1);
// Offset inside the original image
dxp = (int )( (pximage->width - wp) / 2 - (xC - qximage->width / 2) / zoom );
dyp = (int )( (pximage->height - hp) / 2 - (yC - qximage->height / 2) / zoom );
// Correct image size, offset and center
if (dxp < 0) {
nxC -= (int )( dxp*zoom/2);
qximage->width += (int )( dxp*zoom);
dxp = 0;
} else if (dxp + wp > pximage->width) {
nxC -= (int )( (dxp + wp - pximage->width)*zoom/2);
qximage->width -= (int )( (dxp + wp - pximage->width)*zoom);
wp = pximage->width - dxp;
}
if (dyp < 0) {
nyC -= (int )( dyp*zoom/2);
qximage->height += (int )( dyp*zoom);
dyp = 0;
} else if (dyp + hp > pximage->height) {
nyC -= (int )( (dyp + hp - pximage->height)*zoom/2);
qximage->height -= (int )( (dyp + hp - pximage->height)*zoom);
hp = pximage->height - dyp;
}
#ifdef DEBUG
printf ("Xw_draw_zoomed_image info -> WP = %d, HP = %d\n", wp, hp);
printf ("Xw_draw_zoomed_image info -> DX = %d, DY = %d\n", dxp, dyp);
printf ("Xw_draw_zoomed_image info -> New point (%d, %d)\n", nxC, nyC);
printf ("Xw_draw_zoomed_image info -> final image size is (%d x %d)\n\n",qximage->width,qximage->height);
#endif
}
// Truncate image if it is visible (i.e. part of it)
if (qximage->width > 0. && qximage->height > 0.) {
qximage->bytes_per_line = qximage->width * (pximage->bitmap_pad/8);
isize = qximage->bytes_per_line * qximage->height;
qximage->data = (char*) Xw_malloc (isize);
if (!qximage->data) {
// ERROR*XImage Allocation failed
Xw_set_error (60,"Xw_draw_zoomed_image",NULL);
return (XW_ERROR);
}
// Zoom image
for (yp = yq = 0; yp < hp; yq = yn, yp++) {
yn = (int) ((yp+1)*zoom+0.5);
if (yn >= qximage->height) yn = qximage->height-1;
for (xp = xq = 0; xp < wp; xq = xn, xp++) {
xn = (int) ((xp+1)*zoom+0.5);
if (xn >= qximage->width) xn = qximage->width-1;
pixel = XGetPixel(pximage,xp+dxp,yp+dyp) ;
if (((xn-xq) > 1) || ((yn-yq) > 1)) {
for (y = yq; y < yn; y++)
for (x = xq; x < xn; x++)
XPutPixel (qximage, x, y, pixel);
} else {
XPutPixel (qximage, xq, yq, pixel);
}
}
}
if (_ZIMAGE && (_ZIMAGE != _IIMAGE))
XDestroyImage (_ZIMAGE);
_ZIMAGE = qximage;
pimage->zoom = zoom;
// Draw zoomed image at the new location
return Xw_draw_image (awindow, pimage, UXPOINT(nxC), UYPOINT(nyC));
}
return XW_SUCCESS;
}

91
src/Xw/Xw_erase_area.cxx Executable file
View File

@@ -0,0 +1,91 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_ERASE_AREA
#endif
/*
STATUS Xw_erase_area (awindow,px,py,pwidth,pheight)
XW_EXT_WINDOW *awindow
int px,py area center given in PIXELS
int pwidth,pheight area size given in PIXELS
Erase the attached Drawable area .
returns ERROR if NO attached pixmap exist or
area is out of window
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_erase_area (void* awindow,
int px,int py,int pwidth,int pheight)
#else
XW_STATUS Xw_erase_area (awindow,px,py,pwidth,pheight)
void *awindow;
int px,py,pwidth,pheight ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
int i ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_erase_area",pwindow) ;
return (XW_ERROR) ;
}
if( (px + pwidth/2) < 0 || (px - pwidth/2) > _WIDTH ||
(py + pheight/2) < 0 || (py - pheight/2) > _HEIGHT ) {
/*WARNING*Try to Erase outside the window*/
Xw_set_error(40,"Xw_erase_area",pwindow) ;
return (XW_ERROR) ;
}
px -= pwidth/2 ; py -= pheight/2 ;
if( _BPIXMAP ) {
XCopyArea(_DISPLAY,_BPIXMAP,_DRAWABLE,pwindow->qgwind.gccopy,
px,py,pwidth,pheight,px,py) ;
} else {
if( _DRAWABLE == _WINDOW ) {
XClearArea(_DISPLAY,_WINDOW,px,py,pwidth,pheight,False) ;
} else {
XFillRectangle(_DISPLAY,_DRAWABLE,pwindow->qgwind.gcclear,
px,py,pwidth,pheight) ;
}
}
for( i=1 ; i<MAXBUFFERS ; i++ ) {
if( _BUFFER(i).isdrawn ) {
int xmin,ymin,xmax,ymax ;
if( _BUFFER(i).isupdated ) {
xmin = _BUFFER(i).uxmin ;
ymin = _BUFFER(i).uymin ;
xmax = _BUFFER(i).uxmax ;
ymax = _BUFFER(i).uymax ;
} else {
xmin = _BUFFER(i).rxmin ;
ymin = _BUFFER(i).rymin ;
xmax = _BUFFER(i).rxmax ;
ymax = _BUFFER(i).rymax ;
}
if( xmax < px || xmin > px+pwidth ) continue ;
if( ymax < py || ymin > py+pheight ) continue ;
Xw_erase_buffer(pwindow,-i) ;
}
}
XFlush(_DISPLAY) ;
#ifdef TRACE_ERASE_AREA
if( Xw_get_trace() > 1 ) {
printf(" Xw_erase_area(%lx,%d,%d,%d,%d)\n",(long ) pwindow,px,py,pwidth,pheight);
}
#endif
return (XW_SUCCESS);
}

60
src/Xw/Xw_erase_window.cxx Executable file
View File

@@ -0,0 +1,60 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_ERASE_WINDOW
#endif
/*
STATUS Xw_erase_window (awindow)
XW_EXT_WINDOW *awindow
Erase the entire drawable.
returns SUCCESS always
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_erase_window (void* awindow)
#else
XW_STATUS Xw_erase_window (awindow)
void *awindow;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
int i ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_erase_window",pwindow) ;
return (XW_ERROR) ;
}
if( _BPIXMAP ) {
XCopyArea(_DISPLAY,_BPIXMAP,_DRAWABLE,pwindow->qgwind.gccopy,
0,0,_WIDTH,_HEIGHT,0,0) ;
} else {
if( _DRAWABLE == _WINDOW ) {
XClearWindow(_DISPLAY,_WINDOW) ;
} else {
XFillRectangle(_DISPLAY,_DRAWABLE,pwindow->qgwind.gcclear,
0,0,_WIDTH,_HEIGHT) ;
}
}
for( i=0 ; i<MAXBUFFERS ; i++ ) {
_BUFFER(i).isdrawn = False ;
}
XFlush(_DISPLAY) ;
#ifdef TRACE_ERASE_WINDOW
if( Xw_get_trace() > 1 ) {
printf(" Xw_erase_window(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS);
}

52
src/Xw/Xw_flush.cxx Executable file
View File

@@ -0,0 +1,52 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_FLUSH
#endif
/*
STATUS Xw_flush (awindow,synchro)
XW_EXT_WINDOW *awindow
Flush all primitives in the previous window .
Returns SUCCESS always
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_flush (void* awindow,int synchro)
#else
XW_STATUS Xw_flush (awindow,synchro)
void *awindow;
int synchro;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_flush",pwindow) ;
return (XW_ERROR) ;
}
if( synchro ) {
XSync(_DISPLAY,False) ;
} else {
XFlush(_DISPLAY) ;
}
if( (_DRAWABLE == _PIXMAP) || (_DRAWABLE == _BWBUFFER) )
Xw_restore_window (pwindow) ;
#ifdef TRACE_FLUSH
if( Xw_get_trace() ) {
printf (" Xw_flush(%lx)\n",(long ) pwindow) ;
}
#endif
return (XW_SUCCESS);
}

107
src/Xw/Xw_gamma_image.cxx Executable file
View File

@@ -0,0 +1,107 @@
// JR 01.02.100 : convert of float to int : (int )
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
# define TRACE_GAMMA_IMAGE
#endif
/*
XW_STATUS Xw_gamma_image (aimage,gamma):
XW_EXT_IMAGEDATA *aimage Image where apply the gamma correction
float gamma gamma value to apply (>0.)
Apply a GAMMA correction to an image
returns ERROR if bad gamma value
returns SUCCESS if successfull
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_gamma_image (void* aimage,float gamma)
#else
XW_STATUS Xw_gamma_image (aimage,gamma)
void *aimage;
float gamma ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_IMAGEDATA *pimage = (XW_EXT_IMAGEDATA*)aimage ;
XImage *pximage;
int wp,hp,xp,yp,ired,igreen,iblue;
unsigned long cmask,npixel,gpixel = 0,opixel = 0;
int sred,sgreen,sblue ;
float red,green,blue ;
if( !Xw_isdefine_image(pimage) ) {
/*ERROR*Bad EXT_IMAGE Address*/
Xw_set_error(25,"Xw_gamma_image",pimage) ;
return (XW_ERROR) ;
}
if( gamma <= 0. ) {
/*ERROR*Bad Image GAMMA value*/
return (XW_ERROR) ;
}
if( gamma == 1.0 ) return XW_SUCCESS;
pximage = pimage->pximage;
if( !pximage->red_mask || !pximage->green_mask || !pximage->blue_mask ) {
printf(" *** Xw_gamma_image.Cann't apply the gamma correction to this image\n");
return (XW_ERROR) ;
}
gamma = 1./gamma;
wp = pximage->width; hp = pximage->height;
sred = sgreen = sblue = 0 ;
cmask = pximage->red_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sred++ ; }
cmask = pximage->green_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sgreen++ ; }
cmask = pximage->blue_mask ;
while ( !(cmask & 1) ) { cmask >>= 1 ; sblue++ ; }
for( yp=0 ; yp<hp ; yp++ ) {
for( xp=0 ; xp<wp ; xp++ ) {
npixel = XGetPixel(pximage,xp,yp) ;
if( npixel != opixel ) {
opixel = npixel;
ired = (npixel >> sred) & cmask;
igreen = (npixel >> sgreen) & cmask;
iblue = (npixel >> sblue) & cmask;
red = (float)(ired)/(float)cmask;
green = (float)(igreen)/(float)cmask;
blue = (float)(iblue)/(float)cmask;
red = min(1.,pow(double(red),double(gamma)));
green = min(1.,pow(double(green),double(gamma)));
blue = min(1.,pow(double(blue),double(gamma)));
ired = (int )( red * cmask);
igreen = (int )( green * cmask);
iblue = (int )( blue * cmask);
gpixel = (ired << sred) | (igreen << sgreen) | (iblue << sblue);
/*
printf(" npixel %ld gpixel %ld cmask %ld sred %d sgreen %d sblue %d\n",
npixel,gpixel,cmask,sred,sgreen,sblue);
*/
}
XPutPixel(pximage,xp,yp,gpixel) ;
}
}
#ifdef TRACE_GAMMA_IMAGE
if( Xw_get_trace() ) {
printf (" Xw_gamma_image(%lx,%f)\n",(long ) pimage,gamma);
}
#endif
return (XW_SUCCESS);
}

View File

@@ -0,0 +1,63 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_BACKGROUND_COLOR
#endif
/*
STATUS Xw_get_background_color(awindow,r,g,b):
XW_EXT_WINDOW *awindow Window extension structure
float *r,*g,*b ; Return Red,Green,Blue color value 0. >= x <= 1.
Get R,G,B Background Color values from Default index .
Returns ERROR if Extended Window Address is badly defined
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_background_color (void* awindow,float* r,float* g,float* b)
#else
XW_STATUS Xw_get_background_color (awindow,r,g,b)
void *awindow;
float *r,*g,*b ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
unsigned long pixel;
if ( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXTENDED Window ADDRESS*/
Xw_set_error(24,"Xw_get_background_color",pwindow) ;
return (XW_ERROR) ;
}
if( pwindow->backindex >= 0 ) {
switch ( _CLASS ) {
case PseudoColor :
case StaticColor :
case TrueColor :
Xw_get_color (_COLORMAP,pwindow->backindex,r,g,b,&pixel) ;
break ;
default :
/*Unmatchable Visual class*/
Xw_set_error(67,"Xw_get_background_color",&_CLASS) ;
return (XW_ERROR) ;
}
} else {
*r = *g = *b = 1. ;
}
#ifdef TRACE_GET_BACKGROUND_COLOR
if( Xw_get_trace() ) {
printf(" Xw_get_background_color(%lx,%f,%f,%f)\n",(long ) pwindow,*r,*g,*b) ;
}
#endif
return (XW_SUCCESS);
}

View File

@@ -0,0 +1,103 @@
/*
// GG IMP060200 Xw_get_background_image signatuire change
*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_BACKGROUND_IMAGE
#endif
/*
XW_STATUS Xw_get_background_image (awindow,xc,yc,width,height):
XW_EXT_WINDOW *awindow
int xc,yc Image center location in pixels
int width,height Image size in pixels
Get the window Background from the actual Window
at the required Center location
returns ERROR if Image is outside of the window
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_background_image (void* awindow,
int xc,int yc,int width,int height)
#else
XW_STATUS Xw_get_background_image (awindow,xc,yc,width,height)
void *awindow;
int xc,yc ;
int width,height ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_DISPLAY *pdisplay = pwindow->connexion ;
XW_STATUS status ;
XImage *pimage ;
int wx,wy ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_get_background_image",pwindow) ;
return (XW_ERROR) ;
}
wx = xc - width/2 ;
wy = yc - height/2 ;
if( _DGRAB ) {
wx += _X ; wy += _Y ;
if( (wx + width) < 0 || wx > _DWIDTH ||
(wy + height) < 0 || wy > _DHEIGHT ) {
/*WARNING*Try to Get Image from outside the display*/
Xw_set_error(45,"Xw_get_background_image",0) ;
return (XW_ERROR) ;
}
pimage = XGetImage(_DISPLAY,_DROOT,wx,wy,
width,height,AllPlanes,ZPixmap) ;
} else {
if( (wx + width) < 0 || wx > _WIDTH ||
(wy + height) < 0 || wy > _HEIGHT ) {
/*WARNING*Try to Get Image from outside the window*/
Xw_set_error(45,"Xw_get_background_image",0) ;
return (XW_ERROR) ;
}
pimage = XGetImage(_DISPLAY,_WINDOW,wx,wy,
width,height,AllPlanes,ZPixmap) ;
}
if( _BPIXMAP ) Xw_close_background_pixmap(pwindow) ;
if( _PIXMAP || _NWBUFFER > 0 ) {
status = Xw_open_background_pixmap(pwindow) ;
if( !status ) return (XW_ERROR) ;
for( wx=0 ; wx<_WIDTH ; wx += width ) {
for( wy=0 ; wy<_HEIGHT ; wy += height ) {
XPutImage(_DISPLAY,_BPIXMAP,pwindow->qgwind.gccopy,
pimage,0,0,wx,wy,width,height) ;
}
}
} else {
Pixmap pixmap = XCreatePixmap(_DISPLAY,_WINDOW,
width,height,_DEPTH);
if( !pixmap ) return (XW_ERROR) ;
XPutImage(_DISPLAY,pixmap,pwindow->qgwind.gccopy,
pimage,0,0,wx,wy,width,height) ;
XSetWindowBackgroundPixmap(_DISPLAY,_WINDOW,pixmap) ;
XFlush(_DISPLAY) ;
XFreePixmap(_DISPLAY,pixmap) ;
}
Xw_erase_window(pwindow) ;
#ifdef TRACE_GET_BACKGROUND_IMAGE
if( Xw_get_trace() ) {
printf (" Xw_get_background_image(%lx,%d,%d,%d,%d)\n",
(long ) pwindow,xc,yc,width,height);
}
#endif
return (XW_SUCCESS);
}

View File

@@ -0,0 +1,46 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_BACKGROUND_INDEX
#endif
/*
STATUS Xw_get_background_index(awindow,index):
XW_EXT_WINDOW *awindow Window extension structure
int *index ; Returned index
Gets current background index.
Returns ERROR if Extended Window Address is badly defined
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_background_index (void* awindow,int* index)
#else
XW_STATUS Xw_get_background_index (awindow,index)
void *awindow;
int *index ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
if ( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXTENDED Window ADDRESS*/
Xw_set_error(24,"Xw_get_background_index",pwindow) ;
return (XW_ERROR) ;
}
*index = pwindow->backindex ;
#ifdef TRACE_GET_BACKGROUND_INDEX
if( Xw_get_trace() ) {
printf(" Xw_get_background_index(%lx,%d)\n",(long ) pwindow,*index) ;
}
#endif
return (XW_SUCCESS);
}

View File

@@ -0,0 +1,53 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_BACKGROUND_PIXEL
#endif
/*
STATUS Xw_get_background_pixel(awindow,pixel):
XW_EXT_WINDOW *awindow Window extension structure
unsigned long *pixel ; Return Color pixel depending of Visual Class
Returns ERROR if Window or background pixel is not defined properly
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_background_pixel(void* awindow, unsigned long* pixel)
#else
XW_STATUS Xw_get_background_pixel(awindow,pixel)
void *awindow ;
unsigned long *pixel ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
XW_STATUS status = XW_SUCCESS ;
*pixel = 0;
if( !pwindow ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error( 24,"Xw_get_background_pixel",pwindow ) ;
return( XW_ERROR ) ;
}
if( pwindow->backindex < 0 ) {
*pixel = _COLORMAP->backpixel;
} else if( Xw_isdefine_color(_COLORMAP,pwindow->backindex) ) {
*pixel = _COLORMAP->pixels[pwindow->backindex];
} else {
status = XW_ERROR;
}
#ifdef TRACE_GET_BACKGROUND_PIXEL
if( Xw_get_trace() > 3 ) {
printf(" %d = Xw_get_background_pixel(%lx,%lx)\n",
status,(long ) pwindow,*pixel) ;
}
#endif
return( status ) ;
}

96
src/Xw/Xw_get_color.cxx Executable file
View File

@@ -0,0 +1,96 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_COLOR
#endif
/*
STATUS Xw_get_color(acolormap,index,r,g,b,pixel):
XW_EXT_COLORMAP *acolormap Colormap extension structure
int index ; Color index 0 >= x < MAXCOLOR
float *r,*g,*b ; Return Red,Green,Blue color value 0. >= x <= 1.
unsigned long *pixel ;
Get R,G,B Color values from index .
Returns ERROR if BadColor Index or color is not defined
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_color (void* acolormap,int index,float* r,float* g,float* b,unsigned long *pixel)
#else
XW_STATUS Xw_get_color (acolormap,index,r,g,b,pixel)
void *acolormap;
int index ;
float *r,*g,*b ;
unsigned long *pixel ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
XColor color ;
*pixel = 0;
*r = *g = *b = 0.;
if ( !Xw_isdefine_colorindex(pcolormap,index) ) {
/*ERROR*Bad color Index*/
Xw_set_error(1,"Xw_get_color",&index) ;
return (XW_ERROR) ;
}
switch ( _CCLASS ) {
case PseudoColor :
case StaticColor :
color.pixel = pcolormap->pixels[index] ;
XQueryColor(_CDISPLAY,_CINFO.colormap,&color) ;
*r = (float)color.red/0xFFFF ;
*g = (float)color.green/0xFFFF ;
*b = (float)color.blue/0xFFFF ;
break ;
case TrueColor :
{ unsigned long mask = _CVISUAL->map_entries-1 ;
unsigned long red,green,blue ;
unsigned long rmask = _CVISUAL->red_mask ;
unsigned long gmask = _CVISUAL->green_mask ;
unsigned long bmask = _CVISUAL->blue_mask ;
color.pixel = pcolormap->pixels[index] ;
red = color.pixel & rmask ;
while ( !(rmask & 0x01) ) { rmask >>= 1; red >>= 1; }
green = color.pixel & gmask ;
while ( !(gmask & 0x01) ) { gmask >>= 1; green >>= 1; }
blue = color.pixel & bmask ;
while ( !(bmask & 0x01) ) { bmask >>= 1; blue >>= 1; }
*r = (float)red/mask ;
*g = (float)green/mask ;
*b = (float)blue/mask ;
}
break ;
default :
/*Unmatchable Visual class*/
Xw_set_error(67,"Xw_get_color",&_CCLASS) ;
return (XW_ERROR) ;
}
*pixel = color.pixel ;
#ifdef TRACE_GET_COLOR
if( Xw_get_trace() > 1 ) {
printf(" Xw_get_color(%lx,%d,%f,%f,%f,%lx)\n",(long ) pcolormap,index,*r,*g,*b,*pixel) ;
}
#endif
return (XW_SUCCESS);
}

308
src/Xw/Xw_get_color_index.cxx Executable file
View File

@@ -0,0 +1,308 @@
#define PRO9517 /*GG_280897
// Ameliorer le critere de comparaison de 2 couleurs
// sinon ROUGE = VERT = BLEU !!!
*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_COLOR_INDEX
#endif
/*
STATUS Xw_get_color_index(acolormap,r,g,b,index):
XW_EXT_COLORMAP *acolormap Colormap extension structure
float r,g,b ; Red,Green,Blue color value 0. >= x <= 1.
int *index ; Return Color index 0 >= x < MAXCOLOR
Gets the nearest color index from R,G,B Color values.
Returns ERROR if BadColor Index or color is not defined
Returns SUCCESS if Successful
*/
#define XTEST 1
#ifdef TEST /* Optim. No more necessary with XQueryColors() */
#define MAX_COLRS 256
static int indice = 0;
static int indice_max = 0;
static XW_EXT_COLORMAP *qcolormap = NULL;
static float tab_ind[MAX_COLRS][4];
#endif
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_color_index(void* acolormap,float r,float g,float b,int* index)
#else
XW_STATUS Xw_get_color_index(acolormap,r,g,b,index)
void *acolormap ;
float r,g,b ;
int *index ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ;
XW_STATUS status = XW_ERROR ;
XColor colors[MAXCOLOR] ;
int color_indexs[MAXCOLOR] ;
register int i,j,n ;
int curind = -1,freeind = -1,isapproximate ;
#ifdef PRO9517
int drmin,dgmin,dbmin;
#else
float curdist,newdist ;
float dr,dg,db ;
#endif
if( !pcolormap ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error( 42,"Xw_get_color_index",pcolormap ) ;
return( XW_ERROR ) ;
}
if( _CCLASS != TrueColor ) {
if( pcolormap->mapping == Xw_TOM_COLORCUBE ) {
if( (_CGINFO.red_mult > 0) && (fabs(r-g) < 0.01) && (fabs(r-b) < 0.01) ) {
curind = (int)(0.5+r*_CGINFO.red_max)*_CGINFO.red_mult;
if( _CINFO.red_max > 0 ) curind += (_CINFO.red_max+1)*(_CINFO.green_max+1)*(_CINFO.blue_max+1);
} else if( _CINFO.red_mult > 0 ) {
curind = ((int)(0.5+r*_CINFO.red_max))*_CINFO.red_mult+
((int)(0.5+g*_CINFO.green_max))*_CINFO.green_mult+
((int)(0.5+b*_CINFO.blue_max))*_CINFO.blue_mult;
} else if( _CGINFO.red_mult > 0 ) {
float l = (r+g+b)/3.;
curind = (int)(0.5+l*_CGINFO.red_max)*_CGINFO.red_mult;
} else {
curind = 0;
}
if( pcolormap->pixels[curind] == curind +_CINFO.base_pixel )
status = XW_SUCCESS ;
else curind = -1 ;
}
}
if( curind < 0 ) {
#ifdef TEST
if (pcolormap != qcolormap) {
for (i=0; i<MAX_COLRS; i++) tab_ind[i][0] = -1.;
qcolormap = pcolormap;
indice_max = 0;
indice = 0;
}
for (i=0; i<indice_max; i++) {
if ( tab_ind[i][0] >= 0. ) {
if ((tab_ind[i][1] == r) &&
(tab_ind[i][2] == g) &&
(tab_ind[i][3] == b)) {
*index = curind = (int) tab_ind[i][0];
status = XW_SUCCESS;
#ifdef TRACE_GET_COLOR_INDEX
if( Xw_get_trace() > 3 ) {
printf(" %d = Xw_get_color_index(%x,%f,%f,%f,=%d/0x%x)\n",
status,pcolormap,r,g,b,curind,pcolormap->pixels[curind]) ;
}
#endif
return (status);
}
}
}
#endif
#ifdef PRO9517
drmin = dgmin = dbmin = 65536;
#else
newdist = 4.0 ;
curdist = 4.0 ;
#endif
curind = -1 ;
for( i=n=0 ; i<pcolormap->maxcolor ; i++ ) {
if( Xw_isdefine_color( pcolormap,i ) == XW_SUCCESS ) {
if( n < pcolormap->maxhcolor ) {
colors[n].pixel = pcolormap->pixels[i];
color_indexs[n] = i;
n++;
} else {
for( j=0 ; j<n ; j++ ) {
if( colors[j].pixel == pcolormap->pixels[i] ) break;
}
if( j >= n ) {
/* Too many entrys in the virtual colormap */
Xw_set_error(129,"Xw_get_color_index",pcolormap ) ;
}
}
} else {
if( freeind < 0 ) freeind = i ;
}
}
if( _CCLASS != TrueColor ) {
if( n > 0 ) {
XQueryColors(_CDISPLAY,_CINFO.colormap,colors,n) ;
#ifdef PRO9517
{
unsigned long rred = (long unsigned int )( r * 0xFFFF);
unsigned long rgreen = (long unsigned int )( g * 0xFFFF);
unsigned long rblue = (long unsigned int )( b * 0xFFFF);
int dr,dg,db;
for( i=0 ; i<n ; i++ ){
//#if defined(_AIX) || defined(__hpux)
int aLocalInt = rred - colors[i].red ; dr = abs( aLocalInt ) >> 8;
aLocalInt = rgreen - colors[i].green ; dg = abs( aLocalInt ) >> 8;
aLocalInt = rblue - colors[i].blue ; db = abs( aLocalInt ) >> 8;
//#else
// dr = abs( rred - colors[i].red ) >> 8;
// dg = abs( rgreen - colors[i].green ) >> 8;
// db = abs( rblue - colors[i].blue ) >> 8;
//#endif
if( (dr <= drmin) && (dg <= dgmin) && (db <= dbmin) ) {
drmin = dr; dgmin = dg; dbmin = db;
curind = color_indexs[i];
if( !dr && !dg && !db ) break;
}
}
}
#else
for( i=0 ; ((i<n) && (newdist != 0.0)) ; i++ ){
dr = (float)colors[i].red/0xFFFF - r ;
dg = (float)colors[i].green/0xFFFF - g ;
db = (float)colors[i].blue/0xFFFF - b ;
newdist = dr*dr + dg*dg + db*db ;
if( newdist < curdist ) {
curind = color_indexs[i] ;
curdist = newdist ;
}
}
#endif
}
} else {
if( n > 0 ) {
// unsigned long mask = _CVISUAL->map_entries-1 ;
unsigned long red,green,blue,rmask,gmask,bmask ;
#ifdef PRO9517
{
unsigned long rred = (long unsigned int )( r * (1 << _CVISUAL->bits_per_rgb) - 1);
unsigned long rgreen = (long unsigned int )( g * (1 << _CVISUAL->bits_per_rgb) - 1);
unsigned long rblue = (long unsigned int )( b * (1 << _CVISUAL->bits_per_rgb) - 1);
int dr,dg,db;
for( i=0 ; i<n ; i++ ){
rmask = _CVISUAL->red_mask;
red = colors[i].pixel & rmask ;
while ( !(rmask & 0x01) ) { rmask >>= 1; red >>= 1; }
gmask = _CVISUAL->green_mask;
green = colors[i].pixel & gmask ;
while ( !(gmask & 0x01) ) { gmask >>= 1; green >>= 1; }
bmask = _CVISUAL->blue_mask;
blue = colors[i].pixel & bmask ;
while ( !(bmask & 0x01) ) { bmask >>= 1; blue >>= 1; }
//#if defined(_AIX) || defined(__hpux)
int aLocalInt = rred - red ; dr = abs(aLocalInt);
aLocalInt = rgreen - green ; dg = abs(aLocalInt);
aLocalInt = rblue - blue ; db = abs(aLocalInt);
//#else
// dr = abs( rred - red );
// dg = abs( rgreen - green );
// db = abs( rblue - blue );
//#endif
if( (dr <= drmin) && (dg <= dgmin) && (db <= dbmin) ) {
drmin = dr; dgmin = dg; dbmin = db;
curind = color_indexs[i];
if( !dr && !dg && !db ) break;
}
}
}
#else
for( i=0 ; ((i<n) && (newdist != 0.0)) ; i++ ){
rmask = _CVISUAL->red_mask;
red = colors[i].pixel & rmask ;
while ( !(rmask & 0x01) ) { rmask >>= 1; red >>= 1; }
gmask = _CVISUAL->green_mask;
green = colors[i].pixel & gmask ;
while ( !(gmask & 0x01) ) { gmask >>= 1; green >>= 1; }
bmask = _CVISUAL->blue_mask;
blue = colors[i].pixel & bmask ;
while ( !(bmask & 0x01) ) { bmask >>= 1; blue >>= 1; }
dr = (float)red/mask - r ;
dg = (float)green/mask - g ;
db = (float)blue/mask - b ;
newdist = dr*dr + dg*dg + db*db ;
if( newdist < curdist ) {
curind = color_indexs[i] ;
curdist = newdist ;
}
}
#endif
}
}
#ifdef PRO9517
if( drmin > 0 || dgmin > 0 || dbmin > 0 ) {
#else
if( curdist > 0.0 ) {
#endif
if( freeind < 0 ) {
unsigned long pixel;
if( Xw_alloc_color(pcolormap,r,g,b,&pixel,&isapproximate) ) {
for( i=0 ; i<pcolormap->maxcolor ; i++ ) {
if( pixel == pcolormap->pixels[i] ) break;
}
if( i < pcolormap->maxcolor ) {
curind = i;
}
}
} else {
if( Xw_def_color(pcolormap,freeind,r,g,b) ) {
curind = freeind ;
}
}
}
if( curind >= 0 ) {
status = XW_SUCCESS ;
#ifdef TEST
tab_ind[indice][0] = curind ;
tab_ind[indice][1] = r ;
tab_ind[indice][2] = g ;
tab_ind[indice][3] = b ;
/*
* Une fois que le tableau est plein, il faut le
* parcourir completement, donc on ne touche plus
* a indice_max.
*/
indice ++ ;
if( indice < MAX_COLRS ) {
indice_max = max(indice_max,indice);
} else {
indice = 0 ; /* on repart a 0 */
#ifdef TRACE_GET_COLOR_INDEX
if( Xw_get_trace() > 1 ) {
printf(" ************************\n") ;
printf(" Xw_get_color_index, full array\n") ;
printf(" ************************\n") ;
}
#endif
}
#endif
}
}
*index = curind ;
#ifdef TRACE_GET_COLOR_INDEX
if( Xw_get_trace() > 3 ) {
printf(" %d = Xw_get_color_index(%lx,%f,%f,%f,#%d/0x%lx)\n",
status,(long ) pcolormap,r,g,b,curind,(long ) pcolormap->pixels[curind]) ;
}
#endif
return( status ) ;
}

53
src/Xw/Xw_get_color_name.cxx Executable file
View File

@@ -0,0 +1,53 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_COLOR_NAME
#endif
/*
STATUS Xw_get_color_name (acolormap,colorname,r,g,b):
XW_EXT_COLORMAP *acolormap
char *colorname Name of color from file /usr/lib/X11/rgb.txt
float *r,*g,*b Returns Color values in [0,1] space
Returns ERROR if Name is not founded in the database
Returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_color_name (void* acolormap,
const char* colorname,float* r,float* g,float* b)
#else
XW_STATUS Xw_get_color_name (acolormap,colorname,r,g,b)
void *acolormap ;
const char *colorname ;
float *r,*g,*b ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ;
XColor color ;
//int red,green,blue ;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_get_color_name",pcolormap) ;
return (XW_ERROR) ;
}
if( XParseColor(_CDISPLAY,_CINFO.colormap,colorname,&color) ) {
*r = (float)color.red/0xFFFF ;
*g = (float)color.green/0xFFFF;
*b = (float)color.blue/0xFFFF ;
} else return (XW_ERROR) ;
#ifdef TRACE_GET_COLOR_NAME
if( Xw_get_trace() ) {
printf (" Xw_get_color_name(%lx,%s,%f,%f,%f)\n",
(long ) pcolormap,colorname,*r,*g,*b);
}
#endif
return (XW_SUCCESS);
}

153
src/Xw/Xw_get_color_pixel.cxx Executable file
View File

@@ -0,0 +1,153 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_COLOR_PIXEL
#endif
/*
STATUS Xw_get_color_pixel(acolormap,r,g,b,pixel,isapproximate):
XW_EXT_COLORMAP *acolormap Colormap extension structure
float r,g,b ; Red,Green,Blue color value 0. >= x <= 1.
unsigned long *pixel ; Return Color pixel depending of Visual Class
bool isapproximate ;
Gets the nearest color pixel from R,G,B Color values.
Returns ERROR if Colormap is not defined properly
Returns SUCCESS if Successful
*/
#define TEST 1
#ifdef TEST /* Optim. no more necessary with XQueryColors */
#define MAX_COLRS 256
static int indice = 0;
static int indice_max = 0;
static XW_EXT_COLORMAP *qcolormap = NULL;
static float tab_ind[MAX_COLRS][4];
#endif
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_color_pixel(void* acolormap,
float r,float g,float b,unsigned long* pixel,int *isapproximate)
#else
XW_STATUS Xw_get_color_pixel(acolormap,r,g,b,pixel,isapproximate)
void *acolormap ;
float r,g,b ;
unsigned long *pixel ;
int *isapproximate;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ;
XW_STATUS status = XW_ERROR ;
//XColor colors[MAXCOLOR] ;
//int color_indexs[MAXCOLOR] ;
//register i,j,n ;
register int i ;
*pixel = 0;
if( !pcolormap ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error( 42,"Xw_get_color_pixel",pcolormap ) ;
return( XW_ERROR ) ;
}
*isapproximate = False;
if( _CCLASS == TrueColor ) {
unsigned long mask = _CVISUAL->map_entries-1 ;
unsigned long red = (unsigned long) (r * mask) ;
unsigned long green = (unsigned long) (g * mask) ;
unsigned long blue = (unsigned long) (b * mask) ;
mask = _CVISUAL->red_mask;
while ( !(mask & 0x01) ) { mask >>= 1; red <<= 1; }
mask = _CVISUAL->green_mask;
while ( !(mask & 0x01) ) { mask >>= 1; green <<= 1; }
mask = _CVISUAL->blue_mask;
while ( !(mask & 0x01) ) { mask >>= 1; blue <<= 1; }
*pixel = red|green|blue ;
status = XW_SUCCESS ;
} else if( pcolormap->mapping == Xw_TOM_COLORCUBE ) {
int curind = 0;
if( (_CGINFO.red_mult > 0) && (fabs(r-g) < 0.01) && (fabs(r-b) < 0.01) ) {
curind = (int)(0.5+r*_CGINFO.red_max)*_CGINFO.red_mult;
if( _CINFO.red_max > 0 ) curind += (_CINFO.red_max+1)*(_CINFO.green_max+1)*(_CINFO.blue_max+1);
} else if( _CINFO.red_mult > 0 ) {
curind = ((int)(0.5+r*_CINFO.red_max))*_CINFO.red_mult+
((int)(0.5+g*_CINFO.green_max))*_CINFO.green_mult+
((int)(0.5+b*_CINFO.blue_max))*_CINFO.blue_mult;
} else if( _CGINFO.red_mult > 0 ) {
float l = (r+g+b)/3.;
curind = (int)(0.5+l*_CGINFO.red_max)*_CGINFO.red_mult;
}
*pixel = _CINFO.base_pixel + curind ;
if( pcolormap->pixels[curind] == *pixel ) status = XW_SUCCESS ;
}
if( !status ) {
#ifdef TEST
if (pcolormap != qcolormap) {
for (i=0; i<MAX_COLRS; i++) tab_ind[i][0] = -1.;
qcolormap = pcolormap;
indice_max = 0;
indice = 0;
}
for (i=0; i<indice_max; i++) {
if (tab_ind[i][0] >= 0.) {
if ((tab_ind[i][1] == r) &&
(tab_ind[i][2] == g) &&
(tab_ind[i][3] == b)) {
*pixel = (int) tab_ind[i][0];
status = XW_SUCCESS;
break;
}
}
}
#endif
if( !status ) {
status = Xw_alloc_color(pcolormap,r,g,b,pixel,isapproximate) ;
#ifdef TEST
if( status ) {
tab_ind[indice][0] = *pixel ;
tab_ind[indice][1] = r ;
tab_ind[indice][2] = g ;
tab_ind[indice][3] = b ;
/*
* Une fois que le tableau est plein, il faut le
* parcourir completement, donc on ne touche plus
* a indice_max.
*/
indice ++ ;
if( indice < MAX_COLRS ) {
indice_max = max(indice_max,indice);
} else {
indice = 0 ; /* on repart a 0 */
#ifdef TRACE_GET_COLOR_PIXEL
if( Xw_get_trace() > 1 ) {
printf(" ************************\n") ;
printf(" Xw_get_color_pixel, full array\n") ;
printf(" ************************\n") ;
}
#endif
}
}
#endif
}
}
#ifdef TRACE_GET_COLOR_PIXEL
if( Xw_get_trace() > 3 ) {
printf(" %d = Xw_get_color_pixel(%lx,%f,%f,%f,%lx,%d)\n",
status,(long ) pcolormap,r,g,b,*pixel,*isapproximate) ;
}
#endif
return( status ) ;
}

75
src/Xw/Xw_get_colormap_info.cxx Executable file
View File

@@ -0,0 +1,75 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_COLORMAP_INFO
#endif
/*
XW_STATUS Xw_get_colormap_info (acolormap,visual,tclass,visualid,
mcolor,scolor,ucolor,dcolor,fcolor):
XW_EXT_COLORMAP *acolormap
Aspect_Handle **visual Return Visual structure address
Xw_TypeOfVisual *tclass Return Visual Class of the creating colormap
int *visualid Return the visual identificator
int *mcolor Return the maximum color number of the colormap
int *scolor Return the System Color base pixel used in the colormap
int *ucolor Return the User color number used in the colormap
int *dcolor Return the User color number defined in the colormap
int *fcolor Return the First Free User color index in the colormap
NOTE than if fcolor is < 0 No more free colors exist in the colormap
Returns ERROR if the Extended Colormap is not defined
Returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_colormap_info (void* acolormap,
Aspect_Handle** visual,
Xw_TypeOfVisual* tclass,
int* visualid,
int* mcolor,int* scolor,
int* ucolor,int* dcolor,int* fcolor)
#else
XW_STATUS Xw_get_colormap_info (acolormap,visual,tclass,visualid,mcolor,scolor,ucolor,dcolor,fcolor)
void *acolormap;
Aspect_Handle **visual ;
Xw_TypeOfVisual *tclass ;
int *visualid;
int *mcolor,*scolor,*ucolor,*dcolor,*fcolor ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
int i ;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_get_colormap_info",pcolormap) ;
return (XW_ERROR) ;
}
*visual = (Aspect_Handle*) _CVISUAL ;
*tclass = (Xw_TypeOfVisual) _CCLASS ;
*visualid = _CVISUAL->visualid;
*mcolor = pcolormap->maxhcolor ;
*scolor = _CINFO.base_pixel ;
*ucolor = pcolormap->maxucolor ;
*dcolor = 0 ;
*fcolor = -1 ;
for( i=0 ; i< *ucolor ; i++ ) {
if( (pcolormap->define[i] != FREECOLOR) &&
(pcolormap->define[i] != HIGHCOLOR)) (*dcolor)++ ;
else if( *fcolor < 0 ) *fcolor = i ;
}
#ifdef TRACE_GET_COLORMAP_INFO
if( Xw_get_trace() ) {
printf (" Xw_get_colormap_info(%lx,%lx,%d,%d,%d,%d,%d,%d,%d)\n",
(long ) pcolormap,(long ) *visual,*tclass,*visualid,*mcolor,*scolor,*ucolor,*dcolor,*fcolor) ;
}
#endif
return (XW_SUCCESS);
}

View File

@@ -0,0 +1,41 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_COLORMAP_VISUAL
#endif
/*
Xw_TypeOfVisual Xw_get_colormap_visual (acolormap):
XW_EXT_COLORMAP *acolormap
Returns the colormap Visual class ,must be one of :
STATICGRAY,GRAYSCALE,STATICCOLOR,PSEUDOCOLOR,
TRUECOLOR,DIRECTCOLOR
*/
#ifdef XW_PROTOTYPE
Xw_TypeOfVisual Xw_get_colormap_visual (void* acolormap)
#else
Xw_TypeOfVisual Xw_get_colormap_visual (acolormap)
void *acolormap;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_get_colormap_visual",pcolormap) ;
return (Xw_TOV_DEFAULT) ;
}
#ifdef TRACE_GET_COLORMAP_VISUAL
if( Xw_get_trace() > 1 ) {
printf (" %d = Xw_get_colormap_visual(%lx)\n",_CCLASS,(long ) pcolormap) ;
}
#endif
return (Xw_TypeOfVisual) _CCLASS ;
}

163
src/Xw/Xw_get_colormap_xid.cxx Executable file
View File

@@ -0,0 +1,163 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_COLORMAP_XID
#endif
/*
Aspect_Handle Xw_get_colormap_xid (acolormap):
XW_EXT_COLORMAP *acolormap
Returns the colormap XId
*/
#ifdef XW_PROTOTYPE
Aspect_Handle Xw_get_colormap_xid (void* acolormap)
#else
Aspect_Handle Xw_get_colormap_xid (acolormap)
void *acolormap;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_get_colormap_xid",pcolormap) ;
return (0) ;
}
#ifdef TRACE_GET_COLORMAP_XID
if( Xw_get_trace() > 1 ) {
printf (" %lx = Xw_get_colormap_xid(%lx)\n",(long ) _CINFO.colormap,(long ) pcolormap) ;
}
#endif
return (_CINFO.colormap) ;
}
#ifdef TRACE
#define TRACE_GET_COLORMAP_COLORCUBE
#endif
/*
XW_STATUS Xw_get_colormap_colorcube (acolormap,
colormap,visualid,base_pixel,red_max,red_mult,
green_max,green_mult,blue_max,blue_mult):
XW_EXT_COLORMAP *acolormap
Aspect_Handle *colormap
int *visualid
int *base_pixel,*red_max,*red_mult,*green_max,*green_mult,*blue_max,*blue_mult
Returns TRUE if the colormap provide a color-cube definition
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_colormap_colorcube (void* acolormap,
Aspect_Handle *colormap,int *visualid,int *base_pixel,
int *red_max,int *red_mult,int *green_max,int *green_mult,
int *blue_max,int *blue_mult)
#else
XW_STATUS Xw_get_colormap_colorcube (acolormap,
colormap,visualid,base_pixel,red_max,red_mult,green_max,green_mult,
blue_max,blue_mult)
void *acolormap;
Aspect_Handle *colormap;
int *visualid;
int *base_pixel,*red_max,*red_mult,*green_max,*green_mult,*blue_max,*blue_mult;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
XW_STATUS status = XW_SUCCESS;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_get_colormap_colorcube",pcolormap) ;
return (XW_ERROR) ;
}
*colormap = _CINFO.colormap;
*visualid = _CINFO.visualid;
*base_pixel = _CINFO.base_pixel;
*red_max = _CINFO.red_max;
*red_mult = _CINFO.red_mult;
*green_max = _CINFO.green_max;
*green_mult = _CINFO.green_mult;
*blue_max = _CINFO.blue_max;
*blue_mult = _CINFO.blue_mult;
if( _CINFO.red_mult <= 0 ) {
status = XW_ERROR;
}
#ifdef TRACE_GET_COLORMAP_COLORCUBE
if( Xw_get_trace() > 1 ) {
printf (" %d = Xw_get_colormap_colorcube(%lx,%lx,%d,%d,%d,%d,%d,%d,%d,%d)\n",
status,(long ) pcolormap,*colormap,*visualid,*base_pixel,*red_max,*red_mult,
*green_max,*green_mult,*blue_max,*blue_mult) ;
}
#endif
return (status) ;
}
#ifdef TRACE
#define TRACE_GET_COLORMAP_GRAYRAMP
#endif
/*
XW_STATUS Xw_get_colormap_grayramp (acolormap,
colormap,visualid,base_pixel,gray_max,gray_mult):
XW_EXT_COLORMAP *acolormap
Aspect_Handle *colormap
int *visualid
int *base_pixel,*gray_max,*gray_mult
Returns TRUE if the colormap provide a gray_ramp definition
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_colormap_grayramp (void* acolormap,
Aspect_Handle *colormap,int *visualid,int *base_pixel,
int *gray_max,int *gray_mult)
#else
XW_STATUS Xw_get_colormap_grayramp (acolormap,
colormap,visualid,base_pixel,gray_max,gray_mult)
void *acolormap;
Aspect_Handle *colormap;
int *visualid;
int *base_pixel,*gray_max,*gray_mult;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
XW_STATUS status = XW_SUCCESS;
if( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXT_COLORMAP Address*/
Xw_set_error(42,"Xw_get_colormap_grayramp",pcolormap) ;
return (XW_ERROR) ;
}
*colormap = _CGINFO.colormap;
*visualid = _CGINFO.visualid;
*base_pixel = _CGINFO.base_pixel;
*gray_max = _CGINFO.red_max;
*gray_mult = _CGINFO.red_mult;
if( _CGINFO.red_mult <= 0 ) {
status = XW_ERROR;
}
#ifdef TRACE_GET_COLORMAP_GRAYRAMP
if( Xw_get_trace() > 1 ) {
printf (" %d = Xw_get_colormap_grayramp(%lx,%lx,%d,%d,%d,%d)\n",
status,(long ) pcolormap,*colormap,*visualid,*base_pixel,*gray_max,*gray_mult);
}
#endif
return (status) ;
}

View File

@@ -0,0 +1,53 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_CURSOR_POSITION
#endif
/*
XW_STATUS Xw_get_cursor_position (awindow,x,y)
XW_EXT_WINDOW *awindow
int *x,*y Returned Window relative Cursor position
Get the Window cursor position
Returns XW_ERROR if the cursor is out of the window
Returns XW_SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_cursor_position (void *awindow,int *x,int *y)
#else
XW_STATUS Xw_get_cursor_position (awindow,x,y)
void *awindow ;
int *x,*y ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
//XW_EXT_DISPLAY *pdisplay = pwindow->connexion ;
int status ;
Window root,child ;
int root_x,root_y ;
unsigned int key ;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_get_cursor_position",pwindow) ;
return (XW_ERROR) ;
}
status = XQueryPointer(_DISPLAY,_WINDOW,&root,&child,
&root_x,&root_y,x,y,&key) ;
if( *x < 0 || *y < 0 || *x > _WIDTH || *y > _HEIGHT ) status = XW_ERROR ;
#ifdef TRACE_GET_CURSOR_POSITION
if( Xw_get_trace() > 2 ) {
printf (" Xw_get_cursor_position(%lx,%d,%d)\n",(long ) pwindow,*x,*y) ;
}
#endif
return (XW_STATUS) status;
}

59
src/Xw/Xw_get_display_info.cxx Executable file
View File

@@ -0,0 +1,59 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_DISPLAY_INFO
#endif
/*
XW_STATUS Xw_get_display_info (adisplay,display,root,colormap,tclass,depth):
XW_EXT_DISPLAY *adisplay Extended Display structure
Aspect_Handle **display Display XID
Aspect_Handle *root Root XID
Aspect_Handle *colormap Default Colormap XID
Xw_TypeOfVisual *tclass Default Visual Class
int *depth Default Depth
Returns the X display attributes of a connexion
returns XW_ERROR if something is wrong
returns XW_SUCCESS else
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_display_info (void *adisplay,Aspect_Handle **display,Aspect_Handle *root,Aspect_Handle *colormap,Xw_TypeOfVisual *tclass,int *depth)
#else
XW_STATUS Xw_get_display_info (adisplay,display,root,colormap,tclass,depth)
void *adisplay ;
Aspect_Handle **display;
Aspect_Handle *root;
Aspect_Handle *colormap;
Xw_TypeOfVisual *tclass;
int *depth ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_get_display_info",pdisplay) ;
return (XW_ERROR) ;
}
*display = (Aspect_Handle*) _DDISPLAY ;
*root = _DROOT ;
*tclass = (Xw_TypeOfVisual) _DCLASS ;
*colormap = _DCOLORMAP ;
*depth = DefaultDepthOfScreen(_DSCREEN) ;
#ifdef TRACE_GET_DISPLAY_INFO
if( Xw_get_trace() > 1 ) {
printf (" Xw_get_display_info(%lx,%lx,%lx,%lx,%d,%d)\n",
(long ) adisplay,(long ) *display,*root,*colormap,*tclass,*depth) ;
}
#endif
return (XW_SUCCESS) ;
}

View File

@@ -0,0 +1,57 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_DISPLAY_VISUAL
#endif
/*
Xw_TypeOfVisual Xw_get_display_visual (adisplay,pclass):
XW_EXT_DISPLAY *adisplay Extended Display structure
Xw_TypeOfVisual pclass Preferred Visual Class
Returns the X display attributes of a connexion
returns XW_DEFAULT_VISUAL if something is wrong
returns the best Visual class if Successfull
*/
#ifdef XW_PROTOTYPE
Xw_TypeOfVisual Xw_get_display_visual (void *adisplay,Xw_TypeOfVisual pclass)
#else
Xw_TypeOfVisual Xw_get_display_visual (adisplay,pclass)
void *adisplay ;
Xw_TypeOfVisual pclass;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
Xw_TypeOfVisual rclass = Xw_TOV_DEFAULT ;
XVisualInfo *ginfo ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_get_display_visual",pdisplay) ;
return (rclass) ;
}
if( !(ginfo = Xw_get_visual_info(pdisplay,pclass)) ) return (rclass) ;
#if defined(__cplusplus) || defined(c_plusplus)
rclass = (Xw_TypeOfVisual) ginfo->visual->c_class ;
#else
rclass = (Xw_TypeOfVisual) ginfo->visual->class ;
#endif
XFree((char*)ginfo) ;
#ifdef TRACE_GET_DISPLAY_VISUAL
if( Xw_get_trace() > 1 ) {
printf (" %d = Xw_get_display_visual(%lx,%d)\n",rclass,(long ) adisplay,pclass) ;
}
#endif
return (rclass) ;
}

39
src/Xw/Xw_get_double_buffer.cxx Executable file
View File

@@ -0,0 +1,39 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_DOUBLE_BUFFER
#endif
/*
DOUBLEBUFFERMODE Xw_get_double_buffer (awindow)
XW_EXT_WINDOW *awindow
Returns the double_buffering status for this window .
returns SUCCESS always
*/
#ifdef XW_PROTOTYPE
XW_DOUBLEBUFFERMODE Xw_get_double_buffer (void* awindow)
#else
XW_DOUBLEBUFFERMODE Xw_get_double_buffer (awindow)
XW_EXT_WINDOW *awindow;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_DOUBLEBUFFERMODE state ;
if( (_PIXMAP && (_DRAWABLE == _PIXMAP)) ||
(_NWBUFFER > 0 && (_DRAWABLE == _BWBUFFER)) ) state = XW_ENABLE ;
else state = XW_DISABLE ;
#ifdef TRACE_GET_DOUBLE_BUFFER
if( Xw_get_trace() ) {
printf(" %d = Xw_get_double_buffer(%lx)\n",state,(long ) pwindow) ;
}
#endif
return (state);
}

86
src/Xw/Xw_get_env.cxx Executable file
View File

@@ -0,0 +1,86 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_ENV
#define TRACE_PUT_ENV
#endif
/*
STATUS Xw_get_env (symbol,value,length):
char *symbol Symbol string to read
char *value return Symbol value to fill
int length Value max length in chars
Get external Symbol value (Set by setenv UNIX)
Returns ERROR if No symbol exist
or Length is too small for value
Returns SUCCESS if Successful
STATUS Xw_put_env (symbol,value):
char *symbol Symbol string to write
char *value Symbol value to write
Put external Symbol value (Set by putenv UNIX)
Returns ERROR if symbol is empty
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_env (const char* symbol,char* value,int length)
#else
XW_STATUS Xw_get_env (symbol,value,length)
const char *symbol;
char *value ;
int length ;
#endif /*XW_PROTOTYPE*/
{
char *string ;
if( !(string = getenv (symbol)) ) {
if( Xw_get_trace() > 1 )
printf("*UNDEFINED SYMBOL*Xw_get_env('%s',...)\n",symbol);
return (XW_ERROR);
}
if( strlen(string) >= (unsigned int ) length ) return (XW_ERROR) ;
strcpy(value,string) ;
#ifdef TRACE_GET_ENV
if( Xw_get_trace() > 1 ) {
printf (" '%s' = Xw_get_env('%s','%s',%d)\n",value,symbol,string,length) ;
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_put_env (char* symbol,char* value)
#else
XW_STATUS Xw_put_env (symbol,value)
char *symbol,*value ;
#endif /*XW_PROTOTYPE*/
{
char *string ;
if( !strlen(symbol) ) return (XW_ERROR) ;
string = (char*) malloc(strlen(symbol) + strlen(value) + 4) ;
sprintf(string,"%s=%s",symbol,value) ;
if( putenv(string) ) return (XW_ERROR) ;
#ifdef TRACE_PUT_ENV
if( Xw_get_trace() > 1 ) {
printf (" Xw_put_env('%s','%s')\n",symbol,value) ;
}
#endif
return (XW_SUCCESS);
}

102
src/Xw/Xw_get_filename.cxx Executable file
View File

@@ -0,0 +1,102 @@
/* PRO12499 OPTIMISATION & DEBUG GG_100398
// Utiliser plutot une variable statique que allouer de
la memoire.
*/
#define IMP010200 /* GG
Add protection when NO extension is defined
and the path contains a '.'
*/
#include <Xw_Extension.h>
#include <string.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_FILENAME
#endif
/*
char* Xw_get_filename (filename,extension):
char *filename Filename to translate
char *extension File extension
Translate Filename depending of environment and extension
Returns Updated Filename depending of environment and extension
or Returns NULL is translating can't be done
NOTE: Filename can be given under the forms :
1) xxxxxx.ext
2) xxxxxx (.extension is added)
3) /usr/..../xxxxxx.ext
4) $XXXXX/yyyyyy.ext ($XXXXX symbol is get and insert
*/
#define MAXSTRING 512
static char string1[MAXSTRING];
static char string2[MAXSTRING];
#ifdef XW_PROTOTYPE
char* Xw_get_filename (char* filename,const char* extension)
#else
char* Xw_get_filename (filename,extension)
char *filename ;
const char *extension ;
#endif /*XW_PROTOTYPE*/
{
char *pname,*pext,*pslash;
if( !filename || strlen(filename) > MAXSTRING ) {
printf (" *TOO BIG PATH*Xw_get_filename('%s','%s')\n",
filename,extension) ;
return (NULL) ;
}
pname = strcpy(string1,filename) ;
if( *pname == '$' ) {
pname = (char*) strchr(string1,'/') ;
if( pname ) { /* Filename is $XXXX/yyyyy */
XW_STATUS status;
*pname = '\0' ;
status = Xw_get_env(&string1[1],string2,MAXSTRING) ;
*pname = '/' ;
if( status ) {
if( (strlen(string2) + strlen(pname) + 1) < MAXSTRING ) {
pname = strcat(string2,pname) ;
} else {
printf (" *TOO BIG SYMBOL PATH*Xw_get_filename('%s','%s')\n",
filename,extension) ;
return NULL;
}
}
}
}
pext = strrchr(pname,'.') ;
#ifdef IMP010200
pslash = strrchr(pname,'/') ;
if( pext && (pslash > pext) ) pext = NULL;
#endif
if( !pext ) { /* Add file extension ".extension" */
if( (strlen(pname) + strlen(extension) + 2) < MAXSTRING ) {
strcat(pname,".") ;
strcat(pname,extension) ;
} else {
printf (" *TOO BIG EXTENSION*Xw_get_filename('%s','%s')\n",
filename,extension) ;
return NULL;
}
}
#ifdef TRACE_GET_FILENAME
if( Xw_get_trace() > 1 ) {
printf (" '%s'= Xw_get_filename('%s','%s')\n",pname,filename,extension) ;
}
#endif
return (pname);
}

64
src/Xw/Xw_get_font.cxx Executable file
View File

@@ -0,0 +1,64 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_FONT
#endif
/*
char* Xw_get_font (afontmap,index,size,bheight):
XW_EXT_FONTMAP *afontmap
int index font index
float *size font size in MM
float *bheight baseline font height in MM
Get Line Font Extended fontmap FONT values from index .
Returns NULL if BadFont Index or font is not defined
Returns font string address if Successful
*/
#ifdef XW_PROTOTYPE
char* Xw_get_font (void* afontmap,int index,float *size,float *bheight)
#else
char* Xw_get_font (afontmap,index,size,bheight)
void *afontmap;
int index ;
float *size ;
float *bheight ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_FONTMAP *pfontmap = (XW_EXT_FONTMAP*)afontmap;
//XW_EXT_DISPLAY *pdisplay = pfontmap->connexion;
char *font = NULL;
//int i ;
*size = *bheight = 0.;
if ( !Xw_isdefine_font(pfontmap,index) ) {
/*ERROR*Bad defined font*/
Xw_set_error(43,"Xw_get_font",&index) ;
return (NULL) ;
}
if( pfontmap->snames[index] ) font = pfontmap->snames[index] ;
else if( pfontmap->gnames[index] ) font = pfontmap->gnames[index];
if( !font ) {
/*ERROR*Bad defined font*/
Xw_set_error(43,"Xw_get_font",&index);
return NULL;
}
*size = pfontmap->fsizes[index];
*bheight = *size * pfontmap->fratios[index];
#ifdef TRACE_GET_FONT
if( Xw_get_trace() > 1 ) {
printf (" '%s' = Xw_get_font(%lx,%d,%f,%f)\n",font,(long ) pfontmap,index,*size,*bheight) ;
}
#endif
return (font);
}

74
src/Xw/Xw_get_font_index.cxx Executable file
View File

@@ -0,0 +1,74 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_FONT_INDEX
#endif
/*
STATUS Xw_get_font_index(afontmap,size,fontname,index):
XW_EXT_FONTMAP *afontmap Fontmap extension structure
float size ; Font size in MM
char *fontname ; Font descriptor ended with '\0'
int *index ; Return Font index 0 >= x < MAXFONT
Gets the nearest font index from Font Descriptor.
Returns ERROR if BadFont Index or font is not defined
Returns SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_font_index(void* afontmap,float size,char* fontname,int* index)
#else
XW_STATUS Xw_get_font_index(afontmap,size,fontname,index)
void *afontmap ;
float size ;
char *fontname ;
int *index ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_FONTMAP *pfontmap = (XW_EXT_FONTMAP*)afontmap ;
XW_STATUS status = XW_ERROR ;
int i,j ;
if( !pfontmap ) {
/*ERROR*Bad EXT_FONTMAP Address*/
Xw_set_error( 44,"Xw_get_font_index",pfontmap ) ;
return( XW_ERROR ) ;
}
if( fontname && strlen(fontname) ) {
for( i=j=0 ; i<pfontmap->maxfont ; i++ ) {
if( pfontmap->gnames[i] ) {
if( !strcmp(fontname,pfontmap->gnames[i]) ) {
if( fabs(size-pfontmap->gsizes[i]) < 0.1 ) break;
}
} else if( !j ) j = i ;
}
if( i<pfontmap->maxfont ) {
*index = i ;
status = XW_SUCCESS ;
} else {
*index = j ;
status = Xw_def_font (pfontmap,j,size,fontname) ;
}
} else {
*index = 0 ;
status = XW_SUCCESS ;
}
#ifdef TRACE_GET_FONT_INDEX
if( Xw_get_trace() > 1 ) {
printf(" %d = Xw_get_font_index(%lx,%f,'%s',%d)\n",
status,(long ) pfontmap,size,fontname,*index) ;
}
#endif
return( status ) ;
}

58
src/Xw/Xw_get_fontmap_info.cxx Executable file
View File

@@ -0,0 +1,58 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_FONTMAP_INFO
#endif
/*
STATUS Xw_get_fontmap_info (afontmap,mfont,ufont,dfont,ffont):
XW_EXT_FONTMAP *afontmap
int *mfont Return the maximum font number of the fontmap
int *ufont Return the User font number used in the fontmap
int *dfont Return the User font number defined in the fontmap
int *ffont Return the First Free User font index in the fontmap
NOTE than if ffont is 0 No more Free font exist in the fontmap
Returns ERROR if the Extended Fontmap is not defined
Returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_fontmap_info (void* afontmap,
int* mfont,int* ufont,int* dfont,int* ffont)
#else
XW_STATUS Xw_get_fontmap_info (afontmap,mfont,ufont,dfont,ffont)
void *afontmap;
int *mfont,*ufont,*dfont,*ffont ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_FONTMAP *pfontmap = (XW_EXT_FONTMAP*)afontmap;
int i ;
if( !Xw_isdefine_fontmap(pfontmap) ) {
/*ERROR*Bad EXT_FONTMAP Address*/
Xw_set_error(44,"Xw_get_fontmap_info",pfontmap) ;
return (XW_ERROR) ;
}
*mfont = MAXFONT ;
*ufont = pfontmap->maxfont ;
*dfont = 0 ;
*ffont = -1 ;
for( i=0 ; i< *ufont ; i++ ) {
if( pfontmap->fonts[i] ) (*dfont)++ ;
else if( i && *ffont < 0 ) *ffont = i ;
}
#ifdef TRACE_GET_FONTMAP_INFO
if( Xw_get_trace() ) {
printf (" Xw_get_fontmap_info(%lx,%d,%d,%d,%d)\n",
(long ) pfontmap,*mfont,*ufont,*dfont,*ffont) ;
}
#endif
return (XW_SUCCESS);
}

121
src/Xw/Xw_get_highlight_color.cxx Executable file
View File

@@ -0,0 +1,121 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_HIGHLIGHT_COLOR
#define TRACE_GET_HIGHLIGHT_PIXEL
#endif
/*
XW_STATUS Xw_get_highlight_color(acolormap,r,g,b):
XW_EXT_COLORMAP *acolormap Colormap extension structure
float *r,*g,*b ; Returns Red,Green,Blue color value 0. >= x <= 1.
Get R,G,B Highlight Color values from Default index .
Returns ERROR if Extended Colormap Address is badly defined
Returns SUCCESS if Successful
XW_STATUS Xw_get_highlight_pixel(acolormap,pixel):
XW_EXT_COLORMAP *acolormap Colormap extension structure
unsigned long *pixel; Returns HighLight pixel
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_highlight_color (void* acolormap,
float* r,float* g,float* b)
#else
XW_STATUS Xw_get_highlight_color (acolormap,r,g,b)
void *acolormap;
float *r,*g,*b ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
XColor color ;
if ( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXTENDED Colormap ADDRESS*/
Xw_set_error(42,"Xw_get_highlight_color",pcolormap) ;
return (XW_ERROR) ;
}
switch ( _CCLASS ) {
case PseudoColor :
case StaticColor :
color.pixel = pcolormap->highpixel ;
XQueryColor(_CDISPLAY,_CINFO.colormap,&color) ;
*r = (float)color.red/0xFFFF ;
*g = (float)color.green/0xFFFF ;
*b = (float)color.blue/0xFFFF ;
break ;
case TrueColor :
{ unsigned long mask = _CVISUAL->map_entries-1 ;
unsigned long red,green,blue ;
unsigned long rmask = _CVISUAL->red_mask ;
unsigned long gmask = _CVISUAL->green_mask ;
unsigned long bmask = _CVISUAL->blue_mask ;
color.pixel = pcolormap->highpixel ;
red = color.pixel & rmask ;
while ( !(rmask & 0x01) ) { rmask >>= 1; red >>= 1; }
green = color.pixel & gmask ;
while ( !(gmask & 0x01) ) { gmask >>= 1; green >>= 1; }
blue = color.pixel & bmask ;
while ( !(bmask & 0x01) ) { bmask >>= 1; blue >>= 1; }
*r = (float)red/mask ;
*g = (float)green/mask ;
*b = (float)blue/mask ;
}
break ;
default :
/*Unmatchable Visual class*/
Xw_set_error(67,"Xw_get_highlight_color",&_CCLASS) ;
return (XW_ERROR) ;
}
#ifdef TRACE_GET_HIGHLIGHT_COLOR
if( Xw_get_trace() > 1 ) {
printf(" Xw_get_highlight_color(%lx,%f,%f,%f)\n",(long ) pcolormap,*r,*g,*b) ;
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_highlight_pixel (void* acolormap,unsigned long *pixel)
#else
XW_STATUS Xw_get_highlight_pixel (acolormap,pixel)
void *acolormap;
unsigned long *pixel;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
//XColor color ;
if ( !Xw_isdefine_colormap(pcolormap) ) {
/*ERROR*Bad EXTENDED Colormap ADDRESS*/
Xw_set_error(42,"Xw_get_highlight_pixel",pcolormap) ;
return (XW_ERROR) ;
}
*pixel = pcolormap->highpixel ;
#ifdef TRACE_GET_HIGHLIGHT_PIXEL
if( Xw_get_trace() > 1 ) {
printf(" Xw_get_highlight_pixel(%lx,%lx)\n",(long ) pcolormap,*pixel) ;
}
#endif
return (XW_SUCCESS);
}

253
src/Xw/Xw_get_image.cxx Executable file
View File

@@ -0,0 +1,253 @@
#include <Xw_Extension.h>
/*
// GG PRO4521 05/08/96
// Capture an image across all the window memory plans.
// GG PRO6633 21/08/97
// Avoid crash when image size is NULL.
// GG IMP060200
// Capture an image from any pixmap.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_X11_EXTENSIONS_READDISPLAY_H
#include <X11/extensions/readdisplay.h>
#endif
#ifdef HAVE_X11_EXTENSIONS_TRANSOLV_H
#include <X11/extensions/transovl.h>
#endif
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_IMAGE
#endif
/*
XW_EXT_IMAGEDATA* Xw_get_image (awindow,aimageinfo,xc,yc,width,height):
XW_EXT_WINDOW *awindow
XW_USERDATA *aimageinfo Image Informations Address
int xc,yc Image center location in pixels
int width,height Image size in pixels
Get an image from the window at the required Center location
NOTE than current Window position and size are taken.
returns The image descriptor address if successful
returns NULL if BadAllocation or Image is outside of the window
XW_EXT_IMAGEDATA* Xw_get_image_from_pixmap (awindow,aimageinfo,pixmap,xc,yc,width,height):
XW_EXT_WINDOW *awindow
XW_USERDATA *aimageinfo Image Informations Address
Aspect_Handle pixmap,
int xc,yc Image center location in pixels
int width,height Image size in pixels
Get an image from any pixmap at the required Center location and size
returns The image descriptor address if successful
returns NULL if BadAllocation or Image is outside of the pixmap
*/
#ifdef XW_PROTOTYPE
void* Xw_get_image (void* awindow, void *aimageinfo,
int xc,int yc,int width,int height)
#else
void* Xw_get_image (awindow,aimageinfo,xc,yc,width,height)
void *awindow;
void *aimageinfo ;
int xc,yc ;
int width,height ;
#endif // XW_PROTOTYPE
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_DISPLAY *pdisplay = pwindow->connexion ;
XW_EXT_IMAGEDATA *pimage ;
int wx,wy;
#if defined(HAVE_X11_EXTENSIONS_READDISPLAY_H) || defined(HAVE_X11_EXTENSIONS_TRANSOLV_H)
int mOptCode,fEvent,fError;
#endif
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_get_image",pwindow) ;
return (NULL) ;
}
if( width <= 0 || height <= 0 ) return NULL;
wx = xc - width/2 ;
wy = yc - height/2 ;
if( wx < 0 ) wx = 0;
if( wy < 0 ) wy = 0;
if( !(pimage = Xw_add_imagedata_structure(sizeof(XW_EXT_IMAGEDATA))) )
return (NULL) ;
pimage->pimageinfo = aimageinfo ;
if( _DGRAB ) {
wx += _X ; wy += _Y ;
if( (wx + width) < 0 || wx > _DWIDTH ||
(wy + height) < 0 || wy > _DHEIGHT ) {
Xw_del_imagedata_structure(pimage) ;
/*WARNING*Try to Get Image from outside the display*/
Xw_set_error(45,"Xw_get_image",0) ;
return (NULL) ;
}
if( width > _DWIDTH ) width = _DWIDTH;
if( height > _DHEIGHT ) height = _DHEIGHT;
if( wx + width > _DWIDTH ) width = _DWIDTH - wx;
if( wy + height > _DHEIGHT ) height = _DHEIGHT - wy;
_ICOLORMAP = NULL ;
_IIMAGE = NULL ;
#ifdef HAVE_X11_EXTENSIONS_READDISPLAY_H
if( XQueryExtension(_DISPLAY,"ReadDisplay",&mOptCode,&fEvent,&fError) ) {
XGrabServer(_DISPLAY);
XSync(_DISPLAY,False);
_IIMAGE = XReadDisplay(_DISPLAY,_DROOT,wx,wy,width,height,0,0);
XUngrabServer(_DISPLAY);
XSync(_DISPLAY,False);
}
#endif // HAVE_X11_EXTENSIONS_READDISPLAY_H
#ifdef HAVE_X11_EXTENSIONS_TRANSOLV_H
if( XQueryExtension(_DISPLAY,"SUN_OVL",&mOptCode,&fEvent,&fError) ) {
XGrabServer(_DISPLAY);
XSync(_DISPLAY,False);
_IIMAGE = XReadScreen(_DISPLAY,_DROOT,wx,wy,width,height,False);
XUngrabServer(_DISPLAY);
XSync(_DISPLAY,False);
}
#endif // HAVE_X11_EXTENSIONS_TRANSOLV_H
if( !_IIMAGE )
_IIMAGE = XGetImage(_DISPLAY,_DROOT,wx,wy,
width,height,AllPlanes,ZPixmap) ;
} else {
if( (wx + width) < 0 || wx > _WIDTH ||
(wy + height) < 0 || wy > _HEIGHT ) {
Xw_del_imagedata_structure(pimage) ;
/*WARNING*Try to Get Image from outside the window*/
Xw_set_error(45,"Xw_get_image",0) ;
return (NULL) ;
}
if( width > _WIDTH ) width = _WIDTH;
if( height > _HEIGHT ) height = _HEIGHT;
if( wx + width > _WIDTH ) width = _WIDTH - wx;
if( wy + height > _HEIGHT ) height = _HEIGHT - wy;
_ICOLORMAP = _COLORMAP ;
_IIMAGE = NULL;
#ifdef HAVE_X11_EXTENSIONS_READDISPLAY_H
if( XQueryExtension(_DISPLAY,"ReadDisplay",&mOptCode,&fEvent,&fError) )
{
unsigned int flag = XRD_IGNORE_LAYER_1 | XRD_IGNORE_LAYER_2 |
XRD_IGNORE_LAYER_MINUS_1;
int rx,ry;
Window child;
XGrabServer(_DISPLAY);
XSync(_DISPLAY,False);
XTranslateCoordinates(_DISPLAY,_WINDOW,_DROOT,wx,wy,&rx,&ry,&child);
_IIMAGE = XReadDisplay(_DISPLAY,_WINDOW,rx,ry,width,height,flag,0);
XUngrabServer(_DISPLAY);
XSync(_DISPLAY,False);
}
#endif // HAVE_X11_EXTENSIONS_READDISPLAY_H
#ifdef HAVE_X11_EXTENSIONS_TRANSOLV_H
if( XQueryExtension(_DISPLAY,"SUN_OVL",&mOptCode,&fEvent,&fError) )
{
XGrabServer(_DISPLAY);
XSync(_DISPLAY,False);
_IIMAGE = XReadScreen(_DISPLAY,_WINDOW,wx,wy,width,height,False);
XUngrabServer(_DISPLAY);
XSync(_DISPLAY,False);
}
#endif // HAVE_X11_EXTENSIONS_TRANSOLV_H
if( !_IIMAGE )
_IIMAGE = XGetImage(_DISPLAY,_WINDOW,wx,wy,
width,height,AllPlanes,ZPixmap) ;
}
if( !_IIMAGE ) {
Xw_del_imagedata_structure(pimage) ;
/*WARNING*XImage allocation failed*/
Xw_set_error(60,"Xw_get_image",0) ;
return (NULL) ;
}
else if( _IIMAGE->depth > 24 ) _IIMAGE->depth = 24;
#ifdef TRACE_GET_IMAGE
if( Xw_get_trace() ) {
printf (" %lx = Xw_get_image(%lx,%lx,%d,%d,%d,%d)\n",
(long ) pimage,(long ) pwindow,(long ) aimageinfo,xc,yc,width,height);
}
#endif
return (pimage);
}
#ifdef XW_PROTOTYPE
void* Xw_get_image_from_pixmap (void* awindow, void *aimageinfo,
Aspect_Handle pixmap, int xc,int yc,int width,int height)
#else
void* Xw_get_image_from_pixmap (awindow,aimageinfo,pixmap,xc,yc,width,height)
void *awindow;
void *aimageinfo ;
Aspect_Handle pixmap;
int xc,yc ;
int width,height ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
// XW_EXT_DISPLAY *pdisplay = pwindow->connexion ;
XW_EXT_IMAGEDATA *pimage ;
int wx,wy;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_get_image_from_pixmap",pwindow) ;
return (NULL) ;
}
if( pixmap == 0 || width <= 0 || height <= 0 ) return NULL;
wx = xc - width/2 ;
wy = yc - height/2 ;
if( wx < 0 ) wx = 0;
if( wy < 0 ) wy = 0;
if( !(pimage = Xw_add_imagedata_structure(sizeof(XW_EXT_IMAGEDATA))) )
return (NULL) ;
pimage->pimageinfo = aimageinfo ;
_IIMAGE = XGetImage(_DISPLAY,pixmap,wx,wy,
width,height,AllPlanes,ZPixmap) ;
if( !_IIMAGE ) {
Xw_del_imagedata_structure(pimage) ;
/*WARNING*XImage allocation failed*/
Xw_set_error(60,"Xw_get_image_from_pixmap",0) ;
return (NULL) ;
} else {
_IIMAGE->red_mask = _VISUAL->red_mask;
_IIMAGE->green_mask = _VISUAL->green_mask;
_IIMAGE->blue_mask = _VISUAL->blue_mask;
if( _IIMAGE->depth > 24 ) _IIMAGE->depth = 24;
}
#ifdef TRACE_GET_IMAGE
if( Xw_get_trace() ) {
printf (" %lx = Xw_get_image_from_pixmap(%lx,%lx,%lx,%d,%d,%d,%d)\n",
(long ) pimage,(long ) pwindow,(long ) aimageinfo, pixmap,xc,yc,width,height);
}
#endif
return (pimage);
}

57
src/Xw/Xw_get_image_info.cxx Executable file
View File

@@ -0,0 +1,57 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_IMAGE_INFO
#endif
/*
XW_STATUS Xw_get_image_info (aimage,zoom,width,height,depth):
XW_EXT_IMAGEDATA *aimage Image
float *zoom returned Zoom factor
int *width,*height returned Image pixel size
int *depth returned Image planes depth.
Get image size and zoom factor.
returns ERROR if bad image extended address
returns SUCCESS if successfull
*
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_image_info (void* aimage,float *zoom,int* width,int* height,int *depth)
#else
XW_STATUS Xw_get_image_info (aimage,zoom,width,height,depth)
void *aimage;
float *zoom;
int *width;
int *height;
int *depth;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_IMAGEDATA *pimage = (XW_EXT_IMAGEDATA*)aimage;
if( !Xw_isdefine_image(pimage) ) {
/*ERROR*Bad EXT_IMAGE Address*/
Xw_set_error(25,"Xw_get_image_info",pimage) ;
return (XW_ERROR) ;
}
*zoom = pimage->zoom;
*width = _IIMAGE->width;
*height = _IIMAGE->height;
*depth = _IIMAGE->depth;
#ifdef TRACE_GET_IMAGE_INFO
if( Xw_get_trace() ) {
printf (" Xw_get_image_info('%lx',%f,%d,%d,%d)\n",(long ) aimage,
*zoom,*width,*height,*depth);
}
#endif
return (XW_SUCCESS);
}

84
src/Xw/Xw_get_marker_index.cxx Executable file
View File

@@ -0,0 +1,84 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_MARKER_INDEX
#endif
/*
XW_STATUS Xw_get_marker_index(amarkmap,length,spoint,xpoint,ypoint,index):
XW_EXT_MARKMAP *amarkmap Markmap extension structure
int length ; Style Descriptor length
int *spoint; Marker status point vector
float *xpoint; Marker x coordinate vector
float *ypoint; Marker y coordinate vector
int *index ; Return Marker index 0 >= x < MAXMARKER
Gets the nearest marker index from Style Descriptor values.
Returns XW_ERROR if BadMarker Index or marker is not defined
Returns XW_SUCCESS if Successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_marker_index(void *amarkmap,int length,
int *spoint, float *xpoint, float *ypoint, int *index)
#else
XW_STATUS Xw_get_marker_index(amarkmap,length,spoint,xpoint,ypoint,index)
void *amarkmap ;
int length ;
int *spoint;
float *xpoint;
float *ypoint;
int *index ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_MARKMAP *pmarkmap = (XW_EXT_MARKMAP*) amarkmap ;
XW_STATUS status = XW_ERROR ;
int i,j,k,l ;
if( !pmarkmap ) {
/*ERROR*Bad EXT_MARKMAP Address*/
Xw_set_error( 46,"Xw_get_marker_index",pmarkmap ) ;
return( XW_ERROR ) ;
}
if( length > 0 ) {
for( i=k=0 ; i<pmarkmap->maxmarker ; i++ ) {
l = pmarkmap->npoint[i];
if( l == length ) {
int *s = pmarkmap->spoint[i];
float *x = pmarkmap->xpoint[i];
float *y = pmarkmap->ypoint[i];
for( j=0 ; j<l ; j++,s++,x++,y++ ) {
if( *s != spoint[j] ||
*x != xpoint[j] || *y != ypoint[j] ) break;
}
if( j >= l ) break;
} else if( !l && !k ) k = i ;
}
if( i<pmarkmap->maxmarker ) {
*index = i ;
status = XW_SUCCESS ;
} else {
*index = k ;
status = Xw_def_marker (pmarkmap,k,length,spoint,xpoint,ypoint) ;
}
} else {
*index = 0 ;
status = XW_SUCCESS ;
}
#ifdef TRACE_GET_MARKER_INDEX
if( Xw_get_trace() > 1 ) {
printf(" %d = Xw_get_marker_index(%lx,%d,%d)\n",
status,(long ) pmarkmap,length,*index) ;
}
#endif
return( status ) ;
}

58
src/Xw/Xw_get_markmap_info.cxx Executable file
View File

@@ -0,0 +1,58 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_MARKMAP_INFO
#endif
/*
STATUS Xw_get_markmap_info (amarkmap,mmark,umark,dmark,fmark):
XW_EXT_MARKMAP *amarkmap
int *mmark Return the maximum marker number of the markmap
int *umark Return the User marker number used in the markmap
int *dmark Return the User marker number defined in the markmap
int *fmark Return the First free marker index in the markmap
NOTE than if fmark is < 0 No more Free Marker exist in the markmap
Returns ERROR if the Extended Markmap is not defined
Returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_markmap_info (void* amarkmap,
int* mmark,int* umark,int* dmark,int* fmark)
#else
XW_STATUS Xw_get_markmap_info (amarkmap,mmark,umark,dmark,fmark)
void *amarkmap;
int *mmark,*umark,*dmark,*fmark ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_MARKMAP *pmarkmap = (XW_EXT_MARKMAP*) amarkmap;
int i ;
if( !Xw_isdefine_markmap(pmarkmap) ) {
/*ERROR*Bad EXT_MARKMAP Address */
Xw_set_error(46,"Xw_get_markmap_info",pmarkmap) ;
return (XW_ERROR) ;
}
*mmark = MAXMARKER ;
*umark = pmarkmap->maxmarker ;
*dmark = 1 ;
*fmark = -1 ;
for( i=0 ; i< *umark ; i++ ) {
if( pmarkmap->marks[i] ) (*dmark)++ ;
else if( i && *fmark < 0 ) *fmark = i ;
}
#ifdef TRACE_GET_MARKMAP_INFO
if( Xw_get_trace() ) {
printf (" Xw_get_markmap_info(%lx,%d,%d,%d,%d)\n",
(long ) pmarkmap,*mmark,*umark,*dmark,*fmark) ;
}
#endif
return (XW_SUCCESS);
}

View File

@@ -0,0 +1,44 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_MMSCREEN_PIXELVALUE
#endif
/*
float Xw_get_mmscreen_pixelvalue (adisplay,pv):
XW_EXT_DISPLAY *adisplay
int pv Pixel Values
Returns Screen value from Pixel value in MM
*/
#ifdef XW_PROTOTYPE
float Xw_get_mmscreen_pixelvalue(void* adisplay,int pv)
#else
float Xw_get_mmscreen_pixelvalue(adisplay,pv)
void *adisplay;
int pv ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay;
float sv ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_get_mmscreen_pixelvalue",pdisplay) ;
return (XW_ERROR) ;
}
sv = (MMPXVALUE(pv) + MMPYVALUE(pv))/2. ;
#ifdef TRACE_GET_MMSCREEN_PIXELVALUE
if( Xw_get_trace() > 1 ) {
printf (" %f = Xw_get_mmscreen_pixelvalue(%lx,%d)\n",sv,(long ) pdisplay,pv) ;
}
#endif
return (sv);
}

115
src/Xw/Xw_get_pixel.cxx Executable file
View File

@@ -0,0 +1,115 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_PIXEL
#endif
/*
STATUS Xw_get_pixel (aimage,x,y,index,npixel):
XW_EXT_IMAGEDATA *aimage
int x,y Pixel position
int *index return Pixel color index
int *npixel return Pixel number filled with
the same color index
Extract pixels index from an existing IMAGE created by Xw_get_image
or fill with Xw_put_pixel
returns ERROR if No image is defined
or No pixel color is defined
or Pixel position is wrong (Outside of image)
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_pixel (void* aimage,int x,int y,int* index,int* npixel)
#else
XW_STATUS Xw_get_pixel (aimage,x,y,index,npixel)
XW_EXT_IMAGEDATA *aimage ;
int x,y ;
int *index,*npixel ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_IMAGEDATA *pimage = (XW_EXT_IMAGEDATA*) aimage ;
register union {
char *data ;
unsigned char *cdata ;
unsigned short *sdata ;
unsigned long *ldata ;
} data ;
int i=0,fpixel,simage ;
unsigned long lpixel=0 ;
XImage *pximage;
if( !Xw_isdefine_image(pimage) ) {
/*ERROR*Bad EXT_IMAGEDATA Address*/
Xw_set_error(25,"Xw_get_pixel",pimage) ;
return (XW_ERROR) ;
}
pximage = (_ZIMAGE) ? _ZIMAGE : _IIMAGE;
fpixel = x*pximage->width + y ;
simage = pximage->height*pximage->width ;
if( x < 0 || y < 0 || (fpixel >= simage) ) {
/*ERROR*Bad PIXEL position*/
Xw_set_error(47,"Xw_get_pixel",&simage) ;
return (XW_ERROR) ;
}
switch (pximage->bitmap_pad) {
case 8 :
{ register unsigned char cpixel ;
data.data = pximage->data + (fpixel) ; simage -= fpixel ;
cpixel = *data.cdata ;
for( i=1 ; i<simage ; i++ ) {
data.cdata++ ;
if( *data.cdata != cpixel ) break ;
}
}
break ;
case 16 :
{ register unsigned short spixel ;
data.data = pximage->data + (fpixel<<1) ; simage -= fpixel ;
spixel = *data.sdata ;
for( i=1 ; i<simage ; i++ ) {
data.sdata++ ;
if( *data.sdata != spixel ) break ;
}
}
break ;
case 32 :
data.data = pximage->data + (fpixel<<2) ; simage -= fpixel;
lpixel = *data.ldata ;
for( i=1 ; i<simage ; i++ ) {
data.ldata++ ;
if( *data.ldata != lpixel ) break ;
}
}
*npixel = i ;
*index = lpixel ;
for( i=0 ; i<_ICOLORMAP->maxcolor ; i++ ) {
if( _ICOLORMAP->define[i] &&
(lpixel == _ICOLORMAP->pixels[i]) ) break ;
}
if( i < _ICOLORMAP->maxcolor ) {
*index = i ;
} else {
/*ERROR*Bad Defined Color*/
Xw_set_error(41,"Xw_get_pixel",&index) ;
return (XW_ERROR) ;
}
#ifdef TRACE_GET_PIXEL
if( Xw_get_trace() > 2 ) {
printf (" Xw_get_pixel(%lx,%d,%d,%ld,%ld)\n",
(long ) pimage,x,y,(long ) index,(long ) npixel) ;
}
#endif
return (XW_SUCCESS);
}

View File

@@ -0,0 +1,44 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_PIXEL_MMSCREENVALUE
#endif
/*
int Xw_get_pixel_mmscreenvalue (adisplay,sv):
XW_EXT_DISPLAY *adisplay
float sv MM Screen Values
Returns pixel value from MM Screen value
*/
#ifdef XW_PROTOTYPE
int Xw_get_pixel_mmscreenvalue(void* adisplay,float sv)
#else
int Xw_get_pixel_mmscreenvalue(adisplay,sv)
void *adisplay;
float sv ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay;
int pv ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_get_pixel_mmscreenvalue",pdisplay) ;
return (0) ;
}
pv = (PMMXVALUE(sv) + PMMYVALUE(sv))/2 ;
#ifdef TRACE_GET_PIXEL_MMSCREENVALUE
if( Xw_get_trace() > 1 ) {
printf (" %d = Xw_get_pixel_mmscreenvalue(%lx,%f)\n",pv,(long ) pdisplay,sv) ;
}
#endif
return (pv);
}

View File

@@ -0,0 +1,58 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_PIXEL_SCREENCOORD
#endif
/*
STATUS Xw_get_screen_pixelcoord (adisplay,sx,sy,px,py):
XW_EXT_DISPLAY *adisplay
float sx,sy Screen Coordinates defined in DSU Space
int px,py Returns Screen Coordinates defined in Pixels
Get screen coordinate from Screen in DSU Space
returns ERROR if resulting Pixel Coordinate is outside the screen
or the if Extended Window address is not defined
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_pixel_screencoord(void* adisplay,float sx,float sy,int* px,int* py)
#else
XW_STATUS Xw_get_pixel_screencoord(adisplay,sx,sy,px,py)
void *adisplay;
float sx,sy ;
int *px,*py ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay;
int displaywidth ;
int displayheight ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_get_pixel_screencoord",pdisplay) ;
return (XW_ERROR) ;
}
displaywidth = WidthOfScreen(_DSCREEN) ;
displayheight = HeightOfScreen(_DSCREEN) ;
*px = (int)(sx*(float)displaywidth) ;
*py = (int)((1.-sy)*(float)displayheight) ;
if( *px < 0 || *px >= displaywidth || *py < 0 || *py >= displayheight )
return (XW_ERROR);
#ifdef TRACE_GET_PIXEL_SCREENCOORD
if( Xw_get_trace() > 1 ) {
printf (" Xw_get_pixel_screencoord(%lx,%f,%f,%d,%d)\n",(long ) pdisplay,sx,sy,*px,*py) ;
}
#endif
return (XW_SUCCESS);
}

View File

@@ -0,0 +1,44 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_PIXEL_SCREENVALUE
#endif
/*
int Xw_get_pixel_screenvalue (adisplay,sv):
XW_EXT_DISPLAY *adisplay
float sv Screen Values in [0,1] Space
Returns pixel value from screen value
*/
#ifdef XW_PROTOTYPE
int Xw_get_pixel_screenvalue(void* adisplay,float sv)
#else
int Xw_get_pixel_screenvalue(adisplay,sv)
void *adisplay;
float sv ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay;
int pv ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_get_pixel_screenvalue",pdisplay) ;
return (0) ;
}
pv = (int)(sv*min(WidthOfScreen(_DSCREEN),HeightOfScreen(_DSCREEN))) ;
#ifdef TRACE_GET_PIXEL_SCREENVALUE
if( Xw_get_trace() > 1 ) {
printf (" %d = Xw_get_pixel_screenvalue(%lx,%f)\n",pv,(long ) pdisplay,sv) ;
}
#endif
return (pv);
}

View File

@@ -0,0 +1,50 @@
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_GET_PIXEL_WINDOWCOORD
#endif
/*
STATUS Xw_get_pixel_windowcoord (awindow,ux,uy,px,py):
XW_EXT_WINDOW *awindow
float ux,uy Window Coordinates defined in DWU space
int *px,*py Returns Window Coordinates defined in Pixels
Get transformed coordinate from User Space to Pixel Space
NOTE than the current mapping defined by Xw_set_mapping is apply
returns ERROR if User Coordinate is outside the window
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_pixel_windowcoord(void* awindow,float ux,float uy,int* px,int* py)
#else
XW_STATUS Xw_get_pixel_windowcoord(awindow,ux,uy,px,py)
void *awindow;
float ux,uy ;
int *px,*py ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
XW_EXT_DISPLAY *pdisplay = pwindow->connexion ;
//OCC186
*px = PXPOINT(ux, pwindow->xratio) ;
*py = PYPOINT(uy, pwindow->attributes.height, pwindow->yratio) ;
//OCC186
#ifdef TRACE_GET_PIXEL_WINDOWCOORD
if( Xw_get_trace() > 1 ) {
printf (" Xw_get_pixel_windowcoord(%lx,%f,%f,%d,%d)\n",(long ) pwindow,ux,uy,*px,*py) ;
}
#endif
if( !_DGRAB && (*px < 0 || *px > _WIDTH || *py < 0 || *py > _HEIGHT) )
return (XW_ERROR);
else return (XW_SUCCESS);
}

Some files were not shown because too many files have changed in this diff Show More