#pragma warning( disable : 4800 )
OCCViewer::OCCViewer(void)
{
- myGraphicDevice=NULL;
+ myGraphicDriver=NULL;
myViewer=NULL;
myView=NULL;
myAISContext=NULL;
bool OCCViewer::InitViewer(void* wnd)
{
- try {
- myGraphicDevice = new Graphic3d_WNTGraphicDevice();
- } catch (Standard_Failure) {
- return false;
- }
- TCollection_ExtendedString a3DName("Visu3D");
- myViewer = new V3d_Viewer( myGraphicDevice, a3DName.ToExtString(),"", 1000.0,
- V3d_XposYnegZpos, Quantity_NOC_GRAY30,
- V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,
- Standard_True, Standard_False);
+ try
+ {
+ Handle(Aspect_DisplayConnection) aDisplayConnection;
+ myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
+ }
+ catch (Standard_Failure)
+ {
+ return false;
+ }
+
+ TCollection_ExtendedString a3DName("Visu3D");
+ myViewer = new V3d_Viewer (myGraphicDriver, a3DName.ToExtString(),"", 1000.0,
+ V3d_XposYnegZpos, Quantity_NOC_GRAY30,
+ V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,
+ Standard_True, Standard_False);
myViewer->Init();
myViewer->SetDefaultLights();
myViewer->SetLightOn();
myView = myViewer->CreateView();
- Handle(WNT_Window) aWNTWindow = new WNT_Window(myGraphicDevice, reinterpret_cast<HWND> (wnd));
+ Handle(WNT_Window) aWNTWindow = new WNT_Window (reinterpret_cast<HWND> (wnd));
myView->SetWindow(aWNTWindow);
if (!aWNTWindow->IsMapped())
aWNTWindow->Map();
if (myAISContext.IsNull())
return;
myView = myAISContext->CurrentViewer()->CreateView();
- if (myGraphicDevice.IsNull())
- myGraphicDevice = new Graphic3d_WNTGraphicDevice();
- Handle(WNT_Window) aWNTWindow = new WNT_Window(myGraphicDevice, reinterpret_cast<HWND> (wnd));
+ if (myGraphicDriver.IsNull())
+ {
+ Handle(Aspect_DisplayConnection) aDisplayConnection;
+ myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
+ }
+ Handle(WNT_Window) aWNTWindow = new WNT_Window (reinterpret_cast<HWND> (wnd));
myView->SetWindow(aWNTWindow);
Standard_Integer w=100, h=100;
aWNTWindow->Size(w,h);
Handle_V3d_Viewer myViewer;
Handle_V3d_View myView;
Handle_AIS_InteractiveContext myAISContext;
- Handle_Graphic3d_WNTGraphicDevice myGraphicDevice;
+ Handle_Graphic3d_GraphicDriver myGraphicDriver;
public:
__declspec(dllexport) bool InitViewer(void* wnd);
__declspec(dllexport) bool ImportBRep(char* filename);
#include <PTColStd_PersistentTransientMap.hxx>
#include <TCollection_AsciiString.hxx>
//for OCC graphic
+#include <Aspect_DisplayConnection.hxx>
#include <WNT_Window.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <Quantity_NameOfColor.hxx>
+#include <Graphic3d.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
//for object display
#include <V3d_Viewer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <WNT_Window.hxx>
#include <Standard.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <WNT_Window.hxx>
myDegenerateModeIsOn=Standard_True;
m_Pen = NULL;
NbActiveLights=2; // There are 2 default active lights
- myGraphicDriver = Handle(Graphic3d_GraphicDriver)::DownCast(
- ((CViewer3dApp*)AfxGetApp())->GetGraphicDevice()->GraphicDriver() );
+ myGraphicDriver = ((CViewer3dApp*)AfxGetApp())->GetGraphicDriver();
}
CViewer3dView::~CViewer3dView()
// store for restore state after rotation (witch is in Degenerated mode)
myDegenerateModeIsOn = Standard_True;
-
- Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
- ((CViewer3dApp*)AfxGetApp())->GetGraphicDevice();
-
- Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
+ Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd ());
myView->SetWindow(aWNTWindow);
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <MMgt_TShared.hxx>
#include <OSD_Environment.hxx>
#include <Precision.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Text.hxx>
-#include <PrsMgr_PresentationManager2d.hxx>
#include <Quantity_Factor.hxx>
#include <Quantity_Length.hxx>
#include <Quantity_NameOfColor.hxx>
#include <StdPrs_Curve.hxx>
#include <StdPrs_Point.hxx>
#include <StdPrs_PoleCurve.hxx>
-#include <StdSelect_SensitiveText2d.hxx>
-#include <StdSelect_TextProjector2d.hxx>
-#include <StdSelect_ViewerSelector2d.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <UnitsAPI.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
-#include <WNT_WDriver.hxx>
#include <WNT_Window.hxx>
// specific STEP
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <MMgt_TShared.hxx>
#include <OSD_Environment.hxx>
#include <Precision.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Projector.hxx>
#include <Prs3d_Text.hxx>
-#include <PrsMgr_PresentationManager2d.hxx>
#include <Quantity_Factor.hxx>
#include <Quantity_Length.hxx>
#include <Quantity_NameOfColor.hxx>
#include <StdPrs_Curve.hxx>
#include <StdPrs_Point.hxx>
#include <StdPrs_PoleCurve.hxx>
-#include <StdSelect_SensitiveText2d.hxx>
-#include <StdSelect_TextProjector2d.hxx>
-#include <StdSelect_ViewerSelector2d.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <UnitsAPI.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
-#include <WNT_WDriver.hxx>
#include <WNT_Window.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <WNT_Window.hxx>
StaticCount++;
myCount = StaticCount;
- Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
- ((CAnimationApp*)AfxGetApp())->GetGraphicDevice();
+ Handle(Graphic3d_GraphicDriver) aGraphicDriver =
+ ((CAnimationApp*)AfxGetApp())->GetGraphicDriver();
TCollection_ExtendedString a3DName("Visu3D");
- myViewer = new V3d_Viewer(theGraphicDevice,a3DName.ToExtString(),"", 1000.0,
+ myViewer = new V3d_Viewer(aGraphicDriver,a3DName.ToExtString(),"", 1000.0,
V3d_XposYnegZpos, Quantity_NOC_GRAY30,
V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,
Standard_True, Standard_False);
TCHAR tchBuf[80];
CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
- aString = (CASROOTValue + "\\..\\data\\occ");
+ aString = (CASROOTValue + "\\data\\occ");
char DataDirPath[200];
strcpy_s(DataDirPath, aString);
// store for restore state after rotation (witch is in Degenerated mode)
myDegenerateModeIsOn = myView->DegenerateModeIsOn();
- Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
- ((CAnimationApp*)AfxGetApp())->GetGraphicDevice();
-
- Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
+ Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd ());
myView->SetWindow(aWNTWindow);
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
-#include <Graphic2d_Array1OfVertex.hxx>
-#include <Graphic2d_Buffer.hxx>
-#include <Graphic2d_CircleMarker.hxx>
-#include <Graphic2d_DisplayList.hxx>
-#include <Graphic2d_Drawer.hxx>
-#include <Graphic2d_PolyLine.hxx>
-#include <Graphic2d_Segment.hxx>
-#include <Graphic2d_SetOfCurves.hxx>
-#include <Graphic2d_SetOfSegments.hxx>
-#include <Graphic2d_Text.hxx>
-#include <Graphic2d_Vertex.hxx>
-#include <Graphic2d_View.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <MMgt_TShared.hxx>
#include <OSD_Environment.hxx>
#include <Precision.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Text.hxx>
-#include <PrsMgr_PresentationManager2d.hxx>
#include <Quantity_Factor.hxx>
#include <Quantity_Length.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Quantity_PhysicalQuantity.hxx>
#include <Quantity_PlaneAngle.hxx>
#include <Quantity_TypeOfColor.hxx>
-#include <Select2D_SensitiveArc.hxx>
-#include <Select2D_SensitiveBox.hxx>
-#include <Select2D_SensitiveEntity.hxx>
-#include <Select2D_SensitiveSegment.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <SelectBasics_ListOfBox2d.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <StdPrs_Curve.hxx>
#include <StdPrs_Point.hxx>
#include <StdPrs_PoleCurve.hxx>
-#include <StdSelect_SensitiveText2d.hxx>
-#include <StdSelect_TextProjector2d.hxx>
-#include <StdSelect_ViewerSelector2d.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TopoDS_Solid.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <UnitsAPI.hxx>
-#include <V2d_View.hxx>
-#include <V2d_Viewer.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
-#include <WNT_WDriver.hxx>
#include <WNT_Window.hxx>
#include "HLRAlgo_Projector.hxx"
#include "Aspect_MarkMap.hxx"
SampleName = "";
try
{
- myGraphicDevice = new Graphic3d_WNTGraphicDevice;
+ Handle(Aspect_DisplayConnection) aDisplayConnection;
+ myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
}
catch(Standard_Failure)
{
{
public:
COCCDemoApp();
- Handle(Graphic3d_WNTGraphicDevice) GetGraphicDevice() const
- { return myGraphicDevice; } ;
+ Handle(Graphic3d_GraphicDriver) GetGraphicDriver() const
+ { return myGraphicDriver; } ;
// Overrides
// ClassWizard generated virtual function overrides
DECLARE_MESSAGE_MAP()
private:
- Handle(Graphic3d_WNTGraphicDevice) myGraphicDevice;
+ Handle(Graphic3d_GraphicDriver) myGraphicDriver;
};
COCCDemoDoc::COCCDemoDoc()
{
// TODO: add one-time construction code here
- Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
- ((COCCDemoApp*)AfxGetApp())->GetGraphicDevice();
+ Handle(Graphic3d_GraphicDriver) aGraphicDriver =
+ ((COCCDemoApp*)AfxGetApp())->GetGraphicDriver();
- myViewer = new V3d_Viewer(theGraphicDevice,(short *) "Visu3D");
+ myViewer = new V3d_Viewer(aGraphicDriver,(short *) "Visu3D");
myViewer->SetDefaultLights();
myViewer->SetLightOn();
myViewer->SetDefaultBackgroundColor(Quantity_TOC_RGB, 0.,0.,0.);
myCurrentMode = CurAction3d_Nothing;
myVisMode = VIS_SHADE;
m_Pen = NULL;
- myGraphicDriver = Handle(Graphic3d_GraphicDriver)::DownCast(
- ((COCCDemoApp*)AfxGetApp())->GetGraphicDevice()->GraphicDriver() );
+ myGraphicDriver = ((COCCDemoApp*)AfxGetApp())->GetGraphicDriver();
}
COCCDemoView::~COCCDemoView()
myView = GetDocument()->GetViewer()->CreateView();
- Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
- ((COCCDemoApp*)AfxGetApp())->GetGraphicDevice();
-
- Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
+ Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd ());
myView->SetWindow(aWNTWindow);
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
#include <Standard.hxx>
+#include <Aspect_DisplayConnection.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Point.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
+#include <Graphic3d.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <WNT_Window.hxx>
#include "OCC_BaseApp.h"
#include <Standard_Macro.hxx>
-#include <Handle_Graphic3d_WNTGraphicDevice.hxx>
+#include <Handle_Graphic3d_GraphicDriver.hxx>
class Standard_EXPORT OCC_3dApp : public OCC_BaseApp
{
OCC_3dApp();
virtual ~OCC_3dApp();
- Handle_Graphic3d_WNTGraphicDevice GetGraphicDevice() const { return myGraphicDevice; } ;
+ Handle_Graphic3d_GraphicDriver GetGraphicDriver() const { return myGraphicDriver; } ;
protected :
- Handle_Graphic3d_WNTGraphicDevice myGraphicDevice;
+ Handle_Graphic3d_GraphicDriver myGraphicDriver;
};
#endif // !defined(AFX_OCC_3DAPP_H__FC7278BF_390D_11D7_8611_0060B0EE281E__INCLUDED_)
#include <Quantity_Factor.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
-#include <Handle_PrsMgr_PresentationManager2d.hxx>
-#include <Handle_Graphic2d_GraphicObject.hxx>
#include <Standard_Integer.hxx>
#include <Handle_SelectMgr_Selection.hxx>
#include <Standard_OStream.hxx>
#include <Standard_IStream.hxx>
-#include <AIS2D_InteractiveObject.hxx>
DEFINE_STANDARD_HANDLE(Sample2D_Image,AIS2D_InteractiveObject)
class Sample2D_Image : public AIS2D_InteractiveObject {
#include "Standard_ShortReal.hxx"
#pragma warning( default : 4244 ) // Issue warning 4244
-#include <V2d_Viewer.hxx>
-#include <V2d_View.hxx>
-#include <AIS2D_InteractiveContext.hxx>
-#include <WNT_WDriver.hxx>
-
#include <Standard.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <WNT_Window.hxx>
-#include <AIS2D_InteractiveObject.hxx>
-#include <Graphic2d_SetOfCurves.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-#include <Prs2d_AspectLine.hxx>
-#include <Graphic2d_Array1OfVertex.hxx>
-#include <Graphic2d_Polyline.hxx>
-#include <Graphic2d_Text.hxx>
-
#include <Prs3d_Drawer.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <QColor>
#include <QColorDialog>
-#ifndef WNT
-#include <Graphic3d_GraphicDevice.hxx>
-#else
-#include <Graphic3d_WNTGraphicDevice.hxx>
-#endif
-
+#include <Aspect_DisplayConnection.hxx>
#include <AIS_InteractiveObject.hxx>
+#include <Graphic3d.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
+#include <TCollection_AsciiString.hxx>
Handle(V3d_Viewer) DocumentCommon::Viewer( const Standard_CString aDisplay,
const Standard_ExtString aName,
const Standard_Boolean ComputedMode,
const Standard_Boolean aDefaultComputedMode )
{
-#ifndef WNT
-static Handle(Graphic3d_GraphicDevice) defaultdevice;
- if( defaultdevice.IsNull() )
- defaultdevice = new Graphic3d_GraphicDevice( aDisplay );
- return new V3d_Viewer(defaultdevice,aName,aDomain,ViewSize,ViewProj,
- Quantity_NOC_GRAY30,V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,
- ComputedMode,aDefaultComputedMode,V3d_TEX_NONE);
-#else
-static Handle(Graphic3d_WNTGraphicDevice) defaultdevice;
- if( defaultdevice.IsNull() )
- defaultdevice = new Graphic3d_WNTGraphicDevice();
- return new V3d_Viewer(defaultdevice,aName,aDomain,ViewSize,ViewProj,
- Quantity_NOC_GRAY30,V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,
- ComputedMode,aDefaultComputedMode,V3d_TEX_NONE);
+ static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
+
+ if (aGraphicDriver.IsNull())
+ {
+ Handle(Aspect_DisplayConnection) aDisplayConnection;
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+ aDisplayConnection = new Aspect_DisplayConnection (aDisplay);
#endif
+ aGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
+ }
+
+ return new V3d_Viewer(aGraphicDriver,aName,aDomain,ViewSize,ViewProj,
+ Quantity_NOC_GRAY30,V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,
+ ComputedMode,aDefaultComputedMode,V3d_TEX_NONE);
}
DocumentCommon::DocumentCommon( const int theIndex, ApplicationCommonWindow* app )
#include <Visual3d_View.hxx>
#include <Graphic3d_ExportFormat.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
#include <QWindowsStyle>
#if defined(_WIN32) || defined(__WIN32__)
#include <WNT_Window.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
#include <Cocoa_Window.hxx>
#else
#include <X11/Xmu/StdCmap.h>
#include <X11/Xlib.h>
#include <Xw_Window.hxx>
-#include <Graphic3d_GraphicDevice.hxx>
#include <QColormap>
#endif
+#include <Aspect_DisplayConnection.hxx>
+
// the key for multi selection :
#define MULTISELECTIONKEY Qt::ShiftModifier
myView = myContext->CurrentViewer()->CreateView();
#if defined(_WIN32) || defined(__WIN32__)
Aspect_Handle aWindowHandle = (Aspect_Handle )winId();
- Handle(WNT_Window) hWnd = new WNT_Window (Handle(Graphic3d_WNTGraphicDevice)::DownCast (myContext->CurrentViewer()->Device()),
- aWindowHandle);
+ Handle(WNT_Window) hWnd = new WNT_Window (aWindowHandle);
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
NSView* aViewHandle = (NSView* )winId();
Handle(Cocoa_Window) hWnd = new Cocoa_Window (aViewHandle);
#else
Aspect_Handle aWindowHandle = (Aspect_Handle )winId();
- Handle(Xw_Window) hWnd = new Xw_Window (Handle(Graphic3d_GraphicDevice)::DownCast (myContext->CurrentViewer()->Device()),
- aWindowHandle,
- Xw_WQ_SAMEQUALITY);
+ Handle(Aspect_DisplayConnection) aDispConnection = myContext->CurrentViewer()->Driver()->GetDisplayConnection();
+ Handle(Xw_Window) hWnd = new Xw_Window (aDispConnection, aWindowHandle);
#endif // WNT
myView->SetWindow (hWnd);
if (!hWnd->IsMapped())
@ECHO OFF
+call ../../../env.bat %1 %2 %3
+
IF NOT DEFINED CASROOT GOTO ERR_CASROOT
IF NOT EXIST "%CASROOT%\win32\bin\TKernel.dll" GOTO ERR_CASCADE
!macx | equals(MACOSX_USE_GLX, true): INCLUDEPATH += $$QMAKE_INCDIR_X11 $$QMAKE_INCDIR_OPENGL $$QMAKE_INCDIR_THREAD
!macx | equals(MACOSX_USE_GLX, true): DEFINES += LIN LININTEL
+ equals(MACOSX_USE_GLX, true): DEFINES += MACOSX_USE_GLX
DEFINES += OCC_CONVERT_SIGNALS HAVE_CONFIG_H HAVE_WOK_CONFIG_H QT_NO_STL
!macx | equals(MACOSX_USE_GLX, true): LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD
LIBS += -lfreeimageplus
if [ -e "${aSamplePath}/env.sh" ]; then source "${aSamplePath}/env.sh"; fi
cd $aSamplePath
qmake IESample.pro
-if test `uname -s` != "Darwin"; then
- make
+if [ "$(uname -s)" != "Darwin" ] || [ "$MACOSX_USE_GLX" == "true" ]; then
+ if [ "${CASDEB}" == "d" ]; then
+ make debug
+ else
+ make release
+ fi
fi
RES_DIR="${aSamplePath}/res"
aSystem=`uname -s`
-if [ "$aSystem" == "Darwin" ]; then
+if [ "$aSystem" == "Darwin" ] && [ "$MACOSX_USE_GLX" != "true" ]; then
if [ "${CASDEB}" == "d" ]; then
BIN_DIR="${aSamplePath}/build/Debug/IESample.app/Contents/MacOS"
else
if test ! -r "${BIN_DIR}/IESample"; then
echo "Executable \"${BIN_DIR}/IESample\" not found."
- if [ "$aSystem" == "Darwin" ]; then
+ if [ "$aSystem" == "Darwin" ] && [ "$MACOSX_USE_GLX" != "true" ]; then
echo "Probably you don't compile the application. Build it with Xcode."
else
echo "Probably you don't compile the application. Execute \"make\"."
!macx | equals(MACOSX_USE_GLX, true): INCLUDEPATH += $$QMAKE_INCDIR_X11 $$QMAKE_INCDIR_OPENGL $$QMAKE_INCDIR_THREAD
!macx | equals(MACOSX_USE_GLX, true): DEFINES += LIN LININTEL
+ equals(MACOSX_USE_GLX, true): DEFINES += MACOSX_USE_GLX
DEFINES += OCC_CONVERT_SIGNALS HAVE_CONFIG_H HAVE_WOK_CONFIG_H QT_NO_STL
!macx | equals(MACOSX_USE_GLX, true): LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD
LIBS += -lfreeimageplus
if [ -e "${aSamplePath}/env.sh" ]; then source "${aSamplePath}/env.sh"; fi
cd $aSamplePath
qmake Tutorial.pro
-if test `uname -s` != "Darwin"; then
- make
+if [ "$(uname -s)" != "Darwin" ] || [ "$MACOSX_USE_GLX" == "true" ]; then
+ if [ "${CASDEB}" == "d" ]; then
+ make debug
+ else
+ make release
+ fi
fi
RES_DIR="${aSamplePath}/res"
aSystem=`uname -s`
-if [ "$aSystem" == "Darwin" ]; then
+if [ "$aSystem" == "Darwin" ] && [ "$MACOSX_USE_GLX" != "true" ]; then
if [ "${CASDEB}" == "d" ]; then
BIN_DIR="${aSamplePath}/build/Debug/Tutorial.app/Contents/MacOS"
else
if test ! -r "${BIN_DIR}/Tutorial"; then
echo "Executable \"${BIN_DIR}/Tutorial\" not found."
- if [ "$aSystem" == "Darwin" ]; then
+ if [ "$aSystem" == "Darwin" ] && [ "$MACOSX_USE_GLX" != "true" ]; then
echo "Probably you don't compile the application. Build it with Xcode."
else
echo "Probably you don't compile the application. Execute \"make\"."
#include <QMouseEvent>
#include <WNT_Window.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
#include <Voxel_Prs.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <Aspect_DisplayConnection.hxx>
+#include <Graphic3d.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
-static Handle(Graphic3d_WNTGraphicDevice) device;
+static Handle(Graphic3d_GraphicDriver) Viewer_aGraphicDriver;
Viewer::Viewer(QWidget* parent):QWidget(parent)
{
- if(device.IsNull())
+ if (myGraphicDriver.IsNull())
{
- device = new Graphic3d_WNTGraphicDevice();
- if (!device->GraphicDriver().IsNull())
- {
- myGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast(device->GraphicDriver());
- }
+ if (Viewer_aGraphicDriver.IsNull())
+ {
+ Handle(Aspect_DisplayConnection) aDisplayConnection;
+ Viewer_aGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
+ }
+ myGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast(Viewer_aGraphicDriver);
}
-
- Handle(V3d_Viewer) aViewer = new V3d_Viewer(device, TCollection_ExtendedString("Visu3D").ToExtString(), "",
+
+ Handle(V3d_Viewer) aViewer = new V3d_Viewer(myGraphicDriver, TCollection_ExtendedString("Visu3D").ToExtString(), "",
1000, V3d_XposYnegZpos,
Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
true, true, V3d_TEX_NONE);
myIC = new AIS_InteractiveContext(aViewer);
myIC->SetDeviationCoefficient(1.e-3);
- int windowHandle = (int) winId();
- short hi, lo;
-
- lo = (short) windowHandle;
- hi = (short) (windowHandle >> 16);
- Handle(WNT_Window) hWnd =
- new WNT_Window(Handle(Graphic3d_WNTGraphicDevice)::DownCast(aViewer->Device()), (int) hi, (int) lo);
+ Aspect_Handle aWindowHandle = (Aspect_Handle )winId();
+ Handle(WNT_Window) hWnd = new WNT_Window (aWindowHandle);
myView->SetWindow(hWnd);
if(!hWnd->IsMapped())
#include "VoxelClient_VisDrawer.h"
+#include <OpenGl_GlCore11.hxx>
+
#include <ElSLib.hxx>
#include <gp_Dir.hxx>
#include <Geom_Plane.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_NamedStatus.hxx>
-
-#include <GL/gl.h>
-#include <GL/glu.h>
+#include <OpenGl_Workspace.hxx>
/**************************************************************************/
exception GraphicDeviceDefinitionError inherits OutOfRange;
---Category: The exceptions
+ exception DisplayConnectionDefinitionError inherits OutOfRange;
+ ---Category: The exceptions
+
exception LineStyleDefinitionError inherits OutOfRange;
---Category: Exceptions
deferred class Window;
---Purpose: Defines a window.
---Category: Classes
-
- deferred class GraphicDevice;
- ---Purpose: Defines a physical graphic device allowing to
- -- shares graphical ressources.
- ---Category: Classes
deferred class Driver;
---Purpose: Defines a virtual driver.
deferred class ColorScale;
---Purpose: Defines a color scale for viewer.
+ imported DisplayConnection;
+ ---Purpose: Creates and provides connection with X server.
+
+ imported DisplayConnection_Handle;
+ ---Purpose: Handle for DisplayConnection;
+
-------------------------
-- Category: Enumerations
-------------------------
--- /dev/null
+// 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
+// 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 <Aspect_DisplayConnection.hxx>
+
+#include <Aspect_DisplayConnectionDefinitionError.hxx>
+#include <OSD_Environment.hxx>
+
+IMPLEMENT_STANDARD_HANDLE (Aspect_DisplayConnection, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(Aspect_DisplayConnection, Standard_Transient)
+
+// =======================================================================
+// function : Aspect_DisplayConnection
+// purpose :
+// =======================================================================
+Aspect_DisplayConnection::Aspect_DisplayConnection()
+{
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+ OSD_Environment anEnv ("DISPLAY");
+ myDisplayName = anEnv.Value();
+ Init();
+#endif
+}
+
+// =======================================================================
+// function : ~Aspect_DisplayConnection
+// purpose :
+// =======================================================================
+Aspect_DisplayConnection::~Aspect_DisplayConnection()
+{
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+ if (myDisplay != NULL)
+ {
+ XCloseDisplay (myDisplay);
+ }
+#endif
+}
+
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+// =======================================================================
+// function : Aspect_DisplayConnection
+// purpose :
+// =======================================================================
+Aspect_DisplayConnection::Aspect_DisplayConnection (const TCollection_AsciiString& theDisplayName)
+{
+ myDisplayName = theDisplayName;
+ Init();
+}
+
+// =======================================================================
+// function : GetDisplay
+// purpose :
+// =======================================================================
+Display* Aspect_DisplayConnection::GetDisplay()
+{
+ return myDisplay;
+}
+
+// =======================================================================
+// function : GetDisplayName
+// purpose :
+// =======================================================================
+TCollection_AsciiString Aspect_DisplayConnection::GetDisplayName()
+{
+ return myDisplayName;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void Aspect_DisplayConnection::Init()
+{
+ myDisplay = XOpenDisplay (myDisplayName.ToCString());
+
+ if (myDisplay == NULL)
+ {
+ TCollection_AsciiString aMessage;
+ aMessage += "Can not connect to the server \"";
+ aMessage += myDisplayName + "\"";
+ Aspect_DisplayConnectionDefinitionError::Raise (aMessage.ToCString());
+ }
+}
+#endif
--- /dev/null
+// 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
+// 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.
+
+#ifndef _Aspect_DisplayConnection_H__
+#define _Aspect_DisplayConnection_H__
+
+#include <Standard_Transient.hxx>
+#include <Aspect_DisplayConnection_Handle.hxx>
+
+#include <TCollection_AsciiString.hxx>
+
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+ #include <X11/Xlib.h>
+#endif
+
+//! This class creates and provides connection with X server.
+//! Raises exception if can not connect to X server.
+//! On Windows and Mac OS X (in case when Cocoa used) platforms this class do nothing.
+//! WARRNING: Do not close display connection manualy!
+
+class Aspect_DisplayConnection : public Standard_Transient
+{
+public:
+
+ //! Default constructor. Creates connection with display name taken from "DISPLAY" environment variable
+ Standard_EXPORT Aspect_DisplayConnection();
+
+ //! Destructor. Close opened connection.
+ Standard_EXPORT ~Aspect_DisplayConnection();
+
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+ //! Constructor. Creates connection with display specified in theDisplayName.
+ //! Display name should be in format "hostname:number" or "hostname:number.screen_number", where:
+ //! hostname - Specifies the name of the host machine on which the display is physically attached.
+ //! number - Specifies the number of the display server on that host machine.
+ //! screen_number - Specifies the screen to be used on that server. Optional variable.
+ Aspect_DisplayConnection (const TCollection_AsciiString& theDisplayName);
+
+ //! @return pointer to Display structure that serves as the connection to the X server.
+ Display* GetDisplay();
+
+ //! @return display name for this connection.
+ TCollection_AsciiString GetDisplayName();
+
+private:
+
+ //! Open connection with display specified in myDisplayName class field.
+ void Init();
+
+private:
+
+ Display* myDisplay;
+ TCollection_AsciiString myDisplayName;
+#endif
+
+private:
+
+ //! To protect the connection from closing copying allowed only through the handles.
+ Aspect_DisplayConnection (const Aspect_DisplayConnection& );
+ Aspect_DisplayConnection& operator= (const Aspect_DisplayConnection& );
+
+public:
+
+ DEFINE_STANDARD_RTTI(Aspect_DisplayConnection) // Type definition
+
+};
+
+#endif // _Aspect_DisplayConnection_H__
--- /dev/null
+// 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
+// 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.
+
+#ifndef _Aspect_DisplayConnection_Handle_H__
+#define _Aspect_DisplayConnection_Handle_H__
+
+#include <Handle_Standard_Transient.hxx>
+
+class Aspect_DisplayConnection;
+DEFINE_STANDARD_HANDLE(Aspect_DisplayConnection, Standard_Transient)
+typedef Handle(Aspect_DisplayConnection) Aspect_DisplayConnection_Handle;
+
+#endif // _Aspect_DisplayConnection_Handle_H__
+++ /dev/null
--- Created on: 1993-10-19
--- Created by: Jean-Louis FRENKEL
--- 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.
-
-
-
-deferred class GraphicDevice from Aspect inherits TShared from MMgt
-
-uses
-
- GraphicDriver from Aspect
-
-raises
-
- GraphicDeviceDefinitionError from Aspect,
- BadAccess from Aspect
-
-is
-
- Initialize;
-
- GraphicDriver ( me )
- returns GraphicDriver from Aspect
- is deferred;
-
-end GraphicDevice from Aspect;
+++ /dev/null
-// Created on: 1993-10-19
-// Created by: Stephane CALLEGARI
-// 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.
-
-
-
-#include <Aspect_GraphicDevice.ixx>
-
-Aspect_GraphicDevice::Aspect_GraphicDevice () {}
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
--- Modified: GG 28/01/00 G004 Add gamma correction value in Dump methods.
--- GG 07/03/00 G004 Add MMSize() method
--- TCL 26/10/00 G002 SetBackground(aName: CString) method
--- GG 28/11/00 G002 Add BackgroundImage(),
--- BackgroundFillMethod(),
--- HBackground() methods.
--- SAV 24/11/01 SetBackground(Quantity_Color)
-
deferred class Window from Aspect
inherits
TShared from MMgt
- ---Purpose: This class allows the definition of a window
- -- Warning: The position and size for the creation of the window
- -- are defined in Device Screen Unit (DSU)
- -- floating [0,1] space.
-
uses
Background from Aspect,
GradientBackground from Aspect,
- GraphicDevice from Aspect,
TypeOfResize from Aspect,
FillMethod from Aspect,
+ GradientFillMethod from Aspect,
Handle from Aspect,
Ratio from Quantity,
Parameter from Quantity,
WindowError from Aspect
is
- Initialize(aGraphicDevice: GraphicDevice from Aspect);
+ Initialize;
---Level: Public
---Purpose: Initializes the datas of a Window.
---------------------------------------------------
SetBackground ( me : mutable;
- ABack : Background from Aspect ) is deferred;
+ ABack : Background from Aspect );
---Level: Public
---Purpose: Modifies the window background.
---Category: Methods to modify the class definition
SetBackground ( me : mutable ;
- BackColor : NameOfColor from Quantity ) is deferred;
+ theNameOfColor : NameOfColor from Quantity );
---Level: Public
---Purpose: Modifies the window background from a Named Color.
---Category: Methods to modify the class definition
- SetBackground ( me : mutable; color : Color from Quantity ) is deferred;
+ SetBackground ( me : mutable; color : Color from Quantity );
---Level: Public
---Purpose: Modifies the window background.
---Category: Methods to modify the class definition
SetBackground( me: mutable;
- aName : CString from Standard;
- aMethod : FillMethod from Aspect = Aspect_FM_CENTERED)
- returns Boolean from Standard is deferred;
+ ABackground: GradientBackground from Aspect);
---Level: Public
- ---Purpose: Loads the window background from an image file <aName>
- -- defined with a supported format XWD,GIF or BMP
- -- and returns TRUE if the operation is successfull.
- ---Category: Methods to modify the class definition
-
- SetBackground( me: mutable;
- aBitmap: Handle from Aspect) is deferred;
- ---Level: Advanced
- ---Purpose: Loads the window background from a predefined bitmap.
- -- Warning: the bitmap and window must have the same depth.
+ ---Purpose: Modifies the window gradient background.
---Category: Methods to modify the class definition
SetBackground( me: mutable;
- ABackground: GradientBackground from Aspect) is deferred;
+ theFirstColor: Color from Quantity;
+ theSecondColor: Color from Quantity;
+ theFillMethod: GradientFillMethod from Aspect);
---Level: Public
---Purpose: Modifies the window gradient background.
---Category: Methods to modify the class definition
- SetDoubleBuffer ( me : mutable ;
- DBmode : Boolean from Standard )
- ---Level: Advanced
- ---Purpose: Activates/Deactivates the Double Buffering capability
- -- for this window.
- -- Warning: Double Buffering is always DISABLE by default
- -- If there is not enought ressources to activate the
- -- double-buffering the DB mode flag can be set to FALSE.
- ---Category: Methods to modify the class definition
- is deferred;
-
- Flush ( me )
- ---Level: Advanced
- ---Purpose: Flushs all graphics to the screen and Swap the Double
- -- buffer if Enable
- ---Category: Methods to modify the class definition
- ---Trigger: Raises if Something is WRONG at Drawing Time.
- raises WindowError from Aspect is deferred;
-
Map ( me )
raises WindowError from Aspect is deferred;
---Level: Public
---Purpose: Destroy the Window
---Category: Methods to modify the class definition
- Clear (me)
- raises WindowError from Aspect is deferred;
- ---Level: Public
- ---Purpose: Clear The Window in the Background Color
- ---Category: Methods to modify the class definition
-
- ClearArea (me;
- XCenter, YCenter: Integer from Standard;
- Width , Height: Integer from Standard)
- raises WindowError from Aspect is deferred;
- ---Level: Public
- ---Purpose: Clear The Window Area defined in PIXELS
- -- in the Background Color
- ---Category: Methods to modify the class definition
-
- Restore(me)
- ---Level: Public
- ---Purpose: Restore the BackingStored Window <me>.
- ---Category: Methods to modify the class definition
- ---Trigger: Raises if BackingStore() is disable.
- raises WindowError from Aspect is deferred;
-
- RestoreArea (me;
- XCenter, YCenter: Integer from Standard;
- Width , Height: Integer from Standard)
- ---Level: Public
- ---Purpose: Restore the BackingStored Window Area
- -- defined in PIXELS.
- ---Category: Methods to modify the class definition
- ---Trigger: Raises if BackingStore() is disable.
- raises WindowError from Aspect is deferred;
-
- Dump ( me ; aFilename : CString from Standard;
- aGammaValue: Real from Standard = 1.0) returns Boolean
- ---Level: Advanced
- ---Purpose: Dumps the Window to an image file (PNG, BMP, JPEG, GIF) with
- --an optional gamma correction value according to the graphic system
- --and returns TRUE if the dump occurs normaly.
- ---Category: Methods to modify the class definition
- ---Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is deferred;
-
- DumpArea ( me ; aFilename : CString from Standard ;
- Xc, Yc : Integer from Standard ;
- Width, Height : Integer from Standard;
- aGammaValue: Real from Standard = 1.0 ) returns Boolean
- ---Level: Advanced
- ---Purpose: Dumps the Window Area defined by his center and PIXEL size
- -- to an image file with
- -- an optional gamma correction value according to the graphic system
- --and returns TRUE if the dump occurs normaly.
- ---Category: Methods to modify the class definition
- ---Trigger: Raises if Window is not defined properly
- -- or the area is out of the Window.
- raises WindowError from Aspect is deferred;
-
- Load ( me ; aFilename : CString from Standard) returns Boolean
- ---Level: Advanced
- ---Purpose: Loads the XWD file to this Window.
- -- Returns TRUE if the loading occurs normaly.
- -- Warning: Note that the Window is enlarged automatically
- --when the image size is too large for this window.
- ---Category: Methods to modify the class definition
- ---Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is deferred;
-
- LoadArea ( me ; aFilename : CString from Standard ;
- Xc, Yc : Integer from Standard ;
- Width, Height : Integer from Standard ) returns Boolean
- ---Level: Advanced
- ---Purpose: Loads the XWD file to Window Area defined by his center
- --and PIXEL size
- -- Returns TRUE if the loading occurs normaly.
- -- Warning: Note that the Image is zoomed automatically
- --when the image size is too large for this window area.
- ---Category: Methods to modify the class definition
- ---Trigger: Raises if Window is not defined properly
- -- or the area is out of the Window.
- raises WindowError from Aspect is deferred;
-
----------------------------
-- Category: Inquire methods
----------------------------
---Purpose: Returns the window background.
---Category: Inquire methods
- BackgroundImage ( me ) returns CString from Standard;
- ---Level: Public
- ---Purpose: Returns the current image background string
- -- or NULL if nothing is defined.
-
BackgroundFillMethod( me ) returns FillMethod from Aspect;
---Level: Public
---Purpose: Returns the current image background fill mode.
---Level: Public
---Purpose: Returns the window gradient background.
- HBackground ( me )
- returns Handle from Aspect;
- ---Level: Advanced
- ---Purpose: Returns the background bitmap handle or
- -- 0 when nothing is defined
- ---C++: inline
-
- GraphicDevice ( me ) returns GraphicDevice from Aspect;
- ---Level: Public
- ---Purpose: Returns the Graphic Device associated to this Window.
- ---Category: Inquire methods
-
IsMapped ( me ) returns Boolean from Standard is deferred;
---Level: Public
---Purpose: Returns True if the window <me> is opened
-- WIDTH/HEIGHT dimensions
---Category: Inquire methods
- Position ( me ;
- X1, Y1 ,X2, Y2 : out Parameter from Quantity)
- is deferred;
- ---Level: Public
- ---Purpose: Returns The Window POSITION in DSU
- ---Category: Inquire methods
-
Position ( me ;
X1, Y1, X2, Y2 : out Integer from Standard )
is deferred;
---Purpose: Returns The Window POSITION in PIXEL
---Category: Inquire methods
- Size ( me ;
- Width, Height : out Parameter from Quantity )
- is deferred;
- ---Level: Public
- ---Purpose: Returns The Window SIZE in DSU
- ---Category: Inquire methods
-
Size ( me ;
Width, Height : out Integer from Standard )
is deferred;
---Purpose: Returns The Window SIZE in PIXEL
---Category: Inquire methods
- MMSize ( me ;
- Width, Height : out Real from Standard )
- is deferred;
- ---Level: Public
- ---Purpose: Returns The Window SIZE in MM
- ---Category: Inquire methods
-
- Convert ( me ; PV : Integer from Standard )
- returns Parameter from Quantity is deferred;
- ---Level: Public
- ---Purpose: Returns the DSU value depending of the PIXEL value.
- ---Category: Inquire methods
-
- Convert ( me ; DV : Parameter from Quantity )
- returns Integer from Standard is deferred;
- ---Level: Public
- ---Purpose: Returns the PIXEL value depending of the DSU value.
- ---Category: Inquire methods
-
- Convert ( me ;
- PX, PY : Integer from Standard ;
- DX, DY : out Parameter from Quantity ) is deferred;
- ---Level: Public
- ---Purpose: Returns the DSU position depending of the PIXEL position.
- ---Category: Inquire methods
-
- Convert ( me ;
- DX, DY : Parameter from Quantity ;
- PX, PY : out Integer from Standard ) is deferred;
- ---Level: Public
- ---Purpose: Returns the PIXEL position depending of the DSU position.
- ---Category: Inquire methods
-
- BackingStore(me) returns Boolean from Standard is deferred;
- ---Level: Advanced
- ---Purpose: Returns the BackingStore capability for this Window .
- -- If Answer is True Exposure can be recovered by
- -- Restore RestoreArea methods .
- -- If Answer is False,Application must Redraw
- -- the exposed area.
- ---Category: Inquire methods
-
- DoubleBuffer ( me )
- returns Boolean from Standard is deferred;
- ---Level: Advanced
- ---Purpose: Returns the DoubleBuffer state.
- ---Category: Inquire methods
-
fields
- MyGraphicDevice : GraphicDevice from Aspect is protected;
MyBackground : Background from Aspect is protected;
- MyBackgroundImage : AsciiString from TCollection is protected;
- MyBackgroundFillMethod : FillMethod from Aspect is protected;
- MyHBackground : Handle from Aspect is protected;
MyGradientBackground : GradientBackground from Aspect is protected;
+ MyBackgroundFillMethod : FillMethod from Aspect is protected;
MyIsVirtual : Boolean from Standard is protected;
-
end Window;
//-Constructors
-Aspect_Window::Aspect_Window (const Handle(Aspect_GraphicDevice)& aGraphicDevice)
-: MyGraphicDevice(aGraphicDevice),
- MyBackground(),
- MyBackgroundImage(),
+Aspect_Window::Aspect_Window()
+: MyBackground(),
MyGradientBackground(),
- MyBackgroundFillMethod(Aspect_FM_NONE),
- MyHBackground(0)
+ MyBackgroundFillMethod(Aspect_FM_NONE)
{
}
-Handle(Aspect_GraphicDevice) Aspect_Window::GraphicDevice() const
-{
- return MyGraphicDevice;
-}
-
Aspect_Background Aspect_Window::Background() const
{
return MyBackground;
}
-Standard_CString Aspect_Window::BackgroundImage() const
-{
- return MyBackgroundImage.ToCString();
-}
-
Aspect_FillMethod Aspect_Window::BackgroundFillMethod() const
{
return MyBackgroundFillMethod;
{
MyIsVirtual = theVirtual;
}
+
+void Aspect_Window::SetBackground (const Aspect_Background& theBackground)
+{
+ SetBackground (theBackground.Color());
+}
+
+void Aspect_Window::SetBackground (const Quantity_NameOfColor theNameOfColor)
+{
+ MyBackground.SetColor (theNameOfColor);
+}
+
+void Aspect_Window::SetBackground (const Quantity_Color& theColor)
+{
+ MyBackground.SetColor (theColor);
+}
+
+void Aspect_Window::SetBackground (const Aspect_GradientBackground& theBackground)
+{
+ Quantity_Color aFirstColor, aSecondColor;
+ theBackground.Colors (aFirstColor, aSecondColor);
+ SetBackground (aFirstColor, aSecondColor, theBackground.BgGradientFillMethod());
+}
+
+void Aspect_Window::SetBackground (const Quantity_Color& theFirstColor,
+ const Quantity_Color& theSecondColor,
+ const Aspect_GradientFillMethod theFillMethod)
+{
+ MyGradientBackground.SetColors (theFirstColor, theSecondColor, theFillMethod);
+}
+++ /dev/null
-// 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.
-
-inline Aspect_Handle Aspect_Window :: HBackground () const {
-
- return MyHBackground;
-
-}
--- /dev/null
+CSF_XwLibs
+EXTERNLIB
Aspect_WOKSteps.edl
Aspect_CMPLRS.edl
Aspect_FStream.hxx
Aspect_PolygonOffsetMode.hxx
Aspect_GradientBackground.cxx
Aspect_Convert.hxx
+Aspect_DisplayConnection.hxx
+Aspect_DisplayConnection.cxx
+Aspect_DisplayConnection_Handle.hxx
Destroy();
}
- //! Modifies the window background
- Standard_EXPORT virtual void SetBackground (const Aspect_Background& theBackground);
-
- //! Modifies the window background
- Standard_EXPORT virtual void SetBackground (const Quantity_NameOfColor theBackColor);
-
- //! Modifies the window background
- Standard_EXPORT virtual void SetBackground (const Quantity_Color& theColor);
-
- //! Modifies the window background
- Standard_EXPORT void SetBackground (const Aspect_Handle theBackPixmap);
-
- //! Loads the window background from an image file
- Standard_EXPORT Standard_Boolean SetBackground (const Standard_CString theName,
- const Aspect_FillMethod theMethod = Aspect_FM_CENTERED);
-
- //! Modifies the window gradient background
- Standard_EXPORT virtual void SetBackground (const Aspect_GradientBackground& theBackground);
-
- //! Modifies the window gradient background
- Standard_EXPORT void SetBackground (const Quantity_Color& theCol1,
- const Quantity_Color& theCol2,
- const Aspect_GradientFillMethod theMethod = Aspect_GFM_HOR);
-
- //! Activates/Deactivates the Double Buffering capability for this window
- Standard_EXPORT virtual void SetDoubleBuffer (const Standard_Boolean theDBmode);
-
- //! Flushes all graphics to the screen and Swap the Double buffer
- Standard_EXPORT virtual void Flush() const;
-
//! Opens the window <me>
Standard_EXPORT virtual void Map() const;
//! Apply the mapping change to the window <me>
Standard_EXPORT virtual Standard_Boolean DoMapping() const;
- //! Clears the Window in the Background color
- Standard_EXPORT virtual void Clear() const;
-
- //! Clears the Window Area defined by his center and PIXEL size in the Background color
- Standard_EXPORT virtual void ClearArea (const Standard_Integer theCenterX,
- const Standard_Integer theCenterY,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight) const;
-
- //! Restores The Window from the BackingStored Window
- Standard_EXPORT virtual void Restore() const;
-
- //! Restores The Window Area defined by his center and PIXEL size from the BackingStored Window
- Standard_EXPORT virtual void RestoreArea (const Standard_Integer theCenterX,
- const Standard_Integer theCenterY,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight) const;
-
- //! Dumps the Window to file
- Standard_EXPORT virtual Standard_Boolean Dump (const Standard_CString theFilename,
- const Standard_Real theGammaValue = 1.0) const;
-
- //! Dumps the Window Area defined by his center and PIXEL size to an image file
- Standard_EXPORT virtual Standard_Boolean DumpArea (const Standard_CString theFilename,
- const Standard_Integer theCenterX,
- const Standard_Integer theCenterY,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight,
- const Standard_Real theGammaValue = 1.0) const;
-
- //! Loads the image file to this Window
- //! @return TRUE if the loading occurs normaly
- Standard_EXPORT virtual Standard_Boolean Load (const Standard_CString theFilename) const;
-
- //! Loads the image file to Window Area
- Standard_EXPORT virtual Standard_Boolean LoadArea (const Standard_CString theFilename,
- const Standard_Integer theCenterX,
- const Standard_Integer theCenterY,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight) const;
-
- //! Returns the BackingStore capability for this Window
- Standard_EXPORT virtual Standard_Boolean BackingStore() const;
-
- //! Returns the DoubleBuffer state
- Standard_EXPORT virtual Standard_Boolean DoubleBuffer() 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 DSU
- Standard_EXPORT virtual void Position (Quantity_Parameter& X1,
- Quantity_Parameter& Y1,
- Quantity_Parameter& X2,
- Quantity_Parameter& Y2) 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 DSU
- Standard_EXPORT virtual void Size (Quantity_Parameter& theWidth,
- Quantity_Parameter& theHeight) const;
-
//! Returns The Window SIZE in PIXEL
Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
Standard_Integer& theHeight) const;
- //! Returns The Window SIZE in MM
- Standard_EXPORT virtual void MMSize (Standard_Real& theWidth,
- Standard_Real& theHeight) const;
-
- //! Returns the DSU value depending of the PIXEL value
- Standard_EXPORT virtual Quantity_Parameter Convert (const Standard_Integer PV) const;
-
- //! Returns the PIXEL value depending of the DSU value
- Standard_EXPORT virtual Standard_Integer Convert (const Quantity_Parameter DV) const;
-
- //! Returns the DSU position depending of the PIXEL position
- Standard_EXPORT virtual void Convert (const Standard_Integer PX,
- const Standard_Integer PY,
- Quantity_Parameter& DX,
- Quantity_Parameter& DY) const;
-
- //! Returns the PIXEL position depending of the DSU position
- Standard_EXPORT virtual void Convert (const Quantity_Parameter DX,
- const Quantity_Parameter DY,
- Standard_Integer& PX,
- Standard_Integer& PY) const;
-
//! @return associated NSView
Standard_EXPORT NSView* HView() const;
#include <Image_AlienPixMap.hxx>
#include <Aspect_Convert.hxx>
-#include <Aspect_GraphicDevice.hxx>
#include <Aspect_WindowDefinitionError.hxx>
IMPLEMENT_STANDARD_HANDLE (Cocoa_Window, Aspect_Window)
IMPLEMENT_STANDARD_RTTIEXT(Cocoa_Window, Aspect_Window)
-//! Dummy device class implementation
-class Cocoa_GraphicDevice : public Aspect_GraphicDevice
-{
-
-public:
-
- virtual Handle_Aspect_GraphicDriver GraphicDriver() const
- {
- return NULL;
- }
-
- DEFINE_STANDARD_RTTI(Cocoa_GraphicDevice)
-
-};
-
-DEFINE_STANDARD_HANDLE(Cocoa_GraphicDevice, Aspect_GraphicDevice)
-
-IMPLEMENT_STANDARD_HANDLE (Cocoa_GraphicDevice, Aspect_GraphicDevice)
-IMPLEMENT_STANDARD_RTTIEXT(Cocoa_GraphicDevice, Aspect_GraphicDevice)
-
static Standard_Integer getScreenBottom()
{
Cocoa_LocalPool aLocalPool;
const Standard_Integer thePxTop,
const Standard_Integer thePxWidth,
const Standard_Integer thePxHeight)
-: Aspect_Window (new Cocoa_GraphicDevice()),
+: Aspect_Window (),
myHWindow (NULL),
myHView (NULL),
myXLeft (thePxLeft),
// purpose :
// =======================================================================
Cocoa_Window::Cocoa_Window (NSView* theViewNS)
-: Aspect_Window (new Cocoa_GraphicDevice()),
+: Aspect_Window (),
myHWindow (NULL),
myHView ([theViewNS retain]),
myXLeft (0),
myHView = [theView retain];
}
-// =======================================================================
-// function : DoubleBuffer
-// purpose :
-// =======================================================================
-Standard_Boolean Cocoa_Window::DoubleBuffer() const
-{
- return Standard_True;
-}
-
-// =======================================================================
-// function : SetBackground
-// purpose :
-// =======================================================================
-void Cocoa_Window::SetBackground (const Aspect_Background& theBackground)
-{
- SetBackground (theBackground.Color());
-}
-
-// =======================================================================
-// function : SetBackground
-// purpose :
-// =======================================================================
-void Cocoa_Window::SetBackground (const Quantity_NameOfColor theBackColor)
-{
- SetBackground (Quantity_Color (theBackColor));
-}
-
-// =======================================================================
-// function : SetBackground
-// purpose :
-// =======================================================================
-void Cocoa_Window::SetBackground (const Aspect_Handle theBackPixmap)
-{
- //
-}
-
-// =======================================================================
-// function : SetBackground
-// purpose :
-// =======================================================================
-Standard_Boolean Cocoa_Window::SetBackground (const Standard_CString theFileName,
- const Aspect_FillMethod theMethod)
-{
- return Standard_False;
-}
-
-// =======================================================================
-// function : SetBackground
-// purpose :
-// =======================================================================
-void Cocoa_Window::SetBackground (const Quantity_Color& theColor)
-{
- //
-}
-
-// =======================================================================
-// function : SetBackground
-// purpose :
-// =======================================================================
-void Cocoa_Window::SetBackground (const Aspect_GradientBackground& theGrBackground)
-{
- Quantity_Color aColor1, aColor2;
- theGrBackground.Colors (aColor1, aColor2);
- SetBackground (aColor1, aColor2, theGrBackground.BgGradientFillMethod());
-}
-
-// =======================================================================
-// function : SetBackground
-// purpose :
-// =======================================================================
-void Cocoa_Window::SetBackground (const Quantity_Color& theColor1,
- const Quantity_Color& theColor2,
- const Aspect_GradientFillMethod theMethod)
-{
- //
-}
-
-// =======================================================================
-// function : SetDoubleBuffer
-// purpose :
-// =======================================================================
-void Cocoa_Window::SetDoubleBuffer (const Standard_Boolean )
-{
- //
-}
-
-// =======================================================================
-// function : Flush
-// purpose :
-// =======================================================================
-void Cocoa_Window::Flush() const
-{
- Restore();
-}
-
// =======================================================================
// function : IsMapped
// purpose :
return Standard_True;
}
-// =======================================================================
-// function : Clear
-// purpose :
-// =======================================================================
-void Cocoa_Window::Clear() const
-{
- //
-}
-
-// =======================================================================
-// function : ClearArea
-// purpose :
-// =======================================================================
-void Cocoa_Window::ClearArea (const Standard_Integer Xc,
- const Standard_Integer Yc,
- const Standard_Integer Width,
- const Standard_Integer Height) const
-{
- //
-}
-
-// =======================================================================
-// function : Restore
-// purpose :
-// =======================================================================
-void Cocoa_Window::Restore() const
-{
- //
-}
-
-// =======================================================================
-// function : RestoreArea
-// purpose :
-// =======================================================================
-void Cocoa_Window::RestoreArea (const Standard_Integer Xc,
- const Standard_Integer Yc,
- const Standard_Integer Width,
- const Standard_Integer Height) const
-{
- //
-}
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-Standard_Boolean Cocoa_Window::Dump (const Standard_CString theFilename,
- const Standard_Real theGammaValue) const
-{
- /*Image_AlienPixMap anImg;
- if (!ToPixMap (anImg) || anImg.IsEmpty())
- {
- return Standard_False;
- }
- if (Abs (theGammaValue - 1.0) > 0.001)
- {
- anImg.AdjustGamma (theGammaValue);
- }
- return anImg.Save (theFilename);*/
- return Standard_False;
-}
-
-// =======================================================================
-// function : DumpArea
-// purpose :
-// =======================================================================
-Standard_Boolean Cocoa_Window::DumpArea (const Standard_CString theFilename,
- const Standard_Integer theCenterX,
- const Standard_Integer theCenterY,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight,
- const Standard_Real theGammaValue) const
-{
- return Standard_False;
-}
-
-// =======================================================================
-// function : ToPixMap
-// purpose :
-// =======================================================================
-/*Standard_Boolean Cocoa_Window::ToPixMap (Image_PixMap& thePixMap) const
-{
- return Standard_False;
-}*/
-
-// =======================================================================
-// function : Load
-// purpose :
-// =======================================================================
-Standard_Boolean Cocoa_Window::Load (const Standard_CString theFilename) const
-{
- return Standard_False;
-}
-
-// =======================================================================
-// function : LoadArea
-// purpose :
-// =======================================================================
-Standard_Boolean Cocoa_Window::LoadArea (const Standard_CString theFilename,
- const Standard_Integer theCenterX,
- const Standard_Integer theCenterY,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight) const
-{
- return Standard_False;
-}
-
-// =======================================================================
-// function : BackingStore
-// purpose :
-// =======================================================================
-Standard_Boolean Cocoa_Window::BackingStore() const
-{
- return Standard_False;
-}
-
// =======================================================================
// function : Ratio
// purpose :
return Quantity_Ratio (aBounds.size.width / aBounds.size.height);
}
-// =======================================================================
-// function : Position
-// purpose :
-// =======================================================================
-void Cocoa_Window::Position (Quantity_Parameter& X1, Quantity_Parameter& Y1,
- Quantity_Parameter& X2, Quantity_Parameter& Y2) const
-{
- //
-}
-
// =======================================================================
// function : Position
// purpose :
//
}
-// =======================================================================
-// function : Size
-// purpose :
-// =======================================================================
-void Cocoa_Window::Size (Quantity_Parameter& theWidth,
- Quantity_Parameter& theHeight) const
-{
- //
-}
-
// =======================================================================
// function : Size
// purpose :
theWidth = (Standard_Integer )aBounds.size.width;
theHeight = (Standard_Integer )aBounds.size.height;
}
-
-// =======================================================================
-// function : MMSize
-// purpose :
-// =======================================================================
-void Cocoa_Window::MMSize (Standard_Real& theWidth,
- Standard_Real& theHeight) const
-{
- //
-}
-
-// =======================================================================
-// function : Convert
-// purpose :
-// =======================================================================
-Quantity_Parameter Cocoa_Window::Convert (const Standard_Integer PV) const
-{
- return 0.0; ///
-}
-
-// =======================================================================
-// function : Convert
-// purpose :
-// =======================================================================
-Standard_Integer Cocoa_Window::Convert (const Quantity_Parameter DV) const
-{
- return 0; ////
-}
-
-// =======================================================================
-// function : Convert
-// purpose :
-// =======================================================================
-void Cocoa_Window::Convert (const Standard_Integer PX,
- const Standard_Integer PY,
- Quantity_Parameter& DX,
- Quantity_Parameter& DY) const
-{
- //
-}
-
-// =======================================================================
-// function : Convert
-// purpose :
-// =======================================================================
-void Cocoa_Window::Convert (const Quantity_Parameter DX,
- const Quantity_Parameter DY,
- Standard_Integer& PX,
- Standard_Integer& PY) const
-{
- //
-}
Graphic3d_CTransPersStruct.cxx
Graphic3d_NListOfHAsciiString.hxx
Graphic3d_AspectText3d.cxx
-Graphic3d_WNTGraphicDevice.cxx
Graphic3d_PtrFrameBuffer.hxx
Graphic3d_BufferType.hxx
Graphic3d_Vec2.hxx
---Purpose: For grouping together primitives in a structure
---Category: Classes
- class GraphicDevice;
- ---Purpose: Defines a physical graphic device allowing to
- -- shares graphical ressources.
- ---Category: Classes
-
- class WNTGraphicDevice;
- ---Purpose: Defines a physical graphic device for Windows NT
- ---Category: Classes
-
class MaterialAspect;
---Purpose: Aspect attributes of a 3d face.
---Category: Classes
end SortType;
+ ----------------------------
+ -- Category: Package methods
+ ----------------------------
+
+ InitGraphicDriver (theDisplayConnection: DisplayConnection_Handle from Aspect)
+ returns GraphicDriver from Graphic3d
+ raises DriverDefinitionError from Aspect;
+ ---Purpose: Initialize graphic driver and returns Handle to it.
+
+
+
end Graphic3d;
--- /dev/null
+// 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
+// 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 <Graphic3d.ixx>
+
+#include <Aspect_DisplayConnection.hxx>
+#include <Aspect_DriverDefinitionError.hxx>
+#include <OSD_Environment.hxx>
+
+//=======================================================================
+//function : InitGraphicDriver
+//purpose :
+//=======================================================================
+Handle(Graphic3d_GraphicDriver) Graphic3d::InitGraphicDriver (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
+{
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+ if (theDisplayConnection.IsNull())
+ {
+ Aspect_DriverDefinitionError::Raise ("Null display connection.");
+ }
+#endif
+
+ TCollection_AsciiString aGraphicLibName;
+
+ // Setting the library name. Depends on the platform.
+#if defined(_WIN32) || defined(__WIN32__)
+ aGraphicLibName = "TKOpenGl.dll";
+#elif defined(__hpux) || defined(HPUX)
+ aGraphicLibName = "libTKOpenGl.sl";
+#elif defined(__APPLE__)
+ aGraphicLibName = "libTKOpenGl.dylib";
+#else
+ aGraphicLibName = "libTKOpenGl.so";
+#endif
+
+ // Loading the library.
+ OSD_SharedLibrary aSharedLibrary (aGraphicLibName.ToCString());
+ if (!aSharedLibrary.DlOpen (OSD_RTLD_LAZY))
+ {
+ Aspect_DriverDefinitionError::Raise (aSharedLibrary.DlError());
+ }
+
+ // Retrieving factory function pointer.
+ typedef Handle(Graphic3d_GraphicDriver) (*GraphicDriverFactoryPointer) (Standard_CString);
+ GraphicDriverFactoryPointer aGraphicDriverConstructor = (GraphicDriverFactoryPointer )aSharedLibrary.DlSymb ("MetaGraphicDriverFactory");
+ if (aGraphicDriverConstructor == NULL)
+ {
+ Aspect_DriverDefinitionError::Raise (aSharedLibrary.DlError());
+ }
+
+ // Creating driver instance.
+ Handle(Graphic3d_GraphicDriver) aGraphicDriver = aGraphicDriverConstructor (aSharedLibrary.Name());
+
+ // Management of traces.
+ OSD_Environment aTraceEnv ("CSF_GraphicTrace");
+ TCollection_AsciiString aTrace = aTraceEnv.Value();
+ if (aTrace.IsIntegerValue())
+ {
+ aGraphicDriver->SetTrace (aTrace.IntegerValue());
+ }
+
+ // Starting graphic driver.
+ if (!aGraphicDriver->Begin (theDisplayConnection))
+ {
+ Aspect_DriverDefinitionError::Raise ("Cannot connect to graphic library.");
+ }
+
+ return aGraphicDriver;
+}
+++ /dev/null
--- Created on: 1994-01-19
--- Created by: CAL
--- Copyright (c) 1994-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.
-
--- Modified: GG RIC120302 add new constructor to pass Display structure
--- directly instead the connexion name.
-
-class GraphicDevice from Graphic3d inherits GraphicDevice from Xw
-
----Purpose: This class allows the definition of the Advanced
- -- Graphic Device
--- Warning: An Graphic Device is defined by a connexion
- -- "host:server.screen"
-
-
-uses
-
- SharedLibrary from OSD,
- GraphicDriver from Aspect,
- Display from Aspect,
- GraphicDriver from Graphic3d,
- TypeOfMapping from Xw,
- AsciiString from TCollection
-
-raises
-
- GraphicDeviceDefinitionError from Aspect
-
-is
-
- Create ( Connexion : CString from Standard;
- Mapping : TypeOfMapping from Xw = Xw_TOM_COLORCUBE;
- Ncolors : Integer from Standard = 0;
- UseDefault : Boolean from Standard = Standard_True )
- returns mutable GraphicDevice from Graphic3d
- ---Level: Public
- ---Purpose: Creates a GraphicDevice
- ---Warning: Raises if the Device is badly defined
- raises GraphicDeviceDefinitionError from Aspect;
-
- Create ( DisplayHandle : Display from Aspect)
- returns mutable GraphicDevice from Graphic3d
- ---Level: Public
- ---Purpose: Creates a GraphicDevice from the Display structure
- ---Warning: Raises if the Device is badly defined
- raises GraphicDeviceDefinitionError from Aspect;
-
- Destroy ( me : mutable )
- is redefined static;
- ---Level: Public
- ---Purpose: Deletes the GraphicDevice <me>.
- ---C++: alias ~
-
- GraphicDriver ( me )
- returns GraphicDriver from Aspect
- is redefined static;
- ---Level: Public
- ---Purpose: Returns the GraphicDriver.
-
- SetGraphicDriver ( me : mutable )
- is private;
- ---Level: Internal
- ---Purpose: Sets the GraphicDriver.
-
- ShrEnvString ( me )
- returns AsciiString from TCollection
- is private;
- ---Level: Internal
- ---Purpose: Returns the environment string for loading shared graphics library.
- -- The string can be defined in environment by corresponding variables,
- -- or default value will be used for loading from system library path
- -- Environment variables : CSF_GraphicShr
-
-fields
-
- MyGraphicDriver : GraphicDriver from Graphic3d;
-
-end GraphicDevice from Graphic3d;
+++ /dev/null
-// 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.
-
-/***********************************************************************
-
- FONCTION :
- ----------
- Classe Graphic3d_GraphicDevice.cxx :
-
-
- HISTORIQUE DES MODIFICATIONS :
- --------------------------------
- Janvier 1994 : CAL ; Creation.
- 04-02-97 : FMN ; Suppression appel call_tox_set_colormap_mapping()
- 10-09-00 : GG ; NEW OpenGl driver loading specification
- when nothing is defined the driver libTKOpenGl[.so|.sl]
- is loading from the current PATH
-
-************************************************************************/
-#if (!defined(_WIN32) && !defined(__WIN32__))
-
-#include <stdio.h>
-#include <sys/utsname.h>
-
-/*----------------------------------------------------------------------*/
-/*
- * Includes
- */
-
-#include <Graphic3d_GraphicDevice.ixx>
-#include <Graphic3d_GraphicDriver.hxx>
-#include <OSD_Function.hxx>
-#include <OSD_Environment.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <Xw_Cextern.hxx>
-
-//-Static data definitions
-
-static char LocalMessag[80] ;
-
-//-Aliases
-
-//-Global data definitions
-
-//-Constructor
-
-Graphic3d_GraphicDevice::Graphic3d_GraphicDevice (const Standard_CString Connexion, const Xw_TypeOfMapping /*Mapping*/, const Standard_Integer Ncolors, const Standard_Boolean UseDefault ):
-Xw_GraphicDevice () {
-Standard_CString connexion = (Connexion) ? Connexion : Standard_CString("") ;
-Standard_Boolean status ;
-
- MyExtendedDisplay = Xw_open_display((Standard_PCharacter)connexion) ;
-
- if( !MyExtendedDisplay ) {
- sprintf(LocalMessag,"Cannot connect to server '%s'",connexion) ;
- Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
- }
-
- SetGraphicDriver ();
-
- status = MyGraphicDriver->Begin (connexion);
-
- if( !status ) {
- sprintf(LocalMessag,"Cannot connect to graphic library from '%s'",
- connexion) ;
- Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
- }
-
- this->InitMaps (connexion,Xw_TOM_READONLY,Ncolors,UseDefault);
-
-
-}
-
-Graphic3d_GraphicDevice::Graphic3d_GraphicDevice (const Aspect_Display pdisplay)
- : Xw_GraphicDevice ()
- {
- Standard_Boolean status ;
-
- if( !pdisplay )
- Aspect_GraphicDeviceDefinitionError::Raise ("Bad display pointer");
- MyExtendedDisplay = Xw_set_display(pdisplay) ;
- Standard_CString connexion = Xw_get_display_name(MyExtendedDisplay);
-
- if( !MyExtendedDisplay ) {
- if( connexion )
- sprintf(LocalMessag,"Cannot connect to server '%s'",connexion) ;
- else
- sprintf(LocalMessag,"Cannot connect to an UNKNOWN server") ;
- Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
- }
-
- SetGraphicDriver ();
-
- status = MyGraphicDriver->Begin (pdisplay);
-
- if( !status ) {
- sprintf(LocalMessag,"Cannot connect to graphic library from '%s'",
- connexion) ;
- Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
- }
-
- this->InitMaps (connexion,Xw_TOM_READONLY,0,Standard_True);
-}
-
-// Destructor
-void Graphic3d_GraphicDevice::Destroy()
-{
- MyGraphicDriver->End();
-}
-
-// Methods in order
-
-Handle(Aspect_GraphicDriver) Graphic3d_GraphicDevice::GraphicDriver () const {
-
- return MyGraphicDriver;
-
-}
-
-void Graphic3d_GraphicDevice::SetGraphicDriver () {
-
- TCollection_AsciiString aShr = ShrEnvString ();
-
- OSD_SharedLibrary TheSharedLibrary (aShr.ToCString());
-
- Standard_Boolean Result = TheSharedLibrary.DlOpen (OSD_RTLD_LAZY);
-
- if (! Result) {
- Aspect_GraphicDeviceDefinitionError::Raise
- (TheSharedLibrary.DlError ());
- }
- else {
- // Management of traces
-char *tracevalue = NULL;
- tracevalue = (char *)(getenv ("CSF_GraphicTrace"));
- if (tracevalue)
- cout << "Information : " << aShr << " loaded\n" << flush;
-
-OSD_Function new_GLGraphicDriver =
- TheSharedLibrary.DlSymb ("MetaGraphicDriverFactory");
- if (tracevalue)
- cout << "Information : MetaGraphicDriverFactory "
- << (new_GLGraphicDriver ? "found\n" : "not found\n") << flush;
- if (! new_GLGraphicDriver) {
- Aspect_GraphicDeviceDefinitionError::Raise
- (TheSharedLibrary.DlError ());
- }
- else {
- // Sequence :
- // new_GLGraphicDriver is OSD_Function :
- // typedef int (* OSD_Function)(...);
- // that is why good cast in GraphicDriver.
- Handle(Graphic3d_GraphicDriver)
- (*fp) (Standard_CString) = NULL;
- fp = (Handle(Graphic3d_GraphicDriver)
- (*) (Standard_CString)) new_GLGraphicDriver;
- if (tracevalue) cout << "FP == "<<(void *) fp<<endl;
- Standard_CString aSharedName = TheSharedLibrary.Name ();
- MyGraphicDriver = (*fp) (aSharedName);
-
-// MyGraphicDriver = (*fp) (TheSharedLibrary.Name ());
-
- // Management of traces
- if (tracevalue)
- MyGraphicDriver->SetTrace
- ((Standard_Integer) atoi (tracevalue));
- }
- }
-
-}
-
-TCollection_AsciiString Graphic3d_GraphicDevice::ShrEnvString() const
-{
- OSD_Environment aEnvShr ("CSF_GraphicShr");
- if (!aEnvShr.Value().IsEmpty())
- {
- return aEnvShr.Value();
- }
-
- // load TKOpenGl using default searching mechanisms in system
-#if defined(__hpux) || defined(HPUX)
- return TCollection_AsciiString ("libTKOpenGl.sl");
-#elif defined(__APPLE__)
- return TCollection_AsciiString ("libTKOpenGl.dylib");
-#else
- return TCollection_AsciiString ("libTKOpenGl.so");
-#endif
-}
-
-#endif // !WNT
Handle from Aspect,
Display from Aspect,
PrintAlgo from Aspect,
+ DisplayConnection_Handle from Aspect,
AspectLine3d from Graphic3d,
AspectMarker3d from Graphic3d,
-- Category: Init methods
-------------------------
- Begin ( me : mutable;
- ADisplay : CString from Standard )
- returns Boolean from Standard
- is deferred;
- ---Purpose: call_togl_begin
-
- Begin ( me : mutable;
- ADisplay : Display from Aspect )
- returns Boolean from Standard
- is deferred;
- ---Purpose: call_togl_begin_display
+ Begin (me: mutable;
+ theDisplayConnection: DisplayConnection_Handle from Aspect)
+ returns Boolean from Standard
+ is deferred;
+ ---Purpose: Starts graphic driver with given connection
End ( me : mutable )
is deferred;
-- returns Standard_False if fails
-- ABD Integration support of system fonts (using FTGL and FreeType)
+ GetDisplayConnection (me)
+ returns DisplayConnection_Handle from Aspect;
+ ---C++: return const &
+
+ ---Purpose: returns Handle to display connection
+
fields
- MyTraceLevel : Integer from Standard is protected;
- MySharedLibrary : SharedLibrary from OSD is protected;
+ MyTraceLevel : Integer from Standard is protected;
+ MySharedLibrary : SharedLibrary from OSD is protected;
+ myDisplayConnection: DisplayConnection_Handle from Aspect is protected;
end GraphicDriver from Graphic3d;
return MyTraceLevel;
}
+
+const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
+{
+ return myDisplayConnection;
+}
#include <Graphic3d_Group.ixx>
#include <Graphic3d_Group.pxx>
-#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransModeFlags.hxx>
MyCGroup.PickId.IsSet = 0,
MyCGroup.PickId.Value = 0;
- Handle(Aspect_GraphicDriver) agd =
- ((MyStructure->StructureManager ())->GraphicDevice ())->GraphicDriver ();
+ MyGraphicDriver = (MyStructure->StructureManager())->GraphicDriver();
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
MyGraphicDriver->Group (MyCGroup);
#include <Graphic3d_Structure.ixx>
#include <Graphic3d_Structure.pxx>
-#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_MaterialAspect.hxx>
MyCStructure.TransformPersistence.Point.y = 0.0;
MyCStructure.TransformPersistence.Point.z = 0.0;
/* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
- Handle(Aspect_GraphicDriver) agd =
- (AManager->GraphicDevice ())->GraphicDriver ();
-
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+ MyGraphicDriver = AManager->GraphicDriver();
MyGraphicDriver->Structure (MyCStructure);
#ifdef TRACE
SequenceOfInteger from TColStd,
GenId from Aspect,
- GraphicDevice from Aspect,
TypeOfHighlightMethod from Aspect,
TypeOfUpdate from Aspect,
AspectText3d from Graphic3d,
Structure from Graphic3d,
MapOfStructure from Graphic3d,
- SequenceOfStructure from Graphic3d
+ SequenceOfStructure from Graphic3d,
+ GraphicDriver from Graphic3d
raises
is
- Initialize ( aDevice : GraphicDevice from Aspect )
+ Initialize ( theDriver: GraphicDriver from Graphic3d )
---Level: Public
---Purpose: Initialises the ViewManager.
-- Currently creating of more than 100 viewer instances
---Purpose: Transforms the structure <AStructure>.
---Category: Private methods
- GraphicDevice ( me )
- returns GraphicDevice from Aspect;
+ GraphicDriver ( me )
+ returns GraphicDriver from Graphic3d;
---Level: Internal
- ---Purpose: Returns the graphic device of <me>.
+ ---Purpose: Returns the graphic driver of <me>.
---Category: Private methods
+ ---C++: return const &
Invisible ( me : mutable;
AStructure : Structure from Graphic3d )
MyStructGenId : GenId from Aspect is protected;
- MyGraphicDevice : GraphicDevice from Aspect is protected;
+ MyGraphicDriver : GraphicDriver from Graphic3d is protected;
friends
//-Constructors
-Graphic3d_StructureManager::Graphic3d_StructureManager (const Handle(Aspect_GraphicDevice)& aDevice):
+Graphic3d_StructureManager::Graphic3d_StructureManager (const Handle(Graphic3d_GraphicDriver)& theDriver):
MyDisplayedStructure (),
MyHighlightedStructure (),
MyVisibleStructure (),
MyAspectFillArea3d = new Graphic3d_AspectFillArea3d ();
MyUpdateMode = Aspect_TOU_WAIT;
- MyGraphicDevice = aDevice;
+ MyGraphicDriver = theDriver;
}
}
-Handle(Aspect_GraphicDevice) Graphic3d_StructureManager::GraphicDevice () const {
+const Handle(Graphic3d_GraphicDriver)& Graphic3d_StructureManager::GraphicDriver () const {
- return (MyGraphicDevice);
+ return (MyGraphicDriver);
}
// and conditions governing the rights and limitations under the License.
#include <Graphic3d_TextureRoot.ixx>
-#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Image_AlienPixMap.hxx>
+++ /dev/null
--- Created on: 1996-02-15
--- Created by: PLOTNIKOV Eugeny
--- 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.
-
-
-class WNTGraphicDevice from Graphic3d inherits GraphicDevice from WNT
-
- ---Purpose: This class initializes a Windows NT Graphic Device.
-
-uses
-
- Color from Quantity,
- ColorRef from WNT,
- Long from WNT,
- SharedLibrary from OSD,
- GraphicDriver from Aspect,
- GraphicDriver from Graphic3d
-
-raises
-
- GraphicDeviceDefinitionError from Aspect
-
-is
-
- Create
- returns mutable WNTGraphicDevice from Graphic3d
- ---Purpose: Creates a class instance and provide initialization
- -- of the graphic library.
- -- Warning: Raises if something wrong.
- raises GraphicDeviceDefinitionError from Aspect;
-
- Create ( graphicLib : CString from Standard )
- returns mutable WNTGraphicDevice from Graphic3d
- ---Purpose: Creates a class instance and provide initialization
- -- of the graphic library defined by "graphicLib".
- -- Warning: Raises if something wrong.
- raises GraphicDeviceDefinitionError from Aspect;
-
- Destroy ( me : mutable )
- is redefined static;
- ---Purpose: Destroys all resources attached to the graphic device.
- ---C++: alias~
-
- GraphicDriver ( me )
- returns GraphicDriver from Aspect
- is redefined static;
- ---Level: Public
- ---Purpose: Returns the GraphicDriver.
-
- SetGraphicDriver ( me : mutable )
- is private;
- ---Level: Internal
- ---Purpose: Sets the GraphicDriver.
-
- SetGraphicDriver ( me : mutable;
- graphicLib : CString from Standard )
- is private;
- ---Level: Internal
- ---Purpose: Sets the GraphicDriver defined by "graphicLib".
-
-fields
-
- MyGraphicDriver : GraphicDriver from Graphic3d;
- MySharedLibrary : SharedLibrary from OSD;
-
-end WNTGraphicDevice;
+++ /dev/null
-// 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.
-
-
-#if (defined(_WIN32) || defined(__WIN32__))
-
-#include <stdlib.h>
-
-#include <Graphic3d_WNTGraphicDevice.ixx>
-#include <InterfaceGraphic_wntio.hxx>
-#include <OSD_Environment.hxx>
-#include <TCollection_AsciiString.hxx>
-
-// =======================================================================
-// function : Graphic3d_WNTGraphicDevice
-// purpose :
-// =======================================================================
-Graphic3d_WNTGraphicDevice::Graphic3d_WNTGraphicDevice()
-: WNT_GraphicDevice (Standard_True)
-{
- SetGraphicDriver();
- if (!MyGraphicDriver->Begin (""))
- Aspect_GraphicDeviceDefinitionError::Raise ("Cannot connect to graphic library");
-
-}
-
-// =======================================================================
-// function : Graphic3d_WNTGraphicDevice
-// purpose :
-// =======================================================================
-Graphic3d_WNTGraphicDevice::Graphic3d_WNTGraphicDevice (const Standard_CString theGraphicLib)
-: WNT_GraphicDevice (Standard_True)
-{
- SetGraphicDriver (theGraphicLib);
- if (!MyGraphicDriver->Begin (""))
- Aspect_GraphicDeviceDefinitionError::Raise ("Cannot connect to graphic library");
-}
-
-// =======================================================================
-// function : Destroy
-// purpose :
-// =======================================================================
-void Graphic3d_WNTGraphicDevice::Destroy()
-{
- MyGraphicDriver->End();
-}
-
-// =======================================================================
-// function : GraphicDriver
-// purpose :
-// =======================================================================
-Handle(Aspect_GraphicDriver) Graphic3d_WNTGraphicDevice::GraphicDriver() const
-{
- return MyGraphicDriver;
-}
-
-// =======================================================================
-// function : SetGraphicDriver
-// purpose :
-// =======================================================================
-void Graphic3d_WNTGraphicDevice::SetGraphicDriver()
-{
- Standard_CString aLibPath = getenv ("CSF_GraphicShr");
- if (aLibPath == NULL || strlen (aLibPath) == 0)
- aLibPath = "TKOpenGl.dll";
-
- SetGraphicDriver (aLibPath);
-}
-
-// =======================================================================
-// function : SetGraphicDriver
-// purpose :
-// =======================================================================
-void Graphic3d_WNTGraphicDevice::SetGraphicDriver (const Standard_CString theGraphicLib)
-{
- MyGraphicDriver.Nullify();
-
- // load the library
- MySharedLibrary.SetName (theGraphicLib);
- if (!MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
- {
- Aspect_GraphicDeviceDefinitionError::Raise (MySharedLibrary.DlError());
- }
-
- // management of traces
- OSD_Environment aTraceEnv ("CSF_GraphicTrace");
- TCollection_AsciiString aTrace = aTraceEnv.Value();
- if (aTrace.Length() > 0)
- cout << "Information : " << theGraphicLib << " loaded\n" << flush;
-
- // retrieve factory function pointer
- typedef Handle(Graphic3d_GraphicDriver) (*GET_DRIVER_PROC) (const char* );
- GET_DRIVER_PROC aGraphicDriverConstructor = (GET_DRIVER_PROC )MySharedLibrary.DlSymb ("MetaGraphicDriverFactory");
- if (aGraphicDriverConstructor == NULL)
- {
- Aspect_GraphicDeviceDefinitionError::Raise (MySharedLibrary.DlError());
- return;
- }
-
- // create driver instance
- MyGraphicDriver = aGraphicDriverConstructor (theGraphicLib);
-
- // management of traces
- if (aTrace.Length() > 0 && aTrace.IsIntegerValue())
- MyGraphicDriver->SetTrace (aTrace.IntegerValue());
-}
-
-#endif // WNT
#ifdef WNT
#include <InterfaceGraphic_WNT.hxx>
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
#include <InterfaceGraphic_Cocoa.hxx>
#else
#include <InterfaceGraphic_X11.hxx>
/*----------------------------------------------------------------------*/
-OpenGl_Display::OpenGl_Display (const Standard_CString theDisplay)
+OpenGl_Display::OpenGl_Display (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
: myDisplay(NULL),
myFacilities(myDefaultFacilities),
myDBuffer(Standard_True),
#if (defined(_WIN32) || defined(__WIN32__)) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
myDisplay = TheDummyDisplay;
#else
- if (theDisplay != NULL && *theDisplay != '\0')
- {
- OSD_Environment aDispEnv ("DISPLAY", theDisplay);
- aDispEnv.Build();
- }
-
- // Specifies the hardware display name, which determines the
- // display and communications domain to be used.
- // On a POSIX system, if the display_name is NULL, it defaults
- // to the value of the DISPLAY environment variable.
- myDisplay = XOpenDisplay (NULL);
-#endif
-
- Init();
-}
-
-/*----------------------------------------------------------------------*/
-
-OpenGl_Display::OpenGl_Display (const Aspect_Display theDisplay)
-: myDisplay(NULL),
- myFacilities(myDefaultFacilities),
- myDBuffer(Standard_True),
- myDither(Standard_True),
- myBackDither(Standard_False),
- myWalkthrough(Standard_False),
- mySymPerspective(Standard_False),
- myOffsetFactor(1.F),
- myOffsetUnits(0.F),
- myAntiAliasingMode(3),
- myLinestyleBase(0),
- myPatternBase(0),
- myMarkerBase(0)
-{
-#if (defined(_WIN32) || defined(__WIN32__))
- myDisplay = TheDummyDisplay;
-#else
- myDisplay = theDisplay;
+ myDisplay = theDisplayConnection->GetDisplay();
#endif
Init();
#include <NCollection_DataMap.hxx>
#include <Aspect_Display.hxx>
+#include <Aspect_DisplayConnection.hxx>
#include <Aspect_Drawable.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Aspect_TypeOfMarker.hxx>
class OpenGl_Display : public MMgt_TShared
{
public:
- OpenGl_Display (const Standard_CString ADisplay);
- OpenGl_Display (const Aspect_Display ADisplay);
+ OpenGl_Display (const Handle(Aspect_DisplayConnection)& theDisplayConnection);
virtual ~OpenGl_Display ();
Aspect_Display GetDisplay () const { return myDisplay; }
#include <Handle_OpenGl_Workspace.hxx>
#include <Aspect_Display.hxx>
+#include <Aspect_DisplayConnection.hxx>
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_FillMethod.hxx>
#include <Aspect_CLayer2d.hxx>
//! Constructor
Standard_EXPORT OpenGl_GraphicDriver (const Standard_CString theShrName);
- Standard_EXPORT Standard_Boolean Begin (const Standard_CString ADisplay);
- Standard_EXPORT Standard_Boolean Begin (const Aspect_Display ADisplay);
+ Standard_EXPORT Standard_Boolean Begin (const Handle(Aspect_DisplayConnection)& theDisplayConnection);
Standard_EXPORT void End ();
Standard_EXPORT Standard_Integer InquireLightLimit ();
Standard_EXPORT void InquireMat (const Graphic3d_CView& ACView, TColStd_Array2OfReal& AMatO, TColStd_Array2OfReal& AMatM);
//=======================================================================
//function : Begin
-//purpose :
-//=======================================================================
-
-Standard_Boolean OpenGl_GraphicDriver::Begin (const Standard_CString ADisplay)
-{
- try
- {
- openglDisplay = new OpenGl_Display(ADisplay);
- return Standard_True;
- }
- catch (Standard_Failure)
- {
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : Begin
-//purpose :
+//purpose :
//=======================================================================
-Standard_Boolean OpenGl_GraphicDriver::Begin (const Aspect_Display ADisplay)
+Standard_Boolean OpenGl_GraphicDriver::Begin (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
{
+ myDisplayConnection = theDisplayConnection;
try
{
- openglDisplay = new OpenGl_Display(ADisplay);
+ openglDisplay = new OpenGl_Display (myDisplayConnection);
return Standard_True;
}
catch (Standard_Failure)
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_HSequenceOfReal.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <Graphic3d_GraphicDevice.hxx>
#include <Draw.hxx>
#include <Draw_Window.hxx>
#include <Draw_Viewer.hxx>
#include <Aspect_WindowDriver.hxx>
#include <stdio.h>
+#include <Aspect_DisplayConnection.hxx>
+#include <Graphic3d.hxx>
#if ! defined(WNT)
#include <Xw_Window.hxx>
//#include <Xm/Xm.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include <Xw_GraphicDevice.hxx>
#include <Xw_Cextern.hxx>
#include <unistd.h>
#else
#include <WNT.h>
-#include <WNT_GraphicDevice.hxx>
#include <WNT_Window.hxx>
#include <io.h>
#endif
Standard_Integer QAAIS_WindowSize_X = 0;
Standard_Integer QAAIS_WindowSize_Y = 0;
QAAISWindow->Size(QAAIS_WindowSize_X, QAAIS_WindowSize_Y);
- Handle (Graphic3d_GraphicDevice) QAAIS_GraphicDevice = new Graphic3d_GraphicDevice (getenv ("DISPLAY"));
+ Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();
+ Handle(Graphic3d_GraphicDriver) aGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
Draw_Window QAAIS_CoordWindow ("coordinate", 421, 205, 200, 60);
QAAIS_CoordWindow.DisplayWindow ();
QAAIS_CoordWindow.SetColor (12);
- Handle (Xw_Window) QAAIS_ColorWindow = new Xw_Window (QAAIS_GraphicDevice, "color", 0.4074, 0.678, 0.1962, 0.06, Xw_WQ_3DQUALITY, Quantity_NOC_BLACK);
- Handle (V3d_Viewer) QAAIS_ColorViewer = new V3d_Viewer (QAAIS_GraphicDevice, Standard_ExtString ("COLOR"));
+ Handle (Xw_Window) QAAIS_ColorWindow = new Xw_Window (aDisplayConnection, "color", 0.4074, 0.678, 0.1962, 0.06, Quantity_NOC_BLACK);
+ Handle (V3d_Viewer) QAAIS_ColorViewer = new V3d_Viewer (aGraphicDriver, Standard_ExtString ("COLOR"));
Handle (V3d_View) QAAIS_ColorView = QAAIS_ColorViewer -> CreateView ();
QAAIS_ColorWindow -> Map ();
QAAIS_ColorView -> SetWindow (QAAIS_ColorWindow);
-- extension must be one of ".png",".bmp",".jpg",".gif".
-- Returns FALSE when the dump has failed
- Dump ( me: mutable;
- theFile : CString from Standard;
- theFormat : FormatOfSheetPaper from Aspect;
- theBufferType : BufferType from Graphic3d = Graphic3d_BT_RGB )
- returns Boolean from Standard;
- ---Level: Public
- ---Purpose: dump the full contents of the view with a
- -- different scale according to the required sheet
- -- paper size (format) and the ratio
- -- width/height of the view.
- -- and returns FALSE when the dump has failed
- -- Warning : the file name extension must be one of
- -- ".png",".bmp",".jpg",".gif"
- -- but make becarefull about the time to dump and
- -- resulting file size especially for the A0 format.
- -- NOTE that you can use after any standard system utility
- -- for editing or sending the image file to a laser printer.
- -- (i.e: Microsoft Photo Editor on Windows system
- -- or Image Viewer on SUN system)
-
Print (me; hPrnDC: Handle from Aspect = NULL;
showDialog: Boolean = Standard_True;
showBackground : Boolean = Standard_True;
return ToPixMap (anImage, aWinWidth, aWinHeight, theBufferType) && anImage.Save (theFile);
}
-////////////////////////////////////////////////////////////////
-Standard_Boolean V3d_View::Dump (const Standard_CString theFile,
- const Aspect_FormatOfSheetPaper theFormat,
- const Graphic3d_BufferType& theBufferType)
-{
- // convert Aspect_FormatOfSheetPaper size to pixel ...
- Quantity_Length anSPWidth, anSPHeight;
- Aspect::ValuesOfFOSP (theFormat, anSPWidth, anSPHeight);
-
- // adjusting to the ratio width/height ...
- Quantity_Length aWinWidth, aWinHeight;
- MyWindow->MMSize (aWinWidth, aWinHeight);
- Standard_Integer aPixelWidth, aPixelHeight;
- MyWindow->Size (aPixelWidth, aPixelHeight);
-
- Quantity_Factor aScale = Min (anSPWidth / aWinWidth, anSPHeight / aWinHeight);
- aPixelWidth = Standard_Integer (aPixelWidth * aScale);
- aPixelHeight = Standard_Integer (aPixelHeight * aScale);
-
- Image_AlienPixMap anImage;
- ToPixMap (anImage, aPixelWidth, aPixelHeight, theBufferType);
- OSD_Environment anEnvGamma ("CSF_GAMMA_CORRECTION");
- TCollection_AsciiString strGamma (anEnvGamma.Value());
- if (!anImage.IsEmpty() && !strGamma.IsEmpty())
- {
- Standard_Real aGammaValue = strGamma.RealValue();
- anImage.AdjustGamma (aGammaValue);
- }
- return anImage.Save (theFile);
-}
-
////////////////////////////////////////////////////////////////
Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage,
const Standard_Integer theWidth,
uses
- GraphicDevice from Aspect,
+ GraphicDriver from Graphic3d,
TypeOfUpdate from V3d,
TypeOfVisualization from V3d,
TypeOfShadingModel from V3d,
is
- Create ( Device : GraphicDevice from Aspect;
+ Create ( theDriver : GraphicDriver from Graphic3d;
aName : ExtString from Standard;
aDomain : CString from Standard = "";
ViewSize : Length from Quantity = 1000.0 ;
DefaultComputedMode: Boolean from Standard = Standard_True;
SurfaceDetail : TypeOfSurfaceDetail from V3d = V3d_TEX_NONE)
returns mutable Viewer from V3d
- ---Purpose: Create a Viewer on the given device with the given parameters or
+ ---Purpose: Create a Viewer with the given graphic driver and the given parameters or
-- with their default values.
-- Currently creating of more than 100 viewer instances
-- is not supported and leads to an exception.
---Purpose: If the size of the view is <= 0
-- if ComputedMode is false, only the degenerate mode will be used.
--
- -- Warning: Client must creates a graphic-device of type
- -- Graphic3d_GraphicDevice under UNIX
- -- or Graphic3d_WNTGraphicDevice under WindowsNT
+ -- Warning: Client must creates a graphic driver
CreateView (me: mutable) returns mutable View from V3d;
---Level: Public
#include <Viewer_BadValue.hxx>
#include <V3d_OrthographicView.hxx>
#include <V3d_PerspectiveView.hxx>
-#ifdef WNT
-#include <WNT_GraphicDevice.hxx>
-#endif
/*----------------------------------------------------------------------*/
//-Constructor:
-V3d_Viewer::V3d_Viewer(const Handle(Aspect_GraphicDevice)& Device , const Standard_ExtString aName, const Standard_CString aDomain,const Standard_Real ViewSize , const V3d_TypeOfOrientation ViewProj , const Quantity_NameOfColor ViewBackground , const V3d_TypeOfVisualization Visualization , const V3d_TypeOfShadingModel ShadingModel , const V3d_TypeOfUpdate UpdateMode, const Standard_Boolean ComputedMode , const Standard_Boolean DefaultComputedMode , const V3d_TypeOfSurfaceDetail SurfaceDetail )
-:Viewer_Viewer(Device,aName,aDomain,-1),
+V3d_Viewer::V3d_Viewer(const Handle(Graphic3d_GraphicDriver)& theDriver , const Standard_ExtString aName, const Standard_CString aDomain,const Standard_Real ViewSize , const V3d_TypeOfOrientation ViewProj , const Quantity_NameOfColor ViewBackground , const V3d_TypeOfVisualization Visualization , const V3d_TypeOfShadingModel ShadingModel , const V3d_TypeOfUpdate UpdateMode, const Standard_Boolean ComputedMode , const Standard_Boolean DefaultComputedMode , const V3d_TypeOfSurfaceDetail SurfaceDetail )
+:Viewer_Viewer(theDriver,aName,aDomain,-1),
MyDefinedViews(),
MyActiveViews(),
MyDefinedLights(),
#endif
{
- MyViewer = new Visual3d_ViewManager(Device) ;
+ MyViewer = new Visual3d_ViewManager(theDriver) ;
// san (16/09/2010): It has been decided to turn depth test ON
// by default, as this is important for new font rendering
// (without it, there are numerous texture rendering artefacts)
package Viewer
-uses MMgt,TCollection,Aspect,Quantity
+uses MMgt,TCollection,Graphic3d,Quantity
is
uses
AsciiString,ExtendedString from TCollection,
- GraphicDevice from Aspect
+ GraphicDriver from Graphic3d
is
- Initialize( aDevice: GraphicDevice from Aspect;
+ Initialize( aDriver: GraphicDriver from Graphic3d;
aName: ExtString from Standard;
aDomain: CString from Standard;
aNextCount: Integer from Standard);
Update(me: mutable) is deferred;
- Device(me) returns mutable GraphicDevice from Aspect
+ Driver(me) returns mutable GraphicDriver from Graphic3d
is static;
+ ---C++: return const &
NextName(me) returns ExtString from Standard
is static;
myNextCount: Integer from Standard;
myDomain: AsciiString from TCollection;
myName: ExtendedString from TCollection;
- myDevice: GraphicDevice from Aspect;
+ myDriver: GraphicDriver from Graphic3d;
end Viewer from Viewer;
#define nm _nm()
#endif // LOPTIM
-Viewer_Viewer::Viewer_Viewer(const Handle(Aspect_GraphicDevice)& aDevice,
+Viewer_Viewer::Viewer_Viewer(const Handle(Graphic3d_GraphicDriver)& theDriver,
const Standard_ExtString aName,
const Standard_CString aDomain,
const Standard_Integer aNextCount)
:myNextCount(aNextCount),
myDomain(TCollection_AsciiString(aDomain)),
myName(TCollection_ExtendedString(aName)),
-myDevice(aDevice)
+myDriver(theDriver)
{}
Standard_CString Viewer_Viewer::Domain() const {
return myDomain.ToCString();
}
-Handle(Aspect_GraphicDevice) Viewer_Viewer::Device() const {
- return myDevice;
+const Handle(Graphic3d_GraphicDriver)& Viewer_Viewer::Driver() const {
+ return myDriver;
}
Standard_ExtString Viewer_Viewer::NextName () const {
#include <TShort_HArray1OfShortReal.hxx>
#include <AIS_Triangulation.hxx>
-#include <Aspect_GraphicDevice.hxx>
#include <StdPrs_ToolShadedShape.hxx>
#include <Poly_Connect.hxx>
#include <TColgp_Array1OfDir.hxx>
#include <ViewerTest.hxx>
-#include <Aspect_GraphicDevice.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
#include <Draw.hxx>
return 1;
}
- Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Device()->GraphicDriver());
+ Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
if (aDriver.IsNull())
{
std::cerr << "Graphic driver not available.\n";
return 1;
}
- Handle(Graphic3d_GraphicDriver) aDriver =
- Handle(Graphic3d_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Device()->GraphicDriver());
+ Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
+
if (aDriver.IsNull())
{
std::cerr << "Graphic driver not available.\n";
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <DBRep.hxx>
-#include <Graphic3d_GraphicDevice.hxx>
-#include <Xw_GraphicDevice.hxx>
-#include <Xw_WindowQuality.hxx>
-#include <Xw_Window.hxx>
-#include <Graphic3d_GraphicDevice.hxx>
-#include <Xw_GraphicDevice.hxx>
-#include <Xw_WindowQuality.hxx>
-#include <Xw_Window.hxx>
#include <TCollection_AsciiString.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <Aspect_Window.hxx>
+#include <Aspect_DisplayConnection.hxx>
+#include <Graphic3d.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
-
-#ifndef WNT
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#else
+#if defined(_WIN32) || defined(__WIN32__)
#include <WNT_WClass.hxx>
#include <WNT_Window.hxx>
-#include <Graphic3d_WNTGraphicDevice.hxx>
+#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
+#include <Cocoa_Window.hxx>
+#else
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <Xw_WindowQuality.hxx>
+#include <Xw_Window.hxx>
#endif
-
-
-
-
//==============================================================================
// GLOBAL VARIABLES
//==============================================================================
#define ZCLIPWIDTH 1.
-#ifdef WNT
-
-static Handle(Graphic3d_WNTGraphicDevice) GetDevice() {
- static Handle(Graphic3d_WNTGraphicDevice) myDevice;
- static int first = 1;
- if ( first ) myDevice = new Graphic3d_WNTGraphicDevice();
- first = 0;
- return myDevice;
-}
-
-#else
-
-static Handle(Graphic3d_GraphicDevice)& GetDevice() {
- static Handle(Graphic3d_GraphicDevice) myDevice;
- static int first = 1;
- if ( first ) myDevice = new Graphic3d_GraphicDevice (getenv("DISPLAY"),Xw_TOM_READONLY);
- first = 0;
- return myDevice;
+static Handle(Aspect_DisplayConnection)& GetDisplayConnection()
+{
+ static Handle(Aspect_DisplayConnection) aDisplayConnection;
+ static Standard_Boolean isFirst = Standard_True;
+ if (isFirst)
+ {
+ aDisplayConnection = new Aspect_DisplayConnection();
+ isFirst = Standard_False;
+ }
+ return aDisplayConnection;
}
-//static Display *display;
-
-#endif
-
-
Standard_IMPORT Standard_Boolean Draw_VirtualWindows;
//=======================================================================
//function : MakeViewer
-//purpose :
+//purpose :
//=======================================================================
Handle(V3d_Viewer) ViewerTest_Tool::MakeViewer (const Standard_CString theTitle)
{
-#ifdef WNT
- Handle(Aspect_Window) window = new WNT_Window (GetDevice(), theTitle,
+#if defined(_WIN32) || defined(__WIN32__)
+ Handle(Aspect_Window) window = new WNT_Window (theTitle,
Handle(WNT_WClass)::DownCast (ViewerTest::WClass()),
WS_OVERLAPPEDWINDOW, 0, 460, 409, 409, Quantity_NOC_BLACK);
+#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 (GetDevice(), theTitle,
- 0, 460, 409, 409, Xw_WQ_3DQUALITY, Quantity_NOC_BLACK);
+ Handle(Aspect_Window) window = new Xw_Window (GetDisplayConnection(), theTitle,
+ 0, 460, 409, 409, Quantity_NOC_BLACK);
#endif
window->SetVirtual (Draw_VirtualWindows);
window->Map();
// Viewer
- Handle(Aspect_GraphicDevice) theDevice = GetDevice();
+ Handle(Graphic3d_GraphicDriver) aDriver = Graphic3d::InitGraphicDriver (GetDisplayConnection());
TCollection_ExtendedString NameOfWindow("Visu3D");
- Handle(V3d_Viewer) a3DViewer = new V3d_Viewer(theDevice,NameOfWindow.ToExtString());
+ Handle(V3d_Viewer) a3DViewer = new V3d_Viewer(aDriver,NameOfWindow.ToExtString());
a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
a3DViewer->SetDefaultLights();
#include <V3d_LayerMgrPointer.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Image_Diff.hxx>
+#include <Aspect_DisplayConnection.hxx>
+#include <Graphic3d.hxx>
#ifdef WNT
#undef DrawText
#include <cstdlib>
#if defined(_WIN32) || defined(__WIN32__)
- #include <Graphic3d_WNTGraphicDevice.hxx>
#include <WNT_WClass.hxx>
#include <WNT_Window.hxx>
#pragma warning (disable:4996)
#endif
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
- #include <Graphic3d_GraphicDevice.hxx>
#include <Cocoa_Window.hxx>
#include <tk.h>
#else
- #include <Graphic3d_GraphicDevice.hxx>
- #include <Xw_GraphicDevice.hxx>
#include <Xw_WindowQuality.hxx>
#include <Xw_Window.hxx>
#include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
#if defined(_WIN32) || defined(__WIN32__)
-static Handle(Graphic3d_WNTGraphicDevice)& GetG3dDevice(){
- static Handle(Graphic3d_WNTGraphicDevice) GD;
- return GD;
-}
-
static Handle(WNT_Window)& VT_GetWindow() {
static Handle(WNT_Window) WNTWin;
return WNTWin;
}
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
-static Handle(Graphic3d_GraphicDevice)& GetG3dDevice()
-{
- static Handle(Graphic3d_GraphicDevice) aGraphicDevice;
- return aGraphicDevice;
-}
static Handle(Cocoa_Window)& VT_GetWindow()
{
static Handle(Cocoa_Window) aWindow;
}
extern void ViewerTest_SetCocoaEventManagerView (const Handle(Cocoa_Window)& theWindow);
#else
-static Handle(Graphic3d_GraphicDevice)& GetG3dDevice(){
- static Handle(Graphic3d_GraphicDevice) GD;
- return GD;
-}
static Handle(Xw_Window)& VT_GetWindow(){
static Handle(Xw_Window) XWWin;
return XWWin;
static void VProcessEvents(ClientData,int);
#endif
+static Handle(Graphic3d_GraphicDriver)& GetGraphicDriver()
+{
+ static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
+ return aGraphicDriver;
+}
+
static Standard_Boolean DegenerateMode = Standard_True;
#define ZCLIPWIDTH 1.
if (isFirst)
{
- // Create the Graphic device
+ Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();
+ if (GetGraphicDriver().IsNull())
+ {
+ GetGraphicDriver() = Graphic3d::InitGraphicDriver (aDisplayConnection);
+ }
#if defined(_WIN32) || defined(__WIN32__)
- if (GetG3dDevice().IsNull()) GetG3dDevice() = new Graphic3d_WNTGraphicDevice();
if (VT_GetWindow().IsNull())
{
- // Create the Graphic device and the window
- Handle(WNT_GraphicDevice) g_Device = new WNT_GraphicDevice();
-
- VT_GetWindow() = new WNT_Window (g_Device, "Test3d",
+ VT_GetWindow() = new WNT_Window ("Test3d",
Handle(WNT_WClass)::DownCast (WClass()),
WS_OVERLAPPEDWINDOW,
aPxLeft, aPxTop,
Quantity_NOC_BLACK);
}
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
- if (GetG3dDevice().IsNull())
- {
- GetG3dDevice() = new Graphic3d_GraphicDevice (getenv ("DISPLAY"), Xw_TOM_READONLY);
- }
if (VT_GetWindow().IsNull())
{
VT_GetWindow() = new Cocoa_Window ("Test3d",
ViewerTest_SetCocoaEventManagerView (VT_GetWindow());
}
#else
- if (GetG3dDevice().IsNull()) GetG3dDevice() =
- new Graphic3d_GraphicDevice (getenv ("DISPLAY"), Xw_TOM_READONLY);
if (VT_GetWindow().IsNull())
{
- VT_GetWindow() = new Xw_Window (GetG3dDevice(),
+ VT_GetWindow() = new Xw_Window (aDisplayConnection,
"Test3d",
aPxLeft, aPxTop,
aPxWidth, aPxHeight,
- Xw_WQ_3DQUALITY,
Quantity_NOC_BLACK);
}
#endif
TCollection_ExtendedString NameOfWindow("Visu3D");
- a3DViewer = new V3d_Viewer(GetG3dDevice(), NameOfWindow.ToExtString());
+ a3DViewer = new V3d_Viewer(GetGraphicDriver(), NameOfWindow.ToExtString());
NameOfWindow = TCollection_ExtendedString("Collector");
- a3DCollector = new V3d_Viewer(GetG3dDevice(), NameOfWindow.ToExtString());
+ a3DCollector = new V3d_Viewer(GetGraphicDriver(), NameOfWindow.ToExtString());
a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
a3DCollector->SetDefaultBackgroundColor(Quantity_NOC_STEELBLUE);
Handle(NIS_View) aView = Handle(NIS_View)::DownCast(ViewerTest::CurrentView());
Window window = VT_GetWindow()->XWindow();
- Standard_Address theDisplay = GetG3dDevice()->XDisplay();
- display = (Display * ) theDisplay;
+ display = GetGraphicDriver()->GetDisplayConnection()->GetDisplay();
// display = (Display *)GetG3dDevice()->XDisplay();
XSynchronize(display, 1);
Handle(V3d_View) view = viewer->ActiveView();
if (viewer->MoreActiveViews()) ViewerTest::CurrentView(view);
ViewerTest::ResetEventManager();
- Handle(Aspect_GraphicDevice) device = viewer->Device();
Handle(Aspect_Window) window = view->Window();
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
// X11
VT_GetWindow() = Handle(Xw_Window)::DownCast(window);
- GetG3dDevice() = Handle(Graphic3d_GraphicDevice)::DownCast(device);
+ GetGraphicDriver() = viewer->Driver();
OSWindowSetup();
static int first = 1;
if ( first ) {
return 1;
}
- Handle(Graphic3d_GraphicDriver) aDriver =
- Handle(Graphic3d_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Device()->GraphicDriver());
+ Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
+
if (aDriver.IsNull())
{
std::cerr << "Graphic driver not available.\n";
return 1;
}
- Handle(Graphic3d_GraphicDriver) aDriver =
- Handle(Graphic3d_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Device()->GraphicDriver());
+ Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
+
if (aDriver.IsNull())
{
std::cerr << "Graphic driver not available.\n";
// 1) single click selection
// 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)
// 3) selection with polygon having corners at
-// pixel positions (x1,y1),...,(xn,yn)
+// pixel positions (x1,y1),...,(xn,yn)
// 4) any of these selections with shift button pressed
//=======================================================================
static Standard_Integer VSelect (Draw_Interpretor& di,
Standard_Integer argc,
const char ** argv)
{
- if(argc < 3)
+ if(argc < 3)
{
di << "Usage : " << argv[0] << " x1 y1 [x2 y2 [... xn yn]] [shift_selection = 1|0]" << "\n";
return 1;
}
Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
- if(myAIScontext.IsNull())
+ if(myAIScontext.IsNull())
{
di << "use 'vinit' command before " << argv[0] << "\n";
return 1;
//=======================================================================
//function : VMoveTo
-//purpose : Emulates cursor movement to defined pixel position
+//purpose : Emulates cursor movement to defined pixel position
//=======================================================================
static Standard_Integer VMoveTo (Draw_Interpretor& di,
Standard_Integer argc,
const char ** argv)
{
- if(argc != 3)
+ if(argc != 3)
{
di << "Usage : " << argv[0] << " x y" << "\n";
return 1;
}
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if(aContext.IsNull())
+ if(aContext.IsNull())
{
di << "use 'vinit' command before " << argv[0] << "\n";
return 1;
//=======================================================================
//function : VViewParams
-//purpose : Gets or sets AIS View characteristics
+//purpose : Gets or sets AIS View characteristics
//=======================================================================
static Standard_Integer VViewParams (Draw_Interpretor& di,
Standard_Integer argc,
const char ** argv)
{
- if ( argc != 1 && argc != 13)
+ if ( argc != 1 && argc != 13)
{
di << "Usage : " << argv[0] << "\n";
return 1;
}
Handle (V3d_View) anAISView = ViewerTest::CurrentView ();
- if ( anAISView.IsNull () )
+ if ( anAISView.IsNull () )
{
di << "use 'vinit' command before " << argv[0] << "\n";
return 1;
//=======================================================================
//function : VChangeSelected
-//purpose : Adds the shape to selection or remove one from it
+//purpose : Adds the shape to selection or remove one from it
//=======================================================================
static Standard_Integer VChangeSelected (Draw_Interpretor& di,
Standard_Integer argc,
{
aContext->AddOrRemoveSelected(anAISObject);
}
- else
+ else
{
aContext->AddOrRemoveCurrentObject(anAISObject);
}
//=======================================================================
//function : VZClipping
-//purpose : Gets or sets ZClipping mode, width and depth
+//purpose : Gets or sets ZClipping mode, width and depth
//=======================================================================
static Standard_Integer VZClipping (Draw_Interpretor& di,
Standard_Integer argc,
const char ** argv)
{
- if(argc>4)
+ if(argc>4)
{
di << "Usage : " << argv[0] << " [mode] [depth width]" << "\n"
<<"mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
return -1;
}
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if(aContext.IsNull())
+ if(aContext.IsNull())
{
di << "use 'vinit' command before " << argv[0] << "\n";
return 1;
di << "Bad mode; Usage : " << argv[0] << " [mode] [depth width]" << "\n"
<< "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
return 1;
- }
+ }
aView->SetZClippingType(aZClippingMode);
}
if(argc >2)
aDepth = atof(argv[2]);
aWidth = atof(argv[3]);
}
-
+
if(aDepth<0. || aDepth>1.)
{
di << "Bad depth; Usage : " << argv[0] << " [mode] [depth width]" << "\n"
//=======================================================================
//function : VNbSelected
-//purpose : Returns number of selected objects
+//purpose : Returns number of selected objects
//=======================================================================
static Standard_Integer VNbSelected (Draw_Interpretor& di,
Standard_Integer argc,
//=======================================================================
//function : VAntialiasing
-//purpose : Switches altialiasing on or off
+//purpose : Switches altialiasing on or off
//=======================================================================
static Standard_Integer VAntialiasing (Draw_Interpretor& di,
Standard_Integer argc,
//=======================================================================
//function : VPurgeDisplay
-//purpose : Switches altialiasing on or off
+//purpose : Switches altialiasing on or off
//=======================================================================
static Standard_Integer VPurgeDisplay (Draw_Interpretor& di,
Standard_Integer argc,
Standard_Real Dy = atof(argv[2]);
Standard_Real Dz = atof(argv[3]);
Standard_Boolean aStart = Standard_True;
- if (argc == 5)
+ if (argc == 5)
{
aStart = (atoi(argv[4]) > 0);
}
Standard_Real Ay = atof(argv[2]);
Standard_Real Az = atof(argv[3]);
Standard_Boolean aStart = Standard_True;
- if (argc == 5)
+ if (argc == 5)
{
aStart = (atoi(argv[4]) > 0);
}
"- gets or sets current view characteristics",
__FILE__,VViewParams, group);
theCommands.Add("vchangeselected",
- "vchangeselected shape"
+ "vchangeselected shape"
"- adds to shape to selection or remove one from it",
__FILE__, VChangeSelected, group);
theCommands.Add("vzclipping",
// for the class
#include <Visual3d_Layer.ixx>
-#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_TypeOfPrimitive.hxx>
#include <Visual3d_ViewManager.hxx>
#endif
MyPtrViewManager = (void *) AManager.operator->();
- Handle(Aspect_GraphicDriver) agd =
- (MyViewManager->GraphicDevice ())->GraphicDriver ();
-
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+ MyGraphicDriver = MyViewManager->GraphicDriver();
MyCLayer.layerType = int (ALayerType);
- MyCLayer.ptrLayer = NULL;
+ MyCLayer.ptrLayer = NULL;
MyCLayer.ortho[0] = -1.0;
MyCLayer.ortho[1] = 1.0;
MyCLayer.ortho[2] = -1.0;
-- An example when we have 1 view and 1 window
-- -------------------------------------------
--
- -- // Define a graphic device
- -- Handle(Graphic3d_GraphicDevice) GD =
- -- new Graphic3d_GraphicDevice ("dummy:0.0");
+ -- Handle(Aspect_DisplayConnection) aDisplayConnection;
+ --
+ -- // Display connection initialization only needed on Linux platform
+ -- // and on Mac OS X, in cases when you use Xlib for windows drawing.
+ -- aDisplayConnection = new Aspect_DisplayConnection();
+ --
+ -- // Graphic driver initialization
+ -- Handle(Graphic3d_GraphicDriver) aGraphicDriver =
+ -- Graphic3d::InitGraphicDriver (aDisplayConnection);
--
-- // Define a view manager
- -- Handle(Visual3d_ViewManager) VM = new Visual3d_ViewManager (GD);
+ -- Handle(Visual3d_ViewManager) aVisualManager = new Visual3d_ViewManager (aGraphicDriver);
--
-- // Define a view
- -- Handle(Visual3d_View) V = new Visual3d_View (VM);
+ -- Handle(Visual3d_View) aView = new Visual3d_View (aVisaulManager);
--
-- // Define a window
- -- Handle(Xw_Window) W = new Xw_Window
- -- (GD, "Graphic View 1", 0.695, 0.695, 0.600, 0.600,
- -- Xw_WQ_3DQUALITY, Quantity_NOC_MATRAGRAY);
+ -- Handle(Xw_Window) aWindow = new Xw_Window
+ -- (aDisplayConnection, "Graphic View 1", 0.695, 0.695, 0.600, 0.600, Quantity_NOC_MATRAGRAY);
--
-- // Associate the view and the window
- -- V->SetWindow (W);
+ -- aView->SetWindow (aWindow);
--
-- // Map the window
- -- W->Map ();
+ -- aWindow->Map ();
--
-- // Activate the view
- -- V->Activate ();
+ -- aView->Activate ();
--
SetWindow ( me : mutable;
raises ViewDefinitionError from Visual3d is static;
---Purpose:
-- After this call, each view is mapped in an unique window.
- --
- -- Programming example :
- --
- -- An example when we have 1 view and 1 widget
- -- -------------------------------------------
- --
- -- // Define a graphic device
- -- Handle(Graphic3d_GraphicDevice) GD =
- -- new Graphic3d_GraphicDevice ("dummy:0.0");
- --
- -- // Define a view manager
- -- Handle(Visual3d_ViewManager) VM = new Visual3d_ViewManager (GD);
- --
- -- // Define a view
- -- Handle(Visual3d_View) V = new Visual3d_View (VM);
- --
- -- // Define a widget
- -- Widget DA = GLwCreateMDrawingArea (Widget parent, char *name,
- -- ArgList arglist, Cardinal argcount);
- -- Handle(Xw_Window) W = new Xw_Window(DA);
- --
- -- // Define the graphic context
- -- GLXContext CTX = glXCreateContext(...)
- -- // Define the graphic call back and client data
- -- Handle(Object_View) myObject = new Object_View(...);
- -- static void DisplayCallback( Window w, XtPointer client_data,
- -- XtPointer call_data)
- -- { .... }
- -- // Associate the view and the widget
- -- V->SetWindow (W, CTX, DisplayCallback, myObject);
- --
- -- // Activate the view
- -- V->Activate ();
- --
Update ( me : mutable )
is static;
---Level: Internal
---Purpose: Returns the associated GraphicDriver.
---Category: Internal methods
+ ---C++: return const &
HaveTheSameOwner ( me;
AStructure : Structure from Graphic3d )
#include <Graphic3d_DataStructureManager.hxx>
#include <Graphic3d_GraphicDriver.hxx>
-#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
MyCView.GDisplayCB = 0;
MyCView.GClientData = 0;
-Handle(Aspect_GraphicDriver) agd =
- (MyViewManager->GraphicDevice ())->GraphicDriver ();
-
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+ MyGraphicDriver = MyViewManager->GraphicDriver();
}
MyCView.GDisplayCB = 0;
MyCView.GClientData = 0;
-Handle(Aspect_GraphicDriver) agd =
- (MyViewManager->GraphicDevice ())->GraphicDriver ();
-
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+ MyGraphicDriver = MyViewManager->GraphicDriver();
}
}
-Handle(Aspect_GraphicDriver) Visual3d_View::GraphicDriver () const {
+const Handle(Aspect_GraphicDriver)& Visual3d_View::GraphicDriver () const {
return MyGraphicDriver;
MapOfInteger from TColStd,
GenId from Aspect,
- GraphicDevice from Aspect,
Window from Aspect,
TypeOfHighlightMethod from Aspect,
is
- Create ( aDevice : GraphicDevice from Aspect)
+ Create ( theDriver: GraphicDriver from Graphic3d)
returns mutable ViewManager from Visual3d;
---Level: Public
---Purpose: Creates a 3D visualizer.
//-Constructors
-Visual3d_ViewManager::Visual3d_ViewManager (const Handle(Aspect_GraphicDevice)& aDevice):
-Graphic3d_StructureManager (aDevice),
+Visual3d_ViewManager::Visual3d_ViewManager (const Handle(Graphic3d_GraphicDriver)& theDriver):
+Graphic3d_StructureManager (theDriver),
MyDefinedView (),
MyViewGenId (View_IDMIN+((View_IDMIN+View_IDMAX)/(Visual3d_ViewManager::Limit ()))*(Visual3d_ViewManager::CurrentId ()-1),View_IDMIN+((View_IDMIN+View_IDMAX)/(Visual3d_ViewManager::Limit ()))*Visual3d_ViewManager::CurrentId ()-1),
MyZBufferAuto (Standard_False),
myLayerIds.Add (0);
myLayerSeq.Append (0);
- Handle(Aspect_GraphicDriver) agd = aDevice->GraphicDriver ();
-
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+ MyGraphicDriver = theDriver;
}
//-Destructors
WNT_Allocator.cxx
WNT_ColorRef.cxx
WNT_Dword.cxx
-WNT_IconBox_1.cxx
-WNT_ImageProcessor.cxx
WNT_LogFont.cxx
WNT_Long.cxx
WNT_Uint.cxx
WNT_WindowData.cxx
-WNT_WndProc.cxx
-- Category: Classes
--------------------
-
- class GraphicDevice;
- ---Purpose: Creates the graphic device associated with DISPLAY.
- ---Category: Classes
-
class Window;
---Purpose: Creates the Window drawable.
---Category: Classes
---Purpose: Creates a Windows NT window class.
---Category: Classes
- class IconBox;
- ---Purpose: Creates the Icon Box window.
- ---Category: Classes
-
- class ImageManager;
- ---Purpose: Creates and manages images and/or icons.
- ---Category: Classes
-
class Image;
---Purpose: Defines the class
---Category: Classes
- class Icon;
- ---Purpose: Defines the class
- ---Category: Classes
-
---------------------------
-- Category: Enumerations
---------------------------
+++ /dev/null
--- Created on: 1996-01-25
--- Created by: LAVNIKOV Alexey & PLOTNIKOV Eugeny
--- 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.
-
-
-class GraphicDevice from WNT inherits GraphicDevice from Aspect
-
- ---Purpose: This class defines Windows NT display device.
- -- A Graphic Device defines color management. Windows can run in three
- -- different color modes depending of the installed graphic board:
- -- - Low color resolution which allows us to use 16 predefined pure
- -- colors for drawing lines and unlimited number of dithered colors
- -- for window's background, solid filled areas etc. Here Graphic Device
- -- will approximate requested colors by existing ones for line colors
- -- ( really this approximation is doing by Windows ). A dithering
- -- technique will be used for window's backgrounds, solid fills etc.
- -- ( this is doing by WIndows also ). A dithering techique will be use
- -- for solid fill.
- -- - Medium color resolution which requires a Windows palette manager.
- -- This mode takes after X window system's PseudoColor Visual. The
- -- application can create a LOGICAL PALETTE to represent 20 reserved
- -- by Windows colors and 236 programmable ones. It's possible to reserve
- -- odd entries in the palette for highlighting purposes ( but real
- -- technique is not the same as in X window system - see Windows manual ).
- -- It's possible to create several logical palettes. To do it create
- -- other GraphicDevice but in this case color "flicking" is possible.
- -- - High color resolution. Here 65 536 or 16 777 216 colors are available.
- -- Any color we like will be exactly displayed on the screen, but
- -- highlighting technique is not available. This mode often called
- -- TrueColor but it's not the same as X window TrueColor.
- -- A Graphic Device also defines physical dimensions of the screen.
-
- uses
-
- Color from Quantity,
- Length from Quantity,
- ColorMap from Aspect,
- Handle from Aspect,
- ColorRef from WNT,
- HColorTable from WNT,
- Long from WNT,
- GraphicDriver from Aspect
-
- raises
-
- GraphicDeviceDefinitionError from Aspect,
- BadAccess from Aspect
-
- is
-
- Create (
- aColorCube : Boolean from Standard = Standard_False;
- aDevContext : Handle from Aspect = 0
- )
- returns mutable GraphicDevice from WNT
- ---Level: Public
- ---Purpose: Creates a GraphicDevice and logical palette.
- -- Builds an OpenGL colorcube on that palette depending
- -- of the aColorCube flag and hardware.
- -- Warning: Raises if createion of the logical palette failed.
- raises GraphicDeviceDefinitionError from Aspect;
-
- Create (
- aColorCube : Boolean from Standard;
- aDevContext : Integer from Standard
- ) returns mutable GraphicDevice from WNT
- ---Purpose: same as previous one (to provide access form CCL)
- raises GraphicDeviceDefinitionError from Aspect;
-
- Destroy ( me : mutable ) is virtual;
- ---Level: Public
- ---Purpose: Destroies all ressources attached to the GraphicDevice.
- ---C++: alias ~
-
- SetColor (
- me : mutable;
- aColor : Color from Quantity;
- aHighlight : Boolean from Standard = Standard_False
- )
- returns ColorRef from WNT is static;
- ---Level: Public
- ---Purpose: Returns the color value in form specific to Windows NT.
- -- Sets the color values in the logical palette if the
- -- hardware supports it. If in this case there are not
- -- free cell in the logical palette then this method will
- -- search for nearest color in the palette.
- -- If <aHighlight> is True then sets a highlight color.
-
- SetColor (
- me : mutable;
- aRed : Integer from Standard;
- aGreen : Integer from Standard;
- aBlue : Integer from Standard;
- aHighlight : Boolean from Standard = Standard_False
- )
- returns ColorRef from WNT is virtual;
- ---Level: Public
- ---Purpose: See above
-
- SetColor ( me : mutable; aPixel : Long from WNT )
- is virtual;
- ---Level: Internal
- ---Purpose: Color allocation for images.
-
- MapColors (
- me : mutable;
- aColorMap : ColorMap from Aspect;
- aColorTable : in out HColorTable from WNT
- ) is static;
- ---Level: Public
- ---Purpose: Returns the color value in form specific to WIndows NT
- -- in the <aColorTable>. See SetColor method.
- -- Warning: The dimensions and index ranges of the <aColorMap> and
- -- <aColorTable> must be the same;
-
- HPalette ( me ) returns Handle from Aspect is static;
- ---Level: Public
- ---Purpose: Returns logical palette handle attached to the
- -- GraphicDevice.
- ---C++: inline
-
- DisplaySize ( me; aWidth, aHeight : out Integer from Standard ) is static;
- ---Level: Public
- ---Purpose: Returns the Display size in PIXEL
- ---C++: inline
-
- DisplaySize ( me; aWidth, aHeight : out Length from Quantity ) is static;
- ---Level: Public
- ---Purpose: Returns the Display size in working units units
- ---C++: inline
-
- IsPaletteDevice ( me ) returns Boolean from Standard is static;
- ---Level: Public
- ---Purpose: Returns True if hardware is palette-compatible.
- ---C++: inline
-
- NumColors ( me ) returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Returns number of available colors.
- ---C++: inline
-
- HighlightColor ( me ) returns ColorRef from WNT is static;
- ---Level: Public
- ---Purpose: Returns highlight color.
- ---C++: inline
-
- GraphicDriver ( me ) returns GraphicDriver from Aspect is redefined;
- ---Level: Public
- ---Purpose: Dummy method
-
- Init (
- me : mutable;
- aColorCube : Boolean from Standard;
- aDevContext : Handle from Aspect
- ) is protected;
-
- fields
-
- myMWidth,
- myMHeight : Length from Quantity is protected;
- myWidth,
- myHeight,
- myNumColors : Integer from Standard is protected;
- myFreeIndex : Integer from Standard is protected;
- myPalette : Handle from Aspect is protected;
- myLogPal : Address from Standard is protected;
- myHighlightColor : ColorRef from WNT is protected;
- myOpenGLPalette : Boolean from Standard is protected;
-
- friends
-
- class Window from WNT
-
-end GraphicDevice;
+++ /dev/null
-// 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.
-
-/***********************************************************************
- FONCTION :
- ----------
- Classe WNT_GraphicDevice.cxx :
-
- HISTORIQUE DES MODIFICATIONS :
- --------------------------------
- 03-01-95 : EUG -> Creation.
- 20-11-97 : FMN -> Portage WIN95
- MAR-98 : EUG -> Porting Win95
- JUN-98 : EUG -> Modifications to provide access to this class
- from CCL (second constructor + Init () method)
- SEP-98 : DCB -> Avoid memory crash when color indices do not follow
- each other or do not begin with '1'
- JAN-99 : EUG -> Modifications to provide treating display window
- as graphic device
-************************************************************************/
-
-/*----------------------------------------------------------------------*/
-/*
- * Includes
- */
-
-// include windows.h first to have all definitions available
-#include <windows.h>
-
-#include <WNT.h>
-#include <WNT_GraphicDevice.ixx>
-#include <Aspect_ColorMapEntry.hxx>
-#include <Aspect_GraphicDriver.hxx>
-#include <Aspect_Units.hxx>
-
-#include <stdio.h>
-
-/*----------------------------------------------------------------------*/
-/*
- * Constantes
- */
-
-#define PAL ((PLOGPALETTE)myLogPal)
-#define MAX_PAL_ERROR (3*256*256L)
-#define DEFAULT_GAMMA 1.4
-
-static int __fastcall _createColorRamp ( HPALETTE* );
-static BOOL s_SysPalInUse;
-
-extern HWINSTA ( WINAPI *NTOpenWindowStation ) ( LPTSTR, BOOL, DWORD );
-extern BOOL ( WINAPI *NTSetProcessWindowStation ) ( HWINSTA );
-extern HDESK ( WINAPI *NTOpenDesktop ) ( LPTSTR, DWORD, BOOL, DWORD );
-extern BOOL ( WINAPI *NTSetThreadDesktop ) ( HDESK );
-extern BOOL ( WINAPI *NTCloseDesktop ) ( HDESK );
-extern BOOL ( WINAPI *NTCloseWindowStation ) ( HWINSTA );
-
-extern OSVERSIONINFO WNT_osVer;
-
-//=======================================================================
-//function : WNT_GraphicDevice
-//purpose :
-//=======================================================================
-
-WNT_GraphicDevice::WNT_GraphicDevice (
- const Standard_Boolean aColorCube,
- const Aspect_Handle aDevContext
- )
-{
-
- Init ( aColorCube, aDevContext );
-
-} // end constructor ( 1 )
-
-//=======================================================================
-//function : WNT_GraphicDevice
-//purpose :
-//=======================================================================
-
-WNT_GraphicDevice::WNT_GraphicDevice (
- const Standard_Boolean aColorCube,
- const Standard_Integer aDevContext
- )
-{
-
- Init ( aColorCube, ( Aspect_Handle )aDevContext );
-
-} // end constructor ( 2 )
-
-//=======================================================================
-//function : Init
-//purpose :
-//=======================================================================
-
-void WNT_GraphicDevice::Init (
- const Standard_Boolean aColorCube,
- const Aspect_Handle aDevContext
- )
-{
-
- HDC hDC;
- BOOL palDev;
- HWND hwnd = NULL;
- HBITMAP hBmp = NULL;
- int numRes, palSize, nPlanes, nBits;
-
- hDC = ( aDevContext == NULL ) ? GetDC ( NULL ) :
- ( HDC )aDevContext, hwnd = WindowFromDC ( ( HDC )aDevContext );
-
-// It is found that the error occurs in the place in the source code that is
-// responsible for connecting to the desktop and window pointed by the environment
-// variable CSF_DISPLAY.
-// For the moment it is unclear at all what this code is needed for. Therefore it
-// is removed from the sources in order to fix this bug. This allowed to run the
-// code without problems on both win32 and win64 platforms.
-// It is needed to carry out special investigations about this subject. Probably it
-// can be used to connect to a virtual desktop in order to make snapshots on the
-// Windows station on which no user is logged in.
-//
-// if ( aDevContext == 0 && WNT_osVer.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
-
-// HWINSTA hWst = NULL;
-// HDESK hDsk = NULL;
-// DWORD dwLen, dwLenOrig;
-// LPTSTR buff = NULL;
-// LPTSTR sNam = NULL;
-// LPTSTR dNam = NULL;
-// BOOL fSts = FALSE;
-
-// dwLenOrig = GetEnvironmentVariable( TEXT( "CSF_DISPLAY" ), NULL, 0 );
-
-// if ( dwLenOrig == 0 )
-
-// dwLen = sizeof ( TEXT( "WinSta0\\Default" ) );
-
-// else
-
-// dwLen = dwLenOrig + sizeof ( TCHAR );
-
-// buff = ( LPTSTR )HeapAlloc (
-// GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY, dwLen
-// );
-
-// if ( dwLenOrig != 0 )
-
-// GetEnvironmentVariable ( TEXT( "CSF_DISPLAY" ), buff, dwLen );
-
-// else
-
-// lstrcpy ( buff, TEXT( "WinSta0\\Default" ) );
-
-// dwLen = 0;
-
-// while ( buff[ dwLen ] != TEXT( '\\' ) && buff[ dwLen ] != TEXT( '\x00' ) ) ++dwLen;
-
-// sNam = ( LPTSTR )HeapAlloc (
-// GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS,
-// dwLen * sizeof ( TCHAR ) + sizeof ( TCHAR )
-// );
-
-// dwLenOrig = 0;
-
-// while ( dwLenOrig != dwLen ) {
-
-// sNam[ dwLenOrig ] = buff[ dwLenOrig ];
-// ++dwLenOrig;
-
-// } // end while
-
-// sNam[ dwLenOrig ] = TEXT( '\x00' );
-
-// if ( buff[ dwLen ] == TEXT( '\x00' ) ) goto leave;
-
-// lstrcpy ( buff, &buff[ dwLen + 1 ] );
-
-// dNam = ( LPTSTR )HeapAlloc (
-// GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS,
-// lstrlen ( buff ) * sizeof ( TCHAR ) + sizeof ( TCHAR )
-// );
-
-// lstrcpy ( dNam, buff );
-
-// if ( ( hWst = ( *NTOpenWindowStation ) ( sNam, FALSE, MAXIMUM_ALLOWED ) ) == NULL ||
-// !( *NTSetProcessWindowStation ) ( hWst )
-// ) goto leave;
-
-// if ( ( hDsk = ( *NTOpenDesktop ) ( dNam, 0, FALSE, MAXIMUM_ALLOWED ) ) == NULL ||
-// !( *NTSetThreadDesktop ) ( hDsk )
-// )
-
-// if ( GetLastError () == ERROR_BUSY ) {
-
-// if ( hDsk != NULL ) ( *NTCloseDesktop ) ( hDsk );
-// if ( hWst != NULL ) ( *NTCloseWindowStation ) ( hWst );
-
-// } else goto leave;
-
-// fSts = TRUE;
-//leave:
-// if ( sNam != NULL ) HeapFree ( GetProcessHeap (), 0, ( LPVOID )sNam );
-// if ( dNam != NULL ) HeapFree ( GetProcessHeap (), 0, ( LPVOID )dNam );
-// if ( buff != NULL ) HeapFree ( GetProcessHeap (), 0, ( LPVOID )buff );
-
-// if ( !fSts ) {
-
-// if ( hDsk != NULL ) ( *NTCloseDesktop ) ( hDsk );
-// if ( hWst != NULL ) ( *NTCloseWindowStation ) ( hWst );
-
-// Aspect_GraphicDeviceDefinitionError :: Raise ( "Access to station is denied" );
-
-// } // end if
-
-// } // end if
-
- palDev = ( GetDeviceCaps ( hDC, RASTERCAPS ) & RC_PALETTE ) ? TRUE : FALSE;
- numRes = GetDeviceCaps ( hDC, NUMRESERVED );
- palSize = ( palDev ) ? GetDeviceCaps ( hDC, SIZEPALETTE ) : 0;
- nPlanes = GetDeviceCaps ( hDC, PLANES );
- nBits = GetDeviceCaps ( hDC, BITSPIXEL );
- myWidth = GetDeviceCaps ( hDC, HORZRES );
- myHeight = GetDeviceCaps ( hDC, VERTRES );
- myMWidth = ( float )GetDeviceCaps ( hDC, HORZSIZE ) / ( 1. MILLIMETER );
- myMHeight = ( float )GetDeviceCaps ( hDC, VERTSIZE ) / ( 1. MILLIMETER );
-
- if ( aDevContext != NULL && hwnd != NULL ) {
-
- RECT r;
-
- GetClientRect ( hwnd, &r );
-
- myMWidth = myMWidth * r.right / myWidth;
- myMHeight = myMHeight * r.bottom / myHeight;
- myWidth = r.right;
- myHeight = r.bottom;
-
- } else {
-
- BITMAP bm;
-
- hBmp = ( HBITMAP )GetCurrentObject ( hDC, OBJ_BITMAP );
-
- if ( GetObject ( hBmp, sizeof ( BITMAP ), &bm ) ) {
-
- myMWidth = myMWidth * bm.bmWidth / myWidth;
- myMHeight = myMHeight * bm.bmHeight / myHeight;
-// Tempory correction for Windows 98
- if ( WNT_osVer.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS ) {
-//
- myWidth = bm.bmWidth;
- myHeight = bm.bmHeight;
-
- } else hBmp = NULL;
-// Tempory correction for Windows 98
- }
-//
-
- } // end else
-
- if ( aDevContext == NULL ) ReleaseDC ( NULL, hDC );
-
- myNumColors = ( 1 << ( nBits * nPlanes ) );
-
- if ( palDev ) myNumColors -= numRes;
-
- myFreeIndex = 0;
- myOpenGLPalette = aColorCube;
-
- if ( palDev ) {
-
- if ( hwnd == NULL && hBmp == NULL ) {
-
- myLogPal = HeapAlloc (
- GetProcessHeap (), HEAP_ZERO_MEMORY,
- sizeof( LOGPALETTE ) +
- sizeof( PALETTEENTRY ) * myNumColors
- );
-
- if ( !myLogPal )
-
- Aspect_GraphicDeviceDefinitionError :: Raise ( "Out of memory" );
-
- PAL -> palVersion = 0x300;
- PAL -> palNumEntries = 1;
-
- myPalette = CreatePalette ( PAL );
-
- if ( !myPalette ) {
-
- HeapFree ( GetProcessHeap (), 0, myLogPal );
- Aspect_GraphicDeviceDefinitionError :: Raise ( "Unable to create user palette" );
-
- } // end if
-
- myFreeIndex = 0;
-
- if ( myOpenGLPalette && !_createColorRamp ( ( HPALETTE* )&myPalette ) )
-
- Aspect_GraphicDeviceDefinitionError :: Raise ( "Colorcube creation failed" );
-
- } else {
-
- myPalette = GetCurrentObject ( hDC, OBJ_PAL );
- myLogPal = NULL;
-
- } // end else
-
- } else { // not a palette device
-
- myPalette = 0;
- myLogPal = NULL;
-
- } // end else ( palDev . . . )
-
- myHighlightColor = RGB( 255, 255, 255 );
-
-} // end WNT_GraphicDevice :: Init
-
-void WNT_GraphicDevice :: Destroy () {
-
- if ( myPalette && myLogPal != NULL ) {
-
- DeletePalette ( myPalette );
- HeapFree ( GetProcessHeap (), 0, myLogPal );
-
- } // end if
-
-} // end WNT_GraphicDevice :: Destroy
-
-WNT_ColorRef WNT_GraphicDevice :: SetColor (
- const Quantity_Color& aColor,
- const Standard_Boolean aHighlight
- ) {
-
- Standard_Real r, g, b;
- Standard_Integer red, green, blue;
-
- aColor.Values ( r, g, b, Quantity_TOC_RGB );
-
- red = ( Standard_Integer )( 255. * r );
- green = ( Standard_Integer )( 255. * g );
- blue = ( Standard_Integer )( 255. * b );
-
- return SetColor ( red, green, blue, aHighlight );
-
-} // end WNT_GraphicDevice :: SetColor( 1 )
-
-WNT_ColorRef WNT_GraphicDevice :: SetColor (
- const Standard_Integer aRed,
- const Standard_Integer aGreen,
- const Standard_Integer aBlue,
- const Standard_Boolean aHighlight
- ) {
-
- int i;
- WNT_ColorRef retVal;
- BYTE red, green, blue;
-
- red = ( BYTE )aRed;
- green = ( BYTE )aGreen;
- blue = ( BYTE )aBlue;
-
- if ( !myPalette )
-
- retVal = RGB( red, green, blue );
-
- else if ( myOpenGLPalette )
-
- retVal = PALETTEINDEX(
- GetNearestPaletteIndex (
- ( HPALETTE )myPalette, RGB( red, green, blue )
- )
- );
-
- else {
-
- if ( myFreeIndex < myNumColors ) {
-
- for ( i = 0; i < myFreeIndex; ++i ) // avoid color duplication
-
- if ( PAL -> palPalEntry[ i ].peRed == red &&
- PAL -> palPalEntry[ i ].peGreen == green &&
- PAL -> palPalEntry[ i ].peBlue == blue
- )
-
- break;
-
- if ( i == myFreeIndex ) { // add new color entry
-
- PAL -> palPalEntry[ i ].peRed = red;
- PAL -> palPalEntry[ i ].peGreen = green;
- PAL -> palPalEntry[ i ].peBlue = blue;
- PAL -> palPalEntry[ i ].peFlags = 0;
- ++myFreeIndex;
- ResizePalette ( ( HPALETTE )myPalette, myFreeIndex );
- SetPaletteEntries ( ( HPALETTE )myPalette, i, 1, &PAL -> palPalEntry[ i ] );
-
- } // end if
-
- retVal = PALETTEINDEX( i );
-
- } else // get closest color
-
- retVal = PALETTEINDEX(
- GetNearestPaletteIndex (
- ( HPALETTE )myPalette, RGB( red, green, blue )
- )
- );
-
- } // end else ( !myPalette . . . )
-
- if ( aHighlight )
-
- myHighlightColor = retVal;
-
- return retVal;
-
-} // end WNT_GraphicDevice :: SetColor(2)
-
-void WNT_GraphicDevice :: SetColor ( const WNT_Long& aPixel ) {
-
- if ( myPalette && !myOpenGLPalette && myFreeIndex < myNumColors ) {
-
- int idx;
- BYTE red, green, blue;
-
- blue = (BYTE) (aPixel & 0xFF);
- green = (BYTE) (( aPixel >> 8 ) & 0xFF);
- red = (BYTE) (( aPixel >> 16 ) & 0xFF);
-
- idx = myFreeIndex;
-
- for ( int i = 2; i < myFreeIndex; ++i ) // avoid color duplication
-
- if ( PAL -> palPalEntry[ i ].peRed == red &&
- PAL -> palPalEntry[ i ].peGreen == green &&
- PAL -> palPalEntry[ i ].peBlue == blue
- )
-
- return;
-
- PAL -> palPalEntry[ idx ].peRed = red;
- PAL -> palPalEntry[ idx ].peGreen = green;
- PAL -> palPalEntry[ idx ].peBlue = blue;
- PAL -> palPalEntry[ idx ].peFlags = 0;
- ++myFreeIndex;
- ResizePalette ( ( HPALETTE )myPalette, myFreeIndex );
- SetPaletteEntries ( ( HPALETTE )myPalette, idx, 1, &PAL -> palPalEntry[ idx ] );
-
- } // end if ( myPalette . . . )
-
-} // end WNT_GraphicDevice :: SetColor(3)
-
-void WNT_GraphicDevice :: MapColors (
- const Handle( Aspect_ColorMap )& aColorMap,
- Handle( WNT_HColorTable )& aColorTable
- ) {
-
- Aspect_ColorMapEntry entry;
- Quantity_Color color;
- COLORREF dwColor;
- Standard_Real r, g, b;
- int i, index;
-
- if ( myOpenGLPalette || !IsPaletteDevice () ) // readonly palette or no palette
-
- for ( i = 1; i <= aColorMap -> Size (); ++i ) {
-
- entry = aColorMap -> Entry ( i );
- color = entry.Color ();
- aColorTable -> SetValue ( entry.Index (), SetColor ( color ) );
-
- } // end for
-
- else { // writable palette
-
- for ( i = 1; i <= aColorMap -> Size (); ++i ) {
-
- entry = aColorMap -> Entry ( i );
- color = entry.Color ();
- dwColor = aColorTable -> Value ( i );
- index = dwColor & 0x01000000 ? dwColor & 0x00FFFFFF : 0xFFFFFFFF;
-
- if ( index != 0xFFFFFFFF && index < myFreeIndex ) {
-
- color.Values ( r, g, b, Quantity_TOC_RGB );
- PAL -> palPalEntry[ index ].peRed = ( BYTE )( 255. * r );
- PAL -> palPalEntry[ index ].peGreen = ( BYTE )( 255. * g );
- PAL -> palPalEntry[ index ].peBlue = ( BYTE )( 255. * b );
-
- } else
-
- aColorTable -> SetValue ( i, SetColor ( color ) );
-
- } // end for
-
- SetPaletteEntries (
- ( HPALETTE )myPalette, 0, myFreeIndex, &PAL -> palPalEntry[ 0 ]
- );
-
- } // end else
-
-} // WNT_GraphicDevice :: MapColors
-
-Handle( Aspect_GraphicDriver ) WNT_GraphicDevice :: GraphicDriver () const {
-
- Handle( Aspect_GraphicDriver ) dummy;
-
- return dummy;
-
-} // WNT_GraphicDevice :: GraphicDriver
-//***//
-//*** Function to create RGB color map for use with OpenGL. ***//
-//*** For OpenGL RGB rendering we need to know red, green, & blue ***//
-//*** component bit sizes and positions. This program creates an RGB color ***//
-//*** cube with a default gamma of 1.4. ***//
-//*** Unfortunately, because the standard 20 colors in the system palette ***//
-//*** cannot be changed, if we select this palette into a display DC, ***//
-//*** we will not realize all of the logical palette. The function ***//
-//*** changes some of the entries in the logical palette to match enties in ***//
-//*** the system palette using a least-squares calculation to find which ***//
-//*** entries to replace. ***//
-//***//
-static int __fastcall _createColorRamp ( HPALETTE* pal ) {
-
- int i, j;
- int sysPalSize, logPalSize;
- int red_max, green_max, blue_max,
- red_mask, green_mask, blue_mask;
- int iPf;
- HDC hDC;
- PIXELFORMATDESCRIPTOR pfd;
- PPALETTEENTRY sysPal, colorRamp;
- PBYTE gRed, gGreen, gBlue;
- BYTE inc;
- LONG error, min_error, error_index, delta;
- double dv, gamma;
- char buff[ 32 ];
-
- ZeroMemory ( ( PVOID )&pfd, sizeof ( PIXELFORMATDESCRIPTOR ) );
-
- pfd.nSize = sizeof ( PIXELFORMATDESCRIPTOR );
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
- PFD_DOUBLEBUFFER;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 24;
- pfd.cDepthBits = 32;
- pfd.iLayerType = PFD_MAIN_PLANE;
-
- hDC = GetDC ( NULL );
-
- iPf = ChoosePixelFormat ( hDC, &pfd );
- i = DescribePixelFormat (
- hDC, iPf, sizeof ( PIXELFORMATDESCRIPTOR ), &pfd
- );
-
- if ( !i ) {
-
- ReleaseDC ( NULL, hDC );
-
- return 0;
-
- } // end if
-
- sysPalSize = GetDeviceCaps ( hDC, NUMCOLORS );
- logPalSize = 1 << pfd.cColorBits;
- sysPal = new PALETTEENTRY[ sysPalSize + logPalSize ];
- colorRamp = sysPal + sysPalSize;
- GetSystemPaletteEntries ( hDC, 0, sysPalSize, sysPal );
-
- ReleaseDC ( NULL, hDC );
-
- red_max = 1 << pfd.cRedBits;
- green_max = 1 << pfd.cGreenBits;
- blue_max = 1 << pfd.cBlueBits;
-
- red_mask = red_max - 1;
- green_mask = green_max - 1;
- blue_mask = blue_max - 1;
-
- gRed = new BYTE[ red_max + green_max + blue_max ];
- gGreen = gRed + red_max;
- gBlue = gGreen + green_max;
-
- inc = ( BYTE )( 255.0F / ( float )red_mask );
-
- if ( GetEnvironmentVariable ( "CSF_GammaValue", buff, 32 ) ) {
-
- gamma = Atof ( buff );
-
- if ( gamma == 0.0 )
-
- gamma = DEFAULT_GAMMA;
-
- } else
-
- gamma = DEFAULT_GAMMA;
-
- for ( i = 0; i < red_max; ++i ) {
-
- gRed[ i ] = ( i * inc ) & 0xFF;
- dv = ( 255. * pow ( gRed[ i ] / 255., 1. / gamma ) ) + 0.5;
- gRed[ i ] = ( BYTE )dv;
-
- } // end for
-
- inc = ( BYTE )( 255.0F / ( float )green_mask );
-
- for ( i = 0; i < green_max; ++i ) {
-
- gGreen[ i ] = ( i * inc ) & 0xFF;
- dv = ( 255. * pow ( gGreen[ i ] / 255., 1. / gamma ) ) + 0.5;
- gGreen[ i ] = ( BYTE )dv;
-
- } // end for
-
- inc = ( BYTE )( 255.0F / ( float )blue_mask );
-
- for ( i = 0; i < blue_max; ++i ) {
-
- gBlue[ i ] = ( i * inc ) & 0xFF;
- dv = ( 255. * pow ( gBlue[ i ] / 255., 1. / gamma ) ) + 0.5;
- gBlue[ i ] = ( BYTE )dv;
-
- } // end for
-
- for ( i = 0; i < logPalSize; ++i ) {
-
- colorRamp[ i ].peRed =
- gRed[ ( i >> pfd.cRedShift ) & red_mask ];
- colorRamp[ i ].peGreen =
- gGreen[ ( i >> pfd.cGreenShift ) & green_mask ];
- colorRamp[ i ].peBlue =
- gBlue[ ( i >> pfd.cBlueShift ) & blue_mask ];
- colorRamp[ i ].peFlags = 0;
-
- } // end for
-
- if ( pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ) {
-
- s_SysPalInUse = TRUE;
-
- for ( i = 1; i < logPalSize - 1; ++i ) colorRamp[ i ].peFlags = PC_NOCOLLAPSE;
-
- } else {
-
- for ( i = 0; i < sysPalSize; ++i )
-
- for ( j = 0; j < logPalSize; ++j )
-
- if ( sysPal[ i ].peRed == colorRamp[ j ].peRed &&
- sysPal[ i ].peGreen == colorRamp[ j ].peRed &&
- sysPal[ i ].peBlue == colorRamp[ j ].peRed
- )
-
- sysPal[ i ].peFlags = colorRamp[ i ].peFlags = 1;
-
- else
-
- sysPal[ i ].peFlags = colorRamp[ i ].peFlags = 0;
-
- for ( i = 0; i < sysPalSize; ++i ) {
-
- if ( sysPal[ i ].peFlags ) continue;
-
- min_error = MAX_PAL_ERROR;
-
- for ( j = 0; j < logPalSize; ++j ) {
-
- if ( colorRamp[ j ].peFlags ) continue;
-
- delta = colorRamp[ j ].peRed - sysPal[ i ].peRed;
- error = delta * delta;
- delta = colorRamp[ j ].peGreen - sysPal[ i ].peGreen;
- error += delta * delta;
- delta = colorRamp[ j ].peBlue - sysPal[ i ].peBlue;
- error += delta * delta;
-
- if ( error < min_error ) {
-
- error_index = j;
- min_error = error;
-
- } // end if
-
- } // end for ( j . . . )
-
- colorRamp[ error_index ].peRed = sysPal[ i ].peRed;
- colorRamp[ error_index ].peGreen = sysPal[ i ].peGreen;
- colorRamp[ error_index ].peBlue = sysPal[ i ].peBlue;
- colorRamp[ error_index ].peFlags = PC_EXPLICIT;
-
- } // end for ( i . . . )
-
- } // end else
-
- ResizePalette ( *pal, logPalSize );
- SetPaletteEntries ( *pal, 0, logPalSize, colorRamp );
-
- delete [] gRed;
- delete [] sysPal;
-
- return 1;
-
-} // end createColorRamp
-
-int WNT_SysPalInUse ( void ) {
-
- return s_SysPalInUse;
-
-} // end WNT_SysPalInUse
+++ /dev/null
-// 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.
-
-inline Aspect_Handle WNT_GraphicDevice :: HPalette () const {
-
- return myPalette;
-
-} // end WNT_GraphicDevice :: HPalette
-
-inline void WNT_GraphicDevice :: DisplaySize (
- Standard_Integer& aWidth, Standard_Integer& aHeight
- ) const {
-
- aWidth = myWidth;
- aHeight = myHeight;
-
-} // end WNT_GraphicDevice :: DisplaySize
-
-inline void WNT_GraphicDevice :: DisplaySize (
- Quantity_Length& aWidth, Quantity_Length& aHeight
- ) const {
- aWidth = myMWidth;
- aHeight = myMHeight;
-
-} // end WNT_GraphicDevice :: DisplaySize
-
-inline Standard_Boolean WNT_GraphicDevice :: IsPaletteDevice () const {
-
- return ( myPalette != 0 );
-
-} // end WNT_GraphicDevice :: IsPaletteDevice
-
-inline Standard_Integer WNT_GraphicDevice :: NumColors () const {
-
- return myNumColors;
-
-} // end WNT_GraphicDevice :: NumColors
-
-inline WNT_ColorRef WNT_GraphicDevice :: HighlightColor () const {
-
- return myHighlightColor;
-
-} // end WNT_GraphicDevice :: HighlightColor
-
+++ /dev/null
--- Created by: PLOTNIKOV Eugeny
--- 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.
-
-
-
-class Icon from WNT inherits Image from WNT
-
- ---Purpose: Internal class for icon management
-
- uses
-
- Handle from Aspect
-
- is
-
- Create (
- aName : CString from Standard;
- aBitmap : Handle from Aspect;
- aHashCode : Integer from Standard
- )
- returns mutable Icon from WNT;
- ---Purpose: Creates a class.
-
- Destroy ( me : mutable ) is redefined;
- ---Level: Public
- ---Purpose: Destroys all resources attached to the Icon.
- ---C++: alias ~
-
- SetName ( me : mutable; aName : CString from Standard )
- is static;
- ---Level: Public
- ---Purpose: Sets a name for icon.
-
- fields
-
- myName : PCharacter from Standard is protected;
-
- friends
-
- class ImageManager from WNT,
- class IconBox from WNT
-
-end Icon;
+++ /dev/null
-// 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.
-
-
-#include <WNT_Icon.ixx>
-
-//=======================================================================
-//function : WNT_Icon
-//purpose :
-//=======================================================================
-
-WNT_Icon::WNT_Icon (
- const Standard_CString aName,
- const Aspect_Handle aBitmap,
- const Standard_Integer aHashCode
- ) : WNT_Image ( aBitmap, aHashCode )
-{
-
- myName = new char[ strlen ( aName ) + 1 ];
-
- strcpy ( myName, aName );
-
-} // end constructor
-
-//=======================================================================
-//function : Destroy
-//purpose :
-//=======================================================================
-
-void WNT_Icon::Destroy () {
-
- delete [] myName;
-
-} // end WNT_Icon :: Destroy
-
-//=======================================================================
-//function : SetName
-//purpose :
-//=======================================================================
-
-void WNT_Icon::SetName ( const Standard_CString aName ) {
-
- if ( strlen ( myName ) < strlen ( aName ) ) {
-
- delete [] myName;
-
- myName = new char[ strlen ( aName ) + 1 ];
-
- } // end if
-
- strcpy ( myName, aName );
-
-} // end WNT_Icon :: SetName
+++ /dev/null
--- Created on: 1996-01-29
--- Created by: PLOTNIKOV Eugeny
--- 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.
-
-
-
-class IconBox from WNT inherits Window from WNT
-
- ---Purpose: This class defines a Windows NT icon box
-
- uses
-
- Handle from Aspect,
- GraphicDevice from WNT,
- WClass from WNT,
- Window from WNT,
- Uint from WNT,
- Long from WNT,
- Dword from WNT,
- NameOfColor from Quantity
-
- raises
-
- WindowDefinitionError from Aspect,
- WindowError from Aspect
-
- is
-
- Create (
- aDevice : GraphicDevice from WNT;
- aName : CString from Standard;
- aStyle : Dword from WNT = 0;
- Xc : Real from Standard = 0.5;
- Yc : Real from Standard = 0.5;
- aBkColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY
- )
- returns mutable IconBox from WNT
- ---Level: Public
- ---Purpose: Creates an IconBox defined by his Center in DSU.
- -- ALL Icons are loaded from the Icon File Directory Name:
- -- "[$SYMBOL]xxxxxxx[.ifd]"
- -- Warning: Raises if the Position is out of the Screen Space
- -- or the Icon File Directory Name don't exist
- raises WindowDefinitionError from Aspect;
-
-
- ---------------------------------------------------
- -- Category: Methods to modify the class definition
- ---------------------------------------------------
-
-
- LoadIcons ( me : mutable; Name : CString from Standard )
- returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Loads Icon Box from an Other Icon File Directory Name
- -- and returns the loaded icons number.
- -- Warning: The Icons previously loaded are NOT cleared.
-
- Show ( me ) is static;
- ---Level: Public
- ---Purpose: Shows Icon Box to the screen
- -- Warning: The Icon Box is displayed at the centered position
- -- specified at the creation time and the size depend
- -- of the Icon number really loaded inside.
-
- UnloadIcons (
- me : mutable;
- Name : CString from Standard
- )
- returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Unloads All previously loaded Icons in the IconBox
- -- and returns the unloaded icons number.
-
- Destroy ( me : mutable ) is redefined;
- ---Level: Public
- ---Purpose: Destroies the IconBox
- ---C++: alias ~
-
- AddIcon (
- me : mutable;
- W : Window from WNT;
- Name : CString from Standard;
- aWidth : Integer from Standard = 0;
- aHeight : Integer from Standard = 0
- ) is static;
- ---Level: Public
- ---Purpose: Adds an Icon of Size aWidth,aHeight given in PIXEL
- -- to the Icon Box from a FULL Existing Window
- -- NOTE that if aWidth or aHeight is 0 the default icon size is taken.
-
- SaveIcons ( me ) returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Save all new created Icons as iconname.xwd file in the user
- -- directory and returns the saved icons number.
-
- SetDim (
- me : mutable;
- aWidth : Integer from Standard;
- aHeight : Integer from Standard
- ) is static;
- ---Level: Public
- ---Purpose: Sets dimensions for icons which are visible in the box.
-
- ----------------------------
- -- Category: Inquire methods
- ----------------------------
-
-
- IconNumber ( me )
- returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Returns the Number of Icons loaded in the Icon Box.
-
- IconName ( me; Index : Integer from Standard )
- returns CString from Standard
- ---Level: Public
- ---Purpose: Returns the Name of the N ime Icon
- -- Warning: Raises if Index if out of range depending of the
- -- Number of Loaded Icons.
- raises WindowError from Aspect is static;
-
- IconSize (
- me;
- Name : CString from Standard;
- Width, Height : out Integer from Standard
- )
- returns Boolean from Standard is static;
- ---Level: Public
- ---Purpose: Returns the Pixmap Size attached to the Icon Name
- -- Warning: May return FALSE if Icon doesn't exist in the IconBox.
- ---Category: Inquire methods
-
- IconPixmap ( me; Name : CString from Standard )
- returns Handle from Aspect is static;
- ---Level: Public
- ---Purpose: Returns the Pixmap attached to the Icon Name
- -- Warning: May return 0 if Icon doesn't exist in the IconBox.
-
- IconPixmap (
- me;
- Name : CString from Standard;
- Width : Integer from Standard;
- Height : Integer from Standard
- ) returns Handle from Aspect is static;
- ---Level: Public
- ---Purpose: Returns the Centered part of the Pixmap of required Size
- -- attached to the Icon Name
- -- Warning: May return 0 if Icon doesn't exist in the IconBox.
-
- HandleEvent (
- me : mutable;
- hwnd : Handle from Aspect;
- uMsg : Uint from WNT;
- wParam : Dword from WNT;
- lParam : Dword from WNT
- )
- returns Long from WNT is static;
- ---Level: Internal
- ---Purpose: routine to process events sent to the icon box
- fields
-
- myIconWidth : Integer from Standard is protected;
- myIconHeight : Integer from Standard is protected;
- myFont : Handle from Aspect is protected;
- myPen : Handle from Aspect is protected;
-
--- fields for event management
-
- myDragging : Boolean from Standard is protected;
- myStart,
- myIncX,
- myIncY,
- myNX,
- myNY,
- myNPos,
- myMaxPos : Integer from Standard is protected;
-
-end IconBox;
+++ /dev/null
-// 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.
-
-// include windows.h first to have all definitions available
-#include <windows.h>
-#include <windowsx.h>
-
-#include <WNT_IconBox.ixx>
-
-#include <WNT_WClass.hxx>
-#include <WNT_ImageManager.hxx>
-#include <WNT_Icon.hxx>
-
-//***//
-static void __fastcall _get_filename ( char*, int, char*, char* );
-//***//
-HBITMAP LoadImageFromFile ( Handle( WNT_GraphicDevice )&, char*, HDC = NULL );
-int SaveBitmapToFile (
- Handle( WNT_GraphicDevice )& gDev,
- HBITMAP, char*, int, int, int, int
- );
-LRESULT CALLBACK WNT_IconBoxWndProc ( HWND, UINT, WPARAM, LPARAM );
-//***//
-//*************************** Constructor *******************************//
-//***//
-WNT_IconBox :: WNT_IconBox (
- const Handle( WNT_GraphicDevice )& aDevice,
- const Standard_CString aName,
- const WNT_Dword& aStyle,
- const Standard_Real Xc,
- const Standard_Real Yc,
- const Quantity_NameOfColor aBkColor
- ) : WNT_Window (
- aDevice, aName,
- new WNT_WClass (
- "WNT_IconBoxClass", WNT_IconBoxWndProc,
- CS_HREDRAW | CS_VREDRAW
- ),
- aStyle | WS_VSCROLL,
- Xc, Yc, 0.5, 0.2, aBkColor
- ) {
-
- if ( LoadIcons ( aName ) == 0 )
-
- Aspect_WindowDefinitionError :: Raise ( "Unable to load icons" );
-
- myFont = NULL;
- SetDim ( 70, 70 );
- myStart = 1;
-
- myPen = CreatePen ( PS_SOLID, 3, RGB( 0, 255, 0 ) );
-
-} // end constructor
-//***//
-//********************************* Destroy *****************************//
-//***//
-void WNT_IconBox :: Destroy () {
-
- if ( myFont != NULL )
-
- DeleteObject ( myFont );
-
- if ( myPen != NULL )
-
- DeleteObject ( myPen );
-
-} // end WNT_IconBox :: Destroy
-//***//
-//******************************* LoadIcons *****************************//
-//***//
-Standard_Integer WNT_IconBox :: LoadIcons (
- const Standard_CString Name
- ) {
-
- int len;
- Standard_Integer retVal = 0;
- ifstream is;
- char fileName[ MAX_PATH ];
- char fName[ MAX_PATH ];
- char iName[ MAX_PATH ];
- Standard_Integer iHCode;
- HBITMAP hBmp;
- Handle( WNT_Icon ) icon;
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( GraphicDevice () );
-
- _get_filename ( fileName, MAX_PATH, (Standard_PCharacter)Name, "ifd" );
-
- is.open ( fileName );
-
- if ( is ) {
-
- while ( !is.eof () ) {
-
- is >> fName >> iName;
-
- if ( is.bad () ) break;
-
- if ( fName[ 0 ] == '\x00' || iName[ 0 ] == '\x00' ) continue;
-
- if ( fName[ 0 ] == '#' ) continue;
-
- _get_filename ( fileName, MAX_PATH, fName, "" );
-
- iHCode = myImages -> StringHashCode ( fileName );
- len = myImages -> Size ();
- int i;
-
- for ( i = 1; i <= len; ++i )
-
- if ( myImages -> HashCode ( i ) == iHCode ) {
-
- icon = Handle( WNT_Icon ) :: DownCast ( myImages -> Image ( i ) );
-
- if ( lstrcmp ( iName, icon -> myName ) ) {
-
- i = len + 1;
- break;
-
- } /* end if */
-
- } /* end if */
-
- if ( i > len ) {
-
- hBmp = LoadImageFromFile ( gDev, fileName );
-
- if ( hBmp ) {
-
- icon = new WNT_Icon ( iName, hBmp, iHCode );
- myImages -> Add ( icon );
-
- } // end if
-
- } // end if ( i > len . . . )
-
- fName[ 0 ] = iName[ 0 ] = '\x00';
-
- } // end while
-
- retVal = myImages -> Size ();
-
- } // end if
-
- return retVal;
-
-} // end WNT_IconBox :: LoadIcons
-//***//
-//********************************** Show *******************************//
-//***//
-void WNT_IconBox :: Show () const {
-
- Map ();
-
-} // end WNT_IconBox :: Show
-//***//
-//******************************* UnloadIcons ***************************//
-//***//
-Standard_Integer WNT_IconBox :: UnloadIcons (
- const Standard_CString Name
- ) {
-
- Standard_Integer retVal = 0;
- ifstream is;
- char fileName[ MAX_PATH ];
- char fName[ MAX_PATH ];
- char iName[ MAX_PATH ];
- Handle( WNT_Icon ) icon;
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( GraphicDevice () );
-
- _get_filename ( fileName, MAX_PATH, (Standard_PCharacter)Name, "ifd" );
-
- is.open ( fileName );
-
- if ( is ) {
-
- while ( !is.eof () ) {
-
- is >> fName >> iName;
-
- if ( is.bad () ) break;
-
- if ( fName[ 0 ] == '#' ) continue;
-
- for ( int i = 1; i <= myImages -> Size (); ++i ) {
-
- icon = Handle( WNT_Icon ) :: DownCast ( myImages -> Image ( i ) );
-
- if ( icon.IsNull () ) continue;
-
- if ( lstrcmp ( icon -> myName, iName ) ) continue;
-
- myImages -> Delete ( i );
- ++retVal;
-
- } // end for
-
- } // end while
-
- } // end if
-
- return retVal;
-
-} // end WNT_IconBox :: UnloadIcons
-//***//
-//********************************* AddIcon *****************************//
-//***//
-void WNT_IconBox :: AddIcon (
- const Handle( WNT_Window )& W,
- const Standard_CString Name,
- const Standard_Integer aWidth,
- const Standard_Integer aHeight
- ) {
-
- Handle( WNT_Icon ) icon = W -> myIcon;
-
- if ( !icon.IsNull () )
-
- myImages -> Add ( W -> myIcon );
-
-} // end WNT_IconBox :: AddIcon
-//***//
-//********************************* SaveIcons ***************************//
-//***//
-Standard_Integer WNT_IconBox :: SaveIcons () const {
-
- int w, h;
- Standard_Integer retVal = 0;
- char ext[ 5 ];
- char fName[ MAX_PATH ];
- Handle( WNT_Icon ) icon;
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( GraphicDevice () );
-
- switch ( myFormat ) {
-
- case WNT_TOI_XWD:
-
- strcpy ( ext, ".xwd" );
-
- break;
-
- case WNT_TOI_BMP:
-
- strcpy ( ext, ".bmp" );
-
- break;
-
- case WNT_TOI_GIF:
-
- strcpy ( ext, ".gif" );
-
- } // end switch
-
- for ( int i = 1; i <= myImages -> Size (); ++i ) {
-
- icon = Handle( WNT_Icon ) :: DownCast ( myImages -> Image ( i ) );
-
- if ( icon.IsNull () ) continue;
-
- strcpy ( fName, icon -> myName );
-
- if ( strchr ( fName, '.' ) == NULL )
-
- strcat ( fName, ext );
-
- myImages -> Dim ( i, w, h );
-
- if ( SaveBitmapToFile (
- gDev, ( HBITMAP )( myImages -> ImageHandle ( i ) ), fName,
- 0, 0, w, h
- )
- )
-
- ++retVal;
-
- } // end for
-
- return retVal;
-
-} // end WNT_IconBox :: SaveIcons
-//***//
-//********************************* IconNumber **************************//
-//***//
-Standard_Integer WNT_IconBox :: IconNumber () const {
-
- return myImages -> Size ();
-
-} // end WNT_IconBox :: IconNumber
-//***//
-//********************************* IconName ****************************//
-//***//
-Standard_CString WNT_IconBox :: IconName (
- const Standard_Integer Index
- ) const {
-
- Handle( WNT_Icon ) icon = Handle( WNT_Icon ) :: DownCast (
- myImages -> Image ( Index )
- );
-
- return icon -> myName;
-
-} // end WNT_IconBox :: IconName
-//***//
-//********************************* IconSize ****************************//
-//***//
-Standard_Boolean WNT_IconBox :: IconSize (
- const Standard_CString Name,
- Standard_Integer& Width,
- Standard_Integer& Height
- ) const {
-
- int i, len = myImages -> Size ();
- Handle( WNT_Icon ) icon;
-
- for ( i = 1; i <= len; ++i ) {
-
- icon = Handle( WNT_Icon ) :: DownCast ( myImages -> Image ( i ) );
-
- if ( !strcmp ( icon -> myName, Name ) ) break;
-
- } // end for
-
- return ( i > len ) ? Standard_False :
- myImages -> Dim ( i, Width, Height ), Standard_True;
-
-} // end WNT_IconBox :: IconSize
-//***//
-//********************************* IconPixmap (1) **********************//
-//***//
-Aspect_Handle WNT_IconBox :: IconPixmap (
- const Standard_CString Name
- ) const {
-
- int i, len = myImages -> Size ();
- Handle( WNT_Icon ) icon;
-
- for ( i = 1; i <= len; ++i ) {
-
- icon = Handle( WNT_Icon ) :: DownCast ( myImages -> Image ( i ) );
-
- if ( !strcmp ( icon -> myName, Name ) ) break;
-
- } // end for
-
- return ( i > len ) ? NULL : myImages -> ImageHandle ( i );
-
-} // end WNT_IconBox :: IconPixmap
-//***//
-//********************************* IconPixmap (2) **********************//
-//***//
-Aspect_Handle WNT_IconBox :: IconPixmap (
- const Standard_CString Name,
- const Standard_Integer Width,
- const Standard_Integer Height
- ) const {
-
- HBITMAP retVal = NULL;
- int len = myImages -> Size ();
- int i, w, h;
- Handle( WNT_Icon ) icon;
- HPALETTE hOldPal;
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( GraphicDevice () );
-
- for ( i = 1; i <= len; ++i ) {
-
- icon = Handle( WNT_Icon ) :: DownCast ( myImages -> Image ( i ) );
-
- if ( !strcmp ( icon -> myName, Name ) ) break;
-
- } // end for
-
- if ( i <= len ) {
-
- HDC hDC, hDCmemSrc, hDCmemDst;
-
- hDC = GetDC ( NULL );
-
- if ( gDev -> IsPaletteDevice () ) {
-
- hOldPal = SelectPalette ( hDC, ( HPALETTE )( gDev -> HPalette () ), FALSE );
- RealizePalette ( hDC );
-
- } // end if
-
- hDCmemSrc = CreateCompatibleDC ( hDC );
- hDCmemDst = CreateCompatibleDC ( hDC );
-
- retVal = CreateCompatibleBitmap ( hDC, Width, Height );
-
- if ( retVal != NULL ) {
-
- myImages -> Dim ( i, w, h );
-
- SelectBitmap ( hDCmemSrc, myImages -> ImageHandle ( i ) );
- SelectBitmap ( hDCmemDst, retVal );
-
- BitBlt (
- hDCmemDst, 0, 0, Width, Height, hDCmemSrc,
- w / 2 - Width / 2, h / 2 - Height / 2, SRCCOPY
- );
-
- } // end if
-
- DeleteDC ( hDCmemDst );
- DeleteDC ( hDCmemSrc );
-
- if ( gDev -> IsPaletteDevice () )
-
- SelectPalette ( hDC, hOldPal, FALSE );
-
- ReleaseDC ( NULL, hDC );
-
- } // end if
-
- return retVal;
-
-} // end WNT_IconBox :: IconPixmap
-//***//
-//******************************* SetDim ********************************//
-//***//
-void WNT_IconBox :: SetDim (
- const Standard_Integer aWidth,
- const Standard_Integer aHeight
- ) {
-
- LOGFONT lf;
-
- myIconWidth = aWidth;
- myIconHeight = aHeight;
-
- ZeroMemory ( &lf, sizeof ( LOGFONT ) );
-
- lf.lfHeight = myIconHeight / 5;
- strcpy ( lf.lfFaceName, "Modern" );
-
- if ( myFont != NULL ) DeleteObject ( myFont );
-
- myFont = CreateFontIndirect ( &lf );
-
-} // end WNT_IconBox :: SetDim
-//***//
-//***********************************************************************//
-//***//
-static void __fastcall _get_filename ( char* retVal, int len, char* name, char* ext ) {
-
- char* ptr, *ptr1;
- char eNameVal[ MAX_PATH ];
- char fNameVal[ MAX_PATH ];
- DWORD eNameLen;
-
- len = Min ( MAX_PATH, len );
-
- ZeroMemory ( ( PVOID )eNameVal, sizeof ( eNameVal ) );
- ZeroMemory ( ( PVOID )fNameVal, sizeof ( fNameVal ) );
-
- if ( name != NULL ) {
-
- strncpy ( fNameVal, name, len );
-
- if ( *name == '$' ) {
-
- ptr = strpbrk ( fNameVal, "\\/" );
-
- if ( ptr != NULL ) {
-
- *ptr++ = '\x00';
- ptr1 = fNameVal + 1;
-
- if (
- ( eNameLen = GetEnvironmentVariable ( ptr1, eNameVal, MAX_PATH ) ) != 0
- )
-
- strncpy ( retVal, eNameVal, len );
-
- strncat ( retVal, "\\", len );
-
- } else
-
- ptr = fNameVal;
-
- strncat ( retVal, ptr, len );
-
- } else
-
- strncpy ( retVal, fNameVal, len );
-
- if ( strpbrk ( retVal, "." ) == NULL ) {
-
- strncat ( retVal, ".", len );
- strncat ( retVal, ext, len );
-
- } // end if
-
- ptr = retVal;
-
- for ( int i = 0; i < ( int )( strlen ( retVal ) ); ++i )
-
- if ( ptr[ i ] == '/' ) ptr[ i ] = '\\';
-
- } // end if
-
-} // end _get_filename
-//***//
-//***********************************************************************//
-//***//
-LRESULT CALLBACK WNT_IconBoxWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- WINDOW_DATA* wd = (WINDOW_DATA* )GetWindowLongPtr (hwnd, GWLP_USERDATA);
- if (wd != NULL)
- {
- WNT_IconBox* ib = (WNT_IconBox* )(wd->WNT_Window_Ptr);
- return ib->HandleEvent (hwnd, uMsg, wParam, lParam);
- }
- else
- {
- return DefWindowProc (hwnd, uMsg, wParam, lParam);
- }
-} // end WNT_IconBoxWndProc
-//***//
-//***********************************************************************//
+++ /dev/null
-// Copyright (c) 2008-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 <windows.h>
-#include <WNT_IconBox.hxx>
-
-#include <WNT_GraphicDevice.hxx>
-#include <WNT_ImageManager.hxx>
-#include <WNT_Icon.hxx>
-
-#define X_SPACING 10
-#define Y_SPACING 10
-
-//=======================================================================
-//function : HandleEvent
-//purpose :
-//=======================================================================
-
-WNT_Long WNT_IconBox::HandleEvent (
- const Aspect_Handle hwnd,
- const WNT_Uint& uMsg,
- const WNT_Dword& wParam,
- const WNT_Dword& lParam
- )
-{
-
- switch ( uMsg ) {
-
- case WM_SIZE : {
-
- int len;
- RECT r;
- SCROLLINFO si;
-
- GetClientRect ( ( HWND )hwnd, &r );
-
- myIncX = myIconWidth + X_SPACING + 6;
- myNX = r.right / myIncX;
-
- if ( myNX == 0 ) ++myNX;
-
- myIncY = myIconHeight + Y_SPACING + 11 + myIconHeight / Y_SPACING;
- myNY = r.bottom / myIncY;
-
- if ( myNY == 0 ) ++myNY;
-
- len = myImages -> Size ();
-
- if ( myNX * myNY >= len )
-
- ShowScrollBar ( ( HWND )hwnd, SB_VERT, FALSE );
-
- else {
-
- si.cbSize = sizeof ( SCROLLINFO );
- si.fMask = SIF_POS | SIF_RANGE;
- si.nPos = myNPos = 0;
- si.nMin = 0;
- si.nMax = myMaxPos = len / myNX;
-
- SetScrollInfo ( ( HWND )hwnd, SB_VERT, &si, TRUE );
- ShowScrollBar ( ( HWND )hwnd, SB_VERT, TRUE );
- myStart = 1;
-
- } // end else
-
- return 0;
-
- } // WM_SIZE
-
- case WM_VSCROLL : {
-
- int nCurPos;
- int nScrollCode;
- int newStart;
- int len;
- SCROLLINFO si;
-
- nScrollCode = ( Standard_Integer )LOWORD( wParam );
- len = myImages -> Size ();
-
- switch ( nScrollCode ) {
-
- case SB_LINEUP :
- case SB_PAGEUP :
-
- newStart = myStart - myNX;
- myStart = newStart >= 1 ? --myNPos, newStart : ( ( myNPos = 0 ), 1 );
-
- break;
-
- case SB_LINEDOWN :
- case SB_PAGEDOWN :
-
- newStart = myStart + myNX;
- myStart = ( newStart <= len - myNX + 1 ) ? ( ++myNPos, newStart ) :
- ( ( myNPos = myMaxPos ),
- ( len - myNX + 1 )
- );
-
- break;
-
- case SB_THUMBTRACK :
-
- myNPos = ( Standard_Integer )HIWORD( wParam );
- myStart = myNPos * myNX;
-
- break;
-
- case SB_ENDSCROLL :
-
- return 0;
-
- } // end switch
-
- if ( myStart == 0 ) ++myStart;
-
- nCurPos = GetScrollPos ( ( HWND )hwnd, SB_VERT );
-
- if ( nCurPos == myNPos ) return 0;
-
- si.cbSize = sizeof ( SCROLLINFO );
- si.fMask = SIF_POS;
- si.nPos = myNPos;
-
- SetScrollInfo ( ( HWND )hwnd, SB_VERT, &si, TRUE );
- InvalidateRect ( ( HWND )hwnd, NULL, TRUE );
-
- return 0;
-
- } // WM_VSCROLL
-
- case WM_PAINT : {
-
- HDC hDCsrc, hDCdst;
- PAINTSTRUCT ps;
- HPEN hOldPen;
- HFONT hOldFont;
- HPALETTE hOldPal;
- int i, j, x, y, ow, oh, cnt, len;
-
- Handle( WNT_Icon ) icon;
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( GraphicDevice () );
-
- if ( !myDragging ) {
-
- hDCdst = BeginPaint ( ( HWND )hwnd, &ps );
- hDCsrc = CreateCompatibleDC ( hDCdst );
-
- if ( gDev -> IsPaletteDevice () ) {
-
- hOldPal = SelectPalette ( hDCdst, ( HPALETTE )( gDev -> HPalette () ), FALSE );
- RealizePalette ( hDCdst );
-
- } // end if
-
- len = myImages -> Size ();
- hOldPen = SelectPen ( hDCdst, myPen );
- hOldFont = SelectFont ( hDCdst, myFont );
- SetTextAlign ( hDCdst, TA_CENTER | TA_TOP );
- SetStretchBltMode ( hDCdst, COLORONCOLOR );
-
- for ( i = 0, y = Y_SPACING, cnt = myStart; i < myNY; ++i, y += myIncY )
-
- for ( j = 0, x = X_SPACING; j < myNX; ++j, ++cnt, x += myIncX ) {
-
- if ( cnt > len ) goto exit_display;
-
- icon = Handle( WNT_Icon ) :: DownCast ( myImages -> Image ( cnt ) );
-
- if ( icon.IsNull () ) continue;
-
- myImages -> Dim ( cnt, ow, oh );
- SelectBitmap ( hDCsrc, icon -> myImage );
-
- Rectangle ( hDCdst, x, y, x + myIconWidth + 4, y + myIconHeight + 4 );
- TextOut (
- hDCdst, x + myIconWidth / 2, y + myIconHeight + 10,
- icon -> myName, strlen ( icon -> myName )
- );
-
- StretchBlt (
- hDCdst, x + 2, y + 2, myIconWidth, myIconHeight,
- hDCsrc, 0, 0, ow, oh,
- SRCCOPY
- );
-
- } // end for
-
-exit_display:
-
- SelectFont ( hDCdst, hOldFont );
- SelectPen ( hDCdst, hOldPen );
-
- if ( gDev -> IsPaletteDevice () )
-
- SelectPalette ( hDCdst, hOldPal, FALSE );
-
- DeleteDC ( hDCsrc );
- EndPaint ( ( HWND )hwnd, &ps );
-
- return 0;
-
- } else
-
- return DefWindowProc ( ( HWND )hwnd, uMsg, wParam, lParam );
-
- } // WM_PAINT
-
- case WM_ENTERSIZEMOVE :
-
- myDragging = TRUE;
-
- return 0;
-
- case WM_EXITSIZEMOVE :
-
- myDragging = FALSE;
- InvalidateRect ( ( HWND )hwnd, NULL, TRUE );
-
- return 0;
-
- case WM_QUERYNEWPALETTE: {
-
- HDC hDC = GetDC ( ( HWND )hwnd );
- WINDOW_DATA* wd = (WINDOW_DATA* )GetWindowLongPtr ((HWND )hwnd, GWLP_USERDATA);
-
- SelectPalette ( hDC, wd -> hPal, FALSE );
-
-// if ( RealizePalette ( hDC ) );
- if ( RealizePalette ( hDC ) )
- InvalidateRect ( ( HWND )hwnd, NULL, FALSE );
-
- ReleaseDC ( ( HWND )hwnd, hDC );
-
- return TRUE;
-
- } // WM_QUERYNEWPALETTE
-
- case WM_PALETTECHANGED:
-
- if ( hwnd != ( HWND )wParam ) {
-
- HDC hDC = GetDC ( ( HWND )hwnd );
- WINDOW_DATA* wd = (WINDOW_DATA* )GetWindowLongPtr ((HWND )hwnd, GWLP_USERDATA);
- SelectPalette ( hDC, wd -> hPal, TRUE );
-
- if ( RealizePalette ( hDC ) )
-
- UpdateColors ( hDC );
-
- ReleaseDC ( ( HWND )hwnd, hDC );
-
- return 0;
-
- } // end if
-
- default:
-
- return DefWindowProc ( ( HWND )hwnd, uMsg, wParam, lParam );
-
- } // end switch
-
-} // end WNT_IconBox :: HandleEvent
myImage : Address from Standard is protected;
myHashCode : Integer from Standard is protected;
- friends
-
- class ImageManager from WNT
-
end Image;
+++ /dev/null
--- Created on: 1996-03-11
--- Created by: PLOTNIKOV Eugeny <eugeny@maniax>
--- 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.
-
--- Modifications: PLOTNIKOV Eugeny at July 1998 (BUC60286)
-
-
-class ImageManager from WNT inherits TShared from MMgt
-
- ---Purpose: This class defines image management
-
- uses
-
- Handle from Aspect,
- Window from WNT,
- SequenceOfImage from WNT,
- TypeOfImage from WNT,
- Image from WNT,
- WindowPtr from WNT
-
- is
-
- Create ( aWindow : WindowPtr from WNT )
- returns mutable ImageManager from WNT;
- ---Purpose: Creates a class instance
-
- Destroy ( me : mutable )
- is virtual;
- ---Purpose: Deletes all resources associated with the class instance.
- ---C++: alias ~
-
- SetFormat ( me : mutable; aFormat : TypeOfImage from WNT = WNT_TOI_XWD )
- is static;
- ---Purpose: Sets image format for output.
-
- Add ( me : mutable; anImage : Image from WNT )
- is static;
- ---Purpose: Adds <anImage> to manager.
-
- Image ( me : mutable; anIndex : Integer from Standard )
- returns Image from WNT is static;
- ---Purpose: returns Image stored at <anIndex>.
-
- Load ( me : mutable; aFileName : CString from Standard )
- returns Integer from Standard
- is static;
- ---Purpose: Loads image from file and returns its index in the
- -- sequence.
- -- Warning: Returns 0 if loading was failed.
-
- Save (
- me;
- aFileName : CString from Standard;
- aX, aY, aWidth, aHeight : Integer from Standard
- )
- returns Boolean from Standard
- is static;
- ---Purpose: Stories image to the file according to <myFormat>
- -- class field. Returns True on success, otherwise
- -- returns False.
-
- SaveBuffer (
- me;
- aFileName : CString from Standard;
- aX, aY, aWidth, aHeight : Integer from Standard
- )
- returns Boolean from Standard
- is static;
- ---Purpose: Stories contents of the double buffer window pixmap.
- -- See "Save" method.
-
- Draw (
- me : mutable;
- anIndex : Integer from Standard;
- Xc, Yc : Integer from Standard;
- aWidth : Integer from Standard;
- aHeight : Integer from Standard;
- anAngle : Real from Standard = 0.0
- )
- is static;
- ---Purpose: Displays the image according to the DoubleBuffer state
- -- of the associated window.
-
- Delete ( me : mutable; anIndex : Integer from Standard )
- is static;
- ---Purpose: Deletes an image at index <anIndex>.
-
- Discard ( me : mutable; anIndex : Integer from Standard )
- is static;
- ---Purpose: Places an image to the trash
-
- Scale (
- me : mutable;
- anIndex : Integer from Standard;
- aScaleX : Real from Standard;
- aScaleY : Real from Standard;
- aReplace : Boolean from Standard = Standard_False
- ) returns Handle from Aspect is static;
- ---Purpose: Scales the specified image.
-
- Size ( me ) returns Integer from Standard is static;
- ---Purpose: Returns number of loaded images.
-
- ImageHandle (
- me : mutable;
- anIndex : Integer from Standard
- ) returns Handle from Aspect is static;
- ---Purpose: Returns image handle.
-
- Dim (
- me : mutable;
- anIndex : Integer from Standard;
- aWidth, aHeight : out Integer from Standard
- )
- is static;
- ---Purpose: Returns image dimensions.
-
- HashCode (
- me : mutable;
- anIndex : Integer from Standard
- )
- returns Integer from Standard is redefined static;
- ---Purpose: Returns image's hash code.
-
- Index (
- me : mutable;
- aHashCode : Integer from Standard
- )
- returns Integer from Standard is static;
- ---Purpose: Returns image's index.
-
- StringHashCode (
- me : mutable;
- aString : CString from Standard
- )
- returns Integer from Standard is static;
- ---Purpose: Returns hash code of the string.
-
- Open (
- me : mutable;
- aDC : Handle from Aspect;
- aWidth : Integer from Standard;
- aHeight : Integer from Standard;
- aHashCode : Integer from Standard
- )
- returns Integer from Standard is static;
- ---Purpose: Creates new empty image and returns its index
-
- fields
-
- myWindow : Address from Standard is protected;
- myImages : SequenceOfImage from WNT is protected;
- myTrash : SequenceOfImage from WNT is protected;
- myFormat : TypeOfImage from WNT is protected;
- myLastImage : Image from WNT is protected;
- myLastIndex : Integer from Standard is protected;
-
- friends
-
- class Window from WNT
-
-end ImageManager;
+++ /dev/null
-// Copyright (c) 1998-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.
-
-// Modifications: PLOTNIKOV Eugeny at July 1998 (BUC60286)
-
-// include windows.h first to have all definitions available
-#include <windows.h>
-#include <windowsx.h>
-
-#include <WNT_ImageManager.ixx>
-
-#include <WNT_Image.hxx>
-#include <WNT_GraphicDevice.hxx>
-
-#include <WNT_Bitmap.h>
-
-#define TRASH_SIZE 8
-
-#define PWND ( ( WNT_WindowPtr )myWindow )
-
-HBITMAP LoadImageFromFile ( Handle( WNT_GraphicDevice )&, char*, HDC = NULL );
-int SaveWindowToFile (
- Handle( WNT_GraphicDevice )&, HWND, char*, int, int, int, int
- );
-int SaveBitmapToFile (
- Handle( WNT_GraphicDevice )&, HBITMAP, char*, int, int, int, int
- );
-void SetOutputFormat ( WNT_TypeOfImage );
-//***//
-//***************************** Constructor ******************************//
-//***//
-WNT_ImageManager :: WNT_ImageManager ( const WNT_WindowPtr& aWindow ) {
-
- myWindow = aWindow;
- myLastIndex = 0;
-
-} // end constructor
-//***//
-//******************************* Destroy ********************************//
-//***//
-void WNT_ImageManager :: Destroy () {
-
-
-} // end WNT_ImageManager :: Destroy
-//***//
-//******************************* SetFormat ******************************//
-//***//
-void WNT_ImageManager :: SetFormat ( const WNT_TypeOfImage aFormat ) {
-
- myFormat = aFormat;
- SetOutputFormat ( aFormat );
-
-} // end WNT_ImageManager :: SetFormat
-//***//
-//********************************** Load ********************************//
-//***//
-Standard_Integer WNT_ImageManager :: Load ( const Standard_CString aFileName ) {
-
- Handle( WNT_Image ) image;
- Standard_Integer i, iHCode, len, retVal = 0;
- HBITMAP hBmp;
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( PWND -> GraphicDevice () );
-
- iHCode = StringHashCode ( aFileName );
-
- if ( myLastIndex && myLastImage -> myHashCode == iHCode ) return myLastIndex;
-
- for ( i = 1; i <= myTrash.Length (); ++i )
-
- if ( myTrash.Value ( i ) -> myHashCode == iHCode ) {
-
- myLastImage = myTrash.Value ( i );
- retVal = -i;
-
- goto end;
-
- } /* end if */
-
- len = myImages.Length ();
-
- for ( i = 1; i <= len; ++i )
-
- if ( myImages.Value ( i ) -> myHashCode == iHCode ) {
-
- myLastImage = myImages.Value ( i );
- retVal = i;
-
- goto end;
-
- } // end if
-
- hBmp = LoadImageFromFile ( gDev,(Standard_PCharacter) aFileName );
-
- if ( hBmp ) {
-
- myLastImage = new WNT_Image ( hBmp, iHCode );
- myImages.Append ( myLastImage );
- retVal = myImages.Length ();
-
- } // end if
-end:
- return myLastIndex = retVal;
-
-} // end WNT_ImageManager :: Load
-//***//
-//********************************** Save ********************************//
-//***//
-Standard_Boolean WNT_ImageManager :: Save (
- const Standard_CString aFileName,
- const Standard_Integer aX,
- const Standard_Integer aY,
- const Standard_Integer aWidth,
- const Standard_Integer aHeight
- ) const {
-
- Standard_Boolean retVal;
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( PWND -> GraphicDevice () );
-
- retVal = SaveWindowToFile (
- gDev, ( HWND )( PWND -> HWindow () ),
- (Standard_PCharacter) aFileName, aX, aY, aWidth, aHeight
- );
-
- return retVal;
-
-} // end WNT_ImageManager :: Save
-//***//
-//****************************** SaveBuffer ******************************//
-//***//
-Standard_Boolean WNT_ImageManager :: SaveBuffer (
- const Standard_CString aFileName,
- const Standard_Integer aX,
- const Standard_Integer aY,
- const Standard_Integer aWidth,
- const Standard_Integer aHeight
- ) const {
-
- Standard_Boolean retVal;
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( PWND -> GraphicDevice () );
-
- retVal = SaveBitmapToFile (
- gDev, ( HBITMAP )( PWND -> HPixmap () ),
- (Standard_PCharacter)aFileName, aX, aY, aWidth, aHeight
- );
-
- return retVal;
-
-} // end WNT_ImageManager :: SaveBuffer
-//***//
-//********************************** Draw ********************************//
-//***//
-void WNT_ImageManager :: Draw (
- const Standard_Integer anIndex,
- const Standard_Integer Xc,
- const Standard_Integer Yc,
- const Standard_Integer aWidth,
- const Standard_Integer aHeight,
- const Standard_Real anAngle
- ) {
-
- HDC hDC, hDCmemSrc, hDCmemDst = 0;
- HPALETTE hPal, hOldPal;
- Standard_Integer iw, ih;
-
- if ( myLastIndex != anIndex ) {
-
- myLastIndex = anIndex;
- myLastImage = anIndex < 0 ? myTrash.Value ( -anIndex ) : myImages.Value ( anIndex );
-
- } // end if
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( PWND -> GraphicDevice () );
-
- Dim ( anIndex, iw, ih );
-
- hDC = GetDC ( ( HWND )( PWND -> HWindow () ) );
-
- if ( gDev -> IsPaletteDevice () ) {
-
- hOldPal = SelectPalette (
- hDC, hPal = ( HPALETTE )( gDev -> HPalette () ), FALSE
- );
-
- if ( RealizePalette ( hDC ) )
-
- UpdateColors ( hDC );
-
- } // end if
-
- if ( PWND -> DoubleBuffer () ) {
-
- hDCmemDst = CreateCompatibleDC ( hDC );
- SelectBitmap ( hDCmemDst, PWND -> HPixmap () );
-
- } else
-
- hDCmemDst = hDC;
-
- hDCmemSrc = CreateCompatibleDC ( hDC );
- SetStretchBltMode ( hDCmemDst, COLORONCOLOR );
-
- SelectBitmap (
- hDCmemSrc, ( ( PWNT_Bitmap )myLastImage -> myImage ) -> hBmp
- );
-
- if ( aWidth == iw && aHeight == ih && anAngle == 0.0F )
-
- BitBlt (
- hDCmemDst, Xc - aWidth / 2 - ( aWidth & 1 ),
- Yc - aHeight / 2, aWidth, aHeight,
- hDCmemSrc, 0, 0, SRCCOPY
- );
-
- else if ( anAngle == 0.0F )
-
- StretchBlt (
- hDCmemDst, Xc - aWidth / 2,
- Yc - aHeight / 2 + ( aHeight & 1 ), aWidth, aHeight,
- hDCmemSrc, 0, 0, iw, ih, SRCCOPY
- );
-
- else {
-
- XFORM x;
- POINT pivot;
- POINT pts[ 3 ];
- double sinVal, cosVal, angle;
-
- SetGraphicsMode ( hDCmemDst, GM_ADVANCED );
-
- angle = ( double )anAngle * ( M_PI / 180. );
- cosVal = Cos ( angle );
- sinVal = Sin ( angle );
-
- pts[ 0 ].x = Xc - aWidth / 2;
- pts[ 0 ].y = Yc - aHeight / 2 + ( aHeight & 1 );
-
- pts[ 1 ].x = Xc + aWidth / 2;
- pts[ 1 ].y = pts[ 0 ].y;
-
- pts[ 2 ].x = pts[ 0 ].x;
- pts[ 2 ].y = Yc + aHeight / 2 + ( aHeight & 1 );
-
- pivot.x = ( pts[ 1 ].x + pts[ 2 ].x ) / 2;
- pivot.y = ( pts[ 1 ].y + pts[ 2 ].y ) / 2;
-
- x.eM11 = 1.0F; x.eM12 = 0.0F;
- x.eM21 = 0.0F; x.eM22 = 1.0F;
- x.eDx = ( float )-pivot.x;
- x.eDy = ( float )-pivot.y;
- ModifyWorldTransform ( hDCmemDst, &x, MWT_RIGHTMULTIPLY );
-
- x.eM11 = ( float )cosVal; x.eM12 = ( float )-sinVal;
- x.eM21 = ( float )sinVal; x.eM22 = ( float ) cosVal;
- x.eDx = 0.0F;
- x.eDy = 0.0F;
- ModifyWorldTransform ( hDCmemDst, &x, MWT_RIGHTMULTIPLY );
-
- x.eM11 = 1.0F; x.eM12 = 0.0F;
- x.eM21 = 0.0F; x.eM22 = 1.0F;
- x.eDx = ( float )pivot.x;
- x.eDy = ( float )pivot.y;
- ModifyWorldTransform ( hDCmemDst, &x, MWT_RIGHTMULTIPLY );
-
- PlgBlt ( hDCmemDst, pts, hDCmemSrc, 0, 0, iw, ih, NULL, 0, 0 );
-
- } // end else
-
- DeleteDC ( hDCmemSrc );
-
- if ( gDev -> IsPaletteDevice () )
-
- SelectPalette ( hDC, hOldPal, FALSE );
-
- if ( PWND -> DoubleBuffer () )
-
- DeleteDC ( hDCmemDst );
-
- ReleaseDC ( ( HWND )( PWND -> HWindow () ), hDC );
-
-} // end WNT_ImageManager :: Draw
-//***//
-//********************************** Scale *******************************//
-//***//
-Aspect_Handle WNT_ImageManager :: Scale (
- const Standard_Integer anIndex,
- const Standard_Real aScaleX,
- const Standard_Real aScaleY,
- const Standard_Boolean aReplace
- ) {
-
- Standard_Integer iw, ih, iNw, iNh;
- HDC hDCmemSrc, hDCmemDst, hDC;
- HPALETTE hOldPal = NULL;
- HBITMAP hBitmap, hOldBitmap, hBmp;
-
- if ( myLastIndex != anIndex ) {
-
- myLastIndex = anIndex;
- myLastImage = anIndex < 0 ? myTrash.Value ( -anIndex ) : myImages.Value ( anIndex );
-
- } // end if
-
- Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
- DownCast ( PWND -> GraphicDevice () );
-
- Dim ( anIndex, iw, ih );
-
- iNw = ( Standard_Integer )( iw * aScaleX );
- iNh = ( Standard_Integer )( ih * aScaleY );
-
- hDC = GetDC ( NULL );
-
- if ( gDev -> IsPaletteDevice () )
-
- hOldPal = SelectPalette ( hDC, ( HPALETTE )( gDev -> HPalette () ), FALSE );
-
- hDCmemSrc = CreateCompatibleDC ( hDC );
- hDCmemDst = CreateCompatibleDC ( hDC );
-
- SetStretchBltMode ( hDCmemDst, COLORONCOLOR );
-
- hBitmap = CreateCompatibleBitmap ( hDC, iNw, iNh );
-
- if ( hBitmap ) {
-
- hBmp = ( ( PWNT_Bitmap )myLastImage -> myImage ) -> hBmp;
- hOldBitmap = SelectBitmap ( hDCmemSrc, hBmp );
- SelectBitmap ( hDCmemDst, hBitmap );
-
- StretchBlt (
- hDCmemDst, 0, 0, iNw, iNh,
- hDCmemSrc, 0, 0, iw, ih, SRCCOPY
- );
-
- SelectBitmap ( hDCmemSrc, hOldBitmap );
-
- if ( aReplace ) {
-
- DeleteObject ( hBmp );
- ( ( PWNT_Bitmap )myLastImage -> myImage ) -> hBmp = hBitmap;
-
- } // end if
-
- } // end if
-
- DeleteDC ( hDCmemDst );
- DeleteDC ( hDCmemSrc );
-
- if ( hOldPal != NULL ) SelectPalette ( hDC, hOldPal, FALSE );
-
- ReleaseDC ( NULL, hDC );
-
- return ( Aspect_Handle )hBitmap;
-
-} // end WNT_ImageManager :: Scale
-//***//
-//******************************** HashCode ******************************//
-//***//
-Standard_Integer WNT_ImageManager :: StringHashCode (
- const Standard_CString aString
- ) {
-
- Standard_Integer i, n, aHashCode = 0;
-
- union {
-
- char charPtr[ 80 ];
- int intPtr[ 20 ];
-
- } u;
-
- n = (Standard_Integer) strlen ( aString );
-
- if ( n > 0 ) {
-
- if ( n < 80 ) {
-
- n = ( n + 3 ) / 4;
- u.intPtr[ n - 1 ] = 0;
- strcpy ( u.charPtr, aString );
-
- } else {
-
- n = 20;
- strncpy ( u.charPtr, aString, 80 );
-
- } // end else
-
- for ( i = 0; i < n; ++i )
-
- aHashCode = aHashCode ^ u.intPtr[ i ];
-
- } // end if
-
- return Abs ( aHashCode ) + 1;
-
-} // end WNT_ImageManager :: HashCode
-//***//
-//**************************** ImageHandle *******************************//
-//***//
-Aspect_Handle WNT_ImageManager :: ImageHandle (
- const Standard_Integer anIndex
- ) {
-
- if ( myLastIndex == anIndex ) return ( ( PWNT_Bitmap )myLastImage -> myImage ) -> hBmp;
-
- myLastIndex = anIndex;
- myLastImage = anIndex < 0 ? myTrash.Value ( -anIndex ) : myImages.Value ( anIndex );
-
- return ( ( PWNT_Bitmap )myLastImage -> myImage ) -> hBmp;
-
-} // end WNT_ImageManager :: ImageHandle
-//***//
-//******************************** Dim ***********************************//
-//***//
-void WNT_ImageManager :: Dim (
- const Standard_Integer anIndex,
- Standard_Integer& aWidth,
- Standard_Integer& aHeight
- ) {
-
- BITMAP bmp;
-
- if ( myLastIndex != anIndex ) {
-
- myLastIndex = anIndex;
- myLastImage = anIndex < 0 ? myTrash.Value ( -anIndex ) : myImages.Value ( anIndex );
-
- } // end if
-
- GetObject (
- ( ( PWNT_Bitmap )myLastImage -> myImage ) -> hBmp,
- sizeof ( BITMAP ), ( LPVOID )&bmp
- );
-
- aWidth = bmp.bmWidth;
- aHeight = bmp.bmHeight;
-
-} // WNT_ImageManager :: Dim
-//***//
-//****************************** HashCode ********************************//
-//***//
-Standard_Integer WNT_ImageManager :: HashCode (
- const Standard_Integer anIndex
- ) {
-
- if ( myLastIndex == anIndex ) return myLastImage -> myHashCode;
-
- myLastIndex = anIndex;
- myLastImage = anIndex < 0 ? myTrash.Value ( -anIndex ) : myImages.Value ( anIndex );
-
- return myLastImage -> myHashCode;
-
-} // end WNT_ImageManager :: HashCode
-//***//
-//****************************** Index ***********************************//
-//***//
-Standard_Integer WNT_ImageManager :: Index (
- const Standard_Integer aHashCode
- ) {
-
- Standard_Integer retVal = 0;
-
- if ( myLastImage -> myHashCode == aHashCode ) return myLastIndex;
-
- for ( int i = 1; i <= myImages.Length (); ++i )
-
- if ( myImages.Value ( i ) -> myHashCode == aHashCode ) {
-
- myLastImage = myImages.Value ( retVal = myLastIndex = i );
- break;
-
- } // end if
-
- if ( retVal == 0 )
-
- for ( int i = 1; i <= myTrash.Length (); ++i )
-
- if ( myTrash.Value ( i ) -> myHashCode == aHashCode ) {
-
- myLastImage = myImages.Value ( i );
- retVal = myLastIndex = -i;
- break;
-
- } // end if
-
- return retVal;
-
-} // end WNT_ImageManager :: Index
-//***//
-//****************************** Delete **********************************//
-//***//
-void WNT_ImageManager :: Delete ( const Standard_Integer anIndex ) {
-
- myImages.Remove ( anIndex );
-
- if ( myLastIndex == anIndex ) myLastIndex = 0;
-
-} // end WNT_ImageManager :: Delete
-//***//
-//****************************** Delete **********************************//
-//***//
-void WNT_ImageManager :: Discard ( const Standard_Integer anIndex ) {
-
- if ( anIndex > 0 ) {
-
- int len = myTrash.Length ();
-
- if ( len == TRASH_SIZE ) myTrash.Remove ( len );
-
- myTrash.Prepend ( myImages.Value ( anIndex ) );
-
- myImages.Remove ( anIndex );
-
- if ( myLastIndex == anIndex ) myLastIndex = 0;
-
- } // end if
-
-} // end WNT_ImageManager :: Delete
-//***//
-//******************************** Size **********************************//
-//***//
-Standard_Integer WNT_ImageManager :: Size () const {
-
- return myImages.Length ();
-
-} // end WNT_ImageManager :: Size
-//***//
-//******************************** Add ***********************************//
-//***//
-void WNT_ImageManager :: Add ( const Handle_WNT_Image& anImage ) {
-
- myImages.Append ( myLastImage = anImage );
-
- myLastIndex = myImages.Length ();
-
-} // end WNT_ImageManager :: Add
-//***//
-//******************************** Image *********************************//
-//***//
-Handle( WNT_Image ) WNT_ImageManager :: Image (
- const Standard_Integer anIndex
- ) {
-
- if ( myLastIndex == anIndex ) return myLastImage;
-
- myLastIndex = anIndex;
- myLastImage = anIndex < 0 ? myTrash.Value ( -anIndex ) : myImages.Value ( anIndex );
-
- return myLastImage;
-
-} // end WNT_ImageManager :: Image
-//***//
-//******************************** Open **********************************//
-//***//
-Standard_Integer WNT_ImageManager :: Open (
- const Aspect_Handle aDC,
- const Standard_Integer aWidth,
- const Standard_Integer aHeight,
- const Standard_Integer aHashCode
- ) {
-
- HDC hdc = ( HDC )aDC;
- HBITMAP hBmp = CreateCompatibleBitmap ( hdc, aWidth, aHeight );
-
- myImages.Append ( myLastImage = new WNT_Image ( hBmp, aHashCode ) );
-
- return myLastIndex = myImages.Length ();
-
-} // end WNT_ImageMagager :: Open
-//***//
-//************************************************************************//
+++ /dev/null
-// 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.
-
-#define TEST // EPV_160499
-// Avoid do retrieve properly an XWD image with
-// NT 4.0 Service pack 4
-
-#define IMP080200 //GG
-// Enable to evaluate correctly the fileneme extension
-// according to the CSF_DefaultImageFormat symbol.
-
-#define BUC60837 // GG 07/03/01
-// Enable to read a GIF image file even a if the file contains
-// wrong informations.
-
-#define STRICT
-#include <windows.h>
-#include <windowsx.h>
-#include <stdio.h>
-
-#ifdef DrawText
-# undef DrawText
-#endif /* DrawText */
-
-#include <Aspect_XWD.hxx>
-
-#include <WNT.h>
-#include <Quantity_Color.hxx>
-#include <WNT_GraphicDevice.hxx>
-#include <WNT_TypeOfImage.hxx>
-#include <Image_AlienPixMap.hxx>
-#include <TCollection_AsciiString.hxx>
-
-//***//
-#define I_SUCCESS Standard_True
-#define I_ERROR Standard_False
-
-#define PIXEL4 4
-#define PIXEL8 8
-#define PIXEL16 16
-#define PIXEL24 24
-#define PIXEL32 32
-
-#define MAXCOLOR 256
-#define PAD(a) ( ( a ) % sizeof ( LONG ) ? \
- sizeof ( LONG ) - ( ( a ) % sizeof ( LONG ) ) : 0 )
-#ifdef _DEBUG
-# define MALLOC(s) calloc ( ( s ), 1 )
-# define FREE(p) free ( ( p ) )
-#else
-# define MALLOC(s) HeapAlloc ( hHeap, HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS, ( s ) )
-# define FREE(p) HeapFree ( hHeap, 0, ( p ) )
-#endif /* _DEBUG */
-#define WINNT35X() (WNT_osVer.dwPlatformId == VER_PLATFORM_WIN32_NT && \
- WNT_osVer.dwMajorVersion == 3 )
-//***//
-typedef struct {
-
- BYTE pixel[ 3 ];
-
- } TRIPLET, *PTRIPLET;
-
-class _init {
-
- public:
-
- _init ();
- ~_init ();
-
-}; // end _init
-//***//
-OSVERSIONINFO WNT_osVer;
-
-HWINSTA ( WINAPI *NTOpenWindowStation ) ( LPTSTR, BOOL, DWORD );
-BOOL ( WINAPI *NTSetProcessWindowStation ) ( HWINSTA );
-HDESK ( WINAPI *NTOpenDesktop ) ( LPTSTR, DWORD, BOOL, DWORD );
-BOOL ( WINAPI *NTSetThreadDesktop ) ( HDESK );
-BOOL ( WINAPI *NTCloseDesktop ) ( HDESK );
-BOOL ( WINAPI *NTCloseWindowStation ) ( HWINSTA );
-//***//
-static DWORD dwFileSize;
-static LPVOID lpvFile;
-static HDC hDC;
-#ifdef TEST
-static BOOL fWindow=FALSE;
-#endif
-static WNT_TypeOfImage imgType;
-static HANDLE hHeap;
-static _init init;
-//***//
-static HBITMAP loadXWD ( Handle( WNT_GraphicDevice )& );
-static HBITMAP loadBMP ( Handle( WNT_GraphicDevice )& );
-static HBITMAP loadGIF ( Handle( WNT_GraphicDevice )& );
-//***//
-static void __fastcall _swaplong ( char*, unsigned );
-static void __fastcall _swapshort ( char*, unsigned );
-static int __fastcall _getshift ( unsigned long );
-static WNT_TypeOfImage __fastcall _image_type ( LPTSTR, BOOL );
-//***//
-static void __fastcall _alloc_colors (
- PVOID, int, int, int, LPRGBQUAD, Handle( WNT_GraphicDevice )&
- );
-//***//
-int SaveBitmapToFile (
- Handle( WNT_GraphicDevice )& , HBITMAP , char*, int, int, int, int
- );
-//***//
-HBITMAP LoadImageFromFile (
- Handle( WNT_GraphicDevice )& gDev, char* fileName, HDC hDevCtx
- ) {
-
- HANDLE hFile, hFileMap = NULL;
- HBITMAP retVal = NULL;
- DWORD dwProtect, dwAccess;
-
- if ( WNT_osVer.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) {
-
- dwProtect = PAGE_WRITECOPY;
- dwAccess = GENERIC_READ | GENERIC_WRITE;
-
- } else {
-
- dwProtect = PAGE_READONLY;
- dwAccess = GENERIC_READ;
-
- } // end else
-
- hDC = ( hDevCtx != NULL ) ? hDevCtx : GetDC ( NULL );
-
-#ifdef IMP080200 // Check extension
- WNT_TypeOfImage iType = imgType;
- TCHAR drv[ _MAX_DRIVE ];
- TCHAR dir[ _MAX_DIR ];
- TCHAR fnm[ _MAX_FNAME ];
- TCHAR ext[ _MAX_EXT ];
- TCHAR ifl[ _MAX_PATH ];
-
- _splitpath ( fileName, drv, dir, fnm, ext );
-
- if ( ext[ 0 ] == TEXT( '\x00' ) ) {
- ext[ 0 ] = TEXT( '.' );
- ext[ 1 ] = TEXT( '\x00' );
- } // end if
-
- iType = _image_type ( &ext[ 1 ], FALSE );
-
- _makepath ( ifl, drv, dir, fnm, ext );
-#endif
-
- __try {
-
- hFile = CreateFile (
-#ifdef IMP080200
- ifl, dwAccess, FILE_SHARE_READ, NULL,
-#else
- fileName, dwAccess, FILE_SHARE_READ, NULL,
-#endif
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
- );
-
- if ( hFile == INVALID_HANDLE_VALUE ) __leave;
-
- dwFileSize = GetFileSize ( hFile, NULL );
-
- if ( dwFileSize == 0xFFFFFFFF ) __leave;
-
- hFileMap = CreateFileMapping (
- hFile, NULL, dwProtect, 0, dwFileSize, NULL
- );
-
- if ( hFileMap == NULL ) __leave;
-
- lpvFile = MapViewOfFile ( hFileMap, FILE_MAP_COPY, 0, 0, 0 );
-
- if ( lpvFile == NULL ) __leave;
-
- if ( memcmp ( ( const void* )lpvFile, ( const void* )"BM", 2 ) == 0 )
-
- retVal = loadBMP ( gDev );
-
- else if ( memcmp ( ( const void* )lpvFile, ( const void* )"GIF87a", 6 ) == 0 ||
- memcmp ( ( const void* )lpvFile, ( const void* )"GIF89a", 6 ) == 0
- )
-
- retVal = loadGIF ( gDev );
-
- else // assume XWD file
-
- retVal = loadXWD ( gDev );
-
- } // end __try
-
- __finally {
-
- if ( lpvFile != NULL ) {
-
- UnmapViewOfFile ( lpvFile );
- lpvFile = NULL;
-
- } // end if
-
- if ( hFileMap != NULL ) CloseHandle ( hFileMap );
- if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile );
-
- } // end __finally
-
- if ( hDevCtx == NULL ) ReleaseDC ( NULL, hDC );
-
- return retVal;
-
-} // end LoadImageFromFile
-
-int __WNT_API SaveWindowToFile (
- Handle( WNT_GraphicDevice )& gDev,
- HWND hWnd, char* fName, int x, int y, int w, int h
- ) {
-
- int retVal = I_ERROR;
- HDC hDCmem;
- HBITMAP hBmp = NULL, hOldBmp;
- HPALETTE hOldPal;
-
- __try {
-
- hDC = GetDC ( hWnd );
-#ifdef TEST
- fWindow = TRUE;
-#endif
-
- if ( gDev -> IsPaletteDevice () ) {
-
- hOldPal = SelectPalette ( hDC, ( HPALETTE )( gDev -> HPalette () ), FALSE );
- RealizePalette ( hDC );
-
- } // end if
-
- hDCmem = CreateCompatibleDC ( hDC );
-
- hBmp = CreateCompatibleBitmap ( hDC, w, h );
-
- if ( hBmp == NULL ) __leave;
-
- hOldBmp = SelectBitmap ( hDCmem, hBmp );
-
- BitBlt ( hDCmem, 0, 0, w, h, hDC, x, y, SRCCOPY );
-
- SelectBitmap ( hDCmem, hOldBmp );
-
- retVal = SaveBitmapToFile ( gDev, hBmp, fName, 0, 0, w, h );
-
- } // end __try
-
- __finally {
-
-#ifdef TEST
- fWindow = FALSE;
-#endif
-
- if ( hBmp != NULL ) DeleteObject ( hBmp );
-
- if ( gDev -> IsPaletteDevice () )
-
- SelectPalette ( hDC, hOldPal, FALSE );
-
- DeleteDC ( hDCmem );
- ReleaseDC ( hWnd, hDC );
-
- } // end __finally
-
- return retVal;
-
-} // end SaveWindowToFile
-
-int DumpBitmapToFile (HBITMAP theHBitmap,
- const char* theFileName)
-{
- // get informations about the bitmap
- BITMAP aBitmap;
- if (GetObject (theHBitmap, sizeof(BITMAP), &aBitmap) == 0)
- {
- return I_ERROR;
- }
-
- Image_AlienPixMap anImage;
- const Standard_Size aSizeRowBytes = Standard_Size(aBitmap.bmWidth) * 4;
- if (!anImage.InitTrash (Image_PixMap::ImgBGR32, Standard_Size(aBitmap.bmWidth), Standard_Size(aBitmap.bmHeight), aSizeRowBytes))
- {
- return I_ERROR;
- }
- anImage.SetTopDown (false);
-
- // Setup image data
- BITMAPINFOHEADER aBitmapInfo;
- memset (&aBitmapInfo, 0, sizeof(BITMAPINFOHEADER));
- aBitmapInfo.biSize = sizeof(BITMAPINFOHEADER);
- aBitmapInfo.biWidth = aBitmap.bmWidth;
- aBitmapInfo.biHeight = aBitmap.bmHeight; // positive means bottom-up!
- aBitmapInfo.biPlanes = 1;
- aBitmapInfo.biBitCount = 32; // use 32bit for automatic word-alignment per row
- aBitmapInfo.biCompression = BI_RGB;
-
- // Copy the pixels
- HDC aDC = GetDC (NULL);
- Standard_Boolean isSuccess = GetDIBits (aDC, theHBitmap,
- 0, // first scan line to set
- aBitmap.bmHeight, // number of scan lines to copy
- anImage.ChangeData(), // array for bitmap bits
- (LPBITMAPINFO )&aBitmapInfo, // bitmap data info
- DIB_RGB_COLORS) != 0;
-
- ReleaseDC (NULL, aDC);
- return (isSuccess && anImage.Save (theFileName)) ? I_SUCCESS : I_ERROR;
-}
-
-//***//
-int SaveBitmapToFile (Handle(WNT_GraphicDevice)& gDev,
- HBITMAP hBmp, char* fName,
- int x, int y, int w, int h)
-{
- int retVal = I_ERROR;
- HBITMAP hNewBmp = NULL;
- HPALETTE hOldPal;
- BOOL newBmp = FALSE, newDC = FALSE;
-
- __try {
-
- #ifdef TEST
- if (!fWindow)
- #else
- if (y != 0 || x != 0)
- #endif
- {
- HBITMAP hOldBmp;
-
- newDC = TRUE;
- hDC = GetDC (NULL);
-
- if (gDev->IsPaletteDevice())
- {
- hOldPal = SelectPalette (hDC, (HPALETTE)(gDev->HPalette()), FALSE);
- RealizePalette (hDC);
- } // end if
-
- HDC hDCmemSrc = CreateCompatibleDC (hDC);
- HDC hDCmemDst = CreateCompatibleDC (hDC);
-
- hNewBmp = CreateCompatibleBitmap (hDC, w, h);
- if (hNewBmp != NULL)
- {
- hOldBmp = SelectBitmap (hDCmemDst, hNewBmp);
- SelectBitmap (hDCmemSrc, hBmp);
- BitBlt (hDCmemDst, 0, 0, w, h, hDCmemSrc, x, y, SRCCOPY);
- newBmp = TRUE;
- SelectBitmap (hDCmemDst, hOldBmp);
- } // end if
-
- DeleteDC (hDCmemDst);
- DeleteDC (hDCmemSrc);
-
- if (gDev->IsPaletteDevice())
- {
- SelectPalette (hDC, hOldPal, FALSE);
- }
- if (hNewBmp == NULL) __leave;
- }
- else
- {
- hNewBmp = hBmp;
- }
-
- retVal = DumpBitmapToFile (hNewBmp, fName);
- } // end __try
- __finally {
- if (hNewBmp != NULL && newBmp) DeleteObject (hNewBmp);
- if (newDC) ReleaseDC (NULL, hDC);
- } // end __finally
- return retVal;
-} // end SaveBitmapToFile
-//***//
-void SetOutputFormat ( WNT_TypeOfImage type ) {
-
- imgType = type;
-
-} // end SetOutputFormat
-//***//
-//**************** Routines to process XWD file ***************************//
-//***//
-static HBITMAP loadXWD ( Handle( WNT_GraphicDevice )& gDev ) {
-
- UINT i, j, k;
- UINT red_shift, green_shift, blue_shift;
- HBITMAP retVal = NULL;
- PBITMAPINFO pBmi = NULL;
- PBYTE pbInit;
- UINT nBytes, bitmapSize;
- WORD bitCount;
- HPALETTE hOldPal;
- LONG lPixel;
- WORD wPixel;
- BYTE bPixel;
- BOOL newMem = FALSE;
- PBYTE ptrDIB, ptrXWD;
- UINT incDIB, incXWD;
- XWDFileHeader* xwdHdr;
- XColor* xColor;
- Standard_Integer r, g, b;
- WORD colors[ MAXCOLOR ];
- LPVOID imageData;
- DWORD dataSize;
-
- __try {
-
- xwdHdr = ( XWDFileHeader* )lpvFile;
-
- _swaplong ( ( char* )xwdHdr, sizeof ( XWDFileHeader ) );
-
- if ( xwdHdr -> file_version != XWD_FILE_VERSION ||
- xwdHdr -> pixmap_format != ZPixmap ||
- xwdHdr -> header_size < sizeof ( XWDFileHeader )
- ) __leave;
-
- xColor = ( XColor* )( ( char* )lpvFile + xwdHdr -> header_size );
-
- for ( i = 0; i < xwdHdr -> ncolors; ++i ) {
-
- _swaplong ( ( char* )&xColor[ i ].pixel, sizeof ( unsigned long ) );
- _swapshort ( ( char* )&xColor[ i ].red, sizeof ( unsigned short ) * 3 );
-
- } // end for
-
- imageData = ( LPVOID )( xColor + xwdHdr -> ncolors );
- imageData = ( LPVOID )( ( char* )imageData + xwdHdr -> xoffset );
- dataSize = ( DWORD )( ( char* )lpvFile + dwFileSize - ( char* )imageData );
-
- nBytes = sizeof ( BITMAPINFO );
-
- switch ( xwdHdr -> visual_class ) {
-
- case StaticColor:
- case PseudoColor:
-
- if ( xwdHdr -> bits_per_pixel < 12 ) {
-
- bitCount = ( xwdHdr -> bits_per_pixel <= 4 ) ? 4 : 8;
-#ifdef TEST
- nBytes += sizeof ( RGBQUAD ) * ( 1 << bitCount );
-#else
- nBytes += sizeof ( RGBQUAD ) * xwdHdr -> ncolors;
-#endif
- } else if ( xwdHdr -> bits_per_pixel == 16 )
-
- bitCount = 16;
-
- else
-
- __leave;
-
- break;
-
- case TrueColor:
- case DirectColor:
-
- red_shift = _getshift ( xwdHdr -> red_mask );
- green_shift = _getshift ( xwdHdr -> green_mask );
- blue_shift = _getshift ( xwdHdr -> blue_mask );
-
- if ( xwdHdr -> bits_per_pixel < 24 )
-
- bitCount = 16;
-
- else if ( xwdHdr -> bits_per_pixel == 24 )
-
- bitCount = 24;
-
- else if ( xwdHdr -> bits_per_pixel == 32 )
-
- bitCount = 32;
-
- else
-
- __leave;
-
- break;
-
- } // end switch
-
- pBmi = ( PBITMAPINFO )MALLOC( nBytes );
-
- if ( pBmi == NULL ) __leave;
-
- pBmi -> bmiHeader.biSize = sizeof ( BITMAPINFOHEADER );
- pBmi -> bmiHeader.biWidth = xwdHdr -> pixmap_width;
- pBmi -> bmiHeader.biHeight = -( int )xwdHdr -> pixmap_height;
- pBmi -> bmiHeader.biPlanes = 1;
- pBmi -> bmiHeader.biBitCount = bitCount;
- pBmi -> bmiHeader.biCompression = BI_RGB;
-
- ZeroMemory ( ( PVOID )&colors, sizeof ( colors ) );
-
- switch ( xwdHdr -> visual_class ) {
-
- case StaticColor:
- case PseudoColor:
-
- if ( bitCount != 16 ) {
-
- for ( i = 0; i < xwdHdr -> ncolors; ++i ) {
-
- pBmi -> bmiColors[ i ].rgbBlue = ( xColor[ i ].blue >> 8 );
- pBmi -> bmiColors[ i ].rgbGreen = ( xColor[ i ].green >> 8 );
- pBmi -> bmiColors[ i ].rgbRed = ( xColor[ i ].red >> 8 );
-
- } // end for
-
- incXWD = xwdHdr -> bytes_per_line;
- incDIB = incXWD + PAD( incXWD );
-
- if ( xwdHdr -> bytes_per_line == incDIB )
-
- pbInit = ( PBYTE )imageData;
-
- else {
-
- bitmapSize = xwdHdr -> pixmap_height * incDIB;
-
- pbInit = ( PBYTE )MALLOC( bitmapSize );
-
- if ( pbInit == NULL ) __leave;
-
- newMem = TRUE;
-
- ptrDIB = ( PBYTE )pbInit;
- ptrXWD = ( PBYTE )imageData;
-
- for ( i = 0; i < xwdHdr -> pixmap_height; ++i ) {
-
- CopyMemory ( ptrDIB, ptrXWD, incXWD );
-
- ptrDIB += incDIB;
- ptrXWD += incXWD;
-
- } // end for ( i . . . )
-
- } // end else
-
- ptrDIB = ( PBYTE )MALLOC( dataSize );
-
- if ( ptrDIB == NULL ) __leave;
-
- CopyMemory ( ( PVOID )ptrDIB, ( PVOID )pbInit, dataSize );
- FillMemory ( ( PVOID )colors, MAXCOLOR * sizeof ( WORD ), 0xFFFF );
-
- for ( i = 0; i < dataSize; ++i ) {
-
- if ( colors[ ptrDIB[ i ] ] != 0xFFFF ) continue;
-
- for ( j = 0; j < xwdHdr -> ncolors; ++j )
-
- if ( xColor[ j ].pixel == pbInit[ i ] )
-
- break;
-
- for ( k = 0; k < dataSize; ++k )
-
- if ( ptrDIB[ k ] == xColor[ j ].pixel )
-
- pbInit[ k ] = j;
-
- colors[ ptrDIB[ i ] ] = j;
-
- } // end for
-
- if ( gDev -> IsPaletteDevice () ) {
-
- for ( i = 0; i < MAXCOLOR; ++i ) {
-
- if ( colors[ i ] == 0xFFFF ) continue;
-
- b = ( Standard_Integer )( xColor[ colors[ i ] ].blue >> 8 );
- g = ( Standard_Integer )( xColor[ colors[ i ] ].green >> 8 );
- r = ( Standard_Integer )( xColor[ colors[ i ] ].red >> 8 );
-
- gDev -> SetColor ( r, g, b );
-
- } // end for
-
- } // end if
-
- FREE( ptrDIB );
-
- } else { // bitCount == 16
-
- WORD red, green, blue;
-
- incXWD = xwdHdr -> bytes_per_line;
- incDIB = xwdHdr -> pixmap_width * sizeof ( WORD );
- incDIB += PAD( incDIB );
-
- _swapshort ( ( char* )imageData, dataSize );
-
- if ( xwdHdr -> bytes_per_line == incDIB )
-
- pbInit = ( PBYTE )imageData;
-
- else {
-
- bitmapSize = xwdHdr -> pixmap_height * incDIB;
-
- pbInit = ( PBYTE )MALLOC( bitmapSize );
-
- if ( pbInit == NULL ) __leave;
-
- newMem = TRUE;
-
- ptrDIB = ( PBYTE )pbInit;
- ptrXWD = ( PBYTE )imageData;
-
- for ( i = 0; i < xwdHdr -> pixmap_height; ++i ) {
-
- CopyMemory ( ptrDIB, ptrXWD, incXWD );
-
- ptrDIB += incDIB;
- ptrXWD += incXWD;
-
- } // end for ( i . . . )
-
- } // end else
-
- ptrDIB = pbInit;
- dataSize = xwdHdr -> pixmap_height * incDIB;
-
- for ( i = 0; i < xwdHdr -> pixmap_height; ++i ) {
-
- for ( j = 0; j < xwdHdr -> pixmap_width; ++j ) {
-
- wPixel = ( ( PWORD )ptrDIB )[ j ];
- red = ( xColor[ wPixel ].red >> 11 ) << 10;
- green = ( xColor[ wPixel ].green >> 11 ) << 5;
- blue = ( xColor[ wPixel ].blue >> 11 );
- wPixel = red | green | blue;
- ( ( PWORD )ptrDIB )[ j ] = wPixel;
-
- } // end for ( j . . . )
-
- ptrDIB += incDIB;
-
- } // end for ( i . . . )
-
-AllocColors_16:
-
- if ( gDev -> IsPaletteDevice () )
-
- _alloc_colors (
- pbInit, xwdHdr -> pixmap_width, xwdHdr -> pixmap_height, PIXEL16, NULL, gDev
- );
-
- } // end else
-
- break;
-
- case TrueColor:
- case DirectColor:
-
- switch ( bitCount ) {
-
- case 16:
-
- _swapshort ( ( char* )imageData, dataSize );
-
- incXWD = xwdHdr -> bytes_per_line;
- incDIB = xwdHdr -> pixmap_width * sizeof ( WORD );
- incDIB += PAD( incDIB );
- bitmapSize = incDIB * xwdHdr -> pixmap_height;
-
- pbInit = ( PBYTE )MALLOC( bitmapSize );
-
- if ( pbInit == NULL ) __leave;
-
- newMem = TRUE;
-
- ptrDIB = ( PBYTE )pbInit;
- ptrXWD = ( PBYTE )imageData;
-
- switch ( xwdHdr -> bits_per_pixel ) {
-
- case 8:
-
- for ( i = 0; i < xwdHdr -> pixmap_height; ++i ) {
-
- for ( j = 0; j < xwdHdr -> pixmap_width; ++j ) {
-
- bPixel = ptrXWD[ j ];
- b = ( xColor[ ( bPixel & xwdHdr -> blue_mask ) >> blue_shift ].blue ) >> 11;
- g = ( xColor[ ( bPixel & xwdHdr -> green_mask ) >> green_shift ].green ) >> 11;
- r = ( xColor[ ( bPixel & xwdHdr -> red_mask ) >> red_shift ].red ) >> 11;
- ( ( PWORD )ptrDIB )[ j ] = ( WORD )( b | ( g << 5 ) | ( r << 10 ) );
-
- } // end for ( j . . . )
-
- ptrDIB += incDIB;
- ptrXWD += incXWD;
-
- } // end for ( i . . . )
-
- break;
-
- case 16:
-
- for ( i = 0; i < xwdHdr -> pixmap_height; ++i ) {
-
- for ( j = 0; j < xwdHdr -> pixmap_width; ++j ) {
-
- wPixel = ( ( PWORD )ptrXWD )[ j ];
- b = ( xColor[ ( wPixel & xwdHdr -> blue_mask ) >> blue_shift ].blue ) >> 11;
- g = ( xColor[ ( wPixel & xwdHdr -> green_mask ) >> green_shift ].green ) >> 11;
- r = ( xColor[ ( wPixel & xwdHdr -> red_mask ) >> red_shift ].red ) >> 11;
- ( ( PWORD )ptrDIB )[ j ] = ( WORD )( b | ( g << 5 ) | ( r << 10 ) );
-
- } // end for ( j . . . )
-
- ptrDIB += incDIB;
- ptrXWD += incXWD;
-
- } // end for ( i . . . )
-
- break;
-
- default:
-
- __leave;
-
- } // end switch ( xwdHdr -> bits_per_pixel . . . )
-
- goto AllocColors_16; // not attractive but efficient
-
- break;
-
- case 24:
-
- __leave;
-
- case 32:
-
- _swaplong ( ( char* )imageData, dataSize );
-
- pbInit = ( PBYTE )imageData;
- bitmapSize = xwdHdr -> pixmap_height *
- xwdHdr -> pixmap_width * sizeof ( LONG );
-
- if ( xwdHdr -> ncolors != 0 )
-
- for ( i = j = 0; j < bitmapSize; i += sizeof ( LONG ) ) {
-
- lPixel = ( LONG )*( ( PLONG )( ( PBYTE )imageData + j ) );
-
- pbInit[ i ] =
- ( BYTE )( xColor[ ( lPixel & xwdHdr -> blue_mask ) >> blue_shift ].blue );
- pbInit[ i + 1 ] =
- ( BYTE )( xColor[ ( lPixel & xwdHdr -> green_mask ) >> green_shift ].green );
- pbInit[ i + 2 ] =
- ( BYTE )( xColor[ ( lPixel & xwdHdr -> red_mask ) >> red_shift ].red );
- pbInit[ i + 3 ] = 0;
-
- j += sizeof ( LONG );
-
- } // end for
-
- else
-
- for ( i = j = 0; j < bitmapSize; i += sizeof ( LONG ) ) {
-
- lPixel = ( LONG )*( ( PLONG )( ( PBYTE )imageData + j ) );
-
- pbInit[ i ] =
- ( BYTE )( ( lPixel & xwdHdr -> blue_mask ) >> blue_shift );
- pbInit[ i + 1 ] =
- ( BYTE )( ( lPixel & xwdHdr -> green_mask ) >> green_shift );
- pbInit[ i + 2 ] =
- ( BYTE )( ( lPixel & xwdHdr -> red_mask ) >> red_shift );
- pbInit[ i + 3 ] = 0;
-
- j += sizeof ( LONG );
-
- } // end for
-
- if ( gDev -> IsPaletteDevice () )
-
- _alloc_colors (
- pbInit, xwdHdr -> pixmap_width, xwdHdr -> pixmap_height, PIXEL32, NULL, gDev
- );
-
- } // end switch ( bitCount . . . )
-
- } // end switch ( xwdHdr -> visual_class . . . )
-
- if ( gDev -> IsPaletteDevice () ) {
-
- hOldPal = SelectPalette ( hDC, ( HPALETTE )( gDev -> HPalette () ), FALSE );
-
- if ( RealizePalette ( hDC ) )
-
- UpdateColors ( hDC );
-
- } // end if
-
- retVal = CreateDIBitmap (
- hDC, &pBmi -> bmiHeader, CBM_INIT, pbInit, pBmi, DIB_RGB_COLORS
- );
-
- if ( gDev -> IsPaletteDevice () )
-
- SelectPalette ( hDC, hOldPal, FALSE );
-
- } // end try
-
- __finally {
-
- if ( pbInit != NULL && newMem ) FREE( pbInit );
- if ( pBmi != NULL ) FREE( pBmi );
-
- } // end finally
-
- return retVal;
-
-} // end readXWD
-
-static void __fastcall _swaplong ( char* bp, unsigned n ) {
-
- char c;
- char* ep = bp + n;
- char* sp;
-
- while ( bp < ep ) {
-
- sp = bp + 3;
- c = *sp;
- *sp = *bp;
- *bp++ = c;
- sp = bp + 1;
- c = *sp;
- *sp = *bp;
- *bp++ = c;
- bp += 2;
-
- } // end while
-
-} // end _swaplong
-
-static void __fastcall _swapshort ( char* bp, unsigned n ) {
-
- char c;
- char* ep = bp + n;
-
- while ( bp < ep ) {
-
- c = *bp;
- *bp++ = *( bp + 1 );
- *bp++ = c;
-
- } // end while
-
-} // end _swapshort
-
-static int __fastcall _getshift ( unsigned long mask ) {
-
- int retVal = 0;
-
- while ( !( mask & 1 ) ) {
-
- ++retVal;
- mask >>= 1;
-
- } // end while
-
- return retVal;
-
-} // end _getshift
-
-//**************** Routines to process BMP file ***************************//
-//***//
-static HBITMAP loadBMP ( Handle( WNT_GraphicDevice )& gDev ) {
-
- HBITMAP retVal = NULL;
- PBITMAPFILEHEADER pBmfh;
- PBITMAPINFOHEADER pBmih;
- LPRGBQUAD pRGB;
- PBYTE pData;
- HPALETTE hOldPal;
- WORD bitCount;
- UINT nColors;
- DWORD dwWidth, dwHeight;
- BOOL os2Flag;
-
- __try {
-
- pBmfh = ( PBITMAPFILEHEADER )lpvFile;
- pBmih = ( PBITMAPINFOHEADER )( ( PBYTE )lpvFile + sizeof ( BITMAPFILEHEADER ) );
-
- if ( pBmih -> biSize == sizeof ( BITMAPCOREHEADER ) ) { // OS/2 bitmap
-
- PBITMAPCOREHEADER pBmch = ( PBITMAPCOREHEADER )pBmih;
-
- bitCount = pBmch -> bcBitCount;
- nColors = ( bitCount < 16 ) ? ( 1 << bitCount ) : 0;
-
- pBmih = ( PBITMAPINFOHEADER )MALLOC(
- sizeof ( BITMAPINFO ) +
- sizeof ( RGBQUAD ) * nColors
- );
-
- if ( pBmih == NULL ) __leave;
-
- pBmih -> biSize = sizeof ( BITMAPINFOHEADER );
- pBmih -> biWidth = pBmch -> bcWidth;
- pBmih -> biHeight = pBmch -> bcHeight;
- pBmih -> biPlanes = 1;
- pBmih -> biBitCount = bitCount;
- pBmih -> biCompression = BI_RGB;
-
- for ( UINT i = 0; i < nColors; ++i ) {
-
- ( ( PBITMAPINFO )pBmih ) -> bmiColors[ i ].rgbRed =
- ( ( PBITMAPCOREINFO )pBmch ) -> bmciColors[ i ].rgbtRed;
- ( ( PBITMAPINFO )pBmih ) -> bmiColors[ i ].rgbGreen =
- ( ( PBITMAPCOREINFO )pBmch ) -> bmciColors[ i ].rgbtGreen;
- ( ( PBITMAPINFO )pBmih ) -> bmiColors[ i ].rgbBlue =
- ( ( PBITMAPCOREINFO )pBmch ) -> bmciColors[ i ].rgbtBlue;
-
- } // end for
-
- pRGB = ( ( PBITMAPINFO )pBmih ) -> bmiColors;
- os2Flag = TRUE;
-
- } else { // Windows DIB
-
- pRGB = ( LPRGBQUAD )( ( PBYTE )pBmih + pBmih -> biSize );
- os2Flag = FALSE;
-
- } // end else
-
- bitCount = pBmih -> biBitCount;
- dwWidth = pBmih -> biWidth;
- dwHeight = pBmih -> biHeight;
- pData = ( PBYTE )( ( PBYTE )lpvFile + pBmfh -> bfOffBits );
-
- if ( gDev -> IsPaletteDevice () ) {
-
- _alloc_colors ( pData, dwWidth, dwHeight, bitCount, pRGB, gDev );
-
- hOldPal = SelectPalette ( hDC, ( HPALETTE )( gDev -> HPalette () ), FALSE );
- RealizePalette ( hDC );
-
- } // end if
-
- retVal = CreateDIBitmap (
- hDC, pBmih, CBM_INIT, pData, ( PBITMAPINFO )pBmih, DIB_RGB_COLORS
- );
-
- if ( gDev -> IsPaletteDevice () )
-
- SelectPalette ( hDC, hOldPal, FALSE );
-
- } // end __try
-
- __finally {
-
- if ( os2Flag && pBmih ) FREE( pBmih );
-
- } // end __finally
-
- return retVal;
-
-} // end loadBMP
-
-//***//
-//**************** Routines to process GIF file ***************************//
-//***//
-#define NEXT_BYTE ( *ptr++ )
-#define IMAGESEP 0x2C
-#define INTERLACE_MASK 0x40
-#define COLORMAP_MASK 0x80
-#define COMMENT_BYTE 0x21
-
-static UINT x, y, pass, bytesPerLine, imgWidth, imgHeight;
-static PBYTE pData;
-static PBITMAPINFO pBmi;
-static BOOL isInterlace;
-
-static void __fastcall _add_pixel ( UINT );
-//***//
-static HBITMAP loadGIF ( Handle( WNT_GraphicDevice )& gDev ) {
-
- int i, nColors;
- HBITMAP retVal = NULL;
- UINT Bits, BitMask, CodeSize, ClearCode, EOFCode, FreeCode,
- InitCodeSize, MaxCode, ReadMask, FirstFree, OutCount, BitOffset,
- ByteOffset, Code, CurCode, OldCode, FinChar, InCode;
- PUINT OutCode, Prefix, Suffix;
- BYTE byte, byte1;
- PBYTE rasterPtr, ptr1, ptr = ( ( PBYTE )lpvFile ) + 10;
- BOOL hasColormap;
- HPALETTE hOldPal;
- DWORD dataSize;
-
-#ifdef BUC60837
- pBmi = NULL;
- rasterPtr = pData = NULL;
- Suffix = Prefix = OutCode = NULL;
-#endif
-
- __try {
-
-#ifdef BUC60837
- OutCode = ( PUINT )MALLOC( 1026 * sizeof ( UINT ) );
-#else
- pBmi = NULL;
- rasterPtr = pData = NULL;
- OutCode = ( PUINT )MALLOC( 1025 * sizeof ( UINT ) );
-#endif
- Prefix = ( PUINT )MALLOC( 4096 * sizeof ( UINT ) );
- Suffix = ( PUINT )MALLOC( 4096 * sizeof ( UINT ) );
-
- if ( OutCode == NULL || Prefix == NULL || Suffix == NULL ) __leave;
-
- byte = NEXT_BYTE;
-
- hasColormap = ( byte & COLORMAP_MASK ) ? TRUE : FALSE;
- Bits = ( byte & 0x07 ) + 1;
- nColors = 1 << Bits;
- BitMask = nColors - 1;
- ++ptr;
-
- if ( NEXT_BYTE ) __leave;
-
- pBmi = ( PBITMAPINFO )MALLOC(
- sizeof ( BITMAPINFO ) + sizeof ( RGBQUAD ) * 256
- );
-
- if ( pBmi == NULL ) __leave;
-
- if ( hasColormap ) {
-
- for ( i = 0; i < nColors; ++i ) {
-
- pBmi -> bmiColors[ i ].rgbRed = NEXT_BYTE;
- pBmi -> bmiColors[ i ].rgbGreen = NEXT_BYTE;
- pBmi -> bmiColors[ i ].rgbBlue = NEXT_BYTE;
-
- } // end for
-
- } // end if
-
- while ( *ptr == COMMENT_BYTE ) {
-
- ptr += 2;
-
- while ( *ptr ) ( ptr += *ptr )++;
-
- NEXT_BYTE;
-
- } // end while
-
- if ( NEXT_BYTE != IMAGESEP ) __leave;
-
- rasterPtr = ( PBYTE )MALLOC( dwFileSize );
-
- if ( rasterPtr == NULL ) __leave;
-
- ptr += 4;
-
- byte = NEXT_BYTE;
- imgWidth = byte + 0x100 * NEXT_BYTE;
- byte = NEXT_BYTE;
- imgHeight = byte + 0x100 * NEXT_BYTE;
-
- isInterlace = ( NEXT_BYTE & INTERLACE_MASK ) ? TRUE : FALSE;
-
- CodeSize = NEXT_BYTE;
- ClearCode = 1 << CodeSize;
- EOFCode = ClearCode + 1;
- FreeCode = FirstFree = EOFCode + 1;
-
- ++CodeSize;
-
- InitCodeSize = CodeSize;
- MaxCode = 1 << CodeSize;
- ReadMask = MaxCode - 1;
-
- ptr1 = rasterPtr;
-
- do {
-
- byte = byte1 = NEXT_BYTE;
-
- while ( byte != 0 ) {
-
- *ptr1++ = NEXT_BYTE;
- --byte;
-
- } // end while
-
- if ( ( UINT )( ptr1 - rasterPtr ) > dwFileSize ) __leave; // corrupt file - unblock
-
- } while ( byte1 );
-
- bytesPerLine = imgWidth + PAD( imgWidth );
- dataSize = bytesPerLine * imgHeight;
-
- pData = ( PBYTE )MALLOC( dataSize );
-
- if ( pData == NULL ) __leave;
-
- x = y = pass = OutCount = BitOffset = ByteOffset = 0;
-
- Code = rasterPtr[ ByteOffset ] + ( rasterPtr[ ByteOffset + 1 ] << 8 );
-
- if ( CodeSize >= 8 ) Code += ( rasterPtr[ ByteOffset + 2 ] << 16 );
-
- Code >>= ( BitOffset % 8 );
- BitOffset += CodeSize;
- Code &= ReadMask;
-
- while ( Code != EOFCode ) {
-
- if ( Code == ClearCode ) {
-
- CodeSize = InitCodeSize;
- MaxCode = 1 << CodeSize;
- ReadMask = MaxCode - 1;
- FreeCode = FirstFree;
- ByteOffset = BitOffset >> 3;
-#ifdef BUC60837
- if( ByteOffset > (dwFileSize-3) ) break;
-#endif
- Code = rasterPtr[ ByteOffset ] + ( rasterPtr[ ByteOffset + 1 ] << 8 );
-
- if ( CodeSize >= 8 ) Code += ( rasterPtr[ ByteOffset + 2 ] << 16 );
-
- Code >>= ( BitOffset % 8 );
- BitOffset += CodeSize;
- Code &= ReadMask;
-
- CurCode = OldCode = Code;
- FinChar = CurCode & BitMask;
-
- _add_pixel ( FinChar );
-
- } else {
-
- CurCode = InCode = Code;
-
- if ( CurCode >= FreeCode ) {
-
- CurCode = OldCode;
- OutCode[ OutCount++ ] = FinChar;
-
- } // end if
-
- while ( CurCode > BitMask ) {
-
-
- if ( OutCount > 1024 )
-#ifdef BUC60837
- break;
-#else
- __leave;
-#endif
- OutCode[ OutCount++ ] = Suffix[ CurCode ];
- CurCode = Prefix[ CurCode ];
-
- } // end while
-
- FinChar = CurCode & BitMask;
- OutCode[ OutCount++ ] = FinChar;
-
- for ( i = OutCount - 1; i >= 0; --i ) _add_pixel ( OutCode[ i ] );
-
- OutCount = 0;
- Prefix[ FreeCode ] = OldCode;
- Suffix[ FreeCode ] = FinChar;
- OldCode = InCode;
- ++FreeCode;
-
- if ( FreeCode >= MaxCode ) {
-
- if ( CodeSize < 12 ) {
-
- ++CodeSize;
- MaxCode <<= 1;
- ReadMask = ( 1 << CodeSize ) - 1;
-
- } // end if
-
- } // end if
-
- } // end else
-
- ByteOffset = BitOffset >> 3;
-#ifdef BUC60837
- if( ByteOffset > (dwFileSize-3) ) break;
-#endif
- Code = rasterPtr[ ByteOffset ] + ( rasterPtr[ ByteOffset + 1 ] << 8 );
-
- if ( CodeSize >= 8 ) Code += ( rasterPtr[ ByteOffset + 2 ] << 16 );
-
- Code >>= ( BitOffset % 8 );
- BitOffset += CodeSize;
- Code &= ReadMask;
-
- } // end while
-
- pBmi -> bmiHeader.biSize = sizeof ( BITMAPINFOHEADER );
- pBmi -> bmiHeader.biWidth = imgWidth;
- pBmi -> bmiHeader.biHeight = -( INT )imgHeight;
- pBmi -> bmiHeader.biPlanes = 1;
- pBmi -> bmiHeader.biBitCount = 8;
- pBmi -> bmiHeader.biCompression = BI_RGB;
-
- if ( gDev -> IsPaletteDevice () ) {
-
- _alloc_colors (
- pData, imgWidth, imgHeight, PIXEL8, pBmi -> bmiColors, gDev
- );
-
- hOldPal = SelectPalette ( hDC, ( HPALETTE )( gDev -> HPalette () ), FALSE );
- RealizePalette ( hDC );
-
- } // end if
-
- retVal = CreateDIBitmap (
- hDC, ( PBITMAPINFOHEADER )pBmi, CBM_INIT, pData, pBmi, DIB_RGB_COLORS
- );
-
- if ( gDev -> IsPaletteDevice () )
-
- SelectPalette ( hDC, hOldPal, FALSE );
-
- } // end __try
-
- __finally {
-
- if ( pData != NULL ) FREE( pData );
- if ( rasterPtr != NULL ) FREE( rasterPtr );
- if ( pBmi != NULL ) FREE( pBmi );
- if ( Suffix != NULL ) FREE( Suffix );
- if ( Prefix != NULL ) FREE( Prefix );
- if ( OutCode != NULL ) FREE( OutCode );
-
- } // end __finally
-
- return retVal;
-
-} // end loadGIF
-
-typedef struct _screen_descr {
-
- char gifID[ 6 ];
- WORD scrnWidth;
- WORD scrnHeight;
- BYTE scrnFlag;
-
- } SCREEN_DESCR;
-
-typedef struct _image_descr {
-
- WORD imgX;
- WORD imgY;
- WORD imgWidth;
- WORD imgHeight;
- BYTE imgFlag;
-
- } IMAGE_DESCR;
-
-static void __fastcall _add_pixel ( UINT idx ) {
-
- if ( y < imgHeight )
-
- *( pData + y * bytesPerLine + x ) = ( BYTE )idx;
-
- if ( ++x == imgWidth ) {
-
- x = 0;
-
- if ( !isInterlace )
-
- ++y;
-
- else {
-
- switch ( pass ) {
-
- case 0:
-
- y += 8;
-
- if ( y >= imgHeight ) ++pass, y = 4;
-
- break;
-
- case 1:
-
- y += 8;
-
- if ( y >= imgHeight ) ++pass, y = 2;
-
- break;
-
- case 2:
-
- y += 4;
-
- if ( y >= imgHeight ) ++pass, y = 1;
-
- break;
-
- case 3:
-
- y += 2;
-
- } // end switch
-
- } // end else
-
- } // end if
-
-} // end _add_pixel
-
-
-//***//
-//*************************************************************************//
-//***//
-static void __fastcall _alloc_colors (
- PVOID data, int width, int height, int size, LPRGBQUAD colors,
- Handle( WNT_GraphicDevice )& gDev
- ) {
-
- int i, j, k, bytes_per_line;
- Standard_Integer r, g, b;
- PBYTE pLine;
-
- if ( height < 0 ) height = -height;
-
- switch ( size ) {
-
- case PIXEL4: {
-
- PBYTE pixels;
- int l, idx, nColors;
-
- pixels = ( PBYTE )MALLOC( 0x10 );
-
- if ( pixels != NULL ) {
-
- pLine = ( PBYTE )data;
-
- bytes_per_line = width >> 1;
- bytes_per_line += PAD( bytes_per_line );
-
- nColors = gDev -> NumColors ();
-
- for ( i = k = 0; i < height; ++i ) {
-
- for ( j = l = 0; j < width; ++j ) {
-
- idx = pLine[ l ] & 0x0F;
-
- if ( !pixels[ idx ] ) {
-retry_4:
- r = ( Standard_Integer )( colors[ idx ].rgbRed );
- g = ( Standard_Integer )( colors[ idx ].rgbGreen );
- b = ( Standard_Integer )( colors[ idx ].rgbBlue );
-
- gDev -> SetColor ( ( r << 16 ) | ( g << 8 ) | b );
-
- pixels[ idx ] = TRUE;
-
- if ( ++k > nColors )
-
- goto end_4;
-
- } else {
-
- idx = ( pLine[ l++ ] >> 4 ) & 0x0F;
-
- if ( !pixels[ idx ] )
-
- goto retry_4;
-
- } // end else
-
- } // end for ( j . . . )
-
- pLine += bytes_per_line;
-
- } // end for ( i . . . )
-end_4:
- FREE( pixels );
-
- } // end if
-
- } // PIXEL4
-
- break;
-
- case PIXEL8: {
-
- int idx, nColors;
- PBYTE pixels;
-
- pixels = ( PBYTE )MALLOC( 0x100 );
-
- if ( pixels != NULL ) {
-
- pLine = ( PBYTE )data;
-
- bytes_per_line = width + PAD( width );
-
- nColors = gDev -> NumColors ();
-
- for ( i = k = 0; i < height; ++i ) {
-
- for ( j = 0; j < width; ++j ) {
-
- idx = pLine[ j ];
-
- if ( pixels[ idx ] ) continue;
-
- r = ( Standard_Integer )( colors[ idx ].rgbRed );
- g = ( Standard_Integer )( colors[ idx ].rgbGreen );
- b = ( Standard_Integer )( colors[ idx ].rgbBlue );
-
- gDev -> SetColor ( ( r << 16 ) | ( g << 8 ) | b );
-
- pixels[ idx ] = TRUE;
-
- if ( ++k > nColors ) goto end_8;
-
- } // end for ( j . . . )
-
- pLine += bytes_per_line;
-
- } // end for ( i . . . )
-end_8:
- FREE( pixels );
-
- } // end if
-
- } // PIXEL8
-
- break;
-
- case PIXEL16: {
-
- PWORD pixels, hPixels, pData;
- WORD pix, hPix, mask = 0xFF, rmask = 0xFFFF, mult;
- DWORD dataSize;
-
- pixels = ( PWORD )MALLOC( 0x100 * sizeof ( WORD ) );
- hPixels = ( PWORD )MALLOC( 0x100 * sizeof ( WORD ) );
-
- if ( pixels != NULL && hPixels != NULL ) {
-
- FillMemory ( ( PVOID )pixels, 0x100 * sizeof ( WORD ), ~0 );
- FillMemory ( ( PVOID )hPixels, 0x100 * sizeof ( WORD ), ~0 );
-
- pData = ( PWORD )data;
-
- bytes_per_line = width * sizeof ( WORD );
- bytes_per_line += PAD( bytes_per_line );
- dataSize = bytes_per_line * height;
-
- mult = ( WORD )( dataSize / sizeof ( WORD ) / RAND_MAX );
-
- if ( mult == 0 ) {
-
- mult = 1;
- rmask = ( WORD )( dataSize / sizeof ( WORD ) - 1 );
-
- } // end if
-
- for ( i = j = 0, k = gDev -> NumColors ();
- i < ( int )( dataSize / sizeof ( WORD ) );
- ++i
- ) {
-
- pix = pData[ ( rand () * mult ) & rmask ];
- hPix = ( ( pix >> 8 ) ^ pix ) & mask;
-
- if ( pixels[ hPix ] == ~0 || hPixels[ hPix ] != pix ) {
-
- gDev -> SetColor (
- ( ( pix & 0x1F ) << 3 ) |
- ( ( pix & 0x3E0 ) << 6 ) |
- ( ( pix & 0x7C00 ) << 9 )
- );
-
- if ( ++j > k ) break;
-
- hPixels[ hPix ] = pixels[ hPix ] = pix;
-
- } // end if
-
- } // end for
-
- FREE( hPixels );
- FREE( pixels );
-
- } // end if
-
- } // PIXEL16
-
- break;
-
- case PIXEL24: {
-
- PLONG pixels, hPixels;
- PTRIPLET pData;
- LONG pix, hPix, mask = 0x0FFF, rmask = 0xFFFFFFFF, mult;
- DWORD dataSize;
-
- pixels = ( PLONG )MALLOC( 0x1000 * sizeof ( LONG ) );
- hPixels = ( PLONG )MALLOC( 0x1000 * sizeof ( LONG ) );
-
- if ( pixels != NULL && hPixels != NULL ) {
-
- FillMemory ( ( PVOID )pixels, 0x1000 * sizeof ( LONG ), ~0 );
- FillMemory ( ( PVOID )hPixels, 0x1000 * sizeof ( LONG ), ~0 );
-
- pData = ( PTRIPLET )data;
-
- bytes_per_line = width * sizeof ( TRIPLET );
- bytes_per_line += PAD( bytes_per_line );
- dataSize = bytes_per_line * height;
-
- mult = dataSize / sizeof ( TRIPLET ) / RAND_MAX;
-
- if ( mult == 0 ) {
-
- mult = 1;
- rmask = dataSize / sizeof ( TRIPLET ) - 1;
-
- } // end if
-
- for ( i = j = 0, k = gDev -> NumColors ();
- i < ( int )( dataSize / sizeof ( TRIPLET ) );
- ++i
- ) {
-
- pix = ( *( PLONG )( pData[ ( rand () * mult ) & rmask ].pixel ) ) & 0x00FFFFFF;
- hPix = ( ( pix >> 12 ) ^ pix ) & mask;
-
- if ( pixels[ hPix ] == ~0 || hPixels[ hPix ] != pix ) {
-
- gDev -> SetColor ( pix );
-
- if ( ++j > k ) break;
-
- hPixels[ hPix ] = pixels[ hPix ] = pix;
-
- } // end if
-
- } // end for
-
- FREE( hPixels );
- FREE( pixels );
-
- } // end if
-
- } // PIXEL24
-
- break;
-
- case PIXEL32: {
-
- PLONG pixels, hPixels, pData;
- LONG pix, hPix, mask = 0x0FFF, rmask = 0xFFFFFFFF, mult;
- DWORD dataSize;
-
- pixels = ( PLONG )MALLOC( 0x1000 * sizeof ( LONG ) );
- hPixels = ( PLONG )MALLOC( 0x1000 * sizeof ( LONG ) );
-
- if ( pixels != NULL && hPixels != NULL ) {
-
- FillMemory ( ( PVOID )pixels, 0x1000 * sizeof ( LONG ), ~0 );
- FillMemory ( ( PVOID )hPixels, 0x1000 * sizeof ( LONG ), ~0 );
-
- pData = ( PLONG )data;
-
- bytes_per_line = width * sizeof ( LONG );
- bytes_per_line += PAD( bytes_per_line );
- dataSize = bytes_per_line * height;
-
- mult = dataSize / sizeof ( LONG ) / RAND_MAX;
-
- if ( mult == 0 ) {
-
- mult = 1;
- rmask = dataSize / sizeof ( LONG ) - 1;
-
- } // end if
-
- for ( i = j = 0, k = gDev -> NumColors ();
- i < ( int )( dataSize / sizeof ( LONG ) );
- ++i
- ) {
-
- pix = pData[ ( rand () * mult ) & rmask ];
- hPix = ( ( pix >> 12 ) ^ pix ) & mask;
-
- if ( pixels[ hPix ] == ~0 || hPixels[ hPix ] != pix ) {
-
- gDev -> SetColor ( pix );
-
- if ( ++j > k ) break;
-
- hPixels[ hPix ] = pixels[ hPix ] = pix;
-
- } // end if
-
- } // end for
-
- FREE( hPixels );
- FREE( pixels );
-
- } // end if
-
- } // PIXEL32
-
- } // end switch
-
-} // end _alloc_colors
-
-_init :: _init () {
-
- TCHAR cimgType[ 17 ];
-
- WNT_osVer.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO );
-
- GetVersionEx ( &WNT_osVer );
-
- if ( hHeap == NULL ) {
-
- SYSTEM_INFO si;
-
- GetSystemInfo ( &si );
-
- hHeap = HeapCreate ( HEAP_GENERATE_EXCEPTIONS, si.dwPageSize, 0 );
-
- } // end if
-
- if ( WNT_osVer.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
-#ifndef UNICODE
- LPSTR lpNTproc[] = { "OpenWindowStationA", "SetProcessWindowStation",
- "OpenDesktopA" , "SetThreadDesktop" ,
- "CloseDesktop" , "CloseWindowStation"
- };
-#else
- LPSTR lpNTproc[] = { "OpenWindowStationW", "SetProcessWindowStation",
- "OpenDesktopW" , "SetThreadDesktop" ,
- "CloseDesktop" , "CloseWindowStation"
- };
-#endif // UNICODE
- FARPROC* fpNTproc[] = { ( FARPROC* )&NTOpenWindowStation, ( FARPROC* )&NTSetProcessWindowStation,
- ( FARPROC* )&NTOpenDesktop, ( FARPROC* )&NTSetThreadDesktop,
- ( FARPROC* )&NTCloseDesktop, ( FARPROC* )&NTCloseWindowStation
- };
- HMODULE hUser32 = GetModuleHandle ( TEXT( "USER32" ) );
-
- for ( int i = 0; i < ( sizeof ( lpNTproc ) / sizeof ( lpNTproc[ 0 ] ) ); ++i )
-
- *fpNTproc[ i ] = GetProcAddress ( hUser32, lpNTproc[ i ] );
-
- } // end if
-
- ZeroMemory ( cimgType, sizeof ( cimgType ) );
-
- if ( GetEnvironmentVariable (
- TEXT( "CSF_DefaultImageFormat" ), cimgType, sizeof ( imgType )
- ) == 0
- ) lstrcpy ( cimgType, TEXT( "GIF" ) );
-
- imgType = _image_type ( cimgType, TRUE );
-
-} // end constructor
-
-_init :: ~_init () {
-
- if ( hHeap != NULL ) {
-
- HeapDestroy ( hHeap );
- hHeap = NULL;
-
- } // end if
-
-} // end destructor
-
-static WNT_TypeOfImage __fastcall _image_type ( LPTSTR ext, BOOL fInit ) {
-
- WNT_TypeOfImage retVal;
-
- if ( !lstrcmpi ( ext, TEXT( "BMP" ) ) )
-
- retVal = WNT_TOI_BMP;
-
- else if ( !lstrcmpi ( ext, TEXT( "XWD" ) ) )
-
- retVal = WNT_TOI_XWD;
-
- else if ( fInit )
-
- retVal = WNT_TOI_GIF;
-
- else {
-
- retVal = imgType;
-
- if ( lstrcmpi ( ext, TEXT( "GIF" ) ) )
-
- switch ( retVal ) {
-
- case WNT_TOI_BMP:
-
- lstrcpy ( ext, TEXT( "bmp" ) );
-
- break;
-
- case WNT_TOI_XWD:
-
- lstrcpy ( ext, TEXT( "xwd" ) );
-
- break;
-
- default:
-
- lstrcpy ( ext, TEXT( "gif" ) );
-
- } // end switch
-
- } // end else
-
- return retVal;
-
-} // end _image_type
#include <windows.h>
#include <WNT_WClass.ixx>
+#include <Standard_PCharacter.hxx>
#include <InterfaceGraphic_WNT.hxx>
#include <string.h>
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
--- Modified: FMN - 23/01/98 -> Add DoMapping
--- Modified : GG 28/01/00 G004
--- Add gamma correction computation just before dumping an image.
--- GG 07/03/00 G004 Add MMSize() method
--- TCL 26/10/00 G002 SetBackground(aName: CString) method
--- GG - RIC120302 Add NEW HParentWindow methods.
--- SAV 24/11/01 SetBackground(Quantity_Color)
-
class Window from WNT inherits Window from Aspect
---Purpose: This class defines Windows NT window
- -- Warning: The position and size for the creation of the window
- -- are defined in Device Screen Unit (DSU)
- -- floating [0,1] space.
- --
- -- As 3D view window is the main purpose of this class,
- -- and 3D view does not need its background to be drawn
- -- by the system, by default the window background is not drawn.
- -- This can be overridden by calling ClearFlags( WDF_NOERASEBKGRND ).
- -- See also WNT_WndProc.cxx and InterfaceGraphic_WNT.hxx.
uses
Handle from Aspect,
- Background from Aspect,
- GradientBackground from Aspect,
TypeOfResize from Aspect,
- FillMethod from Aspect,
- GradientFillMethod from Aspect,
- PixMap from Image,
NameOfColor from Quantity,
Color from Quantity,
- Parameter from Quantity,
Ratio from Quantity,
- GraphicDevice from WNT,
WClass from WNT,
Uint from WNT,
Long from WNT,
Dword from WNT,
- WindowData from WNT,
- Icon from WNT,
- ImageManager from WNT,
- TypeOfImage from WNT
+ WindowData from WNT
raises
WindowError from Aspect
is
-
- Create (
- aDevice : GraphicDevice from WNT;
- aTitle : CString from Standard;
- aClass : WClass from WNT;
- aStyle : Dword from WNT = 0;
- Xc : Parameter from Quantity = 0.5;
- Yc : Parameter from Quantity = 0.5;
- aWidth : Parameter from Quantity = 0.5;
- aHeight : Parameter from Quantity = 0.5;
- aBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY;
- aParent : Handle from Aspect = 0;
- aMenu : Handle from Aspect = 0;
- aClientStruct : Address from Standard = 0
- )
- returns mutable Window from WNT
- ---Level: Public
- ---Purpose: Creates a Window defined by his Center and his Size
- -- in DSU from the Parent Window. If <aParent> is 0 then
- -- creates a window without parent.
- -- Creation of an WNT_Window automatically determines the
- -- smaller dimension of the screen (usually the height)
- -- and parametrises it as 1.0.
- -- The smaller dimension of the window is limited to 1.0
- -- We can give a value greater than 1.0 to the larger
- -- dimension.
- -- No matter how large the values passed in argument, the
- -- window is automatically limited to the maximum size of
- -- the screen.
- -- The ratio of width to height of a conventional screen is
- -- of the order of 1.3.
- -- Trigger: Raises WindowDefinitionError if the Position out of the
- -- Screen Space or the window creation failed.
- raises WindowDefinitionError from Aspect;
-
- Create (theDevice : GraphicDevice from WNT;
- theTitle : CString from Standard;
+
+ Create (theTitle : CString from Standard;
theClass : WClass from WNT;
theStyle : Dword from WNT;
thePxLeft : Integer from Standard;
raises WindowDefinitionError from Aspect;
Create (
- aDevice : GraphicDevice from WNT;
aHandle : Handle from Aspect;
aBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY
)
-- This handle equals ( aPart1 << 16 ) + aPart2.
Create (
- aDevice : GraphicDevice from WNT;
aPart1 : Integer from Standard;
aPart2 : Integer from Standard;
aBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY
-- Category: Methods to modify the class definition
---------------------------------------------------
-
- SetBackground (
- me : mutable;
- Background : Background from Aspect
- )
- is virtual;
- ---Level: Public
- ---Purpose: Modifies the window background.
-
- SetBackground (
- me : mutable;
- BackColor : NameOfColor from Quantity
- )
- is virtual;
- ---Level: Public
- ---Purpose: Modifies the window background.
-
- SetBackground (
- me : mutable;
- color : Color from Quantity
- )
- is virtual;
- ---Level: Public
- ---Purpose: Modifies the window background.
-
-
- SetBackground (
- me : mutable;
- aBackPixmap : Handle from Aspect
- ) is static;
- ---Level: Public
- ---Purpose: Modifies the window background.
-
- SetBackground (
- me : mutable;
- aName : CString from Standard ;
- aMethod: FillMethod from Aspect = Aspect_FM_CENTERED
- ) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Loads the window background from an image file <aName>
- -- defined with a supported format XWD,GIF or BMP
- -- and returns TRUE if the operation is successfull.
- -- Category: Methods to modify the class definition
-
- SetBackground ( me : mutable ;
- Background : GradientBackground from Aspect ) is virtual;
- ---Level: Public
- ---Purpose: Modifies the window gradient background.
- -- Warning: the gradient background colours is ignored when the quality
- -- of this window is TRANSPARENT.
- ---Category: Methods to modify the class definition
-
- SetBackground( me : mutable;
- aCol1 : Color from Quantity;
- aCol2 : Color from Quantity;
- aMethod : GradientFillMethod from Aspect = Aspect_GFM_HOR);
- ---Level: Public
- ---Purpose: Modifies the window gradient background.
- -- Warning: the gradient background colours are ignored when the quality
- -- of this window is TRANSPARENT.
- ---Category: Methods to modify the class definition
-
SetCursor ( me; aCursor : Handle from Aspect )
is static;
---Level: Public
---Purpose: Sets cursor <aCursor> for ENTIRE WINDOW CLASS to which
-- the Window belongs.
- SetIcon (
- me : mutable;
- anIcon : Handle from Aspect;
- aName : CString from Standard = 0
- )
- is static;
- ---Level: Public
- ---Purpose: Sets icon <anIcon> for window
-
- SetIconName ( me : mutable; aName : CString from Standard )
- is static;
- ---Level: Public
- ---Purpose: Sets name for window's icon
-
- SetDoubleBuffer (
- me : mutable;
- DBmode : Boolean from Standard
- )
- ---Level: Public
- ---Purpose: Activates/Deactivates the Double Buffering capability
- -- for this window.
- -- Warning: Double Buffering is always DISABLE by default.
- -- Trigger: Raises if BackingStore () isn't allowed for this Window
- raises WindowError from Aspect is virtual;
-
- Flush ( me )
- ---Level: Public
- ---Purpose: Flushes all graphics to the screen and Swap the Double
- -- buffer if Enable
- -- Trigger: Raises if Something is WRONG at Drawing Time.
- raises WindowError from Aspect is virtual;
-
Map ( me )
is virtual;
---Level: Public
-- and returns TRUE if the window is mapped at screen.
---Category: Methods to modify the class definition
-
- Clear ( me )
- is virtual;
- ---Level: Public
- ---Purpose: Clears the Window in the Background color.
-
- ClearArea (
- me;
- Xc : Integer from Standard;
- Yc : Integer from Standard;
- Width : Integer from Standard;
- Height : Integer from Standard
- )
- ---Level: Public
- ---Purpose: Clears the Window Area defined by his center and PIXEL
- -- size in the Background color
- -- Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is virtual;
-
- Restore ( me )
- ---Level: Public
- ---Purpose: Restores The Window from the BackingStored Window
- -- See BackingStore () method.
- raises WindowError from Aspect is virtual;
-
- RestoreArea (
- me;
- Xc : Integer from Standard;
- Yc : Integer from Standard;
- Width : Integer from Standard;
- Height : Integer from Standard
- )
- ---Level: Public
- ---Purpose: Restores The Window Area defined by his center
- -- and PIXEL size from the BackingStored Window
- -- See BackingStore () method.
- raises WindowError from Aspect is virtual;
-
- Dump (
- me;
- aFilename : CString from Standard;
- aGammaValue: Real from Standard = 1.0
- )
- returns Boolean
- ---Level: Public
- ---Purpose: Dumps the Window to an XWD,GIF or BMP filei with
- -- an optional gamma correction value according to the graphic system.
- -- and returns TRUE if the dump occurs normaly.
- -- Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is virtual;
-
- DumpArea (
- me;
- aFilename : CString from Standard;
- Xc : Integer from Standard;
- Yc : Integer from Standard;
- Width : Integer from Standard;
- Height : Integer from Standard;
- aGammaValue: Real from Standard = 1.0
- )
- returns Boolean from Standard
- ---Level: Public
- ---Purpose: Dumps the Window Area defined by his center and PIXEL size
- -- to an image file with an optional gamma correction value
- -- and returns TRUE if the dump occurs normaly.
- -- Trigger: Raises if Window is not defined properly
- -- or the area is out of the Window.
- raises WindowError from Aspect is virtual;
-
- ToPixMap ( me ; theImage : in out PixMap from Image )
- returns Boolean
- ---Level : Public
- ---Purpose : dump the full contents of the window to a pixmap.
- is virtual;
-
- Load ( me; aFilename : CString from Standard )
- returns Boolean from Standard
- ---Level: Public
- ---Purpose: Loads the XWD file to this Window.
- -- Returns TRUE if the loading occurs normaly.
- -- Warning: Note that the Window is enlarged automatically
- -- when the image size is too large for this window.
- -- Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is virtual;
-
- LoadArea (
- me;
- aFilename : CString from Standard;
- Xc : Integer from Standard;
- Yc : Integer from Standard;
- Width : Integer from Standard;
- Height : Integer from Standard
- )
- returns Boolean from Standard
- ---Purpose: Loads the XWD file to Window Area defined by his center
- -- and PIXEL size.
- -- Returns TRUE if the loading occurs normaly.
- -- Warning: Note that the Image is zoomed automatically
- -- when the image size is too large for this window area.
- -- Trigger: Raises if Window is not defined properly
- -- or the area is out of the Window.
- raises WindowError from Aspect is virtual;
-
- SetOutputFormat ( me : mutable; aFormat : TypeOfImage from WNT )
- is static;
- ---Level: Public
- ---Purpose: Sets format of the image file created by Dump or
- -- DumpArea methods.
-
SetPos ( me : mutable; X, Y, X1, Y1 : Integer from Standard )
is static;
---Level: Internal
-- Category: Inquire methods
----------------------------
-
- BackingStore ( me )
- returns Boolean from Standard is virtual;
- ---Level: Public
- ---Purpose: Returns the BackingStore capability for this Window.
- -- If Answer is True Exposure can be recovered by
- -- Restore RestoreArea methods.
- -- If Answer is False, Application must Redraw the
- -- exposed area.
-
- DoubleBuffer ( me )
- returns Boolean from Standard is virtual;
- ---Level: Public
- ---Purpose: Returns the DoubleBuffer state.
- ---C++: inline
-
IsMapped ( me )
returns Boolean from Standard is virtual;
---Level: Public
---Purpose: Returns The Window RATIO equal to the physical
-- WIDTH/HEIGHT dimensions.
- Position (
- me;
- X1 : out Parameter from Quantity;
- Y1 : out Parameter from Quantity;
- X2 : out Parameter from Quantity;
- Y2 : out Parameter from Quantity
- )
- is virtual;
- ---Level: Public
- ---Purpose: Returns The Window POSITION in DSU
-
Position (
me;
X1 : out Integer from Standard;
---Level: Public
---Purpose: Returns The Window POSITION in PIXEL
- Size (
- me;
- Width : out Parameter from Quantity;
- Height : out Parameter from Quantity
- )
- is virtual;
- ---Level: Public
- ---Purpose: Returns The Window SIZE in DSU
-
Size (
me;
Width : out Integer from Standard;
---Level: Public
---Purpose: Returns The Window SIZE in PIXEL
- MMSize (
- me;
- Width : out Real from Standard;
- Height : out Real from Standard
- )
- is virtual;
- ---Level: Public
- ---Purpose: Returns The Window SIZE in MM
-
- Convert (
- me;
- PV : Integer from Standard
- )
- returns Parameter from Quantity is virtual;
- ---Level: Public
- ---Purpose: Returns the DSU value depending of the PIXEL value.
-
- Convert (
- me;
- DV : Parameter from Quantity
- )
- returns Integer from Standard is virtual;
- ---Level: Public
- ---Purpose: Returns the PIXEL value depending of the DSU value.
-
- Convert (
- me;
- PX, PY : Integer from Standard;
- DX, DY : out Parameter from Quantity
- )
- is virtual;
- ---Level: Public
- ---Purpose: Returns the DSU position depending of the PIXEL position.
-
- Convert (
- me;
- DX, DY : Parameter from Quantity;
- PX, PY : out Integer from Standard
- )
- is virtual;
- ---Level: Public
- ---Purpose: Returns the PIXEL position depending of the DSU position.
-
HWindow ( me )
returns Handle from Aspect is static;
---Level: Public
---Purpose: Returns the Windows NT handle parent of the created window <me>.
---C++: inline
- HPixmap ( me )
- returns Handle from Aspect is static;
- ---Level: Internal
- ---Purpose: Returns the Windows NT double buffer pixmap handle
- -- of the created window <me>.
- -- If BackingStore () is permitted.
- ---C++: inline
-
- WndProc ( me )
- returns Address from Standard;
- ---Level: Internal
- ---Purpose: Returns address of the window procedure.
- ---C++: inline
-
- ImageManager ( me )
- returns ImageManager from WNT is static;
- ---Level: Internal
- ---Purpose: Returns ImageManager of the Window.
- ---C++: inline
-
doCreate (
me : mutable;
- aDevice : GraphicDevice from WNT;
aHandle : Handle from Aspect;
aBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY
) is static private;
myWClass : WClass from WNT is protected; -- Window class
myHWindow : Handle from Aspect is protected; -- Window handle
myHParentWindow : Handle from Aspect is protected; -- Parent window handle
- myHPixmap : Handle from Aspect is protected; -- Bitmap handle
- myDoubleBuffer : Boolean from Standard is protected; -- DoubleBuffer flag
myExtraData : WindowData from WNT is protected; -- additional data
- myFormat : TypeOfImage from WNT is protected; -- type of output image
- myImages : ImageManager from WNT is protected;
- myIcon : Icon from WNT is protected;
- myWndProc : Address from Standard is protected; -- address of window procedure
myUsrData : Address from Standard is protected;
- friends
-
- class IconBox from WNT
-
end Window;
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-// Modifications: PLOTNIKOV Eugeny at July 1998 (BUC60286)
-// TCL at October 2000 (G002)
-// new method SetBackground(CString aName)
-
// include windows.h first to have all definitions available
#include <windows.h>
extern LRESULT CALLBACK WNT_WndProc (
HWND, UINT, WPARAM, LPARAM
);
-//***//
-#define SELECT_PALETTE(hDC) \
- HPALETTE hOldPal; \
- \
- if ( myExtraData.hPal ) { \
- \
- hOldPal = SelectPalette ( hDC, myExtraData.hPal, FALSE ); \
- \
- if ( RealizePalette ( hDC ) ) \
- \
- UpdateColors ( hDC ); \
- \
- } // end if
-//***//
-#define UNSELECT_PALETTE(hDC) \
- if ( myExtraData.hPal ) \
- \
- SelectPalette ( hDC, hOldPal, FALSE );
-
-HBITMAP LoadImageFromFile ( Handle( WNT_GraphicDevice )&, char*, HDC = NULL );
-
-//***//
-//************************* Constructor **********************************//
-//***//
-// TODO - Here is enough of duplicated code in 1st and second constructors!
-WNT_Window::WNT_Window (const Handle(WNT_GraphicDevice)& theDevice,
- const Standard_CString theTitle,
- const Handle(WNT_WClass)& theClass,
- const WNT_Dword& theStyle,
- const Quantity_Parameter theXc,
- const Quantity_Parameter theYc,
- const Quantity_Parameter theWidth,
- const Quantity_Parameter theHeight,
- const Quantity_NameOfColor theBackColor,
- const Aspect_Handle theParent,
- const Aspect_Handle theMenu,
- const Standard_Address theClientStruct)
-: Aspect_Window (theDevice),
- myWClass (theClass)
-{
- ZeroMemory (&myExtraData, sizeof (WNT_WindowData));
- DWORD dwStyle = theStyle;
- const Handle(WNT_GraphicDevice)& aDev = Handle(WNT_GraphicDevice)::DownCast (MyGraphicDevice);
-
- if (theXc < 0.0 || theXc > 1.0 || theYc < 0.0 || theYc > 1.0 ||
- theWidth <= 0.0 || theHeight <= 0.0)
- {
- Aspect_WindowDefinitionError::Raise ("Coordinate(s) out of range");
- }
-
- Standard_Integer aParentSizeX, aParentSizeY;
- if (theParent)
- {
- RECT aRect;
- GetClientRect ((HWND )theParent, &aRect);
- aParentSizeX = aRect.right;
- aParentSizeY = aRect.bottom;
- }
- else
- {
- aDev->DisplaySize (aParentSizeX, aParentSizeY);
- }
-
- Standard_Integer aPxWidth, aPxHeight;
- Aspect_Convert::ConvertCoordinates (aParentSizeX, aParentSizeY,
- theXc, theYc, theWidth, theHeight,
- aXLeft, aYTop, aPxWidth, aPxHeight);
- Aspect_Convert::FitIn (aParentSizeX, aParentSizeY,
- aXLeft, aYTop, aPxWidth, aPxHeight);
- aXRight = aXLeft + aPxWidth;
- aYBottom = aYTop + aPxHeight;
-
- if (theParent && !(theStyle & WS_CHILD))
- {
- dwStyle |= WS_CHILD | WS_CLIPSIBLINGS;
- }
- else if (!theParent && !(theStyle & WS_CLIPCHILDREN))
- {
- dwStyle |= WS_CLIPCHILDREN;
- }
-
- // include decorations in the window dimensions
- // to reproduce same behaviour of Xw_Window.
- RECT aRect;
- aRect.top = aYTop;
- aRect.bottom = aYBottom;
- aRect.left = aXLeft;
- aRect.right = aXRight;
- AdjustWindowRect (&aRect, dwStyle, theMenu != NULL ? TRUE : FALSE);
- aXLeft = aRect.left;
- aYTop = aRect.top;
- aXRight = aRect.right;
- aYBottom = aRect.bottom;
- myHWindow = CreateWindow (
- myWClass->Name(), // window's class name
- theTitle, // window's name
- dwStyle, // window's style
- aXLeft, aYTop, // window's coordinates
- (aXRight - aXLeft), (aYBottom - aYTop),
- (HWND )theParent, // window's parent
- (HMENU )theMenu, // window's menu
- (HINSTANCE )myWClass->Instance(), // application's instance
- theClientStruct); // pointer to CLIENTCREATESTRUCT
- if (!myHWindow)
- {
- Aspect_WindowDefinitionError::Raise ("Unable to create window");
- }
-
- myDoubleBuffer = Standard_False;
- myHPixmap = 0;
- myHParentWindow = theParent;
- myWndProc = myWClass->WndProc();
- SetBackground (theBackColor);
- SetWindowLongPtr ((HWND )myHWindow, GWLP_WNDPROC, (LONG_PTR )WNT_WndProc);
- myUsrData = (Standard_Address )SetWindowLongPtr ((HWND )myHWindow, GWLP_USERDATA, (LONG_PTR )&myExtraData);
-
- myExtraData.WNT_Window_Ptr = (void* )this;
- myExtraData.hPal = (HPALETTE )aDev->HPalette();
-
- myImages = new WNT_ImageManager (this);
- myFormat = WNT_TOI_XWD;
-
- SetFlags(WDF_NOERASEBKGRND);
-}
-
-WNT_Window::WNT_Window (const Handle(WNT_GraphicDevice)& theDevice,
- const Standard_CString theTitle,
+WNT_Window::WNT_Window (const Standard_CString theTitle,
const Handle(WNT_WClass)& theClass,
const WNT_Dword& theStyle,
const Standard_Integer thePxLeft,
const Aspect_Handle theParent,
const Aspect_Handle theMenu,
const Standard_Address theClientStruct)
-: Aspect_Window (theDevice),
+: Aspect_Window(),
aXLeft (thePxLeft),
aYTop (thePxTop),
aXRight (thePxLeft + thePxWidth),
{
ZeroMemory (&myExtraData, sizeof (WNT_WindowData));
DWORD dwStyle = theStyle;
- const Handle(WNT_GraphicDevice)& aDev = Handle(WNT_GraphicDevice)::DownCast (MyGraphicDevice);
if (thePxWidth <= 0 || thePxHeight <= 0)
{
Aspect_WindowDefinitionError::Raise ("Unable to create window");
}
- myDoubleBuffer = Standard_False;
- myHPixmap = 0;
myHParentWindow = theParent;
- myWndProc = myWClass->WndProc();
SetBackground (theBackColor);
- SetWindowLongPtr ((HWND )myHWindow, GWLP_WNDPROC, (LONG_PTR )WNT_WndProc);
+
myUsrData = (Standard_Address )SetWindowLongPtr ((HWND )myHWindow, GWLP_USERDATA, (LONG_PTR )&myExtraData);
myExtraData.WNT_Window_Ptr = (void* )this;
- myExtraData.hPal = (HPALETTE )aDev->HPalette();
-
- myImages = new WNT_ImageManager (this);
- myFormat = WNT_TOI_XWD;
- SetFlags (WDF_NOERASEBKGRND);
+ SetFlags (WDF_NOERASEBKGRND);
}
//***//
//************************* Constructor **********************************//
//***//
WNT_Window :: WNT_Window (
- const Handle( WNT_GraphicDevice )& aDevice,
const Aspect_Handle aHandle,
const Quantity_NameOfColor aBackColor
- ) : Aspect_Window ( aDevice ) {
-
- doCreate ( aDevice, aHandle, aBackColor );
+ ) : Aspect_Window()
+{
+ doCreate (aHandle, aBackColor);
- /* Bug OCC20596 */
- SetFlags(WDF_NOERASEBKGRND);
+ /* Bug OCC20596 */
+ SetFlags(WDF_NOERASEBKGRND);
} // end constructor
//***//
//************************* Constructor **********************************//
//***//
WNT_Window :: WNT_Window (
- const Handle( WNT_GraphicDevice )& aDevice,
const Standard_Integer aPart1,
const Standard_Integer aPart2,
const Quantity_NameOfColor aBackColor
- ) : Aspect_Window ( aDevice ) {
-
- Aspect_Handle aHandle = ( Aspect_Handle )( ( aPart1 << 16 ) + aPart2 );
+ ) : Aspect_Window()
+{
+ Aspect_Handle aHandle = ( Aspect_Handle )( ( aPart1 << 16 ) + aPart2 );
- doCreate ( aDevice, aHandle, aBackColor );
+ doCreate (aHandle, aBackColor);
- /* Bug OCC20596 */
- SetFlags(WDF_NOERASEBKGRND);
+ /* Bug OCC20596 */
+ SetFlags(WDF_NOERASEBKGRND);
} // end constructor
//***//
//***************************** Destroy **********************************//
//***//
-void WNT_Window :: Destroy () {
-
- if ( MyHBackground ) DeleteObject ( MyHBackground ); // delete background brush
- if ( myHPixmap ) DeleteObject ( myHPixmap ); // . . . and double buffer pixmap if exists
-
- if ( myHWindow ) {
-
- if (myUsrData != Standard_Address(-1))
- {
- SetWindowLongPtr ((HWND )myHWindow, GWLP_USERDATA, (LONG_PTR )myUsrData);
- }
-
- if (myWndProc != NULL)
+void WNT_Window :: Destroy ()
+{
+ if (myHWindow)
{
- SetWindowLongPtr ((HWND )myHWindow, GWLP_WNDPROC, (LONG_PTR )myWndProc);
- }
-
- if ( !( myExtraData.dwFlags & WDF_FOREIGN ) )
-
- DestroyWindow ( ( HWND )myHWindow );
-
- } // end if
-
+ if (myUsrData != Standard_Address(-1))
+ {
+ SetWindowLongPtr ((HWND )myHWindow, GWLP_USERDATA, (LONG_PTR )myUsrData);
+ }
+
+ if (!( myExtraData.dwFlags & WDF_FOREIGN))
+ {
+ DestroyWindow ((HWND )myHWindow);
+ }
+ } // end if
} // end WNT_Window :: Destroy
-//***//
-//************************ SetBackground (1) *****************************//
-//***//
-void WNT_Window :: SetBackground ( const Aspect_Background& Background ) {
-
- SetBackground ( Background.Color ().Name () );
-
-} // end WNT_Window :: SetBackground
-//***//
-//************************ SetBackground (2) *****************************//
-//***//
-void WNT_Window :: SetBackground ( const Quantity_NameOfColor BackColor ) {
-
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- if ( MyHBackground )
- DeleteObject ( MyHBackground );
-
- MyBackground.SetColor ( BackColor );
- MyHBackground = CreateSolidBrush (
- dev -> SetColor ( MyBackground.Color () )
- );
-
-} // end WNT_Window :: SetBackground
-//***//
-//************************ SetBackground (3) *****************************//
-//***//
-void WNT_Window :: SetBackground ( const Aspect_Handle aBackPixmap ) {
-
- Aspect_Handle bitmap = CreatePatternBrush ( ( HBITMAP )aBackPixmap );
-
- if( bitmap ) {
- if ( MyHBackground ) DeleteObject ( MyHBackground );
- MyHBackground = bitmap;
- MyBackgroundImage.Clear();
- MyBackgroundFillMethod = Aspect_FM_NONE;
- }
-
-} // end WNT_Window :: SetBackground
-//***//
-//************************ SetBackground (4) *****************************//
-//***//
-Standard_Boolean WNT_Window::SetBackground( const Standard_CString aName,
- const Aspect_FillMethod aMethod ) {
- Standard_Boolean status = Standard_False;
-
- if( !aName ) return Standard_False;
-
- Handle( WNT_GraphicDevice ) gdev =
- *( ( Handle_WNT_GraphicDevice * )& MyGraphicDevice );
- if ( MyHBackground )
- DeleteObject( MyHBackground );
- MyHBackground = 0;
-
- HBITMAP hBmp = LoadImageFromFile( gdev, (Standard_PCharacter)aName );
-
- if( hBmp ) {
- status = Standard_True;
- MyBackgroundImage = aName;
- MyBackgroundFillMethod = aMethod;
- MyHBackground = CreatePatternBrush( hBmp );
- }
-
- return status;
-} // end WNT_Window :: SetBackground
- //***//
-//************************ SetBackground (5) *****************************//
-//***//
-void WNT_Window::SetBackground( const Quantity_Color& color ) {
-
- const Handle( WNT_GraphicDevice )& dev =
- Handle( WNT_GraphicDevice )::DownCast ( MyGraphicDevice );
-
- if ( MyHBackground )
- DeleteObject( MyHBackground );
-
- MyBackground.SetColor( color );
- MyHBackground = CreateSolidBrush( dev->SetColor( color ) );
-
-} // end WNT_Window :: SetBackground
-
-//************************ SetBackground (6) *****************************//
-//***//
-void WNT_Window::SetBackground (const Aspect_GradientBackground& GrBackground) {
-
- Quantity_Color Color1, Color2;
- GrBackground.Colors(Color1,Color2);
- SetBackground(Color1,Color2, GrBackground.BgGradientFillMethod());
-
-} // end WNT_Window :: SetBackground
-
-//************************ SetBackground (7) *****************************//
-//***//
-void WNT_Window::SetBackground( const Quantity_Color& color1,
- const Quantity_Color& color2,
- const Aspect_GradientFillMethod aMethod){
-
- Standard_Integer bcolor = Standard_Integer( color1.Name() ) + Standard_Integer( color2.Name() );
- if( ( bcolor >= 0 ) )
- MyGradientBackground.SetColors( color1, color2, aMethod ) ;
-} // end WNT_Window :: SetBackground
//**************************** SetCursor *********************************//
//***//
#endif
} // end WNT_Window :: SetCursor
-//***//
-//**************************** SetIcon ***********************************//
-//***//
-void WNT_Window :: SetIcon (
- const Aspect_Handle anIcon,
- const Standard_CString aName
- ) {
-
- if ( !myIcon.IsNull () )
-
- myIcon.Nullify ();
- myIcon = new WNT_Icon ( aName, anIcon, 0 );
-
-} // end WNT_Window :: SetIcon
-//***//
-//**************************** SetIconName *******************************//
-//***//
-void WNT_Window :: SetIconName ( const Standard_CString aName ) {
-
- myIcon -> SetName ( aName );
-
-} // end WNT_Window :: SetIconName
-//***//
-//************************** SetDoubleBuffer *****************************//
-//***//
-void WNT_Window :: SetDoubleBuffer ( const Standard_Boolean DBmode ) {
-
- if ( DBmode )
-
- if ( !BackingStore () )
-
- Aspect_WindowError :: Raise ( "Unable to set double buffer" );
-
- else {
-
- myDoubleBuffer = Standard_True;
- myExtraData.hBmp = ( HBITMAP )myHPixmap;
-
- } // end else
-
- else {
-
- myDoubleBuffer = Standard_False;
- myExtraData.hBmp = NULL;
-
- } // end else
-
-} // end WNT_Window :: SetDoubleBuffer
-//***//
-//***************************** Flush ************************************//
-//***//
-void WNT_Window :: Flush () const {
-
- if ( myDoubleBuffer ) Restore ();
-
-} // end WNT_Window :: Flush
//***//
//***************************** IsMapped *********************************//
//***//
return !( wp.showCmd == SW_HIDE || wp.showCmd == SW_MINIMIZE );
} // WNT_Window :: IsMapped
+
//***//
//***************************** Map (1) **********************************//
//***//
}
Map ( SW_SHOW );
} // end WNT_Window :: Map
+
//***//
//***************************** Map (2) **********************************//
//***//
UpdateWindow ( ( HWND )myHWindow );
} // end WNT_Window :: Map
+
//***//
//**************************** Unmap *************************************//
//***//
Map ( SW_HIDE );
} // end WNT_Window :: Unmap
+
//***//
//**************************** DoResize **********************************//
//***//
-Aspect_TypeOfResize WNT_Window :: DoResize () const {
-
- int mask = 0;
- Aspect_TypeOfResize mode = Aspect_TOR_UNKNOWN;
- WINDOWPLACEMENT wp;
-
- wp.length = sizeof ( WINDOWPLACEMENT );
- GetWindowPlacement ( ( HWND )myHWindow, &wp );
-
- if ( wp.showCmd != SW_SHOWMINIMIZED ) {
-
- if ( Abs ( wp.rcNormalPosition.left - aXLeft ) > 2 ) mask |= 1;
- if ( Abs ( wp.rcNormalPosition.right - aXRight ) > 2 ) mask |= 2;
- if ( Abs ( wp.rcNormalPosition.top - aYTop ) > 2 ) mask |= 4;
- if ( Abs ( wp.rcNormalPosition.bottom - aYBottom ) > 2 ) mask |= 8;
-
- switch ( mask ) {
-
- case 0:
-
- mode = Aspect_TOR_NO_BORDER;
-
- break;
-
- case 1:
-
- mode = Aspect_TOR_LEFT_BORDER;
-
- break;
-
- case 2:
-
- mode = Aspect_TOR_RIGHT_BORDER;
-
- break;
-
- case 4:
-
- mode = Aspect_TOR_TOP_BORDER;
-
- break;
-
- case 5:
-
- mode = Aspect_TOR_LEFT_AND_TOP_BORDER;
-
- break;
-
- case 6:
-
- mode = Aspect_TOR_TOP_AND_RIGHT_BORDER;
-
- break;
-
- case 8:
-
- mode = Aspect_TOR_BOTTOM_BORDER;
-
- break;
-
- case 9:
-
- mode = Aspect_TOR_BOTTOM_AND_LEFT_BORDER;
-
- break;
-
- case 10:
-
- mode = Aspect_TOR_RIGHT_AND_BOTTOM_BORDER;
-
- break;
-
- default:
-
- break;
-
- } // end switch
-
- *( ( Standard_Integer* )&aXLeft ) = wp.rcNormalPosition.left;
- *( ( Standard_Integer* )&aXRight ) = wp.rcNormalPosition.right;
- *( ( Standard_Integer* )&aYTop ) = wp.rcNormalPosition.top;
- *( ( Standard_Integer* )&aYBottom ) = wp.rcNormalPosition.bottom;
-
- if ( myDoubleBuffer ) {
-
- DeleteObject ( myHPixmap );
- *( ( Aspect_Handle* )&myHPixmap ) = 0;
-
- if ( !BackingStore () )
-
- Aspect_WindowError :: Raise ( "WNT_Window::DoResize (): Unable to set double buffer" );
+Aspect_TypeOfResize WNT_Window :: DoResize () const
+{
+ int mask = 0;
+ Aspect_TypeOfResize mode = Aspect_TOR_UNKNOWN;
+ WINDOWPLACEMENT wp;
- } // end if
+ wp.length = sizeof ( WINDOWPLACEMENT );
+ GetWindowPlacement ( ( HWND )myHWindow, &wp );
- } // end if
+ if (wp.showCmd != SW_SHOWMINIMIZED)
+ {
+ if (Abs (wp.rcNormalPosition.left - aXLeft ) > 2) mask |= 1;
+ if (Abs (wp.rcNormalPosition.right - aXRight ) > 2) mask |= 2;
+ if (Abs (wp.rcNormalPosition.top - aYTop ) > 2) mask |= 4;
+ if (Abs (wp.rcNormalPosition.bottom - aYBottom) > 2) mask |= 8;
+
+ switch (mask)
+ {
+ case 0:
+ mode = Aspect_TOR_NO_BORDER;
+ break;
+ case 1:
+ mode = Aspect_TOR_LEFT_BORDER;
+ break;
+ case 2:
+ mode = Aspect_TOR_RIGHT_BORDER;
+ break;
+ case 4:
+ mode = Aspect_TOR_TOP_BORDER;
+ break;
+ case 5:
+ mode = Aspect_TOR_LEFT_AND_TOP_BORDER;
+ break;
+ case 6:
+ mode = Aspect_TOR_TOP_AND_RIGHT_BORDER;
+ break;
+ case 8:
+ mode = Aspect_TOR_BOTTOM_BORDER;
+ break;
+ case 9:
+ mode = Aspect_TOR_BOTTOM_AND_LEFT_BORDER;
+ break;
+ case 10:
+ mode = Aspect_TOR_RIGHT_AND_BOTTOM_BORDER;
+ break;
+ default:
+ break;
+ } // end switch
+
+ *((Standard_Integer* )&aXLeft ) = wp.rcNormalPosition.left;
+ *((Standard_Integer* )&aXRight ) = wp.rcNormalPosition.right;
+ *((Standard_Integer* )&aYTop ) = wp.rcNormalPosition.top;
+ *((Standard_Integer* )&aYBottom) = wp.rcNormalPosition.bottom;
+ }
- return mode;
+ return mode;
} // end WNT_Window :: DoResize
return Standard_True;
}
-//***//
-//**************************** Clear *************************************//
-//***//
-void WNT_Window :: Clear () const {
-
- RECT r;
-
- GetClientRect ( ( HWND )myHWindow, &r );
- ClearArea ( r.right / 2, r.bottom / 2, r.right, r.bottom );
-
-} // end WNT_Window :: Clear
-//***//
-//**************************** ClearArea *********************************//
-//***//
-void WNT_Window :: ClearArea (
- const Standard_Integer Xc,
- const Standard_Integer Yc,
- const Standard_Integer Width,
- const Standard_Integer Height
- ) const {
-
- RECT r;
- HDC hDC = GetDC ( ( HWND )myHWindow );
-
- r.left = Xc - Width / 2;
- r.right = r.left + Width;
- r.top = Yc - Height / 2;
- r.bottom = r.top + Height;
-
- if ( myDoubleBuffer && myHPixmap ) {
-
- HDC hDCmem = CreateCompatibleDC ( hDC );
-
- SELECT_PALETTE( hDCmem );
-
- SelectObject ( hDCmem, myHPixmap );
- FillRect ( hDCmem, &r, ( HBRUSH )MyHBackground );
-
- UNSELECT_PALETTE( hDCmem );
-
- DeleteDC ( hDCmem );
-
- } else {
-
- SELECT_PALETTE( hDC );
-
- FillRect ( hDC, &r, ( HBRUSH )MyHBackground );
-
- UNSELECT_PALETTE( hDC );
-
- } // end else
-
- ReleaseDC ( ( HWND )myHWindow, hDC );
-
-} // end WNT_Window :: ClearArea
-//***//
-//**************************** Restore ***********************************//
-//***//
-void WNT_Window :: Restore () const {
-
- RECT r;
-
- if ( myHPixmap ) {
-
- GetClientRect ( ( HWND )myHWindow, &r );
- RestoreArea (
- r.right / 2, r.bottom - r.bottom / 2, r.right, r.bottom
- );
-
- } // end if
-
-} // end WNT_Window :: Restore
-//***//
-//************************* Restore Area *********************************//
-//***//
-void WNT_Window :: RestoreArea (
- const Standard_Integer Xc,
- const Standard_Integer Yc,
- const Standard_Integer Width,
- const Standard_Integer Height
- ) const {
-
- HDC hDC, hDCmem;
- int x, y;
-
- if ( myHPixmap ) {
-
- hDC = GetDC ( ( HWND )myHWindow );
- hDCmem = CreateCompatibleDC ( hDC );
-
- x = Xc - Width / 2;
- y = Yc - Height / 2;
-
- SelectObject ( hDCmem, myHPixmap );
- BitBlt ( hDC, x, y, Width, Height, hDCmem, x, y, SRCCOPY );
-
- DeleteDC ( hDCmem );
- ReleaseDC ( ( HWND )myHWindow, hDC );
-
- } // end if
-
-} // end WNT_Window :: RestoreArea
-//***//
-//****************************** Dump ************************************//
-//***//
-Standard_Boolean WNT_Window::Dump (const Standard_CString theFilename,
- const Standard_Real theGammaValue) const
-{
- Image_AlienPixMap anImg;
- if (!ToPixMap (anImg) || anImg.IsEmpty())
- {
- return Standard_False;
- }
- if (Abs (theGammaValue - 1.0) > 0.001)
- {
- anImg.AdjustGamma (theGammaValue);
- }
- return anImg.Save (theFilename);
-} // end WNT_Window :: Dump
-//***//
-//*************************** DumpArea ***********************************//
-//***//
-Standard_Boolean WNT_Window::DumpArea (const Standard_CString theFilename,
- const Standard_Integer Xc, const Standard_Integer Yc,
- const Standard_Integer Width, const Standard_Integer Height,
- const Standard_Real aGammaValue) const
-{
-// *** Gamma correction must be implemented also under WNT ...
- Standard_Integer x = Xc - Width / 2;
- Standard_Integer y = Yc - Height / 2;
- return (myDoubleBuffer) ?
- myImages->SaveBuffer (theFilename, x, y, Width, Height) :
- myImages->Save (theFilename, x, y, Width, Height);
-
-} // end WNT_Window :: DumpArea
-//***//
-
static Standard_Boolean ConvertBitmap (HBITMAP theHBitmap,
Image_PixMap& thePixMap)
{
return isSuccess;
}
-Standard_Boolean WNT_Window::ToPixMap (Image_PixMap& thePixMap) const
-{
- if (myDoubleBuffer && myHPixmap)
- {
- return ConvertBitmap ((HBITMAP )myHPixmap, thePixMap);
- }
-
- RECT aRect;
- GetClientRect ((HWND )myHWindow, &aRect);
- int aWidth = aRect.right - aRect.left;
- int aHeight = aRect.bottom - aRect.top;
-
- // Prepare the DCs
- HDC aDstDC = GetDC (NULL);
- HDC aSrcDC = GetDC ((HWND )myHWindow); // we copy only client area
- HDC aMemDC = CreateCompatibleDC (aDstDC);
-
- // Copy the screen to the bitmap
- HBITMAP anHBitmapDump = CreateCompatibleBitmap (aDstDC, aWidth, aHeight);
- HBITMAP anHBitmapOld = (HBITMAP )SelectObject (aMemDC, anHBitmapDump);
- BitBlt (aMemDC, 0, 0, aWidth, aHeight, aSrcDC, 0, 0, SRCCOPY);
-
- Standard_Boolean isSuccess = ConvertBitmap (anHBitmapDump, thePixMap);
-
- // Free objects
- DeleteObject (SelectObject (aMemDC, anHBitmapOld));
- DeleteDC (aMemDC);
-
- return isSuccess;
-}
-
-//****************************** Load ************************************//
-//***//
-Standard_Boolean WNT_Window :: Load ( const Standard_CString aFilename ) const {
-
- RECT r;
-
- GetClientRect ( ( HWND )myHWindow, &r );
-
- return LoadArea ( aFilename, r.right / 2, r.bottom / 2, r.right, r.bottom );
-
-} // end WNT_Window :: Load
-//***//
-//*************************** LoadArea ***********************************//
-//***//
-Standard_Boolean WNT_Window :: LoadArea (
- const Standard_CString aFilename,
- const Standard_Integer Xc,
- const Standard_Integer Yc,
- const Standard_Integer Width,
- const Standard_Integer Height
- ) const {
-
- Standard_Integer idx;
- Standard_Boolean status;
-
- status = ( idx = myImages -> Load ( aFilename ) ) ? Standard_True : Standard_False;
-
- if ( status ) myImages -> Draw ( idx, Xc, Yc, Width, Height );
-
- return status;
-
-} // end WNT_Window :: LoadArea
-//***//
-//*************************** BackingStore *******************************//
-//***//
-Standard_Boolean WNT_Window :: BackingStore () const {
-
- Standard_Boolean retVal = Standard_False;;
- HDC hDC;
- RECT r;
-
- if ( myHPixmap )
-
- retVal = Standard_True;
-
- else {
-
- hDC = GetDC ( ( HWND )myHWindow );
-
- GetClientRect ( ( HWND )myHWindow, &r );
- *( ( Aspect_Handle* )&myHPixmap ) = CreateCompatibleBitmap ( hDC, r.right, r.bottom );
-
- if ( myHPixmap ) {
-
- HDC hDCmem;
-
- hDCmem = CreateCompatibleDC ( hDC );
-
- SELECT_PALETTE( hDCmem );
-
- SelectObject ( hDCmem, myHPixmap );
- FillRect ( hDCmem, &r, ( HBRUSH )MyHBackground );
-
- UNSELECT_PALETTE( hDCmem );
-
- DeleteDC ( hDCmem );
-
- retVal = Standard_True;
-
- } // end if
-
- ReleaseDC ( ( HWND )myHWindow, hDC );
-
- } // end else
-
- return retVal;
-
-} // end WNT_Window :: BackingStore
//***//
//******************************* Ratio **********************************//
//***//
return ( Quantity_Ratio )( ( Quantity_Ratio )r.right / ( Quantity_Ratio )r.bottom );
} // end WNT_Window :: Ratio
-//***//
-//**************************** Position (1) ******************************//
-//***//
-void WNT_Window :: Position (
- Quantity_Parameter& X1, Quantity_Parameter& Y1,
- Quantity_Parameter& X2, Quantity_Parameter& Y2
- ) const {
-
- POINT ptl, ptr;
- RECT pr, cr;
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- if ( myHParentWindow )
-
- GetClientRect ( ( HWND )myHParentWindow, &pr );
-
- else {
-
- int w, h;
-
- dev -> DisplaySize ( w, h );
-
- pr.right = w;
- pr.bottom = h;
-
- } // end else
-
- GetClientRect ( ( HWND )myHWindow, &cr );
-
- ptl.x = ptl.y = 0;
- ClientToScreen ( ( HWND )myHWindow, &ptl );
- cr.left = ptl.x;
- cr.top = ptl.y;
-
- ptr.x = cr.right;
- ptr.y = cr.bottom;
- ClientToScreen ( ( HWND )myHWindow, &ptr );
- cr.right = ptr.x;
- cr.bottom = ptr.y;
-
- if ( myHParentWindow ) {
-
- ScreenToClient ( ( HWND )myHParentWindow, &ptl );
- ScreenToClient ( ( HWND )myHParentWindow, &ptr );
- cr.left = ptl.x;
- cr.top = ptl.y;
- cr.right = ptr.x;
- cr.bottom = ptr.y;
- } // end if
-
- X1 = ( Quantity_Parameter )cr.left / ( Quantity_Parameter )pr.right;
- X2 = ( Quantity_Parameter )cr.right / ( Quantity_Parameter )pr.right;
- Y1 = 1. - ( Quantity_Parameter )cr.top / ( Quantity_Parameter )pr.bottom;
- Y2 = 1. - ( Quantity_Parameter )cr.bottom / ( Quantity_Parameter )pr.bottom;
-
-} // end WNT_Window :: Position
//***//
//**************************** Position (2) ******************************//
//***//
Y2 = ptr.y;
} // end WNT_Window :: Position
-//***//
-//******************************* Size (1) *******************************//
-//***//
-void WNT_Window :: Size (
- Quantity_Parameter& Width, Quantity_Parameter& Height
- ) const {
-
- RECT pr, wr;
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- if ( myHParentWindow )
-
- GetClientRect ( ( HWND )myHParentWindow, &pr );
-
- else {
-
- int w, h;
- dev -> DisplaySize ( w, h );
-
- pr.right = w;
- pr.bottom = h;
-
- } // end else
-
- GetClientRect ( ( HWND )myHWindow, &wr );
-
- Width = ( Quantity_Parameter )wr.right / ( Quantity_Parameter )pr.right;
- Height = ( Quantity_Parameter )wr.bottom / ( Quantity_Parameter )pr.bottom;
-
-} // end WNT_Window :: Size
//***//
//******************************* Size (2) *******************************//
//***//
Height = r.bottom;
} // end WNT_Window :: Size
-//***//
-//******************************* MMSize (1) *******************************//
-//***//
-void WNT_Window :: MMSize (
- Standard_Real& Width, Standard_Real& Height
- ) const {
-
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- int w, h;
- dev -> DisplaySize ( w, h );
- Standard_Real mmw,mmh;
- dev -> DisplaySize ( mmw, mmh );
- Standard_Real mmratio = (mmw/w + mmh/h)/2.;
-
- RECT wr;
- GetClientRect ( ( HWND )myHWindow, &wr );
- Width = mmratio * wr.right;
- Height = mmratio * wr.bottom;
-
-} // end WNT_Window :: MMSize
-//***//
-//**************************** Convert (1) *******************************//
-//***//
-Quantity_Parameter WNT_Window :: Convert (
- const Standard_Integer PV
- ) const {
-
- int w, h;
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- dev -> DisplaySize ( w, h );
-
- return ( Quantity_Parameter )( PV / Min ( w, h ) );
-
-} // end WNT_Window :: Convert
-//***//
-//**************************** Convert (2) *******************************//
-//***//
-Standard_Integer WNT_Window :: Convert (
- const Quantity_Parameter DV
- ) const {
-
- int w, h;
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- dev -> DisplaySize ( w, h );
-
- return ( Standard_Integer )( DV * Min ( w, h ) );
-
-} // end WNT_Window :: Convert
-//***//
-//**************************** Convert (3) *******************************//
-//***//
-
-void WNT_Window :: Convert (
- const Standard_Integer PX, const Standard_Integer PY,
- Quantity_Parameter& DX, Quantity_Parameter& DY
- ) const {
-
- int w, h;
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- dev -> DisplaySize ( w, h );
-
- DX = ( Quantity_Parameter )PX / ( Quantity_Parameter )w;
- DY = 1. - ( Quantity_Parameter )PY / ( Quantity_Parameter )h;
-
-} // end WNT_Window :: Convert
-//***//
-//**************************** Convert (4) *******************************//
-//***//
-void WNT_Window :: Convert (
- const Quantity_Parameter DX, const Quantity_Parameter DY,
- Standard_Integer& PX, Standard_Integer& PY
- ) const {
-
- int w, h;
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- dev -> DisplaySize ( w, h );
-
- PX = ( Standard_Integer )( DX * ( Quantity_Parameter )w );
- PY = ( Standard_Integer )( ( 1. - DY ) * ( Quantity_Parameter )h );
-
-} // end WNT_Window :: Convert
//***//
//******************************* SetPos *********************************//
//***//
aYBottom = Y1;
} // end WNT_Window :: SetPos
-//***//
-//*************************** SetOutputFormat ****************************//
-//***//
-void WNT_Window :: SetOutputFormat ( const WNT_TypeOfImage aFormat ) {
- myFormat = aFormat;
- myImages -> SetFormat ( aFormat );
-
-} // end WNT_Window :: SetOutputFormat
//***//
//**************************** SetFlags **********************************//
//***//
myExtraData.dwFlags |= aFlags;
} // end WNT_Window :: SetFlags
+
//***//
//*************************** ResetFlags *********************************//
//***//
myExtraData.dwFlags &= ~aFlags;
} // end WNT_Window :: ResetFlags
+
//***//
//*************************** doCreate **********************************//
//***//
void WNT_Window :: doCreate (
- const Handle( WNT_GraphicDevice )& aDevice,
const Aspect_Handle aHandle,
const Quantity_NameOfColor aBackColor
- ) {
-
- LONG uData;
- WNDPROC wProc;
- WINDOWPLACEMENT wp;
-
- const Handle( WNT_GraphicDevice )& dev = Handle( WNT_GraphicDevice ) ::
- DownCast ( MyGraphicDevice );
-
- ZeroMemory ( &myExtraData, sizeof ( WNT_WindowData ) );
-
- myHWindow = aHandle;
- myHParentWindow = GetParent ( ( HWND )aHandle );
- myDoubleBuffer = Standard_False;
- myHPixmap = NULL;
- wProc = (WNDPROC )GetWindowLongPtr ((HWND )aHandle, GWLP_WNDPROC);
- uData = GetWindowLongPtr ((HWND )aHandle, GWLP_USERDATA);
- myUsrData = Standard_Address(-1);
- myWndProc = NULL;
+ )
+{
+ LONG uData;
+ WINDOWPLACEMENT wp;
- if ( wProc != &WNT_WndProc ) {
+ ZeroMemory (&myExtraData, sizeof (WNT_WindowData));
- myWndProc = wProc;
+ myHWindow = aHandle;
+ myHParentWindow = GetParent ((HWND )aHandle);
+ uData = GetWindowLongPtr ((HWND )aHandle, GWLP_USERDATA);
+ myUsrData = Standard_Address(-1);
- SetBackground ( aBackColor );
+ SetBackground (aBackColor);
- myExtraData.WNT_Window_Ptr = ( void* )this;
- myExtraData.hPal = ( HPALETTE )dev -> HPalette ();
+ myExtraData.WNT_Window_Ptr = (void* )this;
- if ( uData != ( LONG )&myExtraData )
+ if (uData != (LONG )&myExtraData)
{
myUsrData = (Standard_Address )SetWindowLongPtr ((HWND )myHWindow, GWLP_USERDATA, (LONG_PTR )&myExtraData);
}
- if (myWndProc != NULL)
- {
- SetWindowLongPtr ((HWND )myHWindow, GWLP_WNDPROC, (LONG_PTR )WNT_WndProc);
- }
-
- } // end if
-
- myExtraData.dwFlags = WDF_FOREIGN;
-
- myImages = new WNT_ImageManager ( this );
- myFormat = WNT_TOI_XWD;
+ myExtraData.dwFlags = WDF_FOREIGN;
- wp.length = sizeof ( WINDOWPLACEMENT );
- GetWindowPlacement ( ( HWND )myHWindow, &wp );
-
- aXLeft = wp.rcNormalPosition.left;
- aYTop = wp.rcNormalPosition.top;
- aXRight = wp.rcNormalPosition.right;
- aYBottom = wp.rcNormalPosition.bottom;
+ wp.length = sizeof (WINDOWPLACEMENT);
+ GetWindowPlacement ((HWND )myHWindow, &wp);
+ aXLeft = wp.rcNormalPosition.left;
+ aYTop = wp.rcNormalPosition.top;
+ aXRight = wp.rcNormalPosition.right;
+ aYBottom = wp.rcNormalPosition.bottom;
} // end WNT_Window :: doCreate
-//***//
-//************************************************************************//
// GG RIC120302 Add a NEW HParentWindow method which enable
// to retrieve the parent of the actual Hwindow handle.
-inline Standard_Address WNT_Window :: WndProc () const {
-
- return myWndProc;
-
-} // end WNT_Window :: WndProc
-
-inline Standard_Boolean WNT_Window :: DoubleBuffer () const {
-
- return myDoubleBuffer;
-
-} // end WNT_Window :: DoubleBuffer
-
inline Aspect_Handle WNT_Window :: HWindow () const {
return myHWindow;
return myHParentWindow;
} // end WNT_Window :: HWindow
-
-inline Aspect_Handle WNT_Window :: HPixmap () const {
-
- return myHPixmap;
-
-} // end WNT_Window :: HPixmap
-
-inline Handle_WNT_ImageManager WNT_Window :: ImageManager () const {
-
- return myImages;
-
-} // end WNT_Window :: ImageManager
+++ /dev/null
-// 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.
-
-// include windows.h first to have all definitions available
-#include <windows.h>
-
-#include <WNT_Window.hxx>
-
-//***//
-//*** This window procedure provides management of the window background. ***//
-//*** Background belongs to the window class but we need that windows which ***//
-//*** are based on the same class have different backgrounds. So, we are ***//
-//*** using window subclassing technique to provide this ability. ***//
-//***//
-LRESULT CALLBACK WNT_WndProc (
- HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
- ) {
-
- HDC hDC;
- HPALETTE hOldPal;
- WNDPROC lpfnWndProc;
- WINDOW_DATA* wd;
- WNT_Window* win;
- RECT invRect;
-
- wd = (WINDOW_DATA* )GetWindowLongPtr (hwnd, GWLP_USERDATA);
- win = (WNT_Window* )wd->WNT_Window_Ptr;
- lpfnWndProc = (WNDPROC )win->WndProc();
-
- if ( msg == WM_ERASEBKGND && !( wd -> dwFlags & WDF_NOERASEBKGRND ) ) {
-
- hDC = ( HDC )wParam;
-
- if ( wd -> hPal ) {
-
- hOldPal = SelectPalette ( hDC, wd -> hPal, FALSE );
-
- if ( RealizePalette ( hDC ) )
-
- UpdateColors ( hDC );
-
- } // end if
-
- GetClipBox ( hDC, &invRect );
- FillRect ( hDC, &invRect, ( HBRUSH )( win -> HBackground () ) );
-
- if ( wd -> hPal )
-
- SelectPalette ( hDC, hOldPal, FALSE );
-
- return TRUE;
-
- } else if ( msg == WM_MOVE ) {
-
- WINDOWPLACEMENT wp;
-
- wp.length = sizeof ( WINDOWPLACEMENT );
- GetWindowPlacement ( hwnd, &wp );
-
- win -> SetPos (
- wp.rcNormalPosition.left, wp.rcNormalPosition.top,
- wp.rcNormalPosition.right, wp.rcNormalPosition.bottom
- );
-
- } // end else
-
- return CallWindowProc ( lpfnWndProc, hwnd, msg, wParam, lParam );
-
-} // end WNT_WndProc
-//***//
---Purpose: Creates the X Markmap
---Category: Classes
- class GraphicDevice;
- ---Purpose: Creates the X Device (Connexion & Visual)
- ---Category: Classes
-
- class IconBox;
- ---Purpose: Creates the X Icon Box
- ---Category: Classes
-
-------------------------
-- Category: Enumerations
-------------------------
friends
- class GraphicDevice from Xw,
class Window from Xw
end 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" {
MyExtendedDisplay : Address from Standard;
MyExtendedFontMap : Address from Standard;
-friends
-
- class GraphicDevice from Xw
-
end FontMap;
+++ /dev/null
--- Created on: 1993-10-19
--- Created by: Gerard GRAS
--- 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.
-
--- corrections MFA 21 Oct 94
-
-class GraphicDevice from Xw inherits GraphicDevice from Aspect
-
- ---Purpose: This class defines an X11 Graphic Device
- -- Warning: An Graphic Device is defined by :
- -- - a connection "host:server.screen"
- -- - a colormap mapping of type Xw_TOM_xxxxx
- -- - a "UseDefault" flag which permits the use of the
- -- DefaultColormap if possible.
- -- The connection can be specified directly
- -- or extracted from an existing Window.
- -- All Xw_Windows may share the same Graphic Device if
- -- you don't want to have any side effects on the stations
- -- which have only one hardware pseudo-colormap .
- -- Four kind of mapping are possible :
- -- 1) Xw_TOM_SIMPLERAMP
- -- Allocates the number of required colors in the
- -- colormap.
- -- The number of user colors depends directly on
- -- the hardware colormap size if UseDefault is False,
- -- or on the remainding free colors in the hardware colormap
- -- if UseDefault is True.
- -- 2) Xw_TOM_BESTRAMP
- -- Allocates the number of required colors in the
- -- colormap but leaves the Odd color indexes free
- -- if possible for highlight color management.
- -- (plane 0 is reserved for this usage)
- -- The number of user colors depends directly on
- -- the hardware colormap size if UseDefault is False,
- -- or on the remainding free colors in the hardware colormap
- -- if UseDefault is True.
- -- 3) Xw_TOM_COLORCUBE (the default)
- -- Allocates the maximum available colors in the colormap
- -- and builds a colorcube at this place.
- -- Any user color will be approximate and will be chosen as
- -- the nearest of the set of available colorcube colors.
- -- In this case the number of user colors can be unlimited.
- -- 4) Xw_TOM_HARDWARE
- -- May do serious damage to the color system.
- -- Must be used for maintenance only.
- -- 5) Xw_TOM_READONLY
- -- Allocates the number of required read only colors in the
- -- default colormap.
- -- The number of user colors depends directly on
- -- the hardware colormap size.
-
- ---References:
-
-uses
-
- AsciiString from TCollection,
- Length from Quantity,
- GraphicDriver from Aspect,
- ColorMap from Xw,
- TypeMap from Xw,
- WidthMap from Xw,
- FontMap from Xw,
- MarkMap from Xw,
- TypeOfVisual from Xw,
- TypeOfMapping from Xw,
- Handle from Aspect
-
-raises
-
- GraphicDeviceDefinitionError from Aspect,
- BadAccess from Aspect
-
-is
-
- Create
- returns mutable GraphicDevice from Xw is protected ;
-
- Create (Connection : CString from Standard ;
- Mapping : TypeOfMapping from Xw = Xw_TOM_COLORCUBE ;
- Ncolors : Integer from Standard = 0 ;
- UseDefault : Boolean from Standard = Standard_True )
- returns mutable GraphicDevice from Xw
- ---Level: Public
- ---Purpose: Create an Graphic Device on the specified Connection
- -- by using ALL screen defaults if possible
- -- (i.e:Default Colormap)
- -- Warning: Raises if the Device is Badly defined
- raises GraphicDeviceDefinitionError from Aspect ;
-
- ---------------------------------------------------
- -- Category: methods to modify the class definition
- ---------------------------------------------------
-
- Destroy ( me : mutable )
- ---Level: Public
- ---Purpose: Destroies all ressources attached to the GraphicDevice
- -- (Windows, Colormaps, ....)
- -- Warning: Raises if the Device is Badly defined
- raises BadAccess from Aspect is virtual;
- ---C++: alias ~
- ---Category: methods to modify the class definition
-
- InitMaps ( me : mutable ; Connection : CString from Standard ;
- Mapping : TypeOfMapping from Xw ;
- Ncolors : Integer from Standard ;
- UseDefault: Boolean from Standard )
- ---Level: Public
- ---Purpose: Initializes all ressources attached to the GraphicDevice
- -- Category: methods to modify the class definition
- -- Warning: Raises if the Device is Badly defined
- raises GraphicDeviceDefinitionError from Aspect
- is static protected ;
-
- ----------------------------
- -- Category: Inquire methods
- ----------------------------
-
- ColorMap2D ( me )
- returns ColorMap from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the 2D oriented Device color map.
- ---Category: Inquire methods
-
- VisualClass2D ( me )
- returns TypeOfVisual from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the 2D oriented Visual Class.
- ---Category: Inquire methods
-
- OverlayVisualClass2D ( me )
- returns TypeOfVisual from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the 2D oriented overlay Visual Class.
- ---Category: Inquire methods
-
- ExtendedColorMap2D ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data colormap 2D structure pointer.
- ---Category: Inquire methods
-
- ExtendedOverlayColorMap2D ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data overlay colormap 2D structure pointer.
- ---Category: Inquire methods
-
- ColorMap3D ( me )
- returns ColorMap from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the 3D oriented Device color map.
- ---Category: Inquire methods
-
- VisualClass3D ( me )
- returns TypeOfVisual from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the 3D oriented Visual Class.
- ---Category: Inquire methods
-
- OverlayVisualClass3D ( me )
- returns TypeOfVisual from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the 3D oriented overlay Visual Class.
- ---Category: Inquire methods
-
- ExtendedColorMap3D ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data colormap 3D structure pointer.
- ---Category: Inquire methods
-
- ExtendedOverlayColorMap3D ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data overlay colormap 3D structure pointer.
- ---Category: Inquire methods
-
- TypeMap ( me )
- returns TypeMap from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the Device Type map.
- ---Category: Inquire methods
-
- ExtendedTypeMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data typemap structure pointer.
- ---Category: Inquire methods
-
- WidthMap ( me )
- returns WidthMap from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the Device Width map.
- ---Category: Inquire methods
-
- ExtendedWidthMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data widthmap structure pointer.
- ---Category: Inquire methods
-
- FontMap ( me )
- returns FontMap from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the Device Font map.
- ---Category: Inquire methods
-
- ExtendedFontMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data fontmap structure pointer.
- ---Category: Inquire methods
-
- MarkMap ( me )
- returns MarkMap from Xw is static;
- ---Level: Internal
- ---Purpose: Returns the Device Mark map.
- ---Category: Inquire methods
-
- ExtendedMarkMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data markmap structure pointer.
- ---Category: Inquire methods
-
- Display ( me )
- returns CString from Standard is static;
- ---Level: Internal
- ---Purpose: Returns the Device connection string.
- ---Category: Inquire methods
-
- XDisplay ( me )
- returns Address from Standard is static;
- ---Level: Internal
- ---Purpose: Returns the Device Display Address.
- ---Category: Inquire methods
-
- ExtendedDisplay ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns extended data display structure pointer.
- ---Category: Inquire methods
-
- DisplaySize ( me ; Width, Height : out Integer from Standard )
- ---Level: Public
- ---Purpose: Returns the Display size in PIXEL
- -- Warning: Raises if the connection is not defined properly
- raises BadAccess from Aspect is static;
-
- DisplaySize ( me ; Width, Height : out Length from Quantity )
- ---Level: Public
- ---Purpose: Returns the Display size in METER
- -- Warning: Raises if the connection is not defined properly
- raises BadAccess from Aspect is static;
-
- PlaneLayer ( me ; aVisualID : Integer from Standard )
- returns Integer from Standard
- ---Level: Public
- ---Purpose: Returns the plane layer ID from a visual ID
- -- Warning: Raises if the connection is not defined properly
- raises BadAccess from Aspect is static;
-
- GraphicDriver ( me )
- returns GraphicDriver from Aspect
- is redefined;
-
-fields
-
- MyDisplay : AsciiString from TCollection ;
- MyColorMap2D : ColorMap from Xw ;
- MyColorMap3D : ColorMap from Xw ;
- MyTypeMap : TypeMap from Xw ;
- MyWidthMap : WidthMap from Xw ;
- MyFontMap : FontMap from Xw ;
- MyMarkMap : MarkMap from Xw ;
- MyExtendedDisplay : Address from Standard is protected ;
-
-friends
-
- class Window from Xw
-
-end GraphicDevice from Xw ;
+++ /dev/null
-// Created on: 1993-10-14
-// 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.
-
-#define GG001 //GG_300197
-// Preferer utiliser le visual de la root window en mode
-// 2D plutot que de prendre un visual PseudoColor alors que la root
-// est TrueColor.
-// Ceci corrige notamment les pb de colormap non intallees sur DEC
-// lorsque la station est bootee en TrueColor.
-
-
-
-//-Version
-
-//-Design Creation d'une unite graphique
-
-//-Warning
-
-//-References
-
-//-Language C++ 2.0
-
-//-Declarations
-
-// for the class
-#include <stdio.h>
-#include <Xw.hxx>
-#include <Xw_GraphicDevice.ixx>
-
-// Routines C a declarer en extern
-//extern "C" {
-#include <Xw_Cextern.hxx>
-//}
-
-//-Static data definitions
-
-//static char *ErrorMessag,LocalMessag[80] ;
-static char LocalMessag[80] ;
-//static int ErrorNumber ;
-//static int ErrorGravity ;
-static XW_STATUS status ;
-
-//-Aliases
-
-//-Global data definitions
-
-//-Constructors
-
-Xw_GraphicDevice::Xw_GraphicDevice () : Aspect_GraphicDevice() {
- MyExtendedDisplay = NULL;
-}
-
-Xw_GraphicDevice::Xw_GraphicDevice (const Standard_CString Connexion, const Xw_TypeOfMapping Mapping, const Standard_Integer Ncolors, const Standard_Boolean UseDefault) : Aspect_GraphicDevice() {
-
- InitMaps(Connexion,Mapping,Ncolors,UseDefault) ;
-}
-
-void Xw_GraphicDevice::Destroy () {
-
- if( MyColorMap2D != MyColorMap3D ) {
- MyColorMap3D.Nullify();
- MyColorMap2D.Nullify();
- } else {
- MyColorMap2D.Nullify();
- }
- MyTypeMap.Nullify();
- MyWidthMap.Nullify();
- MyFontMap.Nullify();
- MyMarkMap.Nullify();
-
- if( MyExtendedDisplay ) {
- status = Xw_close_display(MyExtendedDisplay) ;
-
- MyExtendedDisplay = NULL;
- }
-}
-
-void Xw_GraphicDevice::InitMaps (const Standard_CString Connexion,const Xw_TypeOfMapping Mapping,const Standard_Integer Ncolors,const Standard_Boolean UseDefault) {
-#ifdef GG001
-Xw_TypeOfVisual v2d = Xw_TOV_DEFAULT ;
-#else
-Xw_TypeOfVisual v2d = Xw_TOV_PREFERRED_PSEUDOCOLOR ;
-#endif
-Xw_TypeOfVisual v3d = Xw_TOV_PREFERRED_TRUECOLOR ;
-
- Xw_set_trace(Xw::TraceLevel(),Xw::ErrorLevel()) ;
-
- if( Connexion ) {
- MyDisplay = TCollection_AsciiString(Connexion) ;
- } else {
- MyDisplay = TCollection_AsciiString("") ;
- }
-
- MyExtendedDisplay = Xw_open_display((Standard_PCharacter)MyDisplay.ToCString()) ;
-
- if( !MyExtendedDisplay ) {
- sprintf(LocalMessag,"Cannot connect to server '%s'",
- MyDisplay.ToCString());
- Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
- }
-
- v2d = Xw_get_display_visual(MyExtendedDisplay,v2d) ;
- MyColorMap2D = new Xw_ColorMap(MyDisplay.ToCString(),
- v2d,Mapping,Ncolors,UseDefault) ;
-
- v3d = Xw_get_display_visual(MyExtendedDisplay,v3d) ;
- if( v2d != v3d ) {
- MyColorMap3D = new Xw_ColorMap(MyDisplay.ToCString(),
- v3d,Mapping,Ncolors,UseDefault) ;
- } else {
- MyColorMap3D = MyColorMap2D ;
- }
-
- MyTypeMap = new Xw_TypeMap(MyDisplay.ToCString()) ;
- MyWidthMap = new Xw_WidthMap(MyDisplay.ToCString()) ;
- MyFontMap = new Xw_FontMap(MyDisplay.ToCString()) ;
- MyMarkMap = new Xw_MarkMap(MyDisplay.ToCString()) ;
-
-Standard_Address Bof;
- Bof = ExtendedColorMap2D();
- Bof = ExtendedColorMap3D();
- Bof = ExtendedTypeMap();
- Bof = ExtendedWidthMap();
- Bof = ExtendedFontMap();
- Bof = ExtendedMarkMap();
-
- if( !ExtendedColorMap2D() ||
- !ExtendedColorMap3D() ||
- !ExtendedTypeMap() ||
- !ExtendedWidthMap() ||
- !ExtendedFontMap() ||
- !ExtendedMarkMap() ) {
- sprintf(LocalMessag,"Bad Graphic Device Attributs on '%s'",
- Connexion);
- Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
- }
-}
-
-Handle(Xw_ColorMap) Xw_GraphicDevice::ColorMap2D () const {
-
- return (MyColorMap2D) ;
-
-}
-
-Xw_TypeOfVisual Xw_GraphicDevice::VisualClass2D () const {
-
- return (MyColorMap2D->VisualClass()) ;
-}
-
-Xw_TypeOfVisual Xw_GraphicDevice::OverlayVisualClass2D () const {
-
- return (MyColorMap2D->OverlayVisualClass()) ;
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedColorMap2D () const {
-
- return (MyColorMap2D->ExtendedColorMap());
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedOverlayColorMap2D () const {
-
- return (MyColorMap2D->ExtendedOverlayColorMap());
-}
-
-Handle(Xw_ColorMap) Xw_GraphicDevice::ColorMap3D () const {
-
- return (MyColorMap3D) ;
-}
-
-Xw_TypeOfVisual Xw_GraphicDevice::VisualClass3D () const {
-
- return (MyColorMap3D->VisualClass()) ;
-}
-
-Xw_TypeOfVisual Xw_GraphicDevice::OverlayVisualClass3D () const {
-
- return (MyColorMap3D->OverlayVisualClass()) ;
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedColorMap3D () const {
-
- return (MyColorMap3D->ExtendedColorMap());
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedOverlayColorMap3D () const {
-
- return (MyColorMap3D->ExtendedOverlayColorMap());
-}
-
-Handle(Xw_TypeMap) Xw_GraphicDevice::TypeMap () const {
-
- return (MyTypeMap) ;
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedTypeMap () const {
-
- return (MyTypeMap->ExtendedTypeMap());
-}
-
-Handle(Xw_WidthMap) Xw_GraphicDevice::WidthMap () const {
-
- return (MyWidthMap) ;
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedWidthMap () const {
-
- return (MyWidthMap->ExtendedWidthMap());
-}
-
-Handle(Xw_FontMap) Xw_GraphicDevice::FontMap () const {
-
- return (MyFontMap) ;
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedFontMap () const {
-
- return (MyFontMap->ExtendedFontMap());
-}
-
-Handle(Xw_MarkMap) Xw_GraphicDevice::MarkMap () const {
-
- return (MyMarkMap) ;
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedMarkMap () const {
-
- return (MyMarkMap->ExtendedMarkMap());
-}
-
-Standard_CString Xw_GraphicDevice::Display () const {
-
- return (MyDisplay.ToCString());
-}
-
-Standard_Address Xw_GraphicDevice::XDisplay () const {
-Aspect_Handle *display ;
-Aspect_Handle root,colormap ;
-Xw_TypeOfVisual pclass ;
-int depth ;
-
- status = Xw_get_display_info(MyExtendedDisplay,&display,
- &root,&colormap,&pclass,&depth) ;
-
- return (display);
-}
-
-Standard_Address Xw_GraphicDevice::ExtendedDisplay () const {
-
- return (MyExtendedDisplay);
-}
-
-void Xw_GraphicDevice::DisplaySize (Standard_Integer &Width,Standard_Integer &Height) const {
-int width,height ;
-
- status = Xw_get_screen_size(MyExtendedDisplay,&width,&height) ;
-
- Width = width ;
- Height = height ;
-}
-
-void Xw_GraphicDevice::DisplaySize (Quantity_Length &Width,Quantity_Length &Height) const {
-float width,height ;
-
- status = Xw_get_mmscreen_size(MyExtendedDisplay,&width,&height) ;
-
- Width = FROMMILLIMETER(width) ;
- Height = FROMMILLIMETER(height) ;
-}
-
-Standard_Integer Xw_GraphicDevice::PlaneLayer (const Standard_Integer aVisualID) const {
-
- return Xw_get_plane_layer(MyExtendedDisplay,aVisualID);
-}
-
-Handle(Aspect_GraphicDriver) Xw_GraphicDevice::GraphicDriver () const {
-
-static Handle(Aspect_GraphicDriver) foo;
-
- cout << "Xw_GraphicDevice::GraphicDriver returns foo\n" << flush;
-
- return foo;
-
-}
+++ /dev/null
--- 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.
-
-
-class IconBox from Xw inherits Window from Xw
-
- ---Version:
-
- ---Purpose: This class defines a X11 IconBox
- -- Warning: The IconBox is not visible at the creation time .
- -- To show the Icon Box use the method Show () .
- -- In this case the Icon Box appears at the DSU position
- -- specified given in [0,1] space .
- -- The size of the Icon Box grows depending of the number
- -- of the Icons loaded inside .
-
- ---References:
-
-uses
-
- NameOfColor from Quantity,
- GraphicDevice from Xw,
- TypeOfVisual from Xw,
- Handle from Aspect,
- WindowQuality from Xw
-
-raises
-
- WindowDefinitionError from Aspect,
- WindowError from Aspect
-
-is
-
- Create ( Device : GraphicDevice from Xw ;
- Name : CString from Standard ;
- Xc : Real from Standard = 0.5 ;
- Yc : Real from Standard = 0.5 ;
- BackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY;
- aQuality : WindowQuality from Xw = Xw_WQ_SAMEQUALITY)
- returns mutable IconBox from Xw
- ---Level: Public
- ---Purpose: Creates a IconBox n Preferred PseudoColor Visual
- -- defined by his Center in DSU and connects it to the
- -- X server at the first call depending of the GraphicDevice
- -- connexion .
- -- ALL Icons are loaded from the Icon File Directory Name :
- -- "[$SYMBOL]xxxxxxx[.ifd]"
- -- Warning: Raises if the Position is out of the Screen Space
- -- or the Icon File Directory Name don't exist
- raises WindowDefinitionError from Aspect ;
-
- ---------------------------------------------------
- -- Category: Methods to modify the class definition
- ---------------------------------------------------
-
- LoadIcons ( me : mutable ; Name : CString from Standard )
- returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Loads Icon Box from an Other Icon File Directory Name
- -- and returns the loaded icons number.
- -- Warning: The Icons previously loaded are NOT cleared .
- ---Category: Methods to modify the class definition
-
- Show ( me ) is static;
- ---Level: Public
- ---Purpose: Shows Icon Box to the screen
- -- Warning: The Icon Box is displayed at the centered position
- -- specified at the creation time and the size depend
- -- of the Icon number really loaded inside .
-
- UnloadIcons ( me : mutable ; Name : CString from Standard )
- returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Unloads All previously loaded Icons in the IconBox
- -- and returns the unloaded icons number.
- ---Category: methods to modify the class definition
-
- Destroy ( me : mutable) is redefined ;
- ---Level: Public
- ---Purpose: Destroies the IconBox
- ---C++: alias ~
- ---Category: Methods to modify the class definition
-
- AddIcon ( me : mutable ; W : Window from Xw ;
- Name : CString from Standard;
- aWidth : Integer from Standard = 0;
- aHeight : Integer from Standard = 0) is static;
- ---Level: Public
- ---Purpose: Adds an Icon of Size aWidth,aHeight given in PIXEL
- -- to the Icon Box from a FULL Existing Window
- -- NOTE that if aWidth or aHeight is 0 the default icon size is taken.
- ---Category: methods to modify the class definition
-
- SaveIcons ( me ) returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Saves all new created Icons as iconname.xwd file in the user
- -- directory and returns the saved icons number.
-
- ----------------------------
- -- Category: Inquire methods
- ----------------------------
-
- IconNumber ( me )
- returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Returns the Number of Icons loaded in the Icon Box .
-
- IconName ( me ; Index : Integer from Standard )
- returns CString from Standard
- ---Level: Public
- ---Purpose: Returns the Name of the N ime Icon
- -- Warning: Raises if Index if out of range depending of the
- -- Number of Loaded Icons .
- raises WindowError from Aspect is static;
-
- IconSize ( me ; Name : CString from Standard ;
- Width, Height : out Integer from Standard )
- returns Boolean from Standard is static;
- ---Level: Public
- ---Purpose: Returns the Pixmap Size attached to the Icon Name
- -- Warning: May return FALSE if Icon doesn't exist in the IconBox .
- ---Category: Inquire methods
-
- IconPixmap ( me ; Name : CString from Standard )
- returns Handle from Aspect is static;
- ---Level: Public
- ---Purpose: Returns the Pixmap attached to the Icon Name
- -- Warning: May return 0 if Icon doesn't exist in the IconBox .
- ---Category: Inquire methods
-
- IconPixmap ( me ; Name : CString from Standard ;
- Width, Height : Integer from Standard )
- returns Handle from Aspect is static;
- ---Level: Public
- ---Purpose: Returns the Centered part of the Pixmap of required Size
- -- attached to the Icon Name
- -- Warning: May return 0 if Icon doesn't exist in the IconBox .
- ---Category: Inquire methods
-
-fields
-
- MyNumberOfIcons : Integer from Standard ;
-
-end IconBox ;
+++ /dev/null
-// 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.
-
-#define PURIFY //GG_180297
-// Liberation memoire allouee par les icones.
-
-
-
-//-Version
-
-//-Design Creation d'une Icon Box
-
-//-Warning
-
-//-References
-
-//-Language C++ 2.0
-
-//-Declarations
-
-// for the class
-#include <Xw_IconBox.ixx>
-
-// Routines C a declarer en extern
-//extern "C" {
-#include <Xw_Cextern.hxx>
-//}
-
-//-Static data definitions
-
-static XW_STATUS status ;
-
-//-Aliases
-
-//-Global data definitions
-
-//-Constructors
-
-Xw_IconBox::Xw_IconBox (const Handle(Xw_GraphicDevice)& Device, const Standard_CString Name, const Standard_Real Xc, const Standard_Real Yc, const Quantity_NameOfColor BackColor,const Xw_WindowQuality aQuality) :
- Xw_Window(Device,Name,Xc,Yc,0.1,0.1,aQuality,BackColor,0) {
-
- MyNumberOfIcons = Xw_load_icons(MyExtendedWindow,(Standard_PCharacter)Name) ;
-
- if( !MyNumberOfIcons ) {
- PrintError() ;
- }
-}
-
-void Xw_IconBox::Destroy () {
-
- MyNumberOfIcons = 0 ;
-#ifdef PURIFY
- if( MyExtendedWindow ) Xw_clear_icons(MyExtendedWindow,NULL);
-#endif
-}
-
-Standard_Integer Xw_IconBox::UnloadIcons ( const Standard_CString Name) {
-Standard_Integer nicons = 0;
-
- nicons = Xw_clear_icons (MyExtendedWindow,(Standard_PCharacter)Name);
-
- if( !nicons ) Xw_print_error() ;
-
- MyNumberOfIcons -= nicons ;
-
- return nicons;
-}
-
-void Xw_IconBox::Show () const {
-
- status = Xw_show_icons (MyExtendedWindow);
-
- if( !status ) Xw_print_error() ;
-}
-
-Standard_Integer Xw_IconBox::LoadIcons ( const Standard_CString Name ) {
-int nicons ;
-
- nicons = Xw_load_icons(MyExtendedWindow,(Standard_PCharacter)Name) ;
-
- if( nicons > 0 ) MyNumberOfIcons += nicons ;
- else Xw_print_error() ;
-
- return nicons;
-}
-
-void Xw_IconBox::AddIcon ( const Handle(Xw_Window)& W,const Standard_CString Name,
- const Standard_Integer aWidth,const Standard_Integer aHeight ) {
- status = Xw_put_window_icon(MyExtendedWindow,W->ExtendedWindow(),
- (Standard_PCharacter)Name,aWidth,aHeight) ;
-
- if( status ) MyNumberOfIcons++ ;
- else Xw_print_error() ;
-}
-
-Standard_Integer Xw_IconBox::SaveIcons () const {
-Standard_Integer nicons = 0;
-
- nicons = Xw_save_icons(MyExtendedWindow) ;
-
- return nicons;
-}
-
-Standard_Integer Xw_IconBox::IconNumber () const {
-
- return (MyNumberOfIcons);
-}
-
-Standard_CString Xw_IconBox::IconName ( const Standard_Integer Index) const {
-char *Name = NULL ;
-
- if( Index < 0 || Index > MyNumberOfIcons ) {
- PrintError() ;
- }
-
- Name = Xw_get_icon_name(MyExtendedWindow,(int)Index) ;
-
- if( !Name ) Xw_print_error() ;
-
- return (Name);
-}
-
-Standard_Boolean Xw_IconBox::IconSize ( const Standard_CString Name, Standard_Integer& Width, Standard_Integer& Height ) const {
-int width,height ;
-
- status = Xw_get_icon_size( MyExtendedWindow,(Standard_PCharacter)Name,&width,&height) ;
-
- if( status ) {
- Width = width ;
- Height = height ;
- } else {
- Xw_print_error() ;
- }
-
- return Standard_Boolean(status);
-}
-
-Aspect_Handle Xw_IconBox::IconPixmap ( const Standard_CString Name ) const {
-Aspect_Handle pixmap = 0 ;
-
- pixmap = Xw_get_icon_pixmap( MyExtendedWindow,0,0,(Standard_PCharacter)Name) ;
-
- if( !pixmap ) Xw_print_error() ;
-
- return (pixmap);
-}
-
-Aspect_Handle Xw_IconBox::IconPixmap ( const Standard_CString Name, const Standard_Integer Width,const Standard_Integer Height ) const {
-Aspect_Handle pixmap = 0 ;
-
- pixmap = Xw_get_icon_pixmap( MyExtendedWindow,
- (int)Width,(int)Height,
- (Standard_PCharacter)Name) ;
-
- if( !pixmap ) Xw_print_error() ;
-
- return (pixmap);
-}
MyExtendedDisplay : Address from Standard ;
MyExtendedMarkMap : Address from Standard ;
-friends
-
- class GraphicDevice from Xw
-
end MarkMap ;
#include <Aspect_TypeOfMarker.hxx>
#include <Aspect_MarkerStyle.hxx>
#include <Standard_ShortReal.hxx>
+#include <Standard_PCharacter.hxx>
#include <TShort_Array1OfShortReal.hxx>
#include <TColStd_Array1OfBoolean.hxx>
MyExtendedDisplay : Address from Standard ;
MyExtendedTypeMap : Address from Standard ;
-friends
-
- class GraphicDevice from Xw
-
end TypeMap ;
#include <Aspect_TypeOfLine.hxx>
#include <Aspect_LineStyle.hxx>
#include <Standard_ShortReal.hxx>
+#include <Standard_PCharacter.hxx>
#include <TShort_Array1OfShortReal.hxx>
#include <TColQuantity_Array1OfLength.hxx>
MyExtendedDisplay : Address from Standard ;
MyExtendedWidthMap : Address from Standard ;
-friends
-
- class GraphicDevice from Xw
-
end WidthMap ;
#include <Xw_WidthMap.ixx>
#include <Aspect_WidthOfLine.hxx>
+#include <Standard_PCharacter.hxx>
// Routines C a declarer en extern
//extern "C" {
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
--- Modified : GG 28/01/00 G004
--- Add gamma correction computation just before dumping an image.
--- GG 07/03/00 G004 Add MMSize() method
--- TCL 26/10/00 G002 SetBackground(aName: CString) method
--- SAV 24/11/01 SetBackground(Quantity_Color)
--- GG - RIC120302 Add NEW XParentWindow methods.
-
class Window from Xw
- ---Version:
-
- ---Purpose: This class defines a X11 window
- -- Warning: The position and size for the creation of the window
- -- are defined in Device Screen Unit (DSU)
- -- floating [0,1] space.
-
- ---References:
-
inherits
Window from Aspect
uses
- AsciiString from TCollection,
- Background from Aspect,
- GradientBackground from Aspect,
- TypeOfResize from Aspect,
- Handle from Aspect,
- FillMethod from Aspect,
- GradientFillMethod from Aspect,
- PixMap from Image,
- NameOfColor from Quantity,
- Parameter from Quantity,
- Ratio from Quantity,
- Color from Quantity,
- ColorMap from Xw,
- TypeMap from Xw,
- WidthMap from Xw,
- FontMap from Xw,
- MarkMap from Xw,
- GraphicDevice from Xw,
- WindowQuality from Xw,
- TypeOfVisual from Xw
+ 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
is
- Create ( Device : GraphicDevice from Xw )
+ Create ( theDisplayConnection : DisplayConnection_Handle from Aspect )
returns mutable Window from Xw
raises WindowDefinitionError from Aspect;
---Level: Public
- Create ( Device : GraphicDevice from Xw ;
+ Create ( theDisplayConnection : DisplayConnection_Handle from Aspect ;
aPart1, aPart2 : Integer from Standard ;
- aQuality : WindowQuality from Xw = Xw_WQ_SAMEQUALITY ;
BackColor : NameOfColor from Quantity =
Quantity_NOC_MATRAGRAY )
returns mutable Window from Xw
-- or if the Position out of the Screen Space
raises WindowDefinitionError from Aspect ;
- Create ( Device : GraphicDevice from Xw ;
+ Create ( theDisplayConnection : DisplayConnection_Handle from Aspect ;
aWindow : Handle from Aspect;
- aQuality : WindowQuality from Xw = Xw_WQ_SAMEQUALITY ;
BackColor : NameOfColor from Quantity =
Quantity_NOC_MATRAGRAY )
returns mutable Window from Xw
-- or if the Position out of the Screen Space
raises WindowDefinitionError from Aspect ;
- Create ( Device : GraphicDevice from Xw ;
- Title : CString from Standard ;
- Xc : Parameter from Quantity = 0.5 ;
- Yc : Parameter from Quantity = 0.5 ;
- Width : Parameter from Quantity = 0.5 ;
- Height : Parameter from Quantity = 0.5 ;
- Quality : WindowQuality from Xw = Xw_WQ_DRAWINGQUALITY ;
- BackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY ;
- Parent : Handle from Aspect = 0 )
- returns mutable Window from Xw
- ---Level: Public
- ---Purpose: Creates a Window defined by his Center and his Size
- -- in DSU from the Parent Window.
- -- NOTE than if Parent is 0 the window is created from the
- -- ROOT Window.
- -- Connects it to the X server at the first call
- -- depending of the GraphicDevice Visual and
- -- Display parameters.
- -- Quality defined a 2D or 3D Graphics oriented Window and
- -- must be one of :
- -- Xw_WQ_DRAWINGQUALITY for 2D Wireframe.
- -- Xw_WQ_PICTUREQUALITY for Picture.
- -- Xw_WQ_3DQUALITY for 3D Shading, HiddenLines, Wireframe.
- --
- -- Creation of an Xw_Window automatically determines the
- -- smaller dimension of the screen (usually the height)
- -- and parametrises it as 1.0.
- -- The smaller dimension of the window is limited to 1.0
- -- We can give a value greater than 1.0 to the larger
- -- dimension.
- -- No matter how large the values passed in argument, the
- -- window is automatically limited to the maximum size of
- -- the screen.
- -- The ratio of width to height of a conventional screen is
- -- of the order of 1.3.
- --
- -- Trigger: Raises WindowDefinitionError if the connection failed
- -- or if the Position out of the Screen Space
- raises WindowDefinitionError from Aspect ;
-
- Create ( theDevice : GraphicDevice from Xw ;
+ 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 ;
- theQuality : WindowQuality from Xw = Xw_WQ_DRAWINGQUALITY ;
theBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY ;
theParent : Handle from Aspect = 0 )
returns mutable Window from Xw
-- Category: Methods to modify the class definition
---------------------------------------------------
- SetBackground ( me : mutable ;
- Background : Background from Aspect ) is virtual;
- ---Level: Public
- ---Purpose: Modifies the window background.
- -- Warning: the background color is ignored when the quality
- -- of this window is TRANSPARENT.
- ---Category: Methods to modify the class definition
-
- SetBackground ( me : mutable ;
- BackColor : NameOfColor from Quantity ) is virtual;
- ---Level: Public
- ---Purpose: Modifies the window background from a Named Color.
- -- Warning: the background color is ignored when the quality
- -- of this window is TRANSPARENT.
- ---Category: Methods to modify the class definition
-
- SetBackground ( me : mutable; color : Color from Quantity ) is virtual;
- ---Level: Public
- ---Purpose: Modifies the window background from a Named Color.
- -- Warning: the background color is ignored when the quality
- -- of this window is TRANSPARENT.
- ---Category: Methods to modify the class definition
-
- SetBackground( me: mutable;
- aPixmap: Handle from Aspect);
- ---Level: Advanced
- ---Purpose: Defines the window background directly from a bitmap.
- -- Warning: the bitmap and window must have the same depth.
- ---Category: Methods to modify the class definition
-
- SetBackground( me: mutable;
- aName: CString from Standard;
- aMethod : FillMethod from Aspect = Aspect_FM_CENTERED)
- returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Loads the window background from an image file <aName>
- -- defined with a supported format XWD,GIF or BMP
- -- and returns TRUE if the operation is successfull.
- ---Category: Methods to modify the class definition
-
- SetBackground ( me : mutable ;
- Background : GradientBackground from Aspect ) is virtual;
- ---Level: Public
- ---Purpose: Modifies the window gradient background.
- -- Warning: the gradient background colours are ignored when the quality
- -- of this window is TRANSPARENT.
- ---Category: Methods to modify the class definition
-
- SetBackground( me : mutable;
- aCol1 : Color from Quantity;
- aCol2 : Color from Quantity;
- aMethod : GradientFillMethod from Aspect = Aspect_GFM_HOR);
- ---Level: Public
- ---Purpose: Modifies the window gradient background.
- -- Warning: the gradient background colours are ignored when the quality
- -- of this window is TRANSPARENT.
- ---Category: Methods to modify the class definition
-
- SetDoubleBuffer ( me : mutable ;
- DBmode : Boolean from Standard )
- ---Level: Advanced
- ---Purpose: Activates/Deactivates the Double Buffering capability
- -- for this window.
- -- Warning: Double Buffering is always DISABLE by default
- -- If there is not enought ressources to activate the
- -- double-buffering the DB mode flag can be set to FALSE.
- ---Category: Methods to modify the class definition
- is virtual;
-
- Flush ( me )
- ---Level: Advanced
- ---Purpose: Flushs all graphics to the screen and Swap the Double
- -- buffer if Enable
- -- Category: Methods to modify the class definition
- -- Trigger: Raises if Something is WRONG at Drawing Time.
- raises WindowError from Aspect is virtual;
-
Map ( me ) is virtual;
---Level: Public
---Purpose: Opens the window <me>.
-- Trigger: Raises if Window is not defined properly
raises WindowError from Aspect is virtual;
- Clear ( me ) is virtual;
- ---Level: Public
- ---Purpose: Clears the Window in the Background color
- ---Category: Methods to modify the class definition
-
- ClearArea ( me ;
- Xc, Yc : Integer from Standard ;
- Width, Height : Integer from Standard )
- ---Level: Public
- ---Purpose: Clears the Window Area defined by his center and PIXEL size
- -- in the Background color
- -- Category: Methods to modify the class definition
- -- Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is virtual;
-
- Restore ( me )
- ---Level: Public
- ---Purpose: Restores The Window from the BackingStored Window
- -- See BackingStore () method.
- ---Category: Methods to modify the class definition
- raises WindowError from Aspect is virtual;
-
- RestoreArea ( me ;
- Xc, Yc : Integer from Standard ;
- Width, Height : Integer from Standard )
- ---Level: Public
- ---Purpose: Restores The Window Area defined by his center
- -- and PIXEL size from the BackingStored Window
- -- See BackingStore () method.
- ---Category: Methods to modify the class definition
- raises WindowError from Aspect is virtual;
-
- Dump ( me ; aFilename : CString from Standard;
- aGammaValue: Real from Standard = 1.0 ) returns Boolean
- ---Level: Advanced
- ---Purpose: Dumps the Window to an XWD,GIF or BMP file with
- -- an optional gamma correction value according to the graphic system.
- -- and returns TRUE if the dump occurs normaly.
- -- Category: Methods to modify the class definition
- -- Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is virtual;
-
- DumpArea ( me ; aFilename : CString from Standard ;
- Xc, Yc : Integer from Standard ;
- Width, Height : Integer from Standard ;
- aGammaValue: Real from Standard = 1.0 ) returns Boolean
- ---Level: Advanced
- ---Purpose: Dumps the Window Area defined by his center and PIXEL size
- -- to an XWD,GIF or BMP file with
- -- an optional gamma correction value according to the graphic system.
- -- and returns TRUE if the dump occurs normaly.
- -- Category: Methods to modify the class definition
- -- Trigger: Raises if Window is not defined properly
- -- or the area is out of the Window.
- raises WindowError from Aspect is virtual;
-
- ToPixMap ( me ; theImage : in out PixMap from Image )
- returns Boolean
- ---Level : Public
- ---Purpose : dump the full contents of the window to a pixmap.
- is virtual;
-
- Load ( me ; aFilename : CString from Standard) returns Boolean
- ---Level: Advanced
- ---Purpose: Loads the XWD file to this Window.
- -- Returns TRUE if the loading occurs normaly.
- -- Warning: Note that the Window is enlarged automatically
- -- when the image size is too large for this window.
- -- Category: Methods to modify the class definition
- -- Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is virtual;
-
- LoadArea ( me ; aFilename : CString from Standard ;
- Xc, Yc : Integer from Standard ;
- Width, Height : Integer from Standard ) returns Boolean
- ---Level: Advanced
- ---Purpose: Loads the XWD file to Window Area defined by his center
- -- and PIXEL size.
- -- Returns TRUE if the loading occurs normaly.
- -- Warning: Note that the Image is zoomed automatically
- -- when the image size is too large for this window area.
- -- Category: Methods to modify the class definition
- -- Trigger: Raises if Window is not defined properly
- -- or the area is out of the Window.
- raises WindowError from Aspect is virtual;
-
SetCursor ( me ; anId : Integer from Standard ;
aColor : NameOfColor from Quantity
= Quantity_NOC_YELLOW ) is virtual ;
-- Category: Inquire methods
----------------------------
- BackingStore ( me )
- returns Boolean from Standard is virtual;
- ---Level: Advanced
- ---Purpose: Returns the BackingStore capability for this Window.
- -- If Answer is True Exposure can be recovered by
- -- Restore RestoreArea methods.
- -- If Answer is False, Application must Redraw the
- -- exposed area.
- ---Category: Inquire methods
-
- DoubleBuffer ( me )
- returns Boolean from Standard is virtual;
- ---Level: Advanced
- ---Purpose: Returns the DoubleBuffer state.
- ---Category: Inquire methods
-
IsMapped ( me )
returns Boolean from Standard is virtual;
---Level: Public
-- WIDTH/HEIGHT dimensions
---Category: Inquire methods
- Position ( me ;
- X1, Y1, X2, Y2 : out Parameter from Quantity ) is virtual;
- ---Level: Public
- ---Purpose: Returns The Window POSITION in DSU
- ---Category: Inquire methods
-
Position ( me ;
X1, Y1, X2, Y2 : out Integer from Standard ) is virtual;
---Level: Public
---Purpose: Returns The Window POSITION in PIXEL
---Category: Inquire methods
- Size ( me ;
- Width, Height : out Parameter from Quantity ) is virtual;
- ---Level: Public
- ---Purpose: Returns The Window SIZE in DSU
- ---Category: Inquire methods
-
Size ( me ;
Width, Height : out Integer from Standard ) is virtual;
---Level: Public
---Purpose: Returns The Window SIZE in PIXEL
---Category: Inquire methods
- MMSize ( me ;
- Width, Height : out Real from Standard ) is virtual;
- ---Level: Public
- ---Purpose: Returns The Window SIZE in MM
- ---Category: Inquire methods
-
- Convert ( me ; PV : Integer from Standard )
- returns Parameter from Quantity is virtual;
- ---Level: Public
- ---Purpose: Returns the DSU value depending of the PIXEL value.
- ---Category: Inquire methods
-
- Convert ( me ; DV : Parameter from Quantity )
- returns Integer from Standard is virtual;
- ---Level: Public
- ---Purpose: Returns the PIXEL value depending of the DSU value.
- ---Category: Inquire methods
-
- Convert ( me ;
- PX, PY : Integer from Standard ;
- DX, DY : out Parameter from Quantity ) is virtual;
- ---Level: Public
- ---Purpose: Returns the DSU position depending of the PIXEL position.
- ---Category: Inquire methods
-
- Convert ( me ;
- DX, DY : Parameter from Quantity ;
- PX, PY : out Integer from Standard ) is virtual;
- ---Level: Public
- ---Purpose: Returns the PIXEL position depending of the DSU position.
- ---Category: Inquire methods
-
XWindow ( me )
returns Handle from Aspect is static;
---Level: Public
-- and FALSE if the pointer is outside of the window
---Category: Inquire methods
- ColorMap ( me )
- returns ColorMap from Xw is static;
- ---Level: Public
- ---Purpose: Returns the Colormap attached to this Window
-
- TypeMap ( me )
- returns TypeMap from Xw is static;
- ---Level: Public
- ---Purpose: Returns the Typemap attached to this Window
-
- WidthMap ( me )
- returns WidthMap from Xw is static;
- ---Level: Public
- ---Purpose: Returns the Widthmap attached to this Window
-
- FontMap ( me )
- returns FontMap from Xw is static;
- ---Level: Public
- ---Purpose: Returns the Fontmap attached to this Window
-
- MarkMap ( me )
- returns MarkMap from Xw is static;
- ---Level: Public
- ---Purpose: Returns the Markmap attached to this Window
-
- XColorMap ( me )
- returns Handle from Aspect
- ---Level: Internal
- ---Purpose: Returns the Colormap XId attached to this Window
- -- depending of the HardWare and Visual class
- -- Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is static;
-
- XVisual ( me )
- returns Address from Standard
- ---Level: Internal
- ---Purpose: Returns the Visual address attached to this Window
- -- depending of the HardWare
- -- Trigger: Raises if Window is not defined properly
- raises WindowError from Aspect is static;
-
VisualClass ( me )
returns TypeOfVisual from Xw is static;
---Level: Public
---Purpose: Returns the X window Visual class of the created window <me>
---Category: Inquire methods
- VisualDepth ( me )
- returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Returns the X window Visual depth of the created window <me>
- ---Category: Inquire methods
-
- VisualID ( me )
- returns Integer from Standard is static;
- ---Level: Public
- ---Purpose: Returns the Visual ID of the Window
- ---Category: Inquire methods
-
- Quality ( me )
- returns WindowQuality from Xw is static;
- ---Level: Public
- ---Purpose: Returns the Quality of this window
- ---Category: Inquire methods
-
- PixelOfColor ( me ;aColor : NameOfColor from Quantity;
- aPixel : out Integer from Standard )
- returns Boolean from Standard is static;
- ---Level: Public
- ---Purpose: Returns FALSE when the returned pixel value <aPixel>
- -- of an RGB color <aColor> is exact or TRUE
- -- when the pixel value is approximated.
-
- PixelOfColor ( me ;aColor : Color from Quantity;
- aPixel : out Integer from Standard )
- returns Boolean from Standard is static;
- ---Level: Advanced
- ---Purpose: Returns FALSE when the returned pixel value <aPixel>
- -- of an RGB color <aColor> is exact or TRUE
- -- when the pixel value is approximated.
- -- Warning:
- -- make becarefull about the number of different pixel
- -- of colors reserved in the colormap in PseudoColor mode !!!
-
BackgroundPixel ( me ; aPixel : out Integer from Standard )
returns Boolean from Standard is static;
---Level: Public
---Purpose: Returns the ExtendedWindow address of the created window.
---Category: Inquire methods
- ExtendedColorMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns the ExtendedColorMap address of the created window.
- ---Category: Inquire methods
-
- ExtendedTypeMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns the ExtendedTypeMap address of the created window.
- ---Category: Inquire methods
-
- ExtendedWidthMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns the ExtendedWidthMap address of the created window.
- ---Category: Inquire methods
-
- ExtendedFontMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns the ExtendedFontMap address of the created window.
- ---Category: Inquire methods
-
- ExtendedMarkMap ( me )
- returns Address from Standard
- is static protected ;
- ---Level: Internal
- ---Purpose: Returns the ExtendedMarkMap address of the created window.
- ---Category: Inquire methods
-
SetWindow ( me: mutable ; aWindow : Handle from Aspect ;
- aQuality: WindowQuality from Xw ;
BackColor : NameOfColor from Quantity )
---Level: Internal
---Trigger: Raises if Window is not defined properly
SetWindow ( me: mutable ; Title : CString from Standard ;
Xc, Yc, Width, Height: Parameter from Quantity ;
- Quality : WindowQuality from Xw ;
BackColor : NameOfColor from Quantity ;
Parent : Handle from Aspect )
---Level: Internal
fields
- MyQuality : WindowQuality from Xw is protected ;
- MyColorMap : ColorMap from Xw is protected ;
- MyTypeMap : TypeMap from Xw is protected ;
- MyWidthMap : WidthMap from Xw is protected ;
- MyFontMap : FontMap from Xw is protected ;
- MyMarkMap : MarkMap from Xw is protected ;
MyXWindow : Handle from Aspect is protected ;
MyXParentWindow : Handle from Aspect is protected ;
- MyXPixmap : Handle from Aspect is protected ;
MyVisualClass : TypeOfVisual from Xw is protected ;
- MyDepth : Integer from Standard is protected ;
- MyBackgroundIndex : Integer from Standard is protected ;
MyExtendedDisplay : Address from Standard is protected ;
MyExtendedWindow : Address from Standard is protected ;
- MyExtendedColorMap : Address from Standard is protected ;
- MyExtendedTypeMap : Address from Standard is protected ;
- MyExtendedWidthMap : Address from Standard is protected ;
- MyExtendedFontMap : Address from Standard is protected ;
- MyExtendedMarkMap : Address from Standard is protected ;
-
-friends
-
- class IconBox from Xw
+ myDisplayConnection : DisplayConnection_Handle from Aspect is protected;
end Window ;
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-// Modified :
-// GG PRO5426 21/11/96
-// Proteger le viewer 2D contre des tentatives d'affichage
-// dans une fentre detruite ou iconifiee.
-// GG PRO6633 21/08/97
-// Protection contre capture d'image de taille NULLE.
-// GG OPTIMISATION 18/09/97
-// remplacer les appels myWindow->Position() par
-// myWindow->Size() qui est plus optimum.
-// GG OPTIMISATION 20/10/97
-// Implementation de DoMapping()
-// qui met a jour le MAPPING de la fenetre lorsque
-// un evenemment de type GUI_IconifyEvent arrive dans
-// l'application.
-// GG PRO10676 15/12/97
-// Permettre de definir une couleur directement par ses
-// composantes.
-// GG PRO14093 03/07/98
-// Eviter de "raiser" lorsqu'une erreur est detectee.
-// GG PRO14951 20/07/98
-// Ne pas modifier la couleur du background de la fenetre
-// lorsque aucune fille n'est cree.
-// (voir GUI_WidgetTools::DumpWidget())
-// GG CSR404 11/05/99
-// Avoid a crash in Dialog engine with a great number
-// of views.
-// GG G004 28/01/00 Add gama correction computation before dumping
-// an image.
-// GG IMP060200
-// Xw_get_image() signature change.
-// GG IMP070200
-// Add MMSize() method
-// TCL at October 2000 (G002); new method SetBackground( CString aName )
-// SAV 24/11/01 SetBackground( Quantity_Color )
-
#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
#include <Xw_Cextern.hxx>
//}
#include <Aspect_Convert.hxx>
+#include <Aspect_DisplayConnection.hxx>
#include <Image_AlienPixMap.hxx>
+#include <Standard_PCharacter.hxx>
#include <Xw_Extension.h>
//-Constructors
-Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device)
-: Aspect_Window(Device)
+Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
+: Aspect_Window(),
+ myDisplayConnection (theDisplayConnection)
{
Init();
}
//function : Xw_Window
//purpose :
//=======================================================================
-Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device,
+Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
const Standard_Integer aPart1,
const Standard_Integer aPart2,
- const Xw_WindowQuality Quality,
const Quantity_NameOfColor BackColor)
-: Aspect_Window(Device)
+: Aspect_Window(),
+ myDisplayConnection (theDisplayConnection)
{
Init();
Aspect_Handle aWindow = (aPart1 << 16) | (aPart2 & 0xFFFF);
- SetWindow (aWindow, Quality, BackColor);
+ SetWindow (aWindow, BackColor);
}
//=======================================================================
//function : Xw_Window
//purpose :
//=======================================================================
-Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device,
+Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
const Aspect_Handle aWindow,
- const Xw_WindowQuality Quality,
const Quantity_NameOfColor BackColor)
-: Aspect_Window(Device)
-{
- Init();
- SetWindow (aWindow, Quality, BackColor);
-}
-
-//=======================================================================
-//function : Xw_Window
-//purpose :
-//=======================================================================
-Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device,
- const Standard_CString Title,
- const Quantity_Parameter Xc,
- const Quantity_Parameter Yc,
- const Quantity_Parameter Width,
- const Quantity_Parameter Height,
- const Xw_WindowQuality Quality,
- const Quantity_NameOfColor BackColor,
- const Aspect_Handle Parent)
- : Aspect_Window(Device)
+: Aspect_Window(),
+ myDisplayConnection (theDisplayConnection)
{
Init();
- SetWindow (Title,Xc,Yc,Width,Height,Quality,BackColor,Parent);
+ SetWindow (aWindow, BackColor);
}
//=======================================================================
//function : Xw_Window
//purpose :
//=======================================================================
-Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& theDevice,
+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 Xw_WindowQuality theQuality,
const Quantity_NameOfColor theBackColor,
const Aspect_Handle theParent)
-: Aspect_Window (theDevice)
+: Aspect_Window (),
+ myDisplayConnection (theDisplayConnection)
{
Init();
- MyExtendedDisplay = theDevice->ExtendedDisplay();
Standard_Integer aParentSizeX = 1;
Standard_Integer aParentSizeY = 1;
thePxLeft, thePxTop, theWidth, theHeight,
aQCenterX, aQCenterY, aQSizeX, aQSizeY);
SetWindow (theTitle, aQCenterX, aQCenterY, aQSizeX, aQSizeY,
- theQuality, theBackColor, theParent);
+ theBackColor, theParent);
}
void Xw_Window::Init()
{
- MyBackgroundIndex = 0 ;
-
MyXWindow = 0 ;
MyXParentWindow = 0 ;
- MyXPixmap = 0 ;
- MyDepth = 0 ;
- MyExtendedDisplay = NULL ;
+#if defined(__APPLE__) && !defined(MACOSX_USE_GLX)
+ MyExtendedDisplay = NULL;
+#else
+ MyExtendedDisplay = Xw_set_display (myDisplayConnection->GetDisplay());
+#endif
MyExtendedWindow = NULL ;
- MyExtendedColorMap = NULL ;
- MyExtendedTypeMap = NULL ;
- MyExtendedWidthMap = NULL ;
- MyExtendedFontMap = NULL ;
- MyExtendedMarkMap = NULL ;
-
- MyQuality = Xw_WQ_3DQUALITY;
- MyVisualClass = Xw_TOV_STATICGRAY;
+ MyVisualClass = Xw_TOV_TRUECOLOR;
}
//=======================================================================
//=======================================================================
void Xw_Window::SetWindow (const Aspect_Handle aWindow,
- const Xw_WindowQuality Quality,
const Quantity_NameOfColor BackColor)
{
- if( (Quality == Xw_WQ_TRANSPARENT) || (Quality == Xw_WQ_OVERLAY) ) {
- SetWindow ("",0.5,0.5,1.0,1.0,Quality,BackColor,aWindow);
- } else {
- Aspect_Handle window,root,colormap,pixmap ;
- Xw_TypeOfVisual visualclass ;
- int visualdepth,visualid ;
- const Handle(Xw_GraphicDevice)& Device =
- Handle(Xw_GraphicDevice)::DownCast(MyGraphicDevice);
-
- MyExtendedDisplay = Device->ExtendedDisplay() ;
-
- MyBackgroundIndex = 0 ;
- MyXWindow = aWindow ;
- MyXParentWindow = aWindow ;
- MyQuality = Quality ;
-
- if( !MyXWindow ) {
- PrintError() ;
- }
-
- MyExtendedWindow =
- Xw_def_window (MyExtendedDisplay,MyXWindow,Standard_False);
-
- status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap,
- &root,&colormap,&visualclass,
- &visualdepth,&visualid);
- if( !status ) {
- PrintError() ;
- }
-
- Standard_Boolean Res1 =
- (Device->ExtendedColorMap3D() == Device->ExtendedColorMap2D());
- Standard_Boolean Res2 =
- (Quality == Xw_WQ_SAMEQUALITY);
- Standard_Boolean Res3 =
- (Quality == Xw_WQ_DRAWINGQUALITY && visualclass == Xw_TOV_PSEUDOCOLOR);
- Standard_Boolean Res4 =
- (Quality == Xw_WQ_3DQUALITY && visualclass == Xw_TOV_TRUECOLOR);
-
- //if (Quality == Xw_WQ_3DQUALITY && visualclass == Xw_TOV_PSEUDOCOLOR) {
- //Res4 = Standard_True;
- //visualclass = Xw_TOV_TRUECOLOR;
- //}
-
- if (Res1 || Res2 || Res3 || Res4) {
-
- MyVisualClass = visualclass ;
- MyXPixmap = pixmap ;
- MyDepth = visualdepth ;
-
- if( MyVisualClass == Xw_TOV_TRUECOLOR ) {
- MyColorMap = Device->ColorMap3D() ;
- } else {
- MyColorMap = Device->ColorMap2D() ;
- }
-
- if( visualid == MyColorMap->OverlayVisualID() ) {
- MyExtendedColorMap = MyColorMap->ExtendedOverlayColorMap();
- } else {
- MyExtendedColorMap = MyColorMap->ExtendedColorMap();
- }
-
- MyTypeMap = Device->TypeMap() ;
- MyExtendedTypeMap = Device->ExtendedTypeMap();
- MyWidthMap = Device->WidthMap() ;
- MyExtendedWidthMap = Device->ExtendedWidthMap();
- MyFontMap = Device->FontMap() ;
- MyExtendedFontMap = Device->ExtendedFontMap();
- MyMarkMap = Device->MarkMap() ;
- MyExtendedMarkMap = Device->ExtendedMarkMap();
-
- status = Xw_set_colormap(MyExtendedWindow,MyExtendedColorMap) ;
-
- if( !status ) {
- PrintError() ;
- }
-
- status = Xw_set_typemap(MyExtendedWindow,MyExtendedTypeMap) ;
-
- if( !status ) {
- PrintError() ;
- }
-
- status = Xw_set_widthmap(MyExtendedWindow,MyExtendedWidthMap) ;
-
- if( !status ) {
- PrintError() ;
- }
+ Aspect_Handle window,root,colormap,pixmap ;
+ Xw_TypeOfVisual visualclass ;
+ int visualdepth,visualid ;
- status = Xw_set_fontmap(MyExtendedWindow,MyExtendedFontMap) ;
+ MyXWindow = aWindow ;
+ MyXParentWindow = aWindow ;
- if( !status ) {
- PrintError() ;
- }
+ if( !MyXWindow ) {
+ PrintError() ;
+ }
- status = Xw_set_markmap(MyExtendedWindow,MyExtendedMarkMap) ;
+ MyExtendedWindow =
+ Xw_def_window (MyExtendedDisplay,MyXWindow,Standard_False);
- if( !status ) {
- PrintError() ;
- }
- SetBackground(BackColor) ;
-
- } else { // Create a child of this Window in the right Visual
- XW_WINDOWSTATE state = XW_WS_UNKNOWN ;
- int pxc, pyc;
- int width, height;
- float ratio;
- Quantity_Parameter Width = 1.0;
- Quantity_Parameter Height= 1.0;
-
- state = Xw_get_window_position (MyExtendedWindow,
- &pxc,&pyc,&width,&height);
- if( state == XW_WS_UNKNOWN ) {
- Xw_print_error() ;
- }
- ratio = float (width)/ float (height);
- if (ratio > 1.)
- Width = Width*ratio;
- else
- Height = Height/ratio;
- SetWindow ("",0.5,0.5,Width,Height,Quality,BackColor,MyXWindow);
- }
+ status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap,
+ &root,&colormap,&visualclass,
+ &visualdepth,&visualid);
+ if( !status ) {
+ PrintError() ;
}
+
+ SetBackground(BackColor) ;
}
//=======================================================================
const Quantity_Parameter Yc,
const Quantity_Parameter Width,
const Quantity_Parameter Height,
- const Xw_WindowQuality Quality,
const Quantity_NameOfColor BackColor,
const Aspect_Handle Parent)
{
- Aspect_Handle window,root,colormap,pixmap,*display ;
- Xw_TypeOfVisual visualclass ;
- Standard_Integer visualdepth,visualid,istransparent = Standard_False ;
-
- const Handle(Xw_GraphicDevice)& Device =
- Handle(Xw_GraphicDevice)::DownCast(MyGraphicDevice);
+ Standard_Integer istransparent = Standard_False ;
- MyBackgroundIndex = 0 ;
- MyExtendedDisplay = Device->ExtendedDisplay() ;
MyXParentWindow = Parent ;
MyXWindow = 0 ;
- MyQuality = Quality ;
-
- switch (Quality) {
- case Xw_WQ_3DQUALITY :
- case Xw_WQ_PICTUREQUALITY :
- MyColorMap = Device->ColorMap3D() ;
- MyVisualClass = Device->VisualClass3D() ;
- MyExtendedColorMap = Device->ExtendedColorMap3D();
- break ;
- case Xw_WQ_DRAWINGQUALITY :
- MyColorMap = Device->ColorMap2D() ;
- MyVisualClass = Device->VisualClass2D() ;
- MyExtendedColorMap = Device->ExtendedColorMap2D();
- break ;
- case Xw_WQ_SAMEQUALITY :
- if( !MyXParentWindow ) {
- status = Xw_get_display_info (MyExtendedDisplay,
- &display,&root,&colormap,&visualclass,
- &visualdepth) ;
- } else {
- MyExtendedWindow = Xw_def_window(MyExtendedDisplay,
- MyXParentWindow,Standard_False);
-
- status = Xw_get_window_info(MyExtendedWindow,&window,
- &pixmap,&root,&colormap,&visualclass,&visualdepth,
- &visualid) ;
- Xw_close_window(MyExtendedWindow,Standard_False) ;
- MyExtendedWindow = NULL;
- }
-
- if( !status ) {
- PrintError() ;
- }
- if( visualclass == Xw_TOV_TRUECOLOR ) {
- MyColorMap = Device->ColorMap3D() ;
- MyVisualClass = Device->VisualClass3D() ;
- MyExtendedColorMap = Device->ExtendedColorMap3D();
- } else if( visualclass == Xw_TOV_PSEUDOCOLOR ) {
- MyColorMap = Device->ColorMap2D() ;
- MyVisualClass = Device->VisualClass2D() ;
- MyExtendedColorMap = Device->ExtendedColorMap2D();
- }
- break ;
- case Xw_WQ_TRANSPARENT :
- istransparent = Standard_True ;
- case Xw_WQ_OVERLAY :
- if( !MyXParentWindow ) {
- status = Xw_get_display_info (MyExtendedDisplay,
- &display,&root,&colormap,&visualclass,
- &visualdepth) ;
- } else {
- MyExtendedWindow = Xw_def_window(MyExtendedDisplay,
- MyXParentWindow,istransparent);
-
- status = Xw_get_window_info(MyExtendedWindow,&window,
- &pixmap,&root,&colormap,&visualclass,&visualdepth,
- &visualid) ;
- Xw_close_window(MyExtendedWindow,Standard_False) ;
- MyExtendedWindow = NULL;
- }
-
- if( !status ) {
- PrintError() ;
- }
- if( visualclass == Xw_TOV_TRUECOLOR ) {
- MyColorMap = Device->ColorMap3D() ;
- MyExtendedColorMap = Device->ExtendedOverlayColorMap3D();
- MyVisualClass = Xw_TOV_OVERLAY;
- if( !MyExtendedColorMap ) {
- MyVisualClass = Device->VisualClass3D() ;
- MyExtendedColorMap = Device->ExtendedColorMap3D();
- }
- } else if( visualclass == Xw_TOV_PSEUDOCOLOR ) {
- MyColorMap = Device->ColorMap2D() ;
- MyExtendedColorMap = Device->ExtendedOverlayColorMap2D();
- MyVisualClass = Xw_TOV_OVERLAY;
- if( !MyExtendedColorMap ) {
- MyVisualClass = Device->VisualClass2D() ;
- MyExtendedColorMap = Device->ExtendedColorMap2D();
- }
- }
- break ;
- }
-
- if( MyVisualClass != Xw_TOV_DEFAULT ) {
- MyTypeMap = Device->TypeMap() ;
- MyExtendedTypeMap = Device->ExtendedTypeMap();
- MyWidthMap = Device->WidthMap() ;
- MyExtendedWidthMap = Device->ExtendedWidthMap();
- MyFontMap = Device->FontMap() ;
- MyExtendedFontMap = Device->ExtendedFontMap();
- MyMarkMap = Device->MarkMap() ;
- MyExtendedMarkMap = Device->ExtendedMarkMap();
-
- MyXWindow = Xw_open_window(MyExtendedDisplay,MyVisualClass,MyXParentWindow,
- (float)Xc,(float)Yc,(float)Width,(float)Height,
- (Standard_PCharacter)Title,istransparent) ;
- if( !MyXWindow ) {
- PrintError() ;
- }
-
- MyExtendedWindow =
- Xw_def_window (MyExtendedDisplay,MyXWindow,istransparent);
-
- status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap,
- &root,&colormap,&visualclass,&visualdepth,
- &visualid) ;
- if( !status ) {
- PrintError() ;
- }
-
- MyXPixmap = pixmap ;
- MyDepth = visualdepth ;
-
- status = Xw_set_colormap(MyExtendedWindow,MyExtendedColorMap) ;
-
- if( !status ) {
- PrintError() ;
- }
-
- status = Xw_set_typemap(MyExtendedWindow,MyExtendedTypeMap) ;
-
- if( !status ) {
- PrintError() ;
- }
-
- status = Xw_set_widthmap(MyExtendedWindow,MyExtendedWidthMap) ;
-
- if( !status ) {
- PrintError() ;
- }
-
- status = Xw_set_fontmap(MyExtendedWindow,MyExtendedFontMap) ;
-
- if( !status ) {
- PrintError() ;
- }
-
- status = Xw_set_markmap(MyExtendedWindow,MyExtendedMarkMap) ;
-
- if( !status ) {
- PrintError() ;
- }
-
- SetBackground(BackColor) ;
-
- if( MyXParentWindow && (MyXWindow != MyXParentWindow) ) Map() ;
- }
-}
-
-void Xw_Window::SetBackground (const Aspect_Background& Background) {
-Quantity_Color Color = Background.Color() ;
-
- SetBackground(Color.Name());
-
-}
-
-void Xw_Window::SetBackground (const Quantity_NameOfColor BackColor) {
-Quantity_Color Color ;
-Standard_Real r,g,b ;
-Standard_Integer index;
-
- Standard_Integer bcolor = Standard_Integer(BackColor);
- if( (MyQuality != Xw_WQ_TRANSPARENT) && (bcolor >= 0) ) {
- MyBackground.SetColor(BackColor) ;
-
- Color = MyBackground.Color() ;
- Color.Values(r,g,b,Quantity_TOC_RGB) ;
-
- status = Xw_get_color_index(MyExtendedColorMap,
- (float)r,(float)g,(float)b,&index);
-
- if( status ) {
- MyBackgroundIndex = index;
- status = Xw_close_background_pixmap(MyExtendedWindow);
- status = Xw_set_background_index (MyExtendedWindow,index) ;
- }
-
- if( !status ) {
- PrintError() ;
- }
- }
-}
-
-void Xw_Window::SetBackground(const Quantity_Color& color )
-{
- Standard_Real r,g,b;
- Standard_Integer index;
-
- Standard_Integer bcolor = Standard_Integer( color.Name() );
-
- if( ( MyQuality != Xw_WQ_TRANSPARENT ) && ( bcolor >= 0 ) ) {
-
- MyBackground.SetColor( color ) ;
- color.Values( r, g, b, Quantity_TOC_RGB );
-
- status = Xw_get_color_index( MyExtendedColorMap,
- (float)r, (float)g, (float)b, &index);
-
- if( status ) {
- MyBackgroundIndex = index;
- status = Xw_close_background_pixmap( MyExtendedWindow );
- status = Xw_set_background_index( MyExtendedWindow, index );
- }
-
- if( !status ) {
- PrintError() ;
- }
- }
-}
-
-//=======================================================================
-//function : SetBackground
-//purpose :
-//=======================================================================
-
-void Xw_Window::SetBackground (const Aspect_Handle aPixmap)
-{
- status = Xw_set_background_pixmap( MyExtendedWindow, aPixmap);
- if ( status ) {
- MyHBackground = aPixmap;
- MyBackgroundImage.Clear();
- MyBackgroundFillMethod = Aspect_FM_NONE;
- } else {
- PrintError();
- }
-}
-
-Standard_Boolean Xw_Window::SetBackground( const Standard_CString aName,
- const Aspect_FillMethod aMethod ) {
- if( !aName ) return Standard_False;
-
- status = XW_ERROR;
- Standard_Integer hash_code = ::HashCode( aName );
- XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle (MyExtendedWindow, (void* )hash_code);
-
- if ( !pimage )
- pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hash_code,(Standard_PCharacter)aName );
-
- if ( pimage )
- status = Xw_put_background_image( MyExtendedWindow, pimage, aMethod );
-
- if ( status ) {
- MyBackgroundImage = aName;
- MyBackgroundFillMethod = aMethod;
- Xw_get_background_pixmap( MyExtendedWindow, MyHBackground);
- } else {
- PrintError();
+ MyXWindow = Xw_open_window(MyExtendedDisplay,MyVisualClass,MyXParentWindow,
+ (float)Xc,(float)Yc,(float)Width,(float)Height,
+ (Standard_PCharacter)Title,istransparent) ;
+ if( !MyXWindow ) {
+ PrintError() ;
}
- return status;
-
-} // end Xw_Window::SetBackground
-
-void Xw_Window::SetBackground (const Aspect_GradientBackground& GrBackground) {
-
- Quantity_Color Color1, Color2;
- GrBackground.Colors(Color1,Color2);
- SetBackground(Color1,Color2, GrBackground.BgGradientFillMethod());
-
-}
-
-void Xw_Window::SetBackground( const Quantity_Color& color1,
- const Quantity_Color& color2,
- const Aspect_GradientFillMethod aMethod) {
-
- Standard_Integer bcolor = Standard_Integer( color1.Name() ) + Standard_Integer( color2.Name() );
- if( ( MyQuality != Xw_WQ_TRANSPARENT ) && ( bcolor >= 0 ) )
- MyGradientBackground.SetColors( color1, color2, aMethod ) ;
+ MyExtendedWindow =
+ Xw_def_window (MyExtendedDisplay,MyXWindow,istransparent);
-}
-
-void Xw_Window::SetDoubleBuffer (const Standard_Boolean DBmode) {
-
- status = Xw_set_double_buffer(MyExtendedWindow,
- (XW_DOUBLEBUFFERMODE)DBmode) ;
-
- if( !status ) {
- PrintError() ;
- }
-}
-
-void Xw_Window::Flush() const {
+ SetBackground(BackColor) ;
- status = Xw_flush (MyExtendedWindow,Standard_False);
+ if( MyXParentWindow && (MyXWindow != MyXParentWindow) ) Map() ;
- if( !status ) {
- PrintError() ;
- }
}
void Xw_Window::Map () const {
MyXWindow = 0 ;
MyExtendedWindow = NULL ;
- MyExtendedColorMap = NULL ;
- MyExtendedTypeMap = NULL ;
- MyExtendedWidthMap = NULL ;
- MyExtendedFontMap = NULL ;
- MyExtendedMarkMap = NULL ;
-}
-
-void Xw_Window::Clear () const {
-
- status = Xw_erase_window (MyExtendedWindow);
-
- if( !status ) {
- PrintError() ;
- }
-}
-
-void Xw_Window::ClearArea (const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const {
-
- status = Xw_erase_area (MyExtendedWindow,int(Xc),int(Yc),
- int(Width),int(Height));
-
- if( !status ) {
- PrintError() ;
- }
-}
-
-void Xw_Window::Restore () const {
-
- if( !IsMapped() ) return;
- status = Xw_restore_window (MyExtendedWindow);
-
- if( !status ) {
- PrintError() ;
- }
-}
-
-void Xw_Window::RestoreArea (const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const {
-
- if( !IsMapped() ) return;
- status = Xw_restore_area (MyExtendedWindow,int(Xc),int(Yc),
- int(Width),int(Height));
-
- if( !status ) {
- PrintError() ;
- }
-}
-
-Standard_Boolean Xw_Window::Dump (const Standard_CString theFilename,
- const Standard_Real theGammaValue) const
-{
- int aDummy, aWidth, aHeight;
- XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow,
- &aDummy, &aDummy, &aWidth, &aHeight);
- if (state == XW_WS_UNKNOWN)
- {
- return Standard_False;
- }
-
- return DumpArea (theFilename, aWidth / 2, aHeight / 2,
- aWidth, aHeight, theGammaValue);
-}
-
-Standard_Boolean Xw_Window::DumpArea (const Standard_CString theFilename,
- const Standard_Integer theXc, const Standard_Integer theYc,
- const Standard_Integer theWidth, const Standard_Integer theHeight,
- const Standard_Real theGammaValue) const
-{
- int aWidth = Abs(theWidth);
- int aHeight = Abs(theHeight);
- XW_EXT_IMAGEDATA* pimage = NULL;
- if (DoubleBuffer())
- {
- Aspect_Handle window, root, colormap, pixmap;
- Xw_TypeOfVisual visualclass;
- int visualdepth, visualid;
- Xw_get_window_info (MyExtendedWindow, &window, &pixmap,
- &root, &colormap, &visualclass,
- &visualdepth, &visualid);
-
- pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_from_pixmap (MyExtendedWindow, (Standard_PCharacter )theFilename,
- pixmap,
- theXc, theYc, aWidth, aHeight);
- }
- else
- {
- pimage = (XW_EXT_IMAGEDATA* )Xw_get_image (MyExtendedWindow, (Standard_PCharacter )theFilename,
- theXc, theYc, aWidth, aHeight);
- }
-
- if (pimage == NULL)
- {
- return Standard_False;
- }
-
- if (theGammaValue != 1.0)
- {
- Xw_gamma_image (pimage, Standard_ShortReal (theGammaValue));
- }
- XW_STATUS aStatus = Xw_save_image (MyExtendedWindow, pimage, (Standard_PCharacter )theFilename);
- Xw_close_image (pimage);
-
- return Standard_Boolean(aStatus);
-}
-
-Standard_Boolean Xw_Window::ToPixMap (Image_PixMap& thePixMap) const
-{
- int aDummy, aWidth, aHeight;
- XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow,
- &aDummy, &aDummy, &aWidth, &aHeight);
- if (state == XW_WS_UNKNOWN)
- {
- return Standard_False;
- }
-
- XW_EXT_IMAGEDATA* pimage = NULL;
- if (DoubleBuffer())
- {
- Aspect_Handle window, root, colormap, pixmap;
- Xw_TypeOfVisual visualclass;
- int visualdepth, visualid;
- Xw_get_window_info (MyExtendedWindow, &window, &pixmap,
- &root, &colormap, &visualclass,
- &visualdepth, &visualid);
-
- pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_from_pixmap (MyExtendedWindow, NULL,
- pixmap,
- aWidth / 2, aHeight / 2, aWidth, aHeight);
- }
- else
- {
- pimage = (XW_EXT_IMAGEDATA* )Xw_get_image (MyExtendedWindow, NULL,
- aWidth / 2, aHeight / 2, aWidth, aHeight);
- }
-
- if (pimage == NULL)
- {
- return Standard_False;
- }
-
- XImage* pximage = (pimage->zximage) ? pimage->zximage : pimage->pximage;
- XW_EXT_WINDOW* pwindow = (XW_EXT_WINDOW* )MyExtendedWindow;
- if (pwindow->pcolormap->visual->c_class != TrueColor)
- {
- return Standard_False;
- }
-
- const bool isBigEndian = (pximage->byte_order == MSBFirst);
- Image_PixMap::ImgFormat aFormat = (pximage->bits_per_pixel == 32)
- ? (isBigEndian ? Image_PixMap::ImgRGB32 : Image_PixMap::ImgBGR32)
- : (isBigEndian ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR);
- Image_PixMap aWrapper;
- aWrapper.InitWrapper (aFormat, (Standard_Byte* )pximage->data, pximage->width, pximage->height, pximage->bytes_per_line);
- aWrapper.SetTopDown (true);
-
- Standard_Boolean isSuccess = thePixMap.InitCopy (aWrapper);
- Xw_close_image (pimage);
- return isSuccess;
-}
-
-Standard_Boolean Xw_Window::Load (const Standard_CString aFilename) const {
-Standard_Integer hashcode = ::HashCode(aFilename) ;
-XW_WINDOWSTATE state;
-int pxc,pyc,wwidth,wheight,iwidth,iheight,idepth,resize = Standard_False;
-float izoom;
-
- state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&wwidth,&wheight);
-
- status = XW_ERROR;
- XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle( MyExtendedWindow,(void*)hashcode ) ;
- if( !pimage ) {
- pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hashcode,(Standard_PCharacter)aFilename );
- }
-
- if( pimage ) {
- status = Xw_get_image_info(pimage,&izoom,&iwidth,&iheight,&idepth);
- iwidth = (int)(iwidth/izoom);
- iheight = (int)(iheight/izoom);
- }
-
- if( status && state != XW_WS_UNKNOWN ) {
- float uxc,uyc ;
- if( iwidth > wwidth ) {
- resize = Standard_True;
- wwidth = iwidth;
- }
- if( iheight > wheight ) {
- resize = Standard_True;
- wheight = iheight;
- }
- if( resize ) {
- status = Xw_set_window_position (MyExtendedWindow,
- pxc,pyc,wwidth,wheight);
- }
- status = Xw_get_window_pixelcoord(MyExtendedWindow,
- wwidth/2,wheight/2,&uxc,&uyc);
- status = Xw_draw_image(MyExtendedWindow, pimage, uxc, uyc);
- Xw_flush(MyExtendedWindow, Standard_True);
- } else status = XW_ERROR ;
-
- if( !status ) {
- PrintError() ;
- }
-
- return Standard_Boolean(status);
-}
-
-Standard_Boolean Xw_Window::LoadArea (const Standard_CString aFilename, const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const {
-Standard_Integer hashcode = ::HashCode(aFilename) ;
-int pxc,pyc,wwidth,wheight,iwidth,iheight,idepth;
-float izoom,uxc,uyc;
-
- XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&wwidth,&wheight);
- status = XW_ERROR;
- XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle( MyExtendedWindow,(void*)hashcode ) ;
- if( !pimage ) {
- pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hashcode,(Standard_PCharacter)aFilename );
- }
-
- if( pimage ) {
- status = Xw_get_image_info(pimage,&izoom,&iwidth,&iheight,&idepth);
- iwidth = (int)(iwidth/izoom);
- iheight = (int)(iheight/izoom);
- }
-
- if( status && state != XW_WS_UNKNOWN ) {
- if( iwidth > Width || iheight > Height ) {
- izoom = (float)Min(Width,Height)/(float)Max(iwidth,iheight) ;
- status = Xw_zoom_image(pimage,izoom) ;
- }
- status = Xw_get_window_pixelcoord(MyExtendedWindow,Xc,Yc,&uxc,&uyc);
- status = Xw_draw_image(MyExtendedWindow, pimage, uxc, uyc);
- Xw_flush(MyExtendedWindow, Standard_True);
- } else status = XW_ERROR ;
-
- if( !status ) {
- PrintError() ;
- }
-
- return Standard_Boolean(status);
}
void Xw_Window::SetCursor (const Standard_Integer anId, const Quantity_NameOfColor aColor) const {
}
}
-Standard_Boolean Xw_Window::BackingStore () const {
-
- if( MyXPixmap ) status = XW_SUCCESS ;
- else {
- status = Xw_open_pixmap(MyExtendedWindow) ;
- }
-
- return (Standard_Boolean(status)) ;
-}
-
-Standard_Boolean Xw_Window::DoubleBuffer () const {
-XW_DOUBLEBUFFERMODE state = Xw_get_double_buffer(MyExtendedWindow) ;
-
- return (state == XW_ENABLE ? Standard_True : Standard_False) ;
-}
-
Standard_Boolean Xw_Window::IsMapped () const {
if (IsVirtual()) {
return Standard_True;
return ((Standard_Real)width/height) ;
}
-void Xw_Window::Size (Standard_Real &Width, Standard_Real &Height) const {
-int width, height;
-
- status = Xw_get_window_size (MyExtendedWindow,&width,&height);
- if( !status ) {
- Xw_print_error() ;
- }
-
- Width = Xw_get_screen_pixelvalue (MyExtendedDisplay,width) ;
- Height = Xw_get_screen_pixelvalue (MyExtendedDisplay,height) ;
-}
-
void Xw_Window::Size (Standard_Integer &Width, Standard_Integer &Height) const {
int width, height;
status = Xw_get_window_size (MyExtendedWindow,&width,&height);
Height = height ;
}
-void Xw_Window::MMSize (Standard_Real &Width, Standard_Real &Height) const {
-int width, height;
-
- status = Xw_get_window_size (MyExtendedWindow,&width,&height);
- if( !status ) {
- Xw_print_error() ;
- }
-
- float x,y ;
- status = Xw_get_window_pixelcoord(MyExtendedWindow,
- width,0,&x,&y) ;
- if( !status ) {
- PrintError() ;
- }
-
- Width = Standard_Real(x); Height = Standard_Real(y);
-}
-
-void Xw_Window::Position (Standard_Real &X1, Standard_Real &Y1, Standard_Real &X2, Standard_Real &Y2) const {
-XW_WINDOWSTATE state = XW_WS_UNKNOWN ;
-int pxc, pyc;
-int width, height;
-float x1,y1,x2,y2 ;
-
- state = Xw_get_window_position (MyExtendedWindow,
- &pxc,&pyc,&width,&height);
- if( state == XW_WS_UNKNOWN ) {
- Xw_print_error() ;
- }
- Xw_get_screen_pixelcoord (MyExtendedDisplay,pxc-width/2,
- pyc-height/2,
- &x1,&y1) ;
- Xw_get_screen_pixelcoord (MyExtendedDisplay,pxc+width/2,
- pyc+height/2,
- &x2,&y2) ;
- X1 = x1 ; Y1 = y2 ; X2 = x2 ; Y2 = y1 ;
-}
-
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;
X2 = X1 + width - 1 ; Y2 = Y1 + height - 1 ;
}
-Standard_Real Xw_Window::Convert (const Standard_Integer Pv) const {
-Standard_Real Dv ;
-
- Dv = Xw_get_screen_pixelvalue(MyExtendedDisplay,(int)Pv) ;
-
- return (Dv) ;
-}
-
-void Xw_Window::Convert (const Standard_Integer Px, const Standard_Integer Py, Standard_Real &Dx, Standard_Real &Dy ) const {
-float x,y ;
-
- status = Xw_get_screen_pixelcoord(MyExtendedDisplay,
- (int)Px,(int)Py,&x,&y) ;
-
- if( !status ) {
- Xw_print_error() ;
- }
-
- Dx = x ; Dy = y ;
-}
-
-Standard_Integer Xw_Window::Convert (const Standard_Real Dv) const {
-Standard_Integer Pv ;
-
- Pv = Xw_get_pixel_screenvalue(MyExtendedDisplay,(float)Dv) ;
-
- return (Pv) ;
-}
-
-void Xw_Window::Convert (const Standard_Real Dx, const Standard_Real Dy, Standard_Integer &Px, Standard_Integer &Py ) const {
-int x,y ;
-
- status = Xw_get_pixel_screencoord(MyExtendedDisplay,
- (float)Dx,(float)Dy,&x,&y) ;
-
- if( !status ) {
- Xw_print_error() ;
- }
-
- Px = x ; Py = y ;
-}
-
-Handle(Xw_ColorMap) Xw_Window::ColorMap() const {
-
- return (MyColorMap) ;
-}
-
-Handle(Xw_TypeMap) Xw_Window::TypeMap() const {
-
- return (MyTypeMap) ;
-}
-
-Handle(Xw_WidthMap) Xw_Window::WidthMap() const {
-
- return (MyWidthMap) ;
-}
-
-Handle(Xw_FontMap) Xw_Window::FontMap() const {
-
- return (MyFontMap) ;
-}
-
-Handle(Xw_MarkMap) Xw_Window::MarkMap() const {
-
- return (MyMarkMap) ;
-}
-
Aspect_Handle Xw_Window::XWindow () const {
return (MyXWindow);
return (pixmap);
}
-Standard_Address Xw_Window::XVisual( ) const
-{
- Aspect_Handle *VisualInfo ;
- Xw_TypeOfVisual VisualClass ;
- int MaxColor,BaseColor,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid ;
-
- status = Xw_get_colormap_info(MyExtendedColorMap,&VisualInfo,
- &VisualClass,&visualid,&MaxColor,&BaseColor,
- &MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex);
-
- if( !status ) {
- PrintError() ;
- }
-
- return (VisualInfo) ;
-}
-
-Aspect_Handle Xw_Window::XColorMap( ) const
-{
- Aspect_Handle colormap ;
-
- colormap = Xw_get_colormap_xid(MyExtendedColorMap) ;
-
- if( !colormap ) {
- PrintError() ;
- }
-
- return (colormap) ;
-}
-
Standard_Boolean Xw_Window::PointerPosition (Standard_Integer& X, Standard_Integer& Y) const {
Standard_Boolean cstatus ;
int x,y ;
}
-Standard_Integer Xw_Window::VisualDepth () const {
-
- return (MyDepth);
-
-}
-
-Standard_Integer Xw_Window::VisualID( ) 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) ;
-
- return (visualid) ;
-}
-
-Xw_WindowQuality Xw_Window::Quality () const {
-
- return (MyQuality);
-
-}
-
-Standard_Boolean Xw_Window::PixelOfColor ( const Quantity_NameOfColor aColor, Standard_Integer &aPixel ) const {
-Standard_Real Red,Green,Blue ;
-unsigned long pixel ;
-Standard_Integer isapproximate;
-Quantity_Color color(aColor);
-
- color.Values(Red,Green,Blue,Quantity_TOC_RGB) ;
-
- status = Xw_get_color_pixel(MyExtendedColorMap,
- (float)Red,(float)Green,(float)Blue,&pixel,&isapproximate) ;
- if( !status ) PrintError() ;
-
- aPixel = Standard_Integer(pixel);
-
- return (isapproximate) ? Standard_True : Standard_False;
-}
-
-Standard_Boolean Xw_Window::PixelOfColor ( const Quantity_Color &aColor, Standard_Integer &aPixel ) const {
-Standard_Real Red,Green,Blue ;
-unsigned long pixel ;
-Standard_Integer isapproximate;
-
- aColor.Values(Red,Green,Blue,Quantity_TOC_RGB) ;
-
- status = Xw_get_color_pixel(MyExtendedColorMap,
- (float)Red,(float)Green,(float)Blue,&pixel,&isapproximate) ;
- if( !status ) PrintError() ;
-
- aPixel = Standard_Integer(pixel);
-
- return (isapproximate) ? Standard_True : Standard_False;
-}
-
Standard_Boolean Xw_Window::BackgroundPixel ( Standard_Integer &aPixel ) const {
unsigned long pixel ;
return (MyExtendedWindow);
}
-
-Standard_Address Xw_Window::ExtendedColorMap () const {
-
- return (MyExtendedColorMap);
-
-}
-
-Standard_Address Xw_Window::ExtendedTypeMap () const {
-
- return (MyExtendedTypeMap);
-
-}
-
-Standard_Address Xw_Window::ExtendedWidthMap () const {
-
- return (MyExtendedWidthMap);
-
-}
-
-Standard_Address Xw_Window::ExtendedFontMap () const {
-
- return (MyExtendedFontMap);
-
-}
-
-Standard_Address Xw_Window::ExtendedMarkMap () const {
-
- return (MyExtendedMarkMap);
-
-}