mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0022590: Migration to FreeImage - revision of Xw and WNT packages
Clean up Xw package from outdated and unused functionality Adjusting test case for current state of master
This commit is contained in:
parent
b659a6dc19
commit
ed97f43c0c
@ -173,7 +173,7 @@ void View::init()
|
||||
NSView* aViewHandle = (NSView* )winId();
|
||||
Handle(Cocoa_Window) hWnd = new Cocoa_Window (aViewHandle);
|
||||
#else
|
||||
Aspect_Handle aWindowHandle = (Aspect_Handle )winId();
|
||||
Window aWindowHandle = (Window )winId();
|
||||
Handle(Aspect_DisplayConnection) aDispConnection = myContext->CurrentViewer()->Driver()->GetDisplayConnection();
|
||||
Handle(Xw_Window) hWnd = new Xw_Window (aDispConnection, aWindowHandle);
|
||||
#endif // WNT
|
||||
|
@ -74,7 +74,6 @@ uses
|
||||
Quantity,
|
||||
Aspect,
|
||||
MMgt,
|
||||
Xw,
|
||||
WNT,
|
||||
Image,
|
||||
AlienImage,
|
||||
|
@ -1,5 +1,6 @@
|
||||
TKernel
|
||||
TKMath
|
||||
CSF_OpenGlLibs
|
||||
CSF_XwLibs
|
||||
CSF_dpsLibs
|
||||
CSF_XmuLibs
|
||||
|
@ -59,7 +59,6 @@
|
||||
#else
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <Xw_WindowQuality.hxx>
|
||||
#include <Xw_Window.hxx>
|
||||
#endif
|
||||
|
||||
@ -96,8 +95,7 @@ Handle(V3d_Viewer) ViewerTest_Tool::MakeViewer (const Standard_CString theTitle)
|
||||
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
|
||||
Handle(Aspect_Window) window = new Cocoa_Window (theTitle, 0, 460, 409, 409);
|
||||
#else
|
||||
Handle(Aspect_Window) window = new Xw_Window (GetDisplayConnection(), theTitle,
|
||||
0, 460, 409, 409, Quantity_NOC_BLACK);
|
||||
Handle(Aspect_Window) window = new Xw_Window (GetDisplayConnection(), theTitle, 0, 460, 409, 409);
|
||||
#endif
|
||||
window->SetVirtual (Draw_VirtualWindows);
|
||||
window->Map();
|
||||
@ -122,7 +120,7 @@ Handle(V3d_Viewer) ViewerTest_Tool::MakeViewer (const Standard_CString theTitle)
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeContext
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(AIS_InteractiveContext) ViewerTest_Tool::MakeContext (const Standard_CString title)
|
||||
@ -134,7 +132,7 @@ Handle(AIS_InteractiveContext) ViewerTest_Tool::MakeContext (const Standard_CSt
|
||||
|
||||
//=======================================================================
|
||||
//function : InitViewerTest
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
// ********* next method is defined in ViewerTest_ViewerCommands.hxx ****
|
||||
@ -142,7 +140,7 @@ extern void ViewerTest_InitViewerTest (const Handle(AIS_InteractiveContext)&);
|
||||
// **********************************************************************
|
||||
|
||||
void ViewerTest_Tool::InitViewerTest (const Handle(AIS_InteractiveContext)& context)
|
||||
{
|
||||
{
|
||||
ViewerTest_InitViewerTest (context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,6 @@
|
||||
#include <Cocoa_Window.hxx>
|
||||
#include <tk.h>
|
||||
#else
|
||||
#include <Xw_WindowQuality.hxx>
|
||||
#include <Xw_Window.hxx>
|
||||
#include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
|
||||
#include <X11/Xutil.h>
|
||||
@ -247,8 +246,7 @@ void ViewerTest::ViewerInit (const Standard_Integer thePxLeft, const Standard_I
|
||||
VT_GetWindow() = new Xw_Window (aDisplayConnection,
|
||||
"Test3d",
|
||||
aPxLeft, aPxTop,
|
||||
aPxWidth, aPxHeight,
|
||||
Quantity_NOC_BLACK);
|
||||
aPxWidth, aPxHeight);
|
||||
}
|
||||
#endif
|
||||
VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
|
||||
|
@ -56,7 +56,6 @@ uses
|
||||
Graphic3d,
|
||||
Image,
|
||||
MMgt,
|
||||
Xw,
|
||||
WNT,
|
||||
OSD,
|
||||
Font
|
||||
|
@ -464,7 +464,7 @@ void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
|
||||
#else
|
||||
const Handle(Xw_Window) aWin = Handle(Xw_Window)::DownCast (theWindow);
|
||||
MyCView.DefWindow.XWindow = aWin->XWindow();
|
||||
MyCView.DefWindow.XParentWindow = aWin->XParentWindow();
|
||||
//MyCView.DefWindow.XParentWindow = aWin->XParentWindow();
|
||||
#endif
|
||||
|
||||
Standard_Integer Width, Height;
|
||||
@ -1091,7 +1091,7 @@ void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
|
||||
if (IsDeleted ()) return;
|
||||
|
||||
MyViewOrientation = VO;
|
||||
|
||||
|
||||
Standard_Real X, Y, Z;
|
||||
// Tests on modification of parameters.
|
||||
Standard_Boolean VUPIsModified = Standard_False;
|
||||
@ -1166,9 +1166,9 @@ void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
|
||||
|
||||
MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
|
||||
&& !VRUIsModified && !ScaleIsModified;
|
||||
|
||||
|
||||
if (! IsDefined ()) return;
|
||||
|
||||
|
||||
Standard_Boolean AWait = Standard_False; // => immediate update
|
||||
MyGraphicDriver->ViewOrientation (MyCView, AWait);
|
||||
IsInitialized = Standard_True;
|
||||
@ -1276,7 +1276,7 @@ void Visual3d_View::ViewOrientationReset () {
|
||||
// Restart if one of parameters is modified
|
||||
if (!IsInitialized || VUPIsModified || VRPIsModified
|
||||
|| VRUIsModified || ScaleIsModified || CustomIsModified) {
|
||||
|
||||
|
||||
MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
|
||||
&& !VRUIsModified && !ScaleIsModified;
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
CSF_XwLibs
|
||||
CSF_OpenGlLibs
|
||||
|
145
src/Xw/FILES
145
src/Xw/FILES
@ -1,144 +1,3 @@
|
||||
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
|
||||
Xw_Window.cxx
|
||||
Xw_Window.hxx
|
||||
|
124
src/Xw/Xw.cdl
124
src/Xw/Xw.cdl
@ -1,124 +0,0 @@
|
||||
-- Created on: 1993-06-24
|
||||
-- Created by: GG
|
||||
-- Copyright (c) 1993-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
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,
|
||||
TColStd
|
||||
|
||||
is
|
||||
|
||||
--------------------
|
||||
-- Category: Classes
|
||||
--------------------
|
||||
|
||||
class Window;
|
||||
---Purpose: Creates the X Window drawable.
|
||||
---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
|
||||
|
||||
-------------------------
|
||||
-- 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: 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;
|
@ -1,69 +0,0 @@
|
||||
// Created by: GG
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-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 ;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
-- Created on: 1996-10-03
|
||||
-- Created by: Jean GAUTIER
|
||||
-- Copyright (c) 1996-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
@ifnotdefined ( %Xw_EDL) then
|
||||
@set %Xw_EDL = "";
|
||||
@endif;
|
@ -1,64 +0,0 @@
|
||||
-- Copyright (c) 1996-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
@ifnotdefined ( %Xw_CMPLRS_EDL) then
|
||||
@set %Xw_CMPLRS_EDL = "";
|
||||
|
||||
@uses "CSF.edl";
|
||||
|
||||
-- Use GLX or Cocoa
|
||||
@ifnotdefined ( %MACOSX_USE_GLX ) then
|
||||
@set %MACOSX_USE_GLX = "${MACOSX_USE_GLX}";
|
||||
@endif;
|
||||
|
||||
@if ( %Station == "wnt" || (%Station == "mac" && %MACOSX_USE_GLX != "true")) 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;
|
File diff suppressed because it is too large
Load Diff
@ -1,312 +0,0 @@
|
||||
-- Created on: 1993-08-24
|
||||
-- Created by: GG
|
||||
-- Copyright (c) 1993-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
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 Window from Xw
|
||||
|
||||
end ColorMap;
|
@ -1,417 +0,0 @@
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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>
|
||||
#include <Standard_PCharacter.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,MaxDefineColor,FirstFreeColorIndex,visualid, MaxUserColor = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1,955 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 1995-1999 Matra Datavision
|
||||
Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
|
||||
The content of this file is subject to the Open CASCADE Technology Public
|
||||
License Version 6.5 (the "License"). You may not use the content of this file
|
||||
except in compliance with the License. Please obtain a copy of the License
|
||||
at http://www.opencascade.org and read it completely before using this file.
|
||||
|
||||
The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
|
||||
The Original Code and all software distributed under the License is
|
||||
distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
Initial Developer hereby disclaims all such warranties, including without
|
||||
limitation, any warranties of merchantability, fitness for a particular
|
||||
purpose or non-infringement. Please see the License for the specific terms
|
||||
and conditions governing the rights and limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
#define DRAD (M_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*/
|
@ -1,108 +0,0 @@
|
||||
-- Created on: 1993-08-24
|
||||
-- Created by: GG
|
||||
-- Copyright (c) 1993-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
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;
|
||||
|
||||
end FontMap;
|
@ -1,127 +0,0 @@
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
-- Created on: 1995-01-17
|
||||
-- Created by: GG
|
||||
-- Copyright (c) 1995-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
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 ;
|
||||
|
||||
end MarkMap ;
|
@ -1,140 +0,0 @@
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <Xw_MarkMap.ixx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_MarkerStyle.hxx>
|
||||
#include <Standard_ShortReal.hxx>
|
||||
#include <Standard_PCharacter.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);
|
||||
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
-- Created on: 1993-08-24
|
||||
-- Created by: GG
|
||||
-- Copyright (c) 1993-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
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 ;
|
||||
|
||||
end TypeMap ;
|
@ -1,135 +0,0 @@
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <Xw_TypeMap.ixx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_LineStyle.hxx>
|
||||
#include <Standard_ShortReal.hxx>
|
||||
#include <Standard_PCharacter.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);
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
-- Created on: 1999-07-15
|
||||
-- Created by: Atelier CAS2000
|
||||
-- Copyright (c) 1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
|
||||
@ifnotdefined ( %Xw_WOKSteps_EDL ) then
|
||||
---@set %Xw_WOKSteps_EDL = "";
|
||||
|
||||
-- Use GLX or Cocoa
|
||||
@ifnotdefined ( %MACOSX_USE_GLX ) then
|
||||
@set %MACOSX_USE_GLX = "${MACOSX_USE_GLX}";
|
||||
@endif;
|
||||
|
||||
--- Insert your stuff Here
|
||||
@if ( %Station == "wnt" || (%Station == "mac" && %MACOSX_USE_GLX != "true")) then
|
||||
-- Pas d'Xw sur Windows NT
|
||||
@set %WOKSteps_ObjGroup = "";
|
||||
@set %WOKSteps_DepGroup = "";
|
||||
@set %WOKSteps_LibGroup = "";
|
||||
@set %WOKSteps_ExecGroup = "";
|
||||
|
||||
|
||||
@endif;
|
||||
|
||||
|
||||
@endif;
|
@ -1,35 +0,0 @@
|
||||
-- Created on: 1999-07-15
|
||||
-- Created by: Atelier CAS2000
|
||||
-- Copyright (c) 1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
sss
|
||||
@ifnotdefined ( %Xw_WOKUMake_EDL ) then
|
||||
@set %Xw_WOKUMake_EDL = "";
|
||||
|
||||
-- Use GLX or Cocoa
|
||||
@ifnotdefined ( %MACOSX_USE_GLX ) then
|
||||
@set %MACOSX_USE_GLX = "${MACOSX_USE_GLX}";
|
||||
@endif;
|
||||
|
||||
--- Insert your stuff Here
|
||||
|
||||
@if ( %Station == "wnt" || (%Station == "mac" && %MACOSX_USE_GLX != "true")) then
|
||||
@set %WOKUMake_Steps = "*src xcpp.fill(src) xcpp.src(xcpp.fill) xcpp.header(xcpp.fill) .xcpp.template(xcpp.fill) obj.inc";
|
||||
@endif;
|
||||
@endif;
|
@ -1,107 +0,0 @@
|
||||
-- Created on: 1993-08-24
|
||||
-- Created by: GG
|
||||
-- Copyright (c) 1993-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
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 ;
|
||||
|
||||
end WidthMap ;
|
@ -1,124 +0,0 @@
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <Xw_WidthMap.ixx>
|
||||
#include <Aspect_WidthOfLine.hxx>
|
||||
#include <Standard_PCharacter.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);
|
||||
|
||||
}
|
@ -1,263 +0,0 @@
|
||||
-- Created on: 1991-11-18
|
||||
-- Created by: NW,JPB,CAL,GG
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
class Window from Xw
|
||||
|
||||
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,
|
||||
DisplayConnection_Handle from Aspect,
|
||||
PixMap from Image,
|
||||
NameOfColor from Quantity,
|
||||
Parameter from Quantity,
|
||||
Ratio from Quantity,
|
||||
Color from Quantity,
|
||||
ColorMap from Xw,
|
||||
WindowQuality from Xw,
|
||||
TypeOfVisual from Xw
|
||||
|
||||
raises
|
||||
|
||||
WindowDefinitionError from Aspect,
|
||||
WindowError from Aspect
|
||||
|
||||
is
|
||||
|
||||
Create ( theDisplayConnection : DisplayConnection_Handle from Aspect )
|
||||
returns mutable Window from Xw
|
||||
raises WindowDefinitionError from Aspect;
|
||||
---Level: Public
|
||||
|
||||
Create ( theDisplayConnection : DisplayConnection_Handle from Aspect ;
|
||||
aPart1, aPart2 : Integer from Standard ;
|
||||
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 ( theDisplayConnection : DisplayConnection_Handle from Aspect ;
|
||||
aWindow : Handle from Aspect;
|
||||
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 ( theDisplayConnection : DisplayConnection_Handle from Aspect ;
|
||||
theTitle : CString from Standard ;
|
||||
thePxLeft : Integer from Standard ;
|
||||
thePxTop : Integer from Standard ;
|
||||
thePxWidth : Integer from Standard ;
|
||||
thePxHeight : Integer from Standard ;
|
||||
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
|
||||
---------------------------------------------------
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
----------------------------
|
||||
|
||||
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 Integer from Standard ) is virtual;
|
||||
---Level: Public
|
||||
---Purpose: Returns The Window POSITION in PIXEL
|
||||
---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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
SetWindow ( me: mutable ; aWindow : Handle from Aspect ;
|
||||
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 ;
|
||||
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
|
||||
|
||||
MyXWindow : Handle from Aspect is protected ;
|
||||
MyXParentWindow : Handle from Aspect is protected ;
|
||||
MyVisualClass : TypeOfVisual from Xw is protected ;
|
||||
MyExtendedDisplay : Address from Standard is protected ;
|
||||
MyExtendedWindow : Address from Standard is protected ;
|
||||
myDisplayConnection : DisplayConnection_Handle from Aspect is protected;
|
||||
|
||||
end Window ;
|
696
src/Xw/Xw_Window.cxx
Executable file → Normal file
696
src/Xw/Xw_Window.cxx
Executable file → Normal file
@ -1,6 +1,6 @@
|
||||
// Created by: NW,JPB,CAL,GG
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
// Created on: 2013-04-06
|
||||
// Created by: Kirill Gavrilov
|
||||
// Copyright (c) 2013 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
@ -17,449 +17,347 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#define BUC60701 //GG 23/06/00 Enable to dump an exact image size
|
||||
// according to the window size
|
||||
#define RIC120302 //GG Add a NEW XParentWindow methods which enable
|
||||
// to retrieve the parent of the actual Xwindow ID.
|
||||
#include <Xw_Window.hxx>
|
||||
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
|
||||
//-Version
|
||||
|
||||
//-Design Creation d'une fenetre X
|
||||
|
||||
//-Warning
|
||||
|
||||
//-References
|
||||
|
||||
//-Language C++ 2.0
|
||||
|
||||
//-Declarations
|
||||
|
||||
// for the class
|
||||
#include <Xw_Window.ixx>
|
||||
// Routines C a declarer en extern
|
||||
//extern "C" {
|
||||
#include <Xw_Cextern.hxx>
|
||||
//}
|
||||
#include <Aspect_Convert.hxx>
|
||||
#include <Aspect_DisplayConnection.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <Standard_PCharacter.hxx>
|
||||
#include <Aspect_WindowDefinitionError.hxx>
|
||||
|
||||
#include <Xw_Extension.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
//-Static data definitions
|
||||
|
||||
static XW_STATUS status ;
|
||||
|
||||
//============================================================================
|
||||
//==== HashCode : Returns a HashCode CString
|
||||
//============================================================================
|
||||
inline Standard_Integer HashCode (const Standard_CString Value)
|
||||
namespace
|
||||
{
|
||||
Standard_Integer i,n,aHashCode = 0;
|
||||
union {
|
||||
char charPtr[80];
|
||||
int intPtr[20];
|
||||
} u;
|
||||
|
||||
n = strlen(Value);
|
||||
|
||||
if( n > 0 ) {
|
||||
if( n < 80 ) {
|
||||
n = (n+3)/4;
|
||||
u.intPtr[n-1] = 0;
|
||||
strcpy(u.charPtr,Value);
|
||||
} else {
|
||||
n = 20;
|
||||
strncpy(u.charPtr,Value,80);
|
||||
}
|
||||
|
||||
for( i=0 ; i<n ; i++ ) {
|
||||
aHashCode = aHashCode ^ u.intPtr[i];
|
||||
}
|
||||
}
|
||||
|
||||
//printf(" HashCode of '%s' is %d\n",Value,aHashCode);
|
||||
|
||||
return Abs(aHashCode) + 1;
|
||||
}
|
||||
|
||||
void Xw_Window::PrintError() {
|
||||
Standard_CString ErrorMessag ;
|
||||
Standard_Integer ErrorNumber ;
|
||||
Standard_Integer ErrorGravity ;
|
||||
|
||||
status = XW_SUCCESS ;
|
||||
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
|
||||
Xw_print_error() ;
|
||||
}
|
||||
|
||||
//-Aliases
|
||||
|
||||
//-Global data definitions
|
||||
|
||||
//-Constructors
|
||||
|
||||
Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
|
||||
: Aspect_Window(),
|
||||
myDisplayConnection (theDisplayConnection)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Xw_Window
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
|
||||
const Standard_Integer aPart1,
|
||||
const Standard_Integer aPart2,
|
||||
const Quantity_NameOfColor BackColor)
|
||||
: Aspect_Window(),
|
||||
myDisplayConnection (theDisplayConnection)
|
||||
{
|
||||
Init();
|
||||
Aspect_Handle aWindow = (aPart1 << 16) | (aPart2 & 0xFFFF);
|
||||
SetWindow (aWindow, BackColor);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Xw_Window
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
|
||||
const Aspect_Handle aWindow,
|
||||
const Quantity_NameOfColor BackColor)
|
||||
: Aspect_Window(),
|
||||
myDisplayConnection (theDisplayConnection)
|
||||
{
|
||||
Init();
|
||||
SetWindow (aWindow, BackColor);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Xw_Window
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
|
||||
const Standard_CString theTitle,
|
||||
const Standard_Integer thePxLeft,
|
||||
const Standard_Integer thePxTop,
|
||||
const Standard_Integer theWidth,
|
||||
const Standard_Integer theHeight,
|
||||
const Quantity_NameOfColor theBackColor,
|
||||
const Aspect_Handle theParent)
|
||||
: Aspect_Window (),
|
||||
myDisplayConnection (theDisplayConnection)
|
||||
{
|
||||
Init();
|
||||
|
||||
Standard_Integer aParentSizeX = 1;
|
||||
Standard_Integer aParentSizeY = 1;
|
||||
|
||||
Aspect_Handle aRoot, aColormap, *aDisplay;
|
||||
Xw_TypeOfVisual aVisualClass;
|
||||
Standard_Integer aVisualDepth;
|
||||
Xw_get_display_info (MyExtendedDisplay,
|
||||
&aDisplay, &aRoot, &aColormap, &aVisualClass, &aVisualDepth);
|
||||
Xw_get_screen_size (MyExtendedDisplay, &aParentSizeX, &aParentSizeY);
|
||||
if (theParent)
|
||||
//! Search for RGBA double-buffered visual
|
||||
static int TheDoubleBuff[] =
|
||||
{
|
||||
XWindowAttributes anAttributes;
|
||||
if(XGetWindowAttributes ((Display* )aDisplay, theParent, &anAttributes))
|
||||
{
|
||||
aParentSizeX = anAttributes.width;
|
||||
aParentSizeY = anAttributes.height;
|
||||
}
|
||||
}
|
||||
Quantity_Parameter aQCenterX, aQCenterY, aQSizeX, aQSizeY;
|
||||
Aspect_Convert::ConvertCoordinates (aParentSizeX, aParentSizeY,
|
||||
thePxLeft, thePxTop, theWidth, theHeight,
|
||||
aQCenterX, aQCenterY, aQSizeX, aQSizeY);
|
||||
SetWindow (theTitle, aQCenterX, aQCenterY, aQSizeX, aQSizeY,
|
||||
theBackColor, theParent);
|
||||
}
|
||||
GLX_RGBA,
|
||||
GLX_DEPTH_SIZE, 16,
|
||||
GLX_DOUBLEBUFFER,
|
||||
None
|
||||
};
|
||||
|
||||
void Xw_Window::Init()
|
||||
};
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE (Xw_Window, Aspect_Window)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Xw_Window, Aspect_Window)
|
||||
|
||||
// =======================================================================
|
||||
// function : Xw_Window
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
const Standard_CString theTitle,
|
||||
const Standard_Integer thePxLeft,
|
||||
const Standard_Integer thePxTop,
|
||||
const Standard_Integer thePxWidth,
|
||||
const Standard_Integer thePxHeight)
|
||||
: Aspect_Window(),
|
||||
myDisplay (theXDisplay),
|
||||
myXWindow (0),
|
||||
myXLeft (thePxLeft),
|
||||
myYTop (thePxTop),
|
||||
myXRight (thePxLeft + thePxWidth),
|
||||
myYBottom (thePxTop + thePxHeight),
|
||||
myIsOwnWin (Standard_True)
|
||||
{
|
||||
MyXWindow = 0 ;
|
||||
MyXParentWindow = 0 ;
|
||||
#if defined(__APPLE__) && !defined(MACOSX_USE_GLX)
|
||||
MyExtendedDisplay = NULL;
|
||||
#else
|
||||
MyExtendedDisplay = Xw_set_display (myDisplayConnection->GetDisplay());
|
||||
#endif
|
||||
MyExtendedWindow = NULL ;
|
||||
MyVisualClass = Xw_TOV_TRUECOLOR;
|
||||
int aDummy = 0;
|
||||
if (thePxWidth <= 0 || thePxHeight <= 0)
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, Coordinate(s) out of range");
|
||||
}
|
||||
else if (theXDisplay.IsNull())
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, X Display connection is undefined");
|
||||
return;
|
||||
}
|
||||
else if (!glXQueryExtension (myDisplay->GetDisplay(), &aDummy, &aDummy))
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, GLX extension is unavailable");
|
||||
return;
|
||||
}
|
||||
|
||||
Display* aDisp = myDisplay->GetDisplay();
|
||||
int aScreen = DefaultScreen(aDisp);
|
||||
Window aParent = RootWindow (aDisp, aScreen);
|
||||
|
||||
XVisualInfo* aVisInfo = glXChooseVisual (aDisp, aScreen, TheDoubleBuff);
|
||||
if (aVisInfo == NULL)
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, couldn't find compatible Visual (RGBA, double-buffered)");
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long aMask = 0;
|
||||
XSetWindowAttributes aWinAttr;
|
||||
memset(&aWinAttr, 0, sizeof(XSetWindowAttributes));
|
||||
aWinAttr.event_mask = ExposureMask | StructureNotifyMask;
|
||||
aMask |= CWEventMask;
|
||||
aWinAttr.colormap = XCreateColormap(aDisp, aParent, aVisInfo->visual, AllocNone);
|
||||
aWinAttr.border_pixel = 0;
|
||||
aWinAttr.override_redirect = False;
|
||||
|
||||
myXWindow = XCreateWindow(aDisp, aParent,
|
||||
myXLeft, myYTop, thePxWidth, thePxHeight,
|
||||
0, aVisInfo->depth,
|
||||
InputOutput,
|
||||
aVisInfo->visual,
|
||||
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &aWinAttr);
|
||||
XFree (aVisInfo); aVisInfo = NULL;
|
||||
if (myXWindow == 0)
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, Unable to create window");
|
||||
return;
|
||||
}
|
||||
|
||||
// if parent - desktop
|
||||
XSizeHints aSizeHints;
|
||||
aSizeHints.x = myXLeft;
|
||||
aSizeHints.y = myYTop;
|
||||
aSizeHints.flags = PPosition;
|
||||
aSizeHints.width = thePxWidth;
|
||||
aSizeHints.height = thePxHeight;
|
||||
aSizeHints.flags |= PSize;
|
||||
XSetStandardProperties (aDisp, myXWindow, theTitle, theTitle, None,
|
||||
NULL, 0, &aSizeHints);
|
||||
|
||||
/*XTextProperty aTitleProperty;
|
||||
aTitleProperty.encoding = None;
|
||||
char* aTitle = (char* )theTitle;
|
||||
Xutf8TextListToTextProperty(aDisp, &aTitle, 1, XUTF8StringStyle, &aTitleProperty);
|
||||
XSetWMName (aDisp, myXWindow, &aTitleProperty);
|
||||
XSetWMProperties(aDisp, myXWindow, &aTitleProperty, &aTitleProperty, NULL, 0, NULL, NULL, NULL);*/
|
||||
|
||||
XFlush (aDisp);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWindow
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Xw_Window::SetWindow (const Aspect_Handle aWindow,
|
||||
const Quantity_NameOfColor BackColor)
|
||||
// =======================================================================
|
||||
// function : Xw_Window
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
const Window theXWin)
|
||||
: Aspect_Window(),
|
||||
myDisplay (theXDisplay),
|
||||
myXWindow (theXWin),
|
||||
myXLeft (0),
|
||||
myYTop (0),
|
||||
myXRight (512),
|
||||
myYBottom (512),
|
||||
myIsOwnWin (Standard_False)
|
||||
{
|
||||
Aspect_Handle window,root,colormap,pixmap ;
|
||||
Xw_TypeOfVisual visualclass ;
|
||||
int visualdepth,visualid ;
|
||||
|
||||
MyXWindow = aWindow ;
|
||||
MyXParentWindow = aWindow ;
|
||||
|
||||
if( !MyXWindow ) {
|
||||
PrintError() ;
|
||||
int aDummy = 0;
|
||||
if (theXWin == 0)
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, given invalid X window");
|
||||
return;
|
||||
}
|
||||
else if (theXDisplay.IsNull())
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, X Display connection is undefined");
|
||||
return;
|
||||
}
|
||||
else if (!glXQueryExtension (myDisplay->GetDisplay(), &aDummy, &aDummy))
|
||||
{
|
||||
myXWindow = 0;
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, GLX extension is unavailable");
|
||||
return;
|
||||
}
|
||||
|
||||
MyExtendedWindow =
|
||||
Xw_def_window (MyExtendedDisplay,MyXWindow,Standard_False);
|
||||
Display* aDisp = myDisplay->GetDisplay();
|
||||
|
||||
status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap,
|
||||
&root,&colormap,&visualclass,
|
||||
&visualdepth,&visualid);
|
||||
if( !status ) {
|
||||
PrintError() ;
|
||||
XWindowAttributes aWinAttr;
|
||||
XGetWindowAttributes (aDisp, myXWindow, &aWinAttr);
|
||||
const int aScreen = DefaultScreen (aDisp);
|
||||
const long aVisInfoMask = VisualIDMask | VisualScreenMask;
|
||||
XVisualInfo aVisInfoTmp;
|
||||
aVisInfoTmp.visualid = aWinAttr.visual->visualid;
|
||||
aVisInfoTmp.screen = aScreen;
|
||||
int aNbItems = 0;
|
||||
XVisualInfo* aVisInfo = XGetVisualInfo (aDisp, aVisInfoMask, &aVisInfoTmp, &aNbItems);
|
||||
if (aVisInfo == NULL)
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, Visual is unavailable");
|
||||
return;
|
||||
}
|
||||
XFree (aVisInfo);
|
||||
|
||||
SetBackground(BackColor) ;
|
||||
DoResize();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWindow
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Xw_Window::SetWindow (const Standard_CString Title,
|
||||
const Quantity_Parameter Xc,
|
||||
const Quantity_Parameter Yc,
|
||||
const Quantity_Parameter Width,
|
||||
const Quantity_Parameter Height,
|
||||
const Quantity_NameOfColor BackColor,
|
||||
const Aspect_Handle Parent)
|
||||
// =======================================================================
|
||||
// function : Destroy
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Xw_Window::Destroy()
|
||||
{
|
||||
Standard_Integer istransparent = Standard_False ;
|
||||
|
||||
MyXParentWindow = Parent ;
|
||||
MyXWindow = 0 ;
|
||||
|
||||
MyXWindow = Xw_open_window(MyExtendedDisplay,MyVisualClass,MyXParentWindow,
|
||||
(float)Xc,(float)Yc,(float)Width,(float)Height,
|
||||
(Standard_PCharacter)Title,istransparent) ;
|
||||
if( !MyXWindow ) {
|
||||
PrintError() ;
|
||||
if (myIsOwnWin && myXWindow != 0 && !myDisplay.IsNull())
|
||||
{
|
||||
XDestroyWindow (myDisplay->GetDisplay(), myXWindow);
|
||||
}
|
||||
|
||||
MyExtendedWindow =
|
||||
Xw_def_window (MyExtendedDisplay,MyXWindow,istransparent);
|
||||
|
||||
SetBackground(BackColor) ;
|
||||
|
||||
if( MyXParentWindow && (MyXWindow != MyXParentWindow) ) Map() ;
|
||||
|
||||
}
|
||||
|
||||
void Xw_Window::Map () const {
|
||||
#ifdef RIC120302
|
||||
if( MyXWindow == MyXParentWindow ) return;
|
||||
#endif
|
||||
if (IsVirtual()) return;
|
||||
status = Xw_set_window_state (MyExtendedWindow, XW_MAP);
|
||||
if( !status ) {
|
||||
PrintError() ;
|
||||
}
|
||||
// =======================================================================
|
||||
// function : XWindow
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Window Xw_Window::XWindow() const
|
||||
{
|
||||
return myXWindow;
|
||||
}
|
||||
|
||||
void Xw_Window::Unmap () const {
|
||||
#ifdef RIC120302
|
||||
if( MyXWindow == MyXParentWindow ) return;
|
||||
#endif
|
||||
status = Xw_set_window_state (MyExtendedWindow, XW_ICONIFY);
|
||||
if( !status ) {
|
||||
PrintError() ;
|
||||
}
|
||||
}
|
||||
|
||||
Aspect_TypeOfResize Xw_Window::DoResize () const {
|
||||
XW_RESIZETYPE state ;
|
||||
|
||||
state = Xw_resize_window (MyExtendedWindow);
|
||||
// if( state == Aspect_TOR_UNKNOWN ) {
|
||||
if( state == XW_TOR_UNKNOWN ) {
|
||||
PrintError() ;
|
||||
}
|
||||
|
||||
return (Aspect_TypeOfResize(state)) ;
|
||||
}
|
||||
|
||||
Standard_Boolean Xw_Window::DoMapping () const {
|
||||
int pxc,pyc,width,height;
|
||||
XW_WINDOWSTATE state;
|
||||
|
||||
state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&width,&height);
|
||||
|
||||
return IsMapped();
|
||||
}
|
||||
|
||||
void Xw_Window::Destroy () {
|
||||
Standard_Boolean destroy =
|
||||
( MyXWindow == MyXParentWindow ) ? Standard_False : Standard_True;
|
||||
|
||||
status = Xw_close_window (MyExtendedWindow,destroy);
|
||||
if( !status ) {
|
||||
PrintError() ;
|
||||
}
|
||||
|
||||
MyXWindow = 0 ;
|
||||
MyExtendedWindow = NULL ;
|
||||
}
|
||||
|
||||
void Xw_Window::SetCursor (const Standard_Integer anId, const Quantity_NameOfColor aColor) const {
|
||||
Quantity_Color Color(aColor) ;
|
||||
Standard_Real r,g,b ;
|
||||
|
||||
Color.Values(r,g,b,Quantity_TOC_RGB) ;
|
||||
|
||||
status = Xw_set_hard_cursor (MyExtendedWindow,(int)anId,0,
|
||||
(float)r,
|
||||
(float)g,
|
||||
(float)b) ;
|
||||
|
||||
if( !status ) {
|
||||
PrintError() ;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Boolean Xw_Window::IsMapped () const {
|
||||
if (IsVirtual()) {
|
||||
// =======================================================================
|
||||
// function : IsMapped
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Xw_Window::IsMapped() const
|
||||
{
|
||||
if (myXWindow == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (IsVirtual())
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
XW_WINDOWSTATE state;
|
||||
state = Xw_get_window_state (MyExtendedWindow);
|
||||
switch (state) {
|
||||
case XW_WS_UNKNOWN:
|
||||
return Standard_False;
|
||||
case XW_ICONIFY:
|
||||
return Standard_False;
|
||||
case XW_PUSH:
|
||||
return Standard_True;
|
||||
case XW_MAP:
|
||||
return Standard_True;
|
||||
#ifndef DEB
|
||||
default:
|
||||
return Standard_False;
|
||||
#endif
|
||||
}
|
||||
return Standard_False;
|
||||
|
||||
XFlush (myDisplay->GetDisplay());
|
||||
XWindowAttributes aWinAttr;
|
||||
XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &aWinAttr);
|
||||
return aWinAttr.map_state == IsUnviewable
|
||||
|| aWinAttr.map_state == IsViewable;
|
||||
}
|
||||
|
||||
Standard_Real Xw_Window::Ratio () const {
|
||||
int width, height;
|
||||
// =======================================================================
|
||||
// function : Map
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Xw_Window::Map() const
|
||||
{
|
||||
if (IsVirtual() || myXWindow == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
status = Xw_get_window_size (MyExtendedWindow,&width,&height);
|
||||
if( !status ) {
|
||||
Xw_print_error() ;
|
||||
}
|
||||
|
||||
return ((Standard_Real)width/height) ;
|
||||
XMapWindow (myDisplay->GetDisplay(), myXWindow);
|
||||
XFlush (myDisplay->GetDisplay());
|
||||
}
|
||||
|
||||
void Xw_Window::Size (Standard_Integer &Width, Standard_Integer &Height) const {
|
||||
int width, height;
|
||||
status = Xw_get_window_size (MyExtendedWindow,&width,&height);
|
||||
if( !status ) {
|
||||
Xw_print_error() ;
|
||||
}
|
||||
// =======================================================================
|
||||
// function : Unmap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Xw_Window::Unmap() const
|
||||
{
|
||||
if (IsVirtual() || myXWindow == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Width = width ;
|
||||
Height = height ;
|
||||
XIconifyWindow (myDisplay->GetDisplay(), myXWindow, DefaultScreen(myDisplay->GetDisplay()));
|
||||
}
|
||||
|
||||
void Xw_Window::Position (Standard_Integer &X1, Standard_Integer &Y1, Standard_Integer &X2, Standard_Integer &Y2) const {
|
||||
XW_WINDOWSTATE state = XW_WS_UNKNOWN ;
|
||||
int pxc, pyc;
|
||||
int width, height;
|
||||
// =======================================================================
|
||||
// function : DoResize
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Aspect_TypeOfResize Xw_Window::DoResize() const
|
||||
{
|
||||
if (myXWindow == 0)
|
||||
{
|
||||
return Aspect_TOR_UNKNOWN;
|
||||
}
|
||||
|
||||
state = Xw_get_window_position (MyExtendedWindow,
|
||||
&pxc,&pyc,&width,&height);
|
||||
if( state == XW_WS_UNKNOWN ) {
|
||||
Xw_print_error() ;
|
||||
}
|
||||
XFlush (myDisplay->GetDisplay());
|
||||
XWindowAttributes aWinAttr;
|
||||
XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &aWinAttr);
|
||||
if (aWinAttr.map_state == IsUnmapped)
|
||||
{
|
||||
return Aspect_TOR_UNKNOWN;
|
||||
}
|
||||
|
||||
X1 = pxc - width/2 ; Y1 = pyc - height/2 ;
|
||||
X2 = X1 + width - 1 ; Y2 = Y1 + height - 1 ;
|
||||
Standard_Integer aMask = 0;
|
||||
Aspect_TypeOfResize aMode = Aspect_TOR_UNKNOWN;
|
||||
|
||||
if (Abs (aWinAttr.x - myXLeft ) > 2) aMask |= 1;
|
||||
if (Abs ((aWinAttr.x + aWinAttr.width) - myXRight ) > 2) aMask |= 2;
|
||||
if (Abs (aWinAttr.y - myYTop ) > 2) aMask |= 4;
|
||||
if (Abs ((aWinAttr.y + aWinAttr.height) - myYBottom) > 2) aMask |= 8;
|
||||
switch (aMask)
|
||||
{
|
||||
case 0: aMode = Aspect_TOR_NO_BORDER; break;
|
||||
case 1: aMode = Aspect_TOR_LEFT_BORDER; break;
|
||||
case 2: aMode = Aspect_TOR_RIGHT_BORDER; break;
|
||||
case 4: aMode = Aspect_TOR_TOP_BORDER; break;
|
||||
case 5: aMode = Aspect_TOR_LEFT_AND_TOP_BORDER; break;
|
||||
case 6: aMode = Aspect_TOR_TOP_AND_RIGHT_BORDER; break;
|
||||
case 8: aMode = Aspect_TOR_BOTTOM_BORDER; break;
|
||||
case 9: aMode = Aspect_TOR_BOTTOM_AND_LEFT_BORDER; break;
|
||||
case 10: aMode = Aspect_TOR_RIGHT_AND_BOTTOM_BORDER; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
*((Standard_Integer* )&myXLeft ) = aWinAttr.x;
|
||||
*((Standard_Integer* )&myXRight ) = aWinAttr.x + aWinAttr.width;
|
||||
*((Standard_Integer* )&myYTop ) = aWinAttr.y;
|
||||
*((Standard_Integer* )&myYBottom ) = aWinAttr.y + aWinAttr.height;
|
||||
return aMode;
|
||||
}
|
||||
|
||||
Aspect_Handle Xw_Window::XWindow () const {
|
||||
|
||||
return (MyXWindow);
|
||||
|
||||
// =======================================================================
|
||||
// function : DoMapping
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Xw_Window::DoMapping() const
|
||||
{
|
||||
return Standard_True; // IsMapped()
|
||||
}
|
||||
|
||||
void Xw_Window::XWindow (Standard_Integer& aPart1, Standard_Integer& aPart2) const {
|
||||
// =======================================================================
|
||||
// function : Ratio
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Quantity_Ratio Xw_Window::Ratio() const
|
||||
{
|
||||
if (myXWindow == 0)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
aPart1 = (Standard_Integer)((MyXWindow >> 16 ) & 0xffff);
|
||||
aPart2 = (Standard_Integer)(MyXWindow & 0xffff);
|
||||
XFlush (myDisplay->GetDisplay());
|
||||
XWindowAttributes aWinAttr;
|
||||
XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &aWinAttr);
|
||||
return Quantity_Ratio(aWinAttr.width) / Quantity_Ratio(aWinAttr.height);
|
||||
}
|
||||
|
||||
// RIC120302
|
||||
Aspect_Handle Xw_Window::XParentWindow () const {
|
||||
|
||||
return (MyXParentWindow);
|
||||
|
||||
// =======================================================================
|
||||
// function : Position
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Xw_Window::Position (Standard_Integer& X1, Standard_Integer& Y1,
|
||||
Standard_Integer& X2, Standard_Integer& Y2) const
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
void Xw_Window::XParentWindow (Standard_Integer& aPart1, Standard_Integer& aPart2) const {
|
||||
// =======================================================================
|
||||
// function : Size
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Xw_Window::Size (Standard_Integer& theWidth,
|
||||
Standard_Integer& theHeight) const
|
||||
{
|
||||
if (myXWindow == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
aPart1 = (Standard_Integer)((MyXParentWindow >> 16 ) & 0xffff);
|
||||
aPart2 = (Standard_Integer)(MyXParentWindow & 0xffff);
|
||||
}
|
||||
// RIC120302
|
||||
|
||||
Aspect_Handle Xw_Window::XPixmap () const {
|
||||
Aspect_Handle window,pixmap,root,colormap ;
|
||||
Xw_TypeOfVisual visualclass ;
|
||||
int visualdepth,visualid ;
|
||||
|
||||
status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap,
|
||||
&root,&colormap,&visualclass,&visualdepth,&visualid) ;
|
||||
|
||||
return (pixmap);
|
||||
XFlush (myDisplay->GetDisplay());
|
||||
XWindowAttributes aWinAttr;
|
||||
XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &aWinAttr);
|
||||
theWidth = aWinAttr.width;
|
||||
theHeight = aWinAttr.height;
|
||||
}
|
||||
|
||||
Standard_Boolean Xw_Window::PointerPosition (Standard_Integer& X, Standard_Integer& Y) const {
|
||||
Standard_Boolean cstatus ;
|
||||
int x,y ;
|
||||
|
||||
cstatus = Xw_get_cursor_position(MyExtendedWindow,&x,&y) ;
|
||||
X = x ;
|
||||
Y = y ;
|
||||
|
||||
return (cstatus);
|
||||
}
|
||||
|
||||
Xw_TypeOfVisual Xw_Window::VisualClass () const {
|
||||
|
||||
return (MyVisualClass);
|
||||
|
||||
}
|
||||
|
||||
Standard_Boolean Xw_Window::BackgroundPixel ( Standard_Integer &aPixel ) const {
|
||||
unsigned long pixel ;
|
||||
|
||||
status = Xw_get_background_pixel(MyExtendedWindow,&pixel) ;
|
||||
if( !status ) PrintError() ;
|
||||
|
||||
aPixel = Standard_Integer(pixel);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
Standard_Address Xw_Window::ExtendedWindow () const {
|
||||
|
||||
return (MyExtendedWindow);
|
||||
|
||||
}
|
||||
#endif // Win32 or Mac OS X
|
||||
|
124
src/Xw/Xw_Window.hxx
Normal file
124
src/Xw/Xw_Window.hxx
Normal file
@ -0,0 +1,124 @@
|
||||
// Created on: 2013-04-06
|
||||
// Created by: Kirill Gavrilov
|
||||
// Copyright (c) 2013 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 65 (the "License") You may not use the content of this file
|
||||
// except in compliance with the License Please obtain a copy of the License
|
||||
// at http://wwwopencascadeorg and read it completely before using this file
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE SAS, having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License
|
||||
|
||||
#ifndef _Xw_Window_H__
|
||||
#define _Xw_Window_H__
|
||||
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
|
||||
#include <Aspect_Window.hxx>
|
||||
|
||||
#include <Aspect_DisplayConnection.hxx>
|
||||
#include <Aspect_FillMethod.hxx>
|
||||
#include <Aspect_GradientFillMethod.hxx>
|
||||
#include <Aspect_Handle.hxx>
|
||||
#include <Aspect_TypeOfResize.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <Quantity_Parameter.hxx>
|
||||
#include <Quantity_Ratio.hxx>
|
||||
|
||||
class Aspect_WindowDefinitionError;
|
||||
class Aspect_WindowError;
|
||||
class Aspect_Background;
|
||||
class Quantity_Color;
|
||||
class Aspect_GradientBackground;
|
||||
|
||||
//! This class defines XLib window intended for creation of OpenGL context.
|
||||
class Xw_Window : public Aspect_Window
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Creates a XLib window defined by his position and size in pixels.
|
||||
//! Throws exception if window can not be created or Display do not support GLX extension.
|
||||
Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
const Standard_CString theTitle,
|
||||
const Standard_Integer thePxLeft,
|
||||
const Standard_Integer thePxTop,
|
||||
const Standard_Integer thePxWidth,
|
||||
const Standard_Integer thePxHeight);
|
||||
|
||||
//! Creates a wrapper over existing Window handle
|
||||
Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
const Window theXWin);
|
||||
|
||||
//! Destroies the Window and all resourses attached to it
|
||||
Standard_EXPORT virtual void Destroy();
|
||||
|
||||
~Xw_Window()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
//! Opens the window <me>
|
||||
Standard_EXPORT virtual void Map() const;
|
||||
|
||||
//! Closes the window <me>
|
||||
Standard_EXPORT virtual void Unmap() const;
|
||||
|
||||
//! Applies the resizing to the window <me>
|
||||
Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const;
|
||||
|
||||
//! Apply the mapping change to the window <me>
|
||||
Standard_EXPORT virtual Standard_Boolean DoMapping() const;
|
||||
|
||||
//! Returns True if the window <me> is opened
|
||||
Standard_EXPORT virtual Standard_Boolean IsMapped() const;
|
||||
|
||||
//! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
|
||||
Standard_EXPORT virtual Quantity_Ratio Ratio() const;
|
||||
|
||||
//! Returns The Window POSITION in PIXEL
|
||||
Standard_EXPORT virtual void Position (Standard_Integer& X1,
|
||||
Standard_Integer& Y1,
|
||||
Standard_Integer& X2,
|
||||
Standard_Integer& Y2) const;
|
||||
|
||||
//! Returns The Window SIZE in PIXEL
|
||||
Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
|
||||
Standard_Integer& theHeight) const;
|
||||
|
||||
//! @return native Window handle
|
||||
Standard_EXPORT Window XWindow() const;
|
||||
|
||||
//! @return connection to X Display
|
||||
Standard_EXPORT const Handle(Aspect_DisplayConnection)& DisplayConnection() const;
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Aspect_DisplayConnection) myDisplay; //!< X Display connection
|
||||
Window myXWindow; //!< XLib window handle
|
||||
Standard_Integer myXLeft; //!< left position in pixels
|
||||
Standard_Integer myYTop; //!< top position in pixels
|
||||
Standard_Integer myXRight; //!< right position in pixels
|
||||
Standard_Integer myYBottom; //!< bottom position in pixels
|
||||
Standard_Boolean myIsOwnWin; //!< flag to indicate own window handle (to be deallocated on destruction)
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(Xw_Window)
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Xw_Window, Aspect_Window)
|
||||
|
||||
#endif // Win32 or Mac OS X
|
||||
#endif // _Xw_Window_H__
|
@ -1,200 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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;
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
// Created on: 2002-02-20
|
||||
// Created by: Sergey ALTUKHOV
|
||||
// Copyright (c) 2002-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -1,581 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*
|
||||
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) ;
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,206 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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);
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,191 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,618 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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*/
|
@ -1,314 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,223 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,535 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,494 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,275 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,600 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,326 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,459 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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.*M_PI ) angle -= 2.*M_PI ;
|
||||
} else if( angle < 0. ) {
|
||||
while( angle < -2.*M_PI ) angle += 2.*M_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) ;
|
||||
}
|
@ -1,399 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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;
|
||||
}
|
@ -1,469 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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.*M_PI ) angle -= 2.*M_PI ;
|
||||
} else if( angle < 0. ) {
|
||||
while( angle < -2.*M_PI ) angle += 2.*M_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) ;
|
||||
}
|
@ -1,202 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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;
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
// 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);
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*
|
||||
// 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);
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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 ) ;
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,325 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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 ) ;
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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 ) ;
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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 ;
|
||||
}
|
@ -1,180 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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;
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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) ;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/* 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);
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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 ) ;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,270 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#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);
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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 ) ;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#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);
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <Xw_Extension.h>
|
||||
|
||||
/* ifdef then trace on */
|
||||
#ifdef TRACE
|
||||
#define TRACE_GET_PIXEL_WINDOWVALUE
|
||||
#endif
|
||||
|
||||
/*
|
||||
int Xw_get_pixel_windowvalue (awindow,uv):
|
||||
XW_EXT_WINDOW *awindow
|
||||
float uv User Value defined in DWU space
|
||||
|
||||
Returns Pixel value from transformed User Value
|
||||
|
||||
NOTE than the current mapping defined by Xw_set_mapping is apply
|
||||
|
||||
*/
|
||||
|
||||
#ifdef XW_PROTOTYPE
|
||||
int Xw_get_pixel_windowvalue(void *awindow,float uv)
|
||||
#else
|
||||
int Xw_get_pixel_windowvalue(awindow,uv)
|
||||
void *awindow;
|
||||
float uv ;
|
||||
#endif /*XW_PROTOTYPE*/
|
||||
{
|
||||
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
|
||||
int pv ;
|
||||
|
||||
if( !Xw_isdefine_window(pwindow) ) {
|
||||
/*ERROR*Bad EXT_WINDOW Address*/
|
||||
Xw_set_error(24,"Xw_get_pixel_windowvalue",pwindow) ;
|
||||
return (0) ;
|
||||
}
|
||||
|
||||
//OCC186
|
||||
pv = PVALUE( uv, pwindow->xratio, pwindow->yratio );
|
||||
//OCC186
|
||||
|
||||
#ifdef TRACE_GET_PIXEL_WINDOWVALUE
|
||||
if( Xw_get_trace() > 1 ) {
|
||||
printf (" %d = Xw_get_pixel_windowvalue(%lx,%f)\n",pv,(long ) pwindow,uv) ;
|
||||
}
|
||||
#endif
|
||||
return (pv) ;
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <Xw_Extension.h>
|
||||
|
||||
/* ifdef then trace on */
|
||||
#ifdef TRACE
|
||||
#define TRACE_GET_RGBPIXEL
|
||||
#endif
|
||||
|
||||
/*
|
||||
STATUS Xw_get_rgbpixel (aimage,x,y,r,g,b,npixel):
|
||||
XW_EXT_IMAGEDATA *aimage
|
||||
int x,y Pixel position
|
||||
float *r,*g,*b return R,G,B Pixel values
|
||||
int *npixel return Pixel number filled with
|
||||
the same color index
|
||||
|
||||
Extract RGB pixels from an existing IMAGE created by Xw_get_image
|
||||
|
||||
returns ERROR if Extended Image is not defined
|
||||
or VISUAL Image type is not TRUECOLOR
|
||||
or Pixel position is wrong (Outside of image)
|
||||
returns SUCCESS if successful
|
||||
|
||||
*/
|
||||
|
||||
#ifdef XW_PROTOTYPE
|
||||
XW_STATUS Xw_get_rgbpixel (void* aimage,
|
||||
int x,int y,float* r,float* g,float* b,int* npixel)
|
||||
#else
|
||||
XW_STATUS Xw_get_rgbpixel (aimage,x,y,r,g,b,npixel)
|
||||
void *aimage ;
|
||||
int x,y ;
|
||||
float *r,*g,*b ;
|
||||
int *npixel ;
|
||||
#endif /*XW_PROTOTYPE*/
|
||||
{
|
||||
XW_EXT_IMAGEDATA *pimage = (XW_EXT_IMAGEDATA*) aimage ;
|
||||
XW_EXT_COLORMAP *pcolormap = pimage->pcolormap ;
|
||||
union {
|
||||
char *data ;
|
||||
unsigned char *cdata ;
|
||||
unsigned short *sdata ;
|
||||
unsigned long *ldata ;
|
||||
} data ;
|
||||
int i=0,fpixel,simage ;
|
||||
unsigned long pixel=0 ;
|
||||
XColor color ;
|
||||
XImage *pximage;
|
||||
|
||||
if( !Xw_isdefine_image(pimage) ) {
|
||||
/*ERROR*Bad EXT_IMAGEDATA Address*/
|
||||
Xw_set_error(25,"Xw_get_rgbpixel",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_rgbpixel",&simage) ;
|
||||
return (XW_ERROR) ;
|
||||
}
|
||||
|
||||
switch (pximage->bitmap_pad) {
|
||||
case 8 :
|
||||
data.data = pximage->data + (fpixel) ; simage -= fpixel ;
|
||||
pixel = (unsigned long) *data.cdata ;
|
||||
for( i=1 ; i<simage ; i++ ) {
|
||||
data.cdata++ ;
|
||||
if( *data.cdata != (unsigned char) pixel ) break ;
|
||||
}
|
||||
break ;
|
||||
case 16 :
|
||||
data.data = pximage->data + (fpixel<<1) ; simage -= fpixel ;
|
||||
pixel = (unsigned long) *data.sdata ;
|
||||
for( i=1 ; i<simage ; i++ ) {
|
||||
data.sdata++ ;
|
||||
if( *data.sdata != (unsigned short) pixel ) break ;
|
||||
}
|
||||
break ;
|
||||
case 32 :
|
||||
data.data = pximage->data + (fpixel<<2) ; simage -= fpixel ;
|
||||
pixel = (unsigned long) *data.ldata ;
|
||||
for( i=1 ; i<simage ; i++ ) {
|
||||
data.ldata++ ;
|
||||
if( *data.ldata != (unsigned long) pixel ) break ;
|
||||
}
|
||||
}
|
||||
|
||||
*npixel = i ;
|
||||
switch ( _CCLASS ) {
|
||||
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 ;
|
||||
|
||||
red = pixel & rmask ;
|
||||
while ( !(rmask & 0x01) ) { rmask >>= 1; red >>= 1; }
|
||||
|
||||
green = pixel & gmask ;
|
||||
while ( !(gmask & 0x01) ) { gmask >>= 1; green >>= 1; }
|
||||
|
||||
blue = pixel & bmask ;
|
||||
while ( !(bmask & 0x01) ) { bmask >>= 1; blue >>= 1; }
|
||||
|
||||
*r = (float)red/mask ;
|
||||
*g = (float)green/mask ;
|
||||
*b = (float)blue/mask ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PseudoColor :
|
||||
color.pixel = pixel ;
|
||||
XQueryColor(_CDISPLAY,_CINFO.colormap,&color) ;
|
||||
*r = (float) color.red/0xFFFF ;
|
||||
*g = (float) color.green/0xFFFF ;
|
||||
*b = (float) color.blue/0xFFFF ;
|
||||
break ;
|
||||
default :
|
||||
/*ERROR*Unimplemented Visual Class*/
|
||||
Xw_set_error(5,"Xw_get_rgbpixel",&_CCLASS) ;
|
||||
return (XW_ERROR) ;
|
||||
}
|
||||
|
||||
#ifdef TRACE_GET_RGBPIXEL
|
||||
printf (" Xw_get_rgbpixel(%lx,%d,%d,%f,%f,%f,%d)\n",
|
||||
(long ) pimage,x,y,*r,*g,*b,*npixel) ;
|
||||
#endif
|
||||
|
||||
return (XW_SUCCESS);
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <Xw_Extension.h>
|
||||
|
||||
/* ifdef then trace on */
|
||||
#ifdef TRACE
|
||||
#define TRACE_GET_SCREEN_PIXELCOORD
|
||||
#endif
|
||||
|
||||
/*
|
||||
XW_STATUS Xw_get_screen_pixelcoord (adisplay,px,py,sx,sy):
|
||||
XW_EXT_DISPLAY *adisplay
|
||||
int px,py Screen Coordinates defined in Pixels
|
||||
float *sx,*sy Returns Screen Coordinates defined in [0,1] Space
|
||||
|
||||
Get screen coordinate from Pixel Space to [0,1] Space
|
||||
|
||||
returns XW_ERROR if Pixel Coordinate is outside the screen
|
||||
or the if Extended Window address is not defined
|
||||
returns XW_SUCCESS if successful
|
||||
|
||||
*/
|
||||
|
||||
#ifdef XW_PROTOTYPE
|
||||
XW_STATUS Xw_get_screen_pixelcoord(void *adisplay,int px,int py,float *sx,float *sy)
|
||||
#else
|
||||
XW_STATUS Xw_get_screen_pixelcoord(adisplay,px,py,sx,sy)
|
||||
void *adisplay;
|
||||
int px,py ;
|
||||
float *sx,*sy ;
|
||||
#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_screen_pixelcoord",pdisplay) ;
|
||||
return (XW_ERROR) ;
|
||||
}
|
||||
|
||||
displaywidth = WidthOfScreen(_DSCREEN) ;
|
||||
displayheight = HeightOfScreen(_DSCREEN) ;
|
||||
|
||||
*sx = (float)px/(float)displaywidth ;
|
||||
*sy = 1. - (float)py/(float)displayheight ;
|
||||
|
||||
if( px < 0 || px >= displaywidth || py < 0 || py >= displayheight )
|
||||
return (XW_ERROR);
|
||||
|
||||
#ifdef TRACE_GET_SCREEN_PIXELCOORD
|
||||
if( Xw_get_trace() )
|
||||
printf (" Xw_get_screen_pixelcoord(%lx,%d,%d,%f,%f)\n",(long ) pdisplay,px,py,*sx,*sy) ;
|
||||
#endif
|
||||
|
||||
return (XW_SUCCESS);
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#include <Xw_Extension.h>
|
||||
|
||||
#ifdef TRACE
|
||||
#define TRACE_GET_SCREEN_PIXELVALUE
|
||||
#endif
|
||||
|
||||
/*
|
||||
float Xw_get_screen_pixelvalue (adisplay,pv):
|
||||
XW_EXT_DISPLAY *adisplay
|
||||
int pv Pixel Values
|
||||
|
||||
Returns screen value from Pixel value in [0,1] Space
|
||||
|
||||
*/
|
||||
|
||||
#ifdef XW_PROTOTYPE
|
||||
float Xw_get_screen_pixelvalue(void *adisplay,int pv)
|
||||
#else
|
||||
float Xw_get_screen_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_screen_pixelvalue",pdisplay) ;
|
||||
return (0.) ;
|
||||
}
|
||||
|
||||
sv = (float)pv/min(WidthOfScreen(_DSCREEN),HeightOfScreen(_DSCREEN)) ;
|
||||
|
||||
#ifdef TRACE_GET_SCREEN_PIXELVALUE
|
||||
if( Xw_get_trace() > 1 ) {
|
||||
printf (" %f = Xw_get_screen_pixelvalue(%lx,%d)\n",sv,(long ) pdisplay,pv) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (sv);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user