mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
24
src/Draw/COMMANDWINDOW.h
Executable file
24
src/Draw/COMMANDWINDOW.h
Executable file
@@ -0,0 +1,24 @@
|
||||
#ifdef WNT
|
||||
|
||||
|
||||
#define COMMANDCLASS "COMMANDWINDOW"
|
||||
#define COMMANDTITLE "Command Window"
|
||||
|
||||
|
||||
HWND CreateCommandWindow(HWND, int);
|
||||
LONG APIENTRY CommandProc(HWND, UINT, WPARAM, LONG);
|
||||
BOOL CommandCreateProc(HWND);
|
||||
VOID CommandDestroyProc(HWND);
|
||||
BOOL CommandHandler(HWND, WPARAM, LPARAM);
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <tcl.h>
|
||||
#include <Standard_Stream.hxx>
|
||||
#include <stdio.h>
|
||||
//#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
|
||||
#endif
|
261
src/Draw/CommandWindow.cxx
Executable file
261
src/Draw/CommandWindow.cxx
Executable file
@@ -0,0 +1,261 @@
|
||||
// File: CommandWindow.cxx
|
||||
// Created: Thu Aug 6 09:59:19 1998
|
||||
// Author: Administrateur Atelier MDL
|
||||
// <mdl@efalakox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
|
||||
#ifdef WNT
|
||||
#include <windows.h>
|
||||
|
||||
#define COMMANDCLASS "COMMANDWINDOW"
|
||||
#define COMMANDTITLE "Command Window"
|
||||
|
||||
#include <CommandWindow.h>
|
||||
#include <Draw_Window.hxx>
|
||||
#include <MainWindow.h>
|
||||
#include <Draw_Appli.hxx>
|
||||
|
||||
|
||||
|
||||
/****************************************************\
|
||||
* CommandWindow.cxx :
|
||||
*
|
||||
\****************************************************/
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Draw_Interprete(char*); // Implemente dans draw.cxx
|
||||
|
||||
#define CLIENTWND 0
|
||||
|
||||
#define PROMPT "Command >> "
|
||||
#define COMMANDSIZE 1000 // Nb caracteres maximun pour un commande
|
||||
|
||||
|
||||
// Definition des varaibles globales
|
||||
#ifdef STRICT
|
||||
WNDPROC OldEditProc; // Sauvegarde la procedure standard de la fenetre d'edition (Sous Classement)
|
||||
#else
|
||||
FARPROC OldEditProc;
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| CREATE COMMAND WINDOW PROCEDURE
|
||||
\*--------------------------------------------------------*/
|
||||
HWND CreateCommandWindow(HWND hWnd, int nitem)
|
||||
{
|
||||
HINSTANCE hInstance;
|
||||
|
||||
#ifndef _WIN64
|
||||
hInstance = (HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE);
|
||||
#else
|
||||
hInstance = (HINSTANCE)GetWindowLong(hWnd,GWLP_HINSTANCE);
|
||||
#endif
|
||||
HWND hWndCommand = (CreateWindow(COMMANDCLASS, COMMANDTITLE,
|
||||
WS_CLIPCHILDREN | WS_OVERLAPPED |
|
||||
WS_THICKFRAME | WS_CAPTION ,
|
||||
0, 0,
|
||||
400, 100,
|
||||
hWnd, NULL, hInstance, NULL));
|
||||
|
||||
ShowWindow(hWndCommand, SW_SHOW);
|
||||
return hWndCommand;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| COMMAND WINDOW PROCEDURE
|
||||
\*--------------------------------------------------------*/
|
||||
LONG APIENTRY CommandProc(HWND hWnd, UINT wMsg, WPARAM wParam, LONG lParam )
|
||||
{
|
||||
HWND hWndEdit;
|
||||
int index; // Nombre de caractere dans le buffer de hWndEdit
|
||||
MINMAXINFO* lpmmi;
|
||||
|
||||
switch(wMsg)
|
||||
{
|
||||
case WM_CREATE :
|
||||
CommandCreateProc(hWnd);
|
||||
hWndEdit = (HWND)GetWindowLong(hWnd, CLIENTWND);
|
||||
SendMessage(hWndEdit,EM_REPLACESEL, 0,(LPARAM)PROMPT);
|
||||
break;
|
||||
|
||||
case WM_GETMINMAXINFO :
|
||||
lpmmi = (LPMINMAXINFO)lParam;
|
||||
lpmmi->ptMinTrackSize.x = 200;
|
||||
lpmmi->ptMinTrackSize.y = 50;
|
||||
break;
|
||||
|
||||
case WM_SIZE :
|
||||
hWndEdit = (HWND)GetWindowLong(hWnd, CLIENTWND);
|
||||
MoveWindow(hWndEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
|
||||
// Place le curseur a la fin du buffer
|
||||
index = SendMessage(hWnd, WM_GETTEXTLENGTH, 0l, 0l);
|
||||
SendMessage(hWnd, EM_SETSEL, index, index);
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS :
|
||||
hWndEdit = (HWND)GetWindowLong(hWnd, CLIENTWND);
|
||||
SetFocus(hWndEdit);
|
||||
break;
|
||||
|
||||
default :
|
||||
return(DefWindowProc(hWnd, wMsg, wParam, lParam));
|
||||
}
|
||||
return(0l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
LONG APIENTRY EditProc(HWND, UINT, WPARAM, LONG);
|
||||
/*--------------------------------------------------------*\
|
||||
| COMMAND CREATE PROCEDURE
|
||||
\*--------------------------------------------------------*/
|
||||
BOOL CommandCreateProc(HWND hWnd)
|
||||
{
|
||||
|
||||
#ifndef _WIN64
|
||||
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
|
||||
#else
|
||||
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hWnd, GWLP_HINSTANCE);
|
||||
#endif
|
||||
HWND hWndEdit = CreateWindow("EDIT",NULL,
|
||||
WS_CHILD | WS_VISIBLE | WS_VSCROLL |
|
||||
ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
|
||||
0, 0, 0, 0,
|
||||
hWnd, 0,
|
||||
hInstance, NULL);
|
||||
|
||||
// Enregistrement hWndEdit deans l'extra memory en 0 de CommandWindow
|
||||
if (hWndEdit)
|
||||
SetWindowLong(hWnd, CLIENTWND, (LONG)hWndEdit);
|
||||
|
||||
// Sous Classement de la fenetre
|
||||
//-------
|
||||
// Sauvegarde du pointeur sur la procedure existante
|
||||
#ifdef STRICT
|
||||
#ifndef _WIN64
|
||||
OldEditProc = (WNDPROC)GetWindowLong(hWndEdit, GWL_WNDPROC);
|
||||
#else
|
||||
OldEditProc = (WNDPROC)GetWindowLong(hWndEdit, GWLP_WNDPROC);
|
||||
#endif // _WIN64
|
||||
#else
|
||||
OldEditProc = (FARPROC)GetWindowLong(hWndEdit, GWL_WNDPROC);
|
||||
#endif
|
||||
// Mise en place de la nouvelle fonction
|
||||
#ifndef _WIN64
|
||||
SetWindowLong(hWndEdit, GWL_WNDPROC, (LONG) EditProc);
|
||||
#else
|
||||
SetWindowLong(hWndEdit, GWLP_WNDPROC, (LONG) EditProc);
|
||||
#endif
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| GET COMMAND
|
||||
|
|
||||
\*--------------------------------------------------------*/
|
||||
int GetCommand(HWND hWnd, char* buffer)
|
||||
{
|
||||
int again = 1;
|
||||
char temp[COMMANDSIZE]="";
|
||||
|
||||
int nbLine = SendMessage(hWnd, EM_GETLINECOUNT, 0l, 0l);
|
||||
|
||||
int nbChar = 0;
|
||||
buffer[0]='\0';
|
||||
while ( again && nbLine > -1 && nbChar < COMMANDSIZE-1)
|
||||
{
|
||||
strcat(buffer, strrev(temp));
|
||||
// Initialisation du 1er WORD de temp au nombre de caracteres a lire
|
||||
WORD* nbMaxChar = (WORD*)temp;
|
||||
*nbMaxChar = COMMANDSIZE-1;
|
||||
|
||||
int nbCharRead = SendMessage(hWnd, EM_GETLINE, nbLine-1, (LPARAM)temp);
|
||||
nbChar += nbCharRead ;
|
||||
int cmp = strncmp(temp, PROMPT, 10);
|
||||
temp[nbCharRead]='\0';
|
||||
if( cmp == 0 )
|
||||
{
|
||||
strcat(buffer, strrev(temp));
|
||||
again = 0;
|
||||
}
|
||||
nbLine -= 1;
|
||||
}
|
||||
strrev(buffer);
|
||||
return nbChar;
|
||||
}
|
||||
|
||||
extern console_semaphore_value volatile console_semaphore;
|
||||
extern char console_command[1000];
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| EDIT WINDOW PROCEDURE
|
||||
\*--------------------------------------------------------*/
|
||||
LONG APIENTRY EditProc(HWND hWnd, UINT wMsg, WPARAM wParam, LONG lParam )
|
||||
{
|
||||
char buffer[COMMANDSIZE];
|
||||
POINT pos;
|
||||
BOOL rep;
|
||||
static int nbline; // Taille du buffer de la fenetre d`edition
|
||||
int index;
|
||||
|
||||
switch(wMsg)
|
||||
{
|
||||
case WM_CHAR :
|
||||
if (console_semaphore != WAIT_CONSOLE_COMMAND)
|
||||
return 0l;
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
// Surcharge du caractere \n
|
||||
case 0x0d :
|
||||
GetCommand(hWnd, buffer);
|
||||
// Traitement standard
|
||||
CallWindowProc(OldEditProc, hWnd, wMsg, wParam, lParam);
|
||||
// Affichage du PROMPT
|
||||
rep = GetCaretPos(&pos);
|
||||
SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)PROMPT);
|
||||
// Affiche la commande dans la console
|
||||
cout << buffer << endl;
|
||||
/*if (Draw_Interprete(buffer+strlen(PROMPT))== -2)
|
||||
DestroyProc(hWnd); */
|
||||
strcpy(console_command, buffer+strlen(PROMPT));
|
||||
console_semaphore = HAS_CONSOLE_COMMAND;
|
||||
// Purge du buffer
|
||||
nbline = SendMessage(hWnd, EM_GETLINECOUNT, 0l, 0l);
|
||||
if(nbline > 200)
|
||||
{
|
||||
nbline = 0;
|
||||
GetCommand(hWnd, buffer);
|
||||
index = SendMessage(hWnd, EM_LINEINDEX, 100, 0);
|
||||
SendMessage(hWnd, EM_SETSEL, 0, index);
|
||||
SendMessage(hWnd, WM_CUT, 0, 0);
|
||||
// Place le curseur en fin de text
|
||||
index = SendMessage(hWnd, WM_GETTEXTLENGTH, 0l, 0l);
|
||||
SendMessage(hWnd, EM_SETSEL, index, index);
|
||||
}
|
||||
return(0l);
|
||||
break;
|
||||
default :
|
||||
if (IsAlphanumeric((Standard_Character)LOWORD(wParam)))
|
||||
{
|
||||
// Place le curseur en fin de texte avant affichage
|
||||
index = SendMessage(hWnd, WM_GETTEXTLENGTH, 0l, 0l);
|
||||
SendMessage(hWnd, EM_SETSEL, index, index);
|
||||
CallWindowProc(OldEditProc, hWnd, wMsg, wParam, lParam);
|
||||
return 0l;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
if (console_semaphore != WAIT_CONSOLE_COMMAND)
|
||||
return 0l;
|
||||
}
|
||||
return CallWindowProc(OldEditProc, hWnd, wMsg, wParam, lParam);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
213
src/Draw/Draw.cdl
Executable file
213
src/Draw/Draw.cdl
Executable file
@@ -0,0 +1,213 @@
|
||||
-- File: Draw.cdl
|
||||
-- Created: Wed Apr 24 14:09:59 1991
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@topsn2>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
package Draw
|
||||
|
||||
---Purpose: MAQUETTE DESSIN MODELISATION
|
||||
|
||||
uses OSD, MMgt, TCollection, TColStd, gp, Message
|
||||
|
||||
is
|
||||
exception Failure inherits Failure from Standard;
|
||||
|
||||
enumeration ColorKind is blanc,
|
||||
--white in english
|
||||
rouge,
|
||||
--red in english
|
||||
vert,
|
||||
--green in english
|
||||
bleu,
|
||||
--blue in english
|
||||
cyan,
|
||||
-- same in english
|
||||
or,
|
||||
--gold in english
|
||||
magenta,
|
||||
--same in english
|
||||
marron,
|
||||
--brown in english
|
||||
orange,
|
||||
--same in english
|
||||
rose,
|
||||
--pink in english
|
||||
saumon,
|
||||
--salmon in english
|
||||
violet,
|
||||
--same in english
|
||||
jaune,
|
||||
--yellow in english
|
||||
kaki,
|
||||
--DarkOliveGreen in english
|
||||
corail;
|
||||
--Coral in english
|
||||
|
||||
enumeration MarkerShape is
|
||||
Square, Losange, X, Plus, Circle, CircleZoom;
|
||||
|
||||
---Purpose: Circle is not sensible to zoom, like
|
||||
-- other MarkerShape, contrarily to CircleZoom
|
||||
|
||||
|
||||
|
||||
deferred class Drawable3D;
|
||||
|
||||
deferred class Drawable2D;
|
||||
|
||||
class Color;
|
||||
|
||||
class Display;
|
||||
|
||||
class Segment3D;
|
||||
|
||||
class Segment2D;
|
||||
|
||||
class Marker3D;
|
||||
|
||||
class Marker2D;
|
||||
|
||||
class Axis3D;
|
||||
|
||||
class Axis2D;
|
||||
|
||||
class Text3D;
|
||||
|
||||
class Text2D;
|
||||
|
||||
class Circle3D;
|
||||
|
||||
class Circle2D;
|
||||
|
||||
class Number;
|
||||
|
||||
class Chronometer;
|
||||
|
||||
class Grid;
|
||||
|
||||
class Box;
|
||||
---Purpose: a 3d box
|
||||
|
||||
class SequenceOfDrawable3D instantiates
|
||||
Sequence from TCollection (Drawable3D);
|
||||
|
||||
class ProgressIndicator;
|
||||
|
||||
imported PInterp;
|
||||
---Purpose: typedef Tcl_Interp * Draw_PInterp;
|
||||
|
||||
primitive CommandFunction;
|
||||
---Purpose: typedef Standard_Integer (*Draw_CommandFunction)
|
||||
-- (Draw_Interpretor&, Standard_Integer, char**)
|
||||
|
||||
class Interpretor;
|
||||
---Purpose: Encapsulate the Tcl interpretor to add commands.
|
||||
|
||||
class Printer;
|
||||
---Purpose: Implements a printer class to connect Message_Messenger
|
||||
-- tool to Draw_Interpretor output.
|
||||
|
||||
class VMap instantiates
|
||||
DataMap from TCollection(Integer,
|
||||
Drawable3D from Draw,
|
||||
MapIntegerHasher from TColStd);
|
||||
|
||||
private class MapOfFunctions instantiates DataMap from TCollection(AsciiString from TCollection ,Function from OSD, AsciiString from TCollection);
|
||||
|
||||
class MapOfAsciiString instantiates IndexedMap from TCollection(AsciiString from TCollection,AsciiString from TCollection);
|
||||
|
||||
Load(theDI: out Interpretor from Draw; theKey, theResourceFileName: AsciiString from TCollection)
|
||||
-- returns Transient from Standard
|
||||
raises Failure from Draw;
|
||||
|
||||
Load(theDI: out Interpretor from Draw;
|
||||
theKey, theResourceFileName: AsciiString from TCollection;
|
||||
theDefaultsDirectory, theUserDefaultsDirectory: in out AsciiString from TCollection;
|
||||
Verbose : Boolean from Standard = Standard_False)
|
||||
raises Failure from Draw;
|
||||
|
||||
--
|
||||
-- methods to handle variables
|
||||
--
|
||||
|
||||
Set(Name : CString;
|
||||
D : Drawable3D from Draw;
|
||||
Disp : Boolean from Standard);
|
||||
---Purpose: Sets a variable. Display it if <Disp> is true.
|
||||
|
||||
Set(Name : CString;
|
||||
D : Drawable3D from Draw);
|
||||
---Purpose: Sets a variable, a null handle clear the
|
||||
-- vartiable. Automatic display is context driven.
|
||||
|
||||
Set(Name : CString;
|
||||
val : Real);
|
||||
---Purpose: Sets a numeric variable.
|
||||
|
||||
Get(Name : in out CString;
|
||||
Complain : Boolean = Standard_True)
|
||||
returns Drawable3D from Draw;
|
||||
---Purpose: Returns a variable value. Null if the variable
|
||||
-- does not exist, a warning is printed if Complain
|
||||
-- is True.
|
||||
--
|
||||
-- The name "." does a graphic selection. If the
|
||||
-- selection is a variable <Name> is overwritten with
|
||||
-- the name of the variable.
|
||||
|
||||
Get(Name : CString;
|
||||
val : out Real)
|
||||
returns Boolean;
|
||||
---Purpose: Gets a numeric variable. Returns True if the
|
||||
-- variable exist.
|
||||
|
||||
Set(Name : CString; val : CString);
|
||||
---Purpose: Sets a TCL sting variable
|
||||
|
||||
Atof(Name : CString) returns Real;
|
||||
---Purpose: Search a numeric variable. If none found converts
|
||||
-- the string to a real.
|
||||
|
||||
Atoi(Name : CString) returns Integer;
|
||||
---Purpose: Search a numeric variable. If none found converts
|
||||
-- the string to an integer.
|
||||
|
||||
|
||||
LastPick(view,X,Y,button : out Integer);
|
||||
---Purpose: Returns last graphic selection description.
|
||||
|
||||
Repaint;
|
||||
---Purpose: Asks to repaint the screen after the current command.
|
||||
|
||||
SetProgressBar(thePI: ProgressIndicator from Draw);
|
||||
---Purpose: sets progress indicator
|
||||
|
||||
GetProgressBar returns ProgressIndicator from Draw;
|
||||
---Purpose: gets progress indicator
|
||||
|
||||
|
||||
--
|
||||
-- Draw Commands
|
||||
--
|
||||
|
||||
Commands(I : in out Interpretor from Draw);
|
||||
---Purpose: Defines all Draw commands
|
||||
|
||||
BasicCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: Defines Draw basic commands
|
||||
|
||||
VariableCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: Defines Draw variables handling commands.
|
||||
|
||||
GraphicCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: Defines Draw variables handling commands.
|
||||
|
||||
PloadCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: Defines Loads Draw plugins commands.
|
||||
|
||||
UnitCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: Defines Draw unit commands
|
||||
|
||||
end Draw;
|
569
src/Draw/Draw.cxx
Executable file
569
src/Draw/Draw.cxx
Executable file
@@ -0,0 +1,569 @@
|
||||
// File: Draw.cxx
|
||||
// Created: Fri Aug 13 09:22:06 1993
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@phylox>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Draw.ixx>
|
||||
|
||||
#if defined(HAVE_TIME_H) || defined(WNT)
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <OSD.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <Draw_Window.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_ProgressIndicator.hxx>
|
||||
#include <tcl.h>
|
||||
|
||||
#include <Draw_MapOfFunctions.hxx>
|
||||
#include <OSD_SharedLibrary.hxx>
|
||||
#include <Resource_Manager.hxx>
|
||||
#include <Draw_Failure.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
extern Standard_Boolean Draw_ParseFailed;
|
||||
#ifndef WNT
|
||||
extern Standard_Boolean Draw_LowWindows;
|
||||
#endif
|
||||
|
||||
Standard_EXPORT Draw_Viewer dout;
|
||||
Standard_EXPORT Draw_Interpretor theCommands;
|
||||
Standard_EXPORT Standard_Boolean Draw_Batch;
|
||||
Standard_EXPORT Standard_Boolean Draw_Spying = Standard_False;
|
||||
Standard_EXPORT Standard_Boolean Draw_Chrono = Standard_False;
|
||||
Standard_EXPORT Standard_Boolean Draw_VirtualWindows = Standard_False;
|
||||
Standard_EXPORT Standard_Boolean ErrorMessages = Standard_True;
|
||||
|
||||
static const char* ColorNames[MAXCOLOR] = {
|
||||
"White","Red","Green","Blue","Cyan","Gold","Magenta",
|
||||
"Maroon","Orange","Pink","Salmon","Violet","Yellow","Khaki","Coral"
|
||||
};
|
||||
|
||||
filebuf Draw_Spyfile;
|
||||
|
||||
static ostream spystream(&Draw_Spyfile);
|
||||
|
||||
static Standard_Boolean XLoop;
|
||||
|
||||
static Handle(Draw_ProgressIndicator) PInd = NULL;
|
||||
|
||||
Standard_EXPORT Standard_Boolean Draw_Interprete(char* command);
|
||||
// true if complete command
|
||||
|
||||
//#ifndef WNT
|
||||
|
||||
// *******************************************************************
|
||||
// read an init file
|
||||
// *******************************************************************
|
||||
#ifdef WNT
|
||||
extern console_semaphore_value volatile console_semaphore;
|
||||
extern char console_command[1000];
|
||||
#endif
|
||||
|
||||
static void ReadInitFile(char* filename)
|
||||
{
|
||||
#ifdef WNT
|
||||
if (!Draw_Batch) {
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
for(Standard_Integer i = 0; filename[i] != 0; i++)
|
||||
if(filename[i] == '\\') filename[i] = '/';
|
||||
sprintf(console_command,"source \"%s\"",filename);
|
||||
console_semaphore = HAS_CONSOLE_COMMAND;
|
||||
while (console_semaphore == HAS_CONSOLE_COMMAND)
|
||||
Sleep(10);
|
||||
}
|
||||
catch(...) {
|
||||
cout << "Error while reading a script file." << endl;
|
||||
ExitProcess(0);
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
char* com = new char [strlen(filename)+strlen("source ")+2];
|
||||
sprintf(com,"source %s",filename);
|
||||
Draw_Interprete(com);
|
||||
delete [] com;
|
||||
#ifdef WNT
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose : Set/Get Progress Indicator
|
||||
//=======================================================================
|
||||
void Draw::SetProgressBar(const Handle(Draw_ProgressIndicator)& thePI)
|
||||
{
|
||||
PInd = thePI;
|
||||
}
|
||||
|
||||
Handle(Draw_ProgressIndicator) Draw::GetProgressBar()
|
||||
{
|
||||
return PInd;
|
||||
}
|
||||
|
||||
#ifndef WNT
|
||||
/*--------------------------------------------------------*\
|
||||
| exitProc: finalization handler for Tcl/Tk thread. Forces parent process to die
|
||||
\*--------------------------------------------------------*/
|
||||
void exitProc(ClientData /*dc*/)
|
||||
{
|
||||
if (!Draw_Batch) {
|
||||
for (Standard_Integer id = 0; id < MAXVIEW; id++)
|
||||
dout.DeleteView(id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// *******************************************************************
|
||||
// main
|
||||
// *******************************************************************
|
||||
#ifdef WNT
|
||||
//Standard_EXPORT void Draw_Appli(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lps
|
||||
Standard_EXPORT void Draw_Appli(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszLine, int nShow,const FDraw_InitAppli Draw_InitAppli)
|
||||
#else
|
||||
void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_InitAppli)
|
||||
#endif
|
||||
{
|
||||
// *****************************************************************
|
||||
// analyze arguments
|
||||
// *****************************************************************
|
||||
Draw_Batch = Standard_False;
|
||||
char* runfile = NULL;
|
||||
Standard_Integer i;
|
||||
Standard_Boolean isInteractiveForced = Standard_False;
|
||||
#ifndef WNT
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (strcasecmp(argv[i],"-b") == 0)
|
||||
Draw_Batch = Standard_True;
|
||||
# ifndef __sgi
|
||||
else if (strcasecmp(argv[i],"-l") == 0) {
|
||||
Draw_LowWindows = Standard_True;
|
||||
}
|
||||
# endif
|
||||
else if (strcasecmp(argv[i],"-v") == 0) {
|
||||
// force virtual windows
|
||||
Draw_VirtualWindows = Standard_True;
|
||||
} else if (strcasecmp(argv[i],"-i") == 0) {
|
||||
// force interactive
|
||||
Draw_VirtualWindows = Standard_False;
|
||||
isInteractiveForced = Standard_True;
|
||||
} else if (strcasecmp(argv[i],"-f") == 0) { // -f option should be LAST!
|
||||
Draw_VirtualWindows = !isInteractiveForced;
|
||||
if (++i < argc) {
|
||||
runfile = argv[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// On NT command line arguments are in the lpzline and not in argv
|
||||
for (char* p = strtok(lpszLine, " \t"); p != NULL; p = strtok(NULL, " \t")) {
|
||||
if (strcasecmp(p, "-v") == 0) {
|
||||
Draw_VirtualWindows = Standard_True;
|
||||
} else if (strcasecmp(p, "-i") == 0) {
|
||||
// force interactive
|
||||
Draw_VirtualWindows = Standard_False;
|
||||
isInteractiveForced = Standard_True;
|
||||
} else if (strcasecmp(p, "-f") == 0) { // -f option should be LAST!
|
||||
Draw_VirtualWindows = !isInteractiveForced;
|
||||
p = strtok(NULL," \t");
|
||||
if (p != NULL) {
|
||||
runfile = p;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// *****************************************************************
|
||||
// set signals
|
||||
// *****************************************************************
|
||||
OSD::SetSignal();
|
||||
|
||||
// *****************************************************************
|
||||
// init X window and create display
|
||||
// *****************************************************************
|
||||
#ifdef WNT
|
||||
HWND hWnd;
|
||||
#endif
|
||||
|
||||
if (!Draw_Batch)
|
||||
#ifdef WNT
|
||||
Draw_Batch=!Init_Appli(hInst, hPrevInst, nShow, hWnd);
|
||||
#else
|
||||
Draw_Batch=!Init_Appli();
|
||||
#endif
|
||||
else
|
||||
cout << "batch mode" << endl;
|
||||
|
||||
XLoop = !Draw_Batch;
|
||||
if (XLoop) {
|
||||
// Default colors
|
||||
for (i=0;i<MAXCOLOR;i++) {
|
||||
if (!dout.DefineColor(i,ColorNames[i]))
|
||||
cout <<"Could not allocate default color "<<ColorNames[i]<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************
|
||||
// set maximum precision for cout
|
||||
// *****************************************************************
|
||||
cout.precision(15);
|
||||
|
||||
// *****************************************************************
|
||||
// standard commands
|
||||
// *****************************************************************
|
||||
Draw::BasicCommands(theCommands);
|
||||
Draw::VariableCommands(theCommands);
|
||||
Draw::UnitCommands(theCommands);
|
||||
if (!Draw_Batch) Draw::GraphicCommands(theCommands);
|
||||
|
||||
// *****************************************************************
|
||||
// user commands
|
||||
// *****************************************************************
|
||||
Draw_InitAppli(theCommands);
|
||||
|
||||
#ifndef WNT
|
||||
Tcl_CreateExitHandler(exitProc, 0);
|
||||
#endif
|
||||
|
||||
// *****************************************************************
|
||||
// read init files
|
||||
// *****************************************************************
|
||||
// default
|
||||
char* dflt = getenv("DRAWDEFAULT");
|
||||
if (dflt == NULL)
|
||||
{
|
||||
char* casroot = getenv("CASROOT");
|
||||
if (casroot == NULL)
|
||||
{
|
||||
#ifdef WNT
|
||||
ReadInitFile("ddefault");
|
||||
#else
|
||||
cout << " the CASROOT variable is mandatory to Run OpenCascade "<< endl;
|
||||
cout << "No default file" << endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
char* thedefault = (char *) malloc (128);
|
||||
thedefault[0] = '\0';
|
||||
strcat(thedefault,casroot);
|
||||
strcat (thedefault,"/src/DrawResources/DrawDefault");
|
||||
ReadInitFile(thedefault);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadInitFile(dflt);
|
||||
}
|
||||
|
||||
// pure batch
|
||||
if (runfile) {
|
||||
// do not map raise the windows, so test programs are discrete
|
||||
#ifndef WNT
|
||||
Draw_LowWindows = Standard_True;
|
||||
#endif
|
||||
// comme on ne peut pas photographier les fenetres trop discretes sur sgi
|
||||
// on se met en vedette !! (pmn 20/02/97)
|
||||
#ifdef __sgi
|
||||
Draw_LowWindows = Standard_False;
|
||||
#endif
|
||||
|
||||
ReadInitFile(runfile);
|
||||
// provide a clean exit, this is usefull for some analysis tools
|
||||
#ifndef WNT
|
||||
return;
|
||||
#else
|
||||
ExitProcess(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// *****************************************************************
|
||||
// X loop
|
||||
// *****************************************************************
|
||||
if (XLoop) {
|
||||
#ifdef WNT
|
||||
Run_Appli(hWnd);
|
||||
#else
|
||||
Run_Appli(Draw_Interprete);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
char cmd[255];
|
||||
do {
|
||||
cout << "Viewer>";
|
||||
i = -1;
|
||||
do {
|
||||
cin.get(cmd[++i]);
|
||||
} while ((cmd[i] != '\n') && (!cin.fail()));
|
||||
cmd[i] = '\0';
|
||||
} while (Draw_Interprete(cmd) != (unsigned int ) -2);
|
||||
}
|
||||
#ifdef WNT
|
||||
// Destruction de l'application
|
||||
Destroy_Appli(hInst);
|
||||
#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
// User functions called before and after each command
|
||||
void (*Draw_BeforeCommand)() = NULL;
|
||||
void (*Draw_AfterCommand)(Standard_Integer) = NULL;
|
||||
|
||||
Standard_Boolean Draw_Interprete(char* com)
|
||||
{
|
||||
|
||||
static Standard_Boolean first = Standard_True;
|
||||
static Tcl_DString command;
|
||||
|
||||
if (first) {
|
||||
first = Standard_False;
|
||||
Tcl_DStringInit(&command);
|
||||
}
|
||||
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 1)))
|
||||
// OCC63: Since Tcl 8.1 it uses UTF-8 encoding for internal representation of strings
|
||||
Tcl_ExternalToUtfDString ( NULL, com, -1, &command );
|
||||
#else
|
||||
Tcl_DStringAppend(&command,com,-1);
|
||||
#endif
|
||||
|
||||
if (!theCommands.Complete(Tcl_DStringValue(&command)))
|
||||
return Standard_False;
|
||||
|
||||
// *******************************************************************
|
||||
// Command interpreter
|
||||
// *******************************************************************
|
||||
|
||||
// Standard_Integer i = 0;
|
||||
// Standard_Integer j = 0;
|
||||
|
||||
Standard_Boolean wasspying = Draw_Spying;
|
||||
|
||||
OSD_Timer tictac;
|
||||
Standard_Boolean hadchrono = Draw_Chrono;
|
||||
if (hadchrono) tictac.Start();
|
||||
|
||||
if (Draw_BeforeCommand) (*Draw_BeforeCommand) ();
|
||||
|
||||
Standard_Integer c;
|
||||
|
||||
c = theCommands.RecordAndEval(Tcl_DStringValue(&command));
|
||||
|
||||
if (Draw_AfterCommand) (*Draw_AfterCommand)(c);
|
||||
|
||||
if (wasspying && Draw_Spying) {
|
||||
if (c > 0) spystream << "# ";
|
||||
spystream << Tcl_DStringValue(&command) << "\n";
|
||||
}
|
||||
|
||||
dout.Flush();
|
||||
|
||||
if (*theCommands.Result())
|
||||
cout << theCommands.Result() << endl;
|
||||
|
||||
if (Draw_Chrono && hadchrono) {
|
||||
tictac.Stop();
|
||||
tictac.Show();
|
||||
}
|
||||
|
||||
Tcl_DStringFree(&command);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//
|
||||
// for TCl
|
||||
//
|
||||
|
||||
Standard_Integer Tcl_AppInit (Tcl_Interp *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// for debug call
|
||||
//
|
||||
|
||||
|
||||
|
||||
Standard_Integer Draw_Call (char *c)
|
||||
{
|
||||
Standard_Integer r = theCommands.Eval(c);
|
||||
cout << theCommands.Result() << endl;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
//
|
||||
//=================================================================================
|
||||
void Draw::Load(Draw_Interpretor& theDI, const TCollection_AsciiString& theKey,
|
||||
const TCollection_AsciiString& theResourceFileName) {
|
||||
|
||||
static Draw_MapOfFunctions theMapOfFunctions;
|
||||
OSD_Function f;
|
||||
|
||||
if(!theMapOfFunctions.IsBound(theKey)) {
|
||||
|
||||
Handle(Resource_Manager) aPluginResource = new Resource_Manager(theResourceFileName.ToCString());
|
||||
if(!aPluginResource->Find(theKey.ToCString())) {
|
||||
Standard_SStream aMsg; aMsg << "Could not find the resource:";
|
||||
aMsg << theKey.ToCString()<< endl;
|
||||
cout << "could not find the resource:"<<theKey.ToCString()<< endl;
|
||||
Draw_Failure::Raise(aMsg);
|
||||
}
|
||||
|
||||
TCollection_AsciiString aPluginLibrary("");
|
||||
#ifndef WNT
|
||||
aPluginLibrary += "lib";
|
||||
#endif
|
||||
aPluginLibrary += aPluginResource->Value(theKey.ToCString());
|
||||
#ifdef WNT
|
||||
aPluginLibrary += ".dll";
|
||||
#elif __APPLE__
|
||||
aPluginLibrary += ".dylib";
|
||||
#elif defined (HPUX) || defined(_hpux)
|
||||
aPluginLibrary += ".sl";
|
||||
#else
|
||||
aPluginLibrary += ".so";
|
||||
#endif
|
||||
OSD_SharedLibrary aSharedLibrary(aPluginLibrary.ToCString());
|
||||
if(!aSharedLibrary.DlOpen(OSD_RTLD_LAZY)) {
|
||||
TCollection_AsciiString error(aSharedLibrary.DlError());
|
||||
Standard_SStream aMsg; aMsg << "Could not open: ";
|
||||
aMsg << aPluginResource->Value(theKey.ToCString());
|
||||
aMsg << "; reason: ";
|
||||
aMsg << error.ToCString();
|
||||
#ifdef DEB
|
||||
cout << "could not open: " << aPluginResource->Value(theKey.ToCString())<< " ; reason: "<< error.ToCString() << endl;
|
||||
#endif
|
||||
Draw_Failure::Raise(aMsg);
|
||||
}
|
||||
f = aSharedLibrary.DlSymb("PLUGINFACTORY");
|
||||
if( f == NULL ) {
|
||||
TCollection_AsciiString error(aSharedLibrary.DlError());
|
||||
Standard_SStream aMsg; aMsg << "Could not find the factory in: ";
|
||||
aMsg << aPluginResource->Value(theKey.ToCString());
|
||||
aMsg << error.ToCString();
|
||||
Draw_Failure::Raise(aMsg);
|
||||
}
|
||||
theMapOfFunctions.Bind(theKey, f);
|
||||
}
|
||||
else
|
||||
f = theMapOfFunctions(theKey);
|
||||
|
||||
// void (*fp) (Draw_Interpretor&, const TCollection_AsciiString&) = NULL;
|
||||
// fp = (void (*)(Draw_Interpretor&, const TCollection_AsciiString&)) f;
|
||||
// (*fp) (theDI, theKey);
|
||||
|
||||
void (*fp) (Draw_Interpretor&) = NULL;
|
||||
fp = (void (*)(Draw_Interpretor&)) f;
|
||||
(*fp) (theDI);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
//
|
||||
//=================================================================================
|
||||
void Draw::Load(Draw_Interpretor& theDI, const TCollection_AsciiString& theKey,
|
||||
const TCollection_AsciiString& theResourceFileName,
|
||||
TCollection_AsciiString& theDefaultsDirectory,
|
||||
TCollection_AsciiString& theUserDefaultsDirectory,
|
||||
const Standard_Boolean Verbose ) {
|
||||
|
||||
static Draw_MapOfFunctions theMapOfFunctions;
|
||||
OSD_Function f;
|
||||
|
||||
if(!theMapOfFunctions.IsBound(theKey)) {
|
||||
|
||||
Handle(Resource_Manager) aPluginResource = new Resource_Manager(theResourceFileName.ToCString(), theDefaultsDirectory, theUserDefaultsDirectory, Verbose);
|
||||
|
||||
if(!aPluginResource->Find(theKey.ToCString())) {
|
||||
Standard_SStream aMsg; aMsg << "Could not find the resource:";
|
||||
aMsg << theKey.ToCString()<< endl;
|
||||
cout << "could not find the resource:"<<theKey.ToCString()<< endl;
|
||||
Draw_Failure::Raise(aMsg);
|
||||
}
|
||||
|
||||
TCollection_AsciiString aPluginLibrary("");
|
||||
#ifndef WNT
|
||||
aPluginLibrary += "lib";
|
||||
#endif
|
||||
aPluginLibrary += aPluginResource->Value(theKey.ToCString());
|
||||
#ifdef WNT
|
||||
aPluginLibrary += ".dll";
|
||||
#elif __APPLE__
|
||||
aPluginLibrary += ".dylib";
|
||||
#elif defined (HPUX) || defined(_hpux)
|
||||
aPluginLibrary += ".sl";
|
||||
#else
|
||||
aPluginLibrary += ".so";
|
||||
#endif
|
||||
OSD_SharedLibrary aSharedLibrary(aPluginLibrary.ToCString());
|
||||
if(!aSharedLibrary.DlOpen(OSD_RTLD_LAZY)) {
|
||||
TCollection_AsciiString error(aSharedLibrary.DlError());
|
||||
Standard_SStream aMsg; aMsg << "Could not open: ";
|
||||
aMsg << aPluginResource->Value(theKey.ToCString());
|
||||
aMsg << "; reason: ";
|
||||
aMsg << error.ToCString();
|
||||
#ifdef DEB
|
||||
cout << "could not open: " << aPluginResource->Value(theKey.ToCString())<< " ; reason: "<< error.ToCString() << endl;
|
||||
#endif
|
||||
Draw_Failure::Raise(aMsg);
|
||||
}
|
||||
f = aSharedLibrary.DlSymb("PLUGINFACTORY");
|
||||
if( f == NULL ) {
|
||||
TCollection_AsciiString error(aSharedLibrary.DlError());
|
||||
Standard_SStream aMsg; aMsg << "Could not find the factory in: ";
|
||||
aMsg << aPluginResource->Value(theKey.ToCString());
|
||||
aMsg << error.ToCString();
|
||||
Draw_Failure::Raise(aMsg);
|
||||
}
|
||||
theMapOfFunctions.Bind(theKey, f);
|
||||
}
|
||||
else
|
||||
f = theMapOfFunctions(theKey);
|
||||
|
||||
// void (*fp) (Draw_Interpretor&, const TCollection_AsciiString&) = NULL;
|
||||
// fp = (void (*)(Draw_Interpretor&, const TCollection_AsciiString&)) f;
|
||||
// (*fp) (theDI, theKey);
|
||||
|
||||
void (*fp) (Draw_Interpretor&) = NULL;
|
||||
fp = (void (*)(Draw_Interpretor&)) f;
|
||||
(*fp) (theDI);
|
||||
|
||||
}
|
30
src/Draw/DrawRessource.h
Executable file
30
src/Draw/DrawRessource.h
Executable file
@@ -0,0 +1,30 @@
|
||||
#ifdef WNT
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Draw.rc
|
||||
//
|
||||
#define APPMENU 102
|
||||
#define IDI_ICON1 103
|
||||
#define ACCEL_ID 106
|
||||
#define IDM_WINDOW_CASCADE 40001
|
||||
#define IDM_WINDOW_TILEHOR 40002
|
||||
#define IDM_WINDOW_TILEVERT 40003
|
||||
#define IDM_FILE_EXIT 40004
|
||||
#define IDM_WINDOW_NEXT 40005
|
||||
#define ID_COMMAND_SHOW 40006
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 109
|
||||
#define _APS_NEXT_COMMAND_VALUE 40007
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
88
src/Draw/Draw_Appli.hxx
Executable file
88
src/Draw/Draw_Appli.hxx
Executable file
@@ -0,0 +1,88 @@
|
||||
// File: Draw_Appli.hxx
|
||||
// Created: Tue Apr 7 10:47:21 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
// JR 21 Oct 1999 : Change for Draw_Init_Appli which is in main and is
|
||||
// called from Draw ===> undefined symbol on UNIX
|
||||
// ===> duplication of code on NT :
|
||||
// One argument added to DrawAppli : Draw_Init_Appli ===>
|
||||
// Draw_Appli of Draw/TKDraw may call Draw_Init_Appli
|
||||
|
||||
#ifndef Draw_Appli_HeaderFile
|
||||
#define Draw_Appli_HeaderFile
|
||||
|
||||
|
||||
#include <Draw_Viewer.hxx>
|
||||
#include <Draw.hxx>
|
||||
|
||||
typedef void (*FDraw_InitAppli)(Draw_Interpretor&);
|
||||
|
||||
#ifdef WNT
|
||||
#include <windows.h>
|
||||
//extern void Draw_Appli(HINSTANCE,HINSTANCE,LPSTR,int);
|
||||
Standard_EXPORT void Draw_Appli(HINSTANCE,HINSTANCE,LPSTR,int,
|
||||
const FDraw_InitAppli Draw_InitAppli);
|
||||
#else
|
||||
extern void Draw_Appli(Standard_Integer argc, char** argv,
|
||||
const FDraw_InitAppli Draw_InitAppli);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(WNT) && !defined(HAVE_NO_DLL)
|
||||
#ifndef __Draw_API
|
||||
# ifdef __Draw_DLL
|
||||
# define __Draw_API __declspec ( dllexport )
|
||||
# else
|
||||
# define __Draw_API __declspec ( dllimport )
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define __Draw_API
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef WNT
|
||||
extern Draw_Viewer dout;
|
||||
extern Standard_Boolean Draw_Batch;
|
||||
#endif
|
||||
|
||||
#define atof(X) Draw::Atof(X)
|
||||
#define atoi(X) Draw::Atoi(X)
|
||||
|
||||
class Draw_SaveAndRestore {
|
||||
|
||||
public :
|
||||
|
||||
// __Draw_API Draw_SaveAndRestore
|
||||
Standard_EXPORT Draw_SaveAndRestore
|
||||
(const char* name,
|
||||
Standard_Boolean (*test)(const Handle(Draw_Drawable3D)&),
|
||||
void (*save)(const Handle(Draw_Drawable3D)&, ostream&),
|
||||
Handle(Draw_Drawable3D) (*restore) (istream&),
|
||||
Standard_Boolean display = Standard_True);
|
||||
|
||||
|
||||
const char* Name() const {return myName;}
|
||||
Standard_Boolean Test(const Handle(Draw_Drawable3D)&d);
|
||||
void Save(const Handle(Draw_Drawable3D)& d, ostream& os) const;
|
||||
Handle(Draw_Drawable3D) Restore(istream&) const;
|
||||
Standard_Boolean Disp() const {return myDisplay;}
|
||||
Draw_SaveAndRestore* Next() {return myNext;}
|
||||
|
||||
private :
|
||||
|
||||
const char* myName;
|
||||
Standard_Boolean (*myTest)(const Handle(Draw_Drawable3D)&);
|
||||
void (*mySave)(const Handle(Draw_Drawable3D)&, ostream&);
|
||||
Handle(Draw_Drawable3D) (*myRestore) (istream&);
|
||||
Standard_Boolean myDisplay;
|
||||
Draw_SaveAndRestore* myNext;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
36
src/Draw/Draw_Axis2D.cdl
Executable file
36
src/Draw/Draw_Axis2D.cdl
Executable file
@@ -0,0 +1,36 @@
|
||||
-- File: Draw_Axis2D.cdl
|
||||
-- Created: Mon Apr 18 18:08:38 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class Axis2D from Draw inherits Drawable2D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Pnt2d from gp,
|
||||
Ax22d from gp,
|
||||
Color from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
|
||||
Create(col : Color; Size : Integer = 5)
|
||||
returns mutable Axis2D;
|
||||
|
||||
Create(p : Pnt2d; col : Color; Size : Integer = 5)
|
||||
returns mutable Axis2D;
|
||||
|
||||
Create(A : Ax22d from gp; col : Color; Size : Integer = 5)
|
||||
returns mutable Axis2D;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
fields
|
||||
|
||||
myAxes : Ax22d from gp;
|
||||
myColor : Color;
|
||||
mySize : Integer;
|
||||
|
||||
end Axis2D;
|
67
src/Draw/Draw_Axis2D.cxx
Executable file
67
src/Draw/Draw_Axis2D.cxx
Executable file
@@ -0,0 +1,67 @@
|
||||
// File: Draw_Axis2D.cxx
|
||||
// Created: Wed Apr 29 15:24:18 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
#include <Draw_Axis2D.ixx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <gp.hxx>
|
||||
|
||||
extern Standard_Boolean Draw_Bounds;
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Axis2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Axis2D::Draw_Axis2D (const Draw_Color& col,
|
||||
const Standard_Integer Size) :
|
||||
myAxes(gp_Pnt2d(0,0),gp_Dir2d(1,0)),myColor(col), mySize(Size)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Axis2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Axis2D::Draw_Axis2D (const gp_Pnt2d& p,
|
||||
const Draw_Color& col,
|
||||
const Standard_Integer Size) :
|
||||
myAxes(p,gp_Dir2d(1,0)), myColor(col), mySize(Size)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Axis2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Axis2D::Draw_Axis2D (const gp_Ax22d& a,
|
||||
const Draw_Color& col,
|
||||
const Standard_Integer Size) :
|
||||
myAxes(a), myColor(col), mySize(Size)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Axis2D::DrawOn (Draw_Display& dis) const
|
||||
{
|
||||
Draw_Bounds = Standard_False;
|
||||
dis.SetColor(myColor);
|
||||
Standard_Real z = dis.Zoom();
|
||||
z = (Standard_Real)mySize / z;
|
||||
gp_Pnt2d P,P0 = myAxes.Location();
|
||||
P = P0.Translated(gp_Vec2d(myAxes.XDirection()) * z);
|
||||
dis.Draw(P0,P);
|
||||
dis.DrawString(P,"X");
|
||||
P = P0.Translated(gp_Vec2d(myAxes.YDirection()) * z);
|
||||
dis.Draw(P0,P);
|
||||
dis.DrawString(P,"Y");
|
||||
Draw_Bounds = Standard_True;
|
||||
}
|
||||
|
36
src/Draw/Draw_Axis3D.cdl
Executable file
36
src/Draw/Draw_Axis3D.cdl
Executable file
@@ -0,0 +1,36 @@
|
||||
-- File: Axis3D.cdl
|
||||
-- Created: Wed Apr 29 13:43:28 1992
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@sdsun1>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Axis3D from Draw inherits Drawable3D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Pnt from gp,
|
||||
Ax3 from gp,
|
||||
Color from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
|
||||
Create(col : Color; Size : Integer = 5)
|
||||
returns mutable Axis3D;
|
||||
|
||||
Create(p : Pnt; col : Color; Size : Integer = 5)
|
||||
returns mutable Axis3D;
|
||||
|
||||
Create(A : Ax3 from gp; col : Color; Size : Integer = 5)
|
||||
returns mutable Axis3D;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
fields
|
||||
|
||||
myAxes : Ax3 from gp;
|
||||
myColor : Color;
|
||||
mySize : Integer;
|
||||
|
||||
end Axis3D;
|
71
src/Draw/Draw_Axis3D.cxx
Executable file
71
src/Draw/Draw_Axis3D.cxx
Executable file
@@ -0,0 +1,71 @@
|
||||
// File: Draw_Axis3D.cxx
|
||||
// Created: Wed Apr 29 15:24:18 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
#include <Draw_Axis3D.ixx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp.hxx>
|
||||
|
||||
extern Standard_Boolean Draw_Bounds;
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Axis3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Axis3D::Draw_Axis3D (const Draw_Color& col,
|
||||
const Standard_Integer Size) :
|
||||
myAxes(gp::XOY()),myColor(col), mySize(Size)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Axis3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Axis3D::Draw_Axis3D (const gp_Pnt& p,
|
||||
const Draw_Color& col,
|
||||
const Standard_Integer Size) :
|
||||
myAxes(p,gp::DZ(),gp::DX()), myColor(col), mySize(Size)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Axis3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Axis3D::Draw_Axis3D (const gp_Ax3& a,
|
||||
const Draw_Color& col,
|
||||
const Standard_Integer Size) :
|
||||
myAxes(a), myColor(col), mySize(Size)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Axis3D::DrawOn (Draw_Display& dis) const
|
||||
{
|
||||
Draw_Bounds = Standard_False;
|
||||
dis.SetColor(myColor);
|
||||
Standard_Real z = dis.Zoom();
|
||||
z = (Standard_Real)mySize / z;
|
||||
gp_Pnt P,P0 = myAxes.Location();
|
||||
P = P0.Translated(gp_Vec(myAxes.XDirection()) * z);
|
||||
dis.Draw(P0,P);
|
||||
dis.DrawString(P,"X");
|
||||
P = P0.Translated(gp_Vec(myAxes.YDirection()) * z);
|
||||
dis.Draw(P0,P);
|
||||
dis.DrawString(P,"Y");
|
||||
P = P0.Translated(gp_Vec(myAxes.Direction()) * z);
|
||||
dis.Draw(P0,P);
|
||||
dis.DrawString(P,"Z");
|
||||
Draw_Bounds = Standard_True;
|
||||
}
|
||||
|
273
src/Draw/Draw_BasicCommands.cxx
Executable file
273
src/Draw/Draw_BasicCommands.cxx
Executable file
@@ -0,0 +1,273 @@
|
||||
// File: Draw_BasicCommands.cxx
|
||||
// Created: Thu Feb 23 18:21:17 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_Stream.hxx>
|
||||
#include <Standard_SStream.hxx>
|
||||
|
||||
#include <Draw.ixx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Printer.hxx>
|
||||
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_TIME_H) || defined(WNT)
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifndef WNT
|
||||
# include <sys/resource.h>
|
||||
# ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
# endif
|
||||
#else
|
||||
//WNT
|
||||
extern Standard_Boolean Draw_Batch;
|
||||
#include <windows.h>
|
||||
#include <winbase.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_LIMITS
|
||||
# include <limits>
|
||||
#elif defined (HAVE_LIMITS_H)
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifdef WNT
|
||||
# include <limits>
|
||||
#endif
|
||||
|
||||
static clock_t MDTV_CPU_LIMIT; // Cpu_limit in Sec.
|
||||
static clock_t MDTV_CPU_CURRENT; // cpu time already used at last
|
||||
// cpulimit call. (sec.)
|
||||
//#define strcasecmp strcmp Already defined
|
||||
#define RLIM_INFINITY 0x7fffffff
|
||||
#endif
|
||||
|
||||
#include <Draw_Chronometer.hxx>
|
||||
|
||||
#if defined (__hpux) || defined ( HPUX )
|
||||
#define RLIM_INFINITY 0x7fffffff
|
||||
#define RLIMIT_CPU 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
// chronom
|
||||
//=======================================================================
|
||||
|
||||
extern Standard_Boolean Draw_Chrono;
|
||||
|
||||
static Standard_Integer chronom(Draw_Interpretor& di,
|
||||
Standard_Integer n,const char** a)
|
||||
{
|
||||
if ((n == 1) || (*a[1] == '0') || (*a[1] == '1')) {
|
||||
if (n == 1)
|
||||
Draw_Chrono = !Draw_Chrono;
|
||||
else
|
||||
Draw_Chrono = (*a[1] == '1');
|
||||
|
||||
if (Draw_Chrono) di << "Chronometers activated."<<"\n";
|
||||
else di << "Chronometers desactivated."<<"\n";
|
||||
}
|
||||
else {
|
||||
Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
|
||||
Handle(Draw_Chronometer) C;
|
||||
if (!D.IsNull()) {
|
||||
C = Handle(Draw_Chronometer)::DownCast(D);
|
||||
}
|
||||
if (C.IsNull()) {
|
||||
C = new Draw_Chronometer();
|
||||
Draw::Set(a[1],C,Standard_False);
|
||||
}
|
||||
if (n <= 2) {
|
||||
C->Timer().Reset();
|
||||
}
|
||||
else {
|
||||
if (!strcasecmp(a[2],"reset"))
|
||||
C->Timer().Reset();
|
||||
if (!strcasecmp(a[2],"start"))
|
||||
C->Timer().Start();
|
||||
if (!strcasecmp(a[2],"stop"))
|
||||
C->Timer().Stop();
|
||||
if (!strcasecmp(a[2],"show"))
|
||||
C->Timer().Show();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer dchronom(Draw_Interpretor& I,
|
||||
Standard_Integer n,const char** a)
|
||||
{
|
||||
if ((n == 1) || (*a[1] == '0') || (*a[1] == '1')) {
|
||||
if (n == 1)
|
||||
Draw_Chrono = !Draw_Chrono;
|
||||
else
|
||||
Draw_Chrono = (*a[1] == '1');
|
||||
|
||||
if (Draw_Chrono) I << "Chronometers activated."<<"\n";
|
||||
else I << "Chronometers desactivated."<<"\n";
|
||||
}
|
||||
else {
|
||||
Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
|
||||
Handle(Draw_Chronometer) C;
|
||||
if (!D.IsNull()) {
|
||||
C = Handle(Draw_Chronometer)::DownCast(D);
|
||||
}
|
||||
if (C.IsNull()) {
|
||||
C = new Draw_Chronometer();
|
||||
Draw::Set(a[1],C,Standard_False);
|
||||
}
|
||||
if (n <= 2) {
|
||||
C->Timer().Reset();
|
||||
}
|
||||
else {
|
||||
if (!strcasecmp(a[2],"reset"))
|
||||
C->Timer().Reset();
|
||||
if (!strcasecmp(a[2],"start"))
|
||||
C->Timer().Start();
|
||||
if (!strcasecmp(a[2],"stop"))
|
||||
C->Timer().Stop();
|
||||
if (!strcasecmp(a[2],"show")) {
|
||||
Standard_SStream ss;
|
||||
C->Timer().Show(ss);
|
||||
I << ss;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ifbatch
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer ifbatch(Draw_Interpretor& DI, Standard_Integer , const char** )
|
||||
{
|
||||
if (Draw_Batch)
|
||||
DI << "1";
|
||||
else
|
||||
DI << "0";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : spy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
extern Standard_Boolean Draw_Spying;
|
||||
extern filebuf Draw_Spyfile;
|
||||
|
||||
static Standard_Integer spy(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (Draw_Spying)
|
||||
Draw_Spyfile.close();
|
||||
Draw_Spying = Standard_False;
|
||||
if (n > 1) {
|
||||
if (!Draw_Spyfile.open(a[1],ios::out)) {
|
||||
di << "Cannot open "<<a[1]<<" for writing"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
Draw_Spying = Standard_True;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : wait
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer Draw_wait(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
Standard_Integer w = 10;
|
||||
if (n > 1)
|
||||
w = atoi(a[1]);
|
||||
time_t ct = time(NULL) + w;
|
||||
while (time(NULL) < ct) {};
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static Standard_Integer cpulimit(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
#ifndef WNT
|
||||
rlimit rlp;
|
||||
rlp.rlim_max = RLIM_INFINITY;
|
||||
if (n <= 1)
|
||||
rlp.rlim_cur = RLIM_INFINITY;
|
||||
else
|
||||
rlp.rlim_cur = atoi(a[1]);
|
||||
|
||||
int status;
|
||||
status=setrlimit(RLIMIT_CPU,&rlp);
|
||||
if (status !=0)
|
||||
di << "status cpulimit setrlimit : " << status << "\n";
|
||||
|
||||
#else
|
||||
//WNT
|
||||
static int first=1;
|
||||
/*
|
||||
unsigned int __stdcall CpuFunc(void * );
|
||||
unsigned ThreadID;
|
||||
|
||||
if (n <= 1) MDTV_CPU_LIMIT = RLIM_INFINITY;
|
||||
else {
|
||||
|
||||
MDTV_CPU_LIMIT = atoi(a[1]);
|
||||
MDTV_CPU_CURRENT = clock()/1000;
|
||||
|
||||
if (first) // Lancer le thread au 1er appel seulement.
|
||||
{
|
||||
first=0 ;
|
||||
_beginthreadex(NULL,0,CpuFunc,NULL,0,&ThreadID);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Draw::BasicCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean Done = Standard_False;
|
||||
if (Done) return;
|
||||
Done = Standard_True;
|
||||
|
||||
const char* g = "DRAW General Commands";
|
||||
|
||||
theCommands.Add("batch", "returns 1 in batch mode",
|
||||
__FILE__,ifbatch,g);
|
||||
theCommands.Add("spy","spy [file], Save commands in file. no file close",
|
||||
__FILE__,spy,g);
|
||||
theCommands.Add("wait","wait [time(10)], wait time seconds",
|
||||
__FILE__,Draw_wait,g);
|
||||
theCommands.Add("cpulimit","cpulimit [nbseconds], no args remove limits",
|
||||
__FILE__,cpulimit,g);
|
||||
theCommands.Add("chrono","chrono [ name start/stop/reset/show]",
|
||||
__FILE__,chronom,g);
|
||||
theCommands.Add("dchrono","dchrono [ name start/stop/reset/show]",
|
||||
__FILE__,dchronom,g);
|
||||
}
|
44
src/Draw/Draw_Box.cdl
Executable file
44
src/Draw/Draw_Box.cdl
Executable file
@@ -0,0 +1,44 @@
|
||||
-- File: Draw_Box.cdl
|
||||
-- Created: Fri Mar 10 14:18:31 1995
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phobox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
class Box from Draw inherits Drawable3D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Pnt from gp,
|
||||
Color from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
|
||||
Create(p1,p2 : Pnt; col : Color)
|
||||
returns mutable Box;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
First(me) returns Pnt from gp
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
First(me : mutable; P : Pnt from gp)
|
||||
is static;
|
||||
|
||||
Last(me) returns Pnt from gp
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
Last(me : mutable; P : Pnt from gp)
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
myFirst : Pnt;
|
||||
myLast : Pnt;
|
||||
myColor : Color;
|
||||
|
||||
end Box;
|
123
src/Draw/Draw_Box.cxx
Executable file
123
src/Draw/Draw_Box.cxx
Executable file
@@ -0,0 +1,123 @@
|
||||
// File: Draw_Box.cxx
|
||||
// Created: Fri Mar 10 14:43:04 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@phobox>
|
||||
|
||||
|
||||
#include <Draw_Box.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Box
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Box::Draw_Box(const gp_Pnt& p1, const gp_Pnt& p2, const Draw_Color& col) :
|
||||
myFirst(p1), myLast(p2),myColor(col)
|
||||
{
|
||||
Standard_Real t;
|
||||
if (myLast.X() < myFirst.X()) {
|
||||
t = myFirst.X();
|
||||
myFirst.SetX(myLast.X());
|
||||
myLast.SetX(t);
|
||||
}
|
||||
if (myLast.Y() < myFirst.Y()) {
|
||||
t = myFirst.Y();
|
||||
myFirst.SetY(myLast.Y());
|
||||
myLast.SetY(t);
|
||||
}
|
||||
if (myLast.Z() < myFirst.Z()) {
|
||||
t = myFirst.Z();
|
||||
myFirst.SetZ(myLast.Z());
|
||||
myLast.SetZ(t);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Box::DrawOn(Draw_Display& dis) const
|
||||
{
|
||||
dis.SetColor(myColor);
|
||||
gp_Pnt P = myFirst;
|
||||
|
||||
dis.MoveTo(P);
|
||||
P.SetX(myLast.X());
|
||||
dis.DrawTo(P);
|
||||
P.SetY(myLast.Y());
|
||||
dis.DrawTo(P);
|
||||
P.SetZ(myLast.Z());
|
||||
dis.DrawTo(P);
|
||||
P.SetX(myFirst.X());
|
||||
dis.DrawTo(P);
|
||||
P.SetY(myFirst.Y());
|
||||
dis.DrawTo(P);
|
||||
P.SetZ(myFirst.Z());
|
||||
dis.DrawTo(P);
|
||||
|
||||
P.SetX(myLast.X());
|
||||
dis.MoveTo(P);
|
||||
P.SetZ(myLast.Z());
|
||||
dis.DrawTo(P);
|
||||
P.SetX(myFirst.X());
|
||||
dis.DrawTo(P);
|
||||
|
||||
P.SetX(myLast.X());
|
||||
dis.MoveTo(P);
|
||||
P.SetY(myLast.Y());
|
||||
dis.DrawTo(P);
|
||||
|
||||
P.SetX(myFirst.X());
|
||||
dis.MoveTo(P);
|
||||
P.SetZ(myFirst.Z());
|
||||
dis.DrawTo(P);
|
||||
P.SetY(myFirst.Y());
|
||||
dis.DrawTo(P);
|
||||
|
||||
P.SetY(myLast.Y());
|
||||
dis.MoveTo(P);
|
||||
P.SetX(myLast.X());
|
||||
dis.DrawTo(P);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : First
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const gp_Pnt& Draw_Box::First() const
|
||||
{
|
||||
return myFirst;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : First
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Box::First(const gp_Pnt& P)
|
||||
{
|
||||
myFirst = P;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Last
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const gp_Pnt& Draw_Box::Last() const
|
||||
{
|
||||
return myLast;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Last
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Box::Last(const gp_Pnt& P)
|
||||
{
|
||||
myLast = P;
|
||||
}
|
||||
|
6
src/Draw/Draw_CMPLRS.edl
Executable file
6
src/Draw/Draw_CMPLRS.edl
Executable file
@@ -0,0 +1,6 @@
|
||||
|
||||
@uses "CSF.edl";
|
||||
|
||||
---@string %CMPLRS_CXX_Options += " -I"%CSF_TCL_INCLUDE" -DUSE_TK";
|
||||
@string %CMPLRS_CXX_Options += " -I"%CSF_TCL_INCLUDE;
|
||||
|
47
src/Draw/Draw_Chronometer.cdl
Executable file
47
src/Draw/Draw_Chronometer.cdl
Executable file
@@ -0,0 +1,47 @@
|
||||
-- File: Draw_Chronometer.cdl
|
||||
-- Created: Mon Aug 16 11:36:24 1993
|
||||
-- Author: Bruno DUMORTIER
|
||||
-- <dub@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class Chronometer from Draw inherits Drawable3D from Draw
|
||||
|
||||
---Purpose: Class to store chronometer variables.
|
||||
|
||||
uses
|
||||
|
||||
Timer from OSD,
|
||||
Display from Draw,
|
||||
Interpretor from Draw
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable Chronometer from Draw;
|
||||
|
||||
|
||||
Timer(me : mutable) returns Timer from OSD
|
||||
---C++: return &
|
||||
is static;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
---Purpose: Does nothhing,
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
---Purpose: For variable dump.
|
||||
is redefined;
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
---Purpose: For variable whatis command.
|
||||
is redefined;
|
||||
|
||||
fields
|
||||
|
||||
myTimer : Timer from OSD;
|
||||
|
||||
end Chronometer;
|
75
src/Draw/Draw_Chronometer.cxx
Executable file
75
src/Draw/Draw_Chronometer.cxx
Executable file
@@ -0,0 +1,75 @@
|
||||
// File: Draw_Chronometer.cxx
|
||||
// Created: Mon Aug 16 12:18:58 1993
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@phylox>
|
||||
|
||||
|
||||
|
||||
#include <Draw_Chronometer.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Chronometer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Chronometer::Draw_Chronometer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Timer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
OSD_Timer& Draw_Chronometer::Timer()
|
||||
{
|
||||
return myTimer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Chronometer::DrawOn(Draw_Display&)const
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) Draw_Chronometer::Copy()const
|
||||
{
|
||||
Handle(Draw_Chronometer) C = new Draw_Chronometer();
|
||||
return C;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Chronometer::Dump(Standard_OStream& S)const
|
||||
{
|
||||
S << "Chronometer : ";
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Chronometer::Whatis(Draw_Interpretor& i)const
|
||||
{
|
||||
i << "chronometer";
|
||||
}
|
||||
|
||||
|
33
src/Draw/Draw_Circle2D.cdl
Executable file
33
src/Draw/Draw_Circle2D.cdl
Executable file
@@ -0,0 +1,33 @@
|
||||
-- File: Draw_Circle2D.cdl
|
||||
-- Created: Mon Apr 18 18:11:17 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
|
||||
class Circle2D from Draw inherits Drawable2D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Circ2d from gp,
|
||||
Color from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
|
||||
Create(C : Circ2d from gp; A1,A2 : Real; col : Color)
|
||||
returns mutable Circle2D;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
fields
|
||||
|
||||
myCirc : Circ2d from gp;
|
||||
myA1 : Real;
|
||||
myA2 : Real;
|
||||
myColor : Color;
|
||||
|
||||
end Circle2D;
|
||||
|
30
src/Draw/Draw_Circle2D.cxx
Executable file
30
src/Draw/Draw_Circle2D.cxx
Executable file
@@ -0,0 +1,30 @@
|
||||
// File: Draw_Circle2D.cxx
|
||||
// Created: Thu Apr 30 12:05:20 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
|
||||
#include <Draw_Circle2D.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Circle2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Circle2D::Draw_Circle2D(const gp_Circ2d& C,
|
||||
const Standard_Real A1, const Standard_Real A2,
|
||||
const Draw_Color& col) :
|
||||
myCirc(C), myA1(A1), myA2(A2), myColor(col)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Circle2D::DrawOn(Draw_Display& d) const
|
||||
{
|
||||
d.SetColor(myColor);
|
||||
d.Draw(myCirc,myA1,myA2);
|
||||
}
|
33
src/Draw/Draw_Circle3D.cdl
Executable file
33
src/Draw/Draw_Circle3D.cdl
Executable file
@@ -0,0 +1,33 @@
|
||||
-- File: Circle3D.cdl
|
||||
-- Created: Thu Apr 30 11:17:40 1992
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@sdsun1>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
|
||||
class Circle3D from Draw inherits Drawable3D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Circ from gp,
|
||||
Color from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
|
||||
Create(C : Circ from gp; A1,A2 : Real; col : Color)
|
||||
returns mutable Circle3D;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
fields
|
||||
|
||||
myCirc : Circ from gp;
|
||||
myA1 : Real;
|
||||
myA2 : Real;
|
||||
myColor : Color;
|
||||
|
||||
end Circle3D;
|
||||
|
30
src/Draw/Draw_Circle3D.cxx
Executable file
30
src/Draw/Draw_Circle3D.cxx
Executable file
@@ -0,0 +1,30 @@
|
||||
// File: Draw_Circle3D.cxx
|
||||
// Created: Thu Apr 30 12:05:20 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
|
||||
#include <Draw_Circle3D.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Circle3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Circle3D::Draw_Circle3D(const gp_Circ& C,
|
||||
const Standard_Real A1, const Standard_Real A2,
|
||||
const Draw_Color& col) :
|
||||
myCirc(C), myA1(A1), myA2(A2), myColor(col)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Circle3D::DrawOn(Draw_Display& d) const
|
||||
{
|
||||
d.SetColor(myColor);
|
||||
d.Draw(myCirc,myA1,myA2);
|
||||
}
|
30
src/Draw/Draw_Color.cdl
Executable file
30
src/Draw/Draw_Color.cdl
Executable file
@@ -0,0 +1,30 @@
|
||||
-- File: Color.cdl
|
||||
-- Created: Wed Apr 24 14:23:43 1991
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@topsn2>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
class Color from Draw inherits Storable
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses ColorKind from Draw
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
returns Color from Draw;
|
||||
|
||||
Create(c : ColorKind)
|
||||
returns Color from Draw;
|
||||
|
||||
ID(me)
|
||||
returns ColorKind from Draw;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myKind : ColorKind from Draw;
|
||||
|
||||
end Color;
|
22
src/Draw/Draw_Color.cxx
Executable file
22
src/Draw/Draw_Color.cxx
Executable file
@@ -0,0 +1,22 @@
|
||||
// Copyright: Matra-Datavision 1991
|
||||
// File: Draw_Color.cxx
|
||||
// Created: Wed Apr 24 16:52:41 1991
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <Draw_Color.ixx>
|
||||
|
||||
Draw_Color::Draw_Color () :
|
||||
myKind(Draw_blanc)
|
||||
{
|
||||
}
|
||||
|
||||
Draw_Color::Draw_Color (const Draw_ColorKind c) :
|
||||
myKind(c)
|
||||
{
|
||||
}
|
||||
|
||||
Draw_ColorKind Draw_Color::ID () const
|
||||
{
|
||||
return myKind;
|
||||
}
|
14
src/Draw/Draw_CommandFunction.hxx
Executable file
14
src/Draw/Draw_CommandFunction.hxx
Executable file
@@ -0,0 +1,14 @@
|
||||
// File: Draw_CommandFunction.hxx
|
||||
// Created: Thu Feb 23 17:59:38 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
|
||||
#ifndef _Draw_CommandFunction_HeaderFile
|
||||
#define _Draw_CommandFunction_HeaderFile
|
||||
|
||||
class Draw_Interpretor;
|
||||
|
||||
typedef Standard_Integer (*Draw_CommandFunction)(Draw_Interpretor&, Standard_Integer, const char**);
|
||||
|
||||
#endif
|
15
src/Draw/Draw_Commands.cxx
Executable file
15
src/Draw/Draw_Commands.cxx
Executable file
@@ -0,0 +1,15 @@
|
||||
// File: Draw_Commands.cxx
|
||||
// Created: Wed Mar 1 13:34:09 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
#include <Draw.ixx>
|
||||
|
||||
void Draw::Commands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
Draw::BasicCommands(theCommands);
|
||||
Draw::VariableCommands(theCommands);
|
||||
Draw::GraphicCommands(theCommands);
|
||||
Draw::PloadCommands(theCommands);
|
||||
Draw::UnitCommands(theCommands);
|
||||
}
|
132
src/Draw/Draw_Display.cdl
Executable file
132
src/Draw/Draw_Display.cdl
Executable file
@@ -0,0 +1,132 @@
|
||||
-- File: Display.cdl
|
||||
-- Created: Mon Jul 15 10:05:54 1991
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@topsn2>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
class Display from Draw
|
||||
|
||||
---Purpose: Use to draw in a 3d or a 2d view.
|
||||
--
|
||||
-- * The 3d methods draw in the 3d system, in a 2d
|
||||
-- view the drawing is projected on X,Y.
|
||||
--
|
||||
-- * The 2d methods draw in the projection plane.
|
||||
--
|
||||
-- * To draw in screen coordinates the length must be
|
||||
-- divided by the zoom.
|
||||
|
||||
uses
|
||||
CString,
|
||||
Color from Draw,
|
||||
MarkerShape from Draw,
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
Circ from gp,
|
||||
Circ2d from gp
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
returns Display;
|
||||
|
||||
SetColor(me; col : Color)
|
||||
---Purpose: Following drawings will use this color.
|
||||
is static;
|
||||
|
||||
SetMode(me; M : Integer)
|
||||
---Purpose: Set the drawing mode, 3 = copy, 6 = xor
|
||||
is static;
|
||||
|
||||
Flush(me)
|
||||
is static;
|
||||
|
||||
MoveTo(me : in out; pt : Pnt from gp)
|
||||
is static;
|
||||
|
||||
DrawTo(me : in out; pt : Pnt from gp)
|
||||
is static;
|
||||
|
||||
MoveTo(me : in out; pt : Pnt2d from gp)
|
||||
is static;
|
||||
|
||||
DrawTo(me : in out; pt : Pnt2d from gp)
|
||||
is static;
|
||||
|
||||
Draw(me : in out; p1,p2 : Pnt from gp)
|
||||
is static;
|
||||
|
||||
Draw(me : in out; p1,p2 : Pnt2d from gp)
|
||||
is static;
|
||||
|
||||
Draw(me : in out; C : Circ from gp; A1, A2 : Real;
|
||||
ModifyWithZoom : Boolean = Standard_True)
|
||||
---Purpose: Draw a circle <C> from angle <A1> to <A2>
|
||||
-- (Radians). if ModifyWithZoom = 0, then
|
||||
-- rayon of circle is convert to Integer.
|
||||
is static;
|
||||
|
||||
Draw(me : in out; C : Circ2d from gp; A1, A2 : Real;
|
||||
ModifyWithZoom : Boolean = Standard_True)
|
||||
---Purpose: Draw a 2D circle <C> from angle <A1> to <A2>
|
||||
-- (Radians). if ModifyWithZoom = 0, then
|
||||
-- rayon of circle is convert to Integer.
|
||||
is static;
|
||||
|
||||
DrawMarker(me : in out; pt : Pnt from gp; S : MarkerShape from Draw;
|
||||
Size : Integer = 5)
|
||||
is static;
|
||||
|
||||
DrawMarker(me : in out; pt : Pnt2d from gp; S : MarkerShape from Draw;
|
||||
Size : Integer = 5)
|
||||
is static;
|
||||
|
||||
DrawMarker(me : in out; pt : Pnt from gp; S : MarkerShape from Draw;
|
||||
Size : Real)
|
||||
is static;
|
||||
|
||||
DrawMarker(me : in out; pt : Pnt2d from gp; S : MarkerShape from Draw;
|
||||
Size : Real)
|
||||
is static;
|
||||
|
||||
DrawString(me : in out; pt : Pnt from gp; S : CString)
|
||||
is static;
|
||||
|
||||
DrawString(me : in out; pt : Pnt2d from gp; S : CString)
|
||||
is static;
|
||||
|
||||
DrawString(me : in out; pt : Pnt from gp; S : CString; moveX : Real; moveY : Real)
|
||||
is static;
|
||||
|
||||
DrawString(me : in out; pt : Pnt2d from gp; S : CString; moveX : Real; moveY : Real)
|
||||
is static;
|
||||
|
||||
Project(me; pt : Pnt from gp) returns Pnt2d from gp
|
||||
---Purpose: Returns the 2D projection of a 3D point.
|
||||
is static;
|
||||
|
||||
Project(me; pt : Pnt from gp; pt2d : out Pnt2d from gp)
|
||||
---Purpose: Returns the 2D projection of a 3D point.
|
||||
is static;
|
||||
|
||||
Zoom(me) returns Real
|
||||
---Purpose: Returns the current Zoom value.
|
||||
is static;
|
||||
|
||||
ViewId(me) returns Integer
|
||||
---Purpose: Returns the identifier of the view where the
|
||||
-- display is drawing.
|
||||
is static;
|
||||
|
||||
HasPicked(me) returns Boolean
|
||||
---Purpose: Returs True if the last drawing operations
|
||||
-- generated a pick hit. When HasPicked is True the
|
||||
-- Drawing should be resumed.
|
||||
--
|
||||
-- This function is used to shorten the drawing when
|
||||
-- picking and to save the picked sub-parts.
|
||||
|
||||
is static;
|
||||
|
||||
end Display;
|
267
src/Draw/Draw_Display.cxx
Executable file
267
src/Draw/Draw_Display.cxx
Executable file
@@ -0,0 +1,267 @@
|
||||
// Copyright: Matra-Datavision 1991
|
||||
// File: Draw_Display.cxx
|
||||
// Created: Mon Jul 15 10:58:59 1991
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
|
||||
#include <Draw_Display.ixx>
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
extern Standard_Boolean Draw_Bounds;
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawMarker
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Display::DrawMarker (const gp_Pnt& pt,
|
||||
const Draw_MarkerShape S,
|
||||
const Standard_Integer Size)
|
||||
{
|
||||
gp_Pnt2d p;
|
||||
Project(pt,p);
|
||||
DrawMarker(p,S,Size);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawMarker
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Display::DrawMarker (const gp_Pnt2d& pt,
|
||||
const Draw_MarkerShape S,
|
||||
const Standard_Integer ISize)
|
||||
{
|
||||
Draw_Bounds = Standard_False;
|
||||
|
||||
gp_Pnt2d p1 = pt;
|
||||
gp_Pnt2d p2 = p1;
|
||||
gp_Circ2d C;
|
||||
Standard_Real Size = ((Standard_Real) ISize) / Zoom();
|
||||
|
||||
switch (S) {
|
||||
|
||||
case Draw_Square :
|
||||
p1.Translate(gp_Vec2d(-Size,-Size));
|
||||
p2.Translate(gp_Vec2d( Size,-Size));
|
||||
Draw(p1,p2);
|
||||
p1.Translate(gp_Vec2d(2*Size,2*Size));
|
||||
Draw(p1,p2);
|
||||
p2.Translate(gp_Vec2d(-2*Size,2*Size));
|
||||
Draw(p1,p2);
|
||||
p1.Translate(gp_Vec2d(-2*Size,-2*Size));
|
||||
Draw(p1,p2);
|
||||
break;
|
||||
|
||||
case Draw_Losange :
|
||||
p1.Translate(gp_Vec2d(-Size,0));
|
||||
p2.Translate(gp_Vec2d( 0,Size));
|
||||
Draw(p1,p2);
|
||||
p1.Translate(gp_Vec2d(2*Size,0));
|
||||
Draw(p1,p2);
|
||||
p2.Translate(gp_Vec2d(0,-2*Size));
|
||||
Draw(p1,p2);
|
||||
p1.Translate(gp_Vec2d(-2*Size,0));
|
||||
Draw(p1,p2);
|
||||
break;
|
||||
|
||||
case Draw_X :
|
||||
p1.Translate(gp_Vec2d(-Size,-Size));
|
||||
p2.Translate(gp_Vec2d( Size,Size));
|
||||
Draw(p1,p2);
|
||||
p1.Translate(gp_Vec2d(2*Size,0));
|
||||
p2.Translate(gp_Vec2d(-2*Size,0));
|
||||
Draw(p1,p2);
|
||||
break;
|
||||
|
||||
case Draw_Plus :
|
||||
p1.Translate(gp_Vec2d(-Size,0));
|
||||
p2.Translate(gp_Vec2d( Size,0));
|
||||
Draw(p1,p2);
|
||||
p1.Translate(gp_Vec2d(Size,Size));
|
||||
p2.Translate(gp_Vec2d(-Size,-Size));
|
||||
Draw(p1,p2);
|
||||
break;
|
||||
|
||||
case Draw_Circle :
|
||||
// gp_Circ2d C;
|
||||
C.SetRadius(ISize);
|
||||
C.SetLocation(pt);
|
||||
Draw(C, 0, 2*PI, Standard_False);
|
||||
break;
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
|
||||
}
|
||||
Draw_Bounds = Standard_True;
|
||||
MoveTo(pt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawMarker
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Display::DrawMarker (const gp_Pnt& pt,
|
||||
const Draw_MarkerShape S,
|
||||
const Standard_Real Size)
|
||||
{
|
||||
gp_Pnt2d p;
|
||||
Project(pt,p);
|
||||
DrawMarker(p,S,Size);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawMarker
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Display::DrawMarker (const gp_Pnt2d& pt,
|
||||
const Draw_MarkerShape S,
|
||||
const Standard_Real R)
|
||||
{
|
||||
switch (S) {
|
||||
case Draw_Square :
|
||||
case Draw_Losange :
|
||||
case Draw_X :
|
||||
case Draw_Plus :
|
||||
case Draw_Circle :
|
||||
{
|
||||
Standard_Integer I = (Standard_Integer ) R;
|
||||
if(!I) return;
|
||||
DrawMarker(pt, S, I);
|
||||
break;
|
||||
}
|
||||
case Draw_CircleZoom :
|
||||
if(R == 0.0) return;
|
||||
gp_Circ2d C;
|
||||
C.SetRadius(R);
|
||||
C.SetLocation(pt);
|
||||
// if the circus is too small, a "plus" is drawn to mark the point
|
||||
Standard_Boolean b = (R * Zoom()) > 2;
|
||||
if(b)
|
||||
Draw(C, 0, 2*PI);
|
||||
else
|
||||
DrawMarker(pt, Draw_Plus);
|
||||
}
|
||||
Draw_Bounds = Standard_True;
|
||||
MoveTo(pt);
|
||||
}
|
||||
|
||||
#define MAXPNT 200
|
||||
#define DEFLECTION 5
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Display::Draw(const gp_Circ& C, const Standard_Real A1,const Standard_Real A3,
|
||||
const Standard_Boolean ModifyWithZoom)
|
||||
{
|
||||
Standard_Real A2 = A3;
|
||||
while (A2 < A1) A2 += 2*PI;
|
||||
|
||||
Standard_Real angle = DEFLECTION / (C.Radius() * Zoom());
|
||||
Standard_Integer n = (Standard_Integer )( (A2 - A1) / angle);
|
||||
if (n > MAXPNT) {
|
||||
angle = (A2 - A1) / MAXPNT;
|
||||
n = MAXPNT;
|
||||
}
|
||||
if (n <= 6) {
|
||||
angle = (A2 - A1) / 6;
|
||||
n = 6;
|
||||
}
|
||||
Standard_Real c = 2*Cos(angle);
|
||||
|
||||
gp_Circ Cloc(C);
|
||||
if(!ModifyWithZoom) {
|
||||
Standard_Integer ISize = (Standard_Integer )( Cloc.Radius() / Zoom());
|
||||
Cloc.SetRadius(ISize);
|
||||
}
|
||||
|
||||
gp_Pnt PC = Cloc.Location();
|
||||
gp_Pnt P = ElCLib::Value(A1,Cloc);
|
||||
MoveTo(P);
|
||||
gp_Vec V1(PC,P);
|
||||
P = ElCLib::Value(A1+angle,Cloc);
|
||||
gp_Vec V2(PC,P);
|
||||
DrawTo(P);
|
||||
gp_Vec V;
|
||||
|
||||
for (Standard_Integer i = 2; i < n; i++) {
|
||||
V = c * V2 - V1;
|
||||
V1 = V2;
|
||||
V2 = V;
|
||||
DrawTo(PC.Translated(V));
|
||||
}
|
||||
|
||||
P = ElCLib::Value(A2,Cloc);
|
||||
DrawTo(P);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Display::Draw(const gp_Circ2d& C, const Standard_Real A1, const Standard_Real A3,
|
||||
const Standard_Boolean ModifyWithZoom)
|
||||
{
|
||||
Standard_Real A2 = A3;
|
||||
while (A2 < A1) A2 += 2*PI;
|
||||
|
||||
Standard_Real angle = DEFLECTION / (C.Radius() * Zoom());
|
||||
Standard_Integer n = (Standard_Integer )( (A2 - A1) / angle);
|
||||
if (n > MAXPNT) {
|
||||
angle = (A2 - A1) / MAXPNT;
|
||||
n = MAXPNT;
|
||||
}
|
||||
else if (n <= 6) {
|
||||
angle = (A2 - A1) / 6;
|
||||
n = 6;
|
||||
}
|
||||
Standard_Real c = 2*Cos(angle);
|
||||
|
||||
gp_Circ2d Cloc(C);
|
||||
if(!ModifyWithZoom) {// the effet of zoom is cancelled to follow
|
||||
Standard_Real Size = Cloc.Radius() / Zoom();
|
||||
Cloc.SetRadius(Size);
|
||||
}
|
||||
|
||||
gp_Pnt2d PC = Cloc.Location();
|
||||
gp_Pnt2d P = ElCLib::Value(A1,Cloc);
|
||||
MoveTo(P);
|
||||
gp_Vec2d V1(PC,P);
|
||||
P = ElCLib::Value(A1+angle,Cloc);
|
||||
gp_Vec2d V2(PC,P);
|
||||
DrawTo(P);
|
||||
gp_Vec2d V;
|
||||
|
||||
for (Standard_Integer i = 2; i < n; i++) {
|
||||
V = c * V2 - V1;
|
||||
V1 = V2;
|
||||
V2 = V;
|
||||
DrawTo(PC.Translated(V));
|
||||
}
|
||||
|
||||
P = ElCLib::Value(A2,Cloc);
|
||||
DrawTo(P);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt2d Draw_Display::Project(const gp_Pnt& p) const
|
||||
{
|
||||
gp_Pnt2d pt;
|
||||
Project(p,pt);
|
||||
return pt;
|
||||
}
|
23
src/Draw/Draw_Drawable2D.cdl
Executable file
23
src/Draw/Draw_Drawable2D.cdl
Executable file
@@ -0,0 +1,23 @@
|
||||
-- File: Draw_Drawable2D.cdl
|
||||
-- Created: Mon Apr 18 18:04:34 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
|
||||
|
||||
deferred class Drawable2D from Draw inherits Drawable3D from Draw
|
||||
|
||||
uses
|
||||
Pnt2d from gp,
|
||||
Pnt from gp
|
||||
|
||||
is
|
||||
|
||||
|
||||
Is3D(me) returns Boolean
|
||||
---Purpose: Returns False.
|
||||
is redefined;
|
||||
|
||||
end Drawable2D;
|
6
src/Draw/Draw_Drawable2D.cxx
Executable file
6
src/Draw/Draw_Drawable2D.cxx
Executable file
@@ -0,0 +1,6 @@
|
||||
#include <Draw_Drawable2D.ixx>
|
||||
|
||||
Standard_Boolean Draw_Drawable2D::Is3D() const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
82
src/Draw/Draw_Drawable3D.cdl
Executable file
82
src/Draw/Draw_Drawable3D.cdl
Executable file
@@ -0,0 +1,82 @@
|
||||
-- File: Drawable3D.cdl
|
||||
-- Created: Wed Apr 24 14:19:59 1991
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@topsn2>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
deferred class Drawable3D from Draw inherits TShared from MMgt
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Color from Draw,
|
||||
Display from Draw,
|
||||
Interpretor from Draw,
|
||||
OStream
|
||||
|
||||
is
|
||||
|
||||
Initialize;
|
||||
|
||||
DrawOn(me; dis : in out Display)
|
||||
is deferred;
|
||||
|
||||
PickReject(me; X,Y,Prec : Real) returns Boolean
|
||||
---Purpose: Returs True if the pick is outside the box
|
||||
is virtual;
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
is virtual;
|
||||
---Purpose: For variable copy.
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
is virtual;
|
||||
---Purpose: For variable dump.
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
is virtual;
|
||||
---Purpose: For variable whatis command. Set as a result the
|
||||
-- type of the variable.
|
||||
|
||||
Is3D(me) returns Boolean
|
||||
is virtual;
|
||||
---Purpose: Is a 3D object. (Default True).
|
||||
|
||||
SetBounds(me : mutable; xmin,xmax,ymin,ymax : Real)
|
||||
is static;
|
||||
|
||||
Bounds(me; xmin,xmax,ymin,ymax : out Real)
|
||||
is static;
|
||||
|
||||
Visible(me) returns Boolean;
|
||||
---C++: inline
|
||||
|
||||
Visible(me : mutable; V : Boolean);
|
||||
---C++: inline
|
||||
|
||||
Protected(me) returns Boolean;
|
||||
---C++: inline
|
||||
|
||||
Protected(me : mutable; P : Boolean);
|
||||
---C++: inline
|
||||
|
||||
Name(me) returns CString;
|
||||
---C++: inline
|
||||
|
||||
Name(me : mutable; N : CString)
|
||||
is virtual;
|
||||
---C++: inline
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myXmin : Real;
|
||||
myXmax : Real;
|
||||
myYmin : Real;
|
||||
myYmax : Real;
|
||||
|
||||
isVisible : Boolean;
|
||||
isProtected : Boolean;
|
||||
myName : CString;
|
||||
|
||||
end Drawable3D;
|
112
src/Draw/Draw_Drawable3D.cxx
Executable file
112
src/Draw/Draw_Drawable3D.cxx
Executable file
@@ -0,0 +1,112 @@
|
||||
// Copyright: Matra-Datavision 1991
|
||||
// File: Draw_Drawable3D.cxx
|
||||
// Created: Wed Apr 24 15:44:04 1991
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
|
||||
#include <Draw_Drawable3D.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Drawable3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Drawable3D::Draw_Drawable3D() :
|
||||
isVisible(Standard_False),
|
||||
isProtected(Standard_False),
|
||||
myName(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PickReject
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_Drawable3D::PickReject(const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Standard_Real Prec) const
|
||||
{
|
||||
return ((X+Prec < myXmin) || (X-Prec > myXmax) ||
|
||||
(Y+Prec < myYmin) || (Y-Prec > myYmax));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) Draw_Drawable3D::Copy() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Drawable3D::Dump(Standard_OStream& S) const
|
||||
{
|
||||
S << myXmin << " " << myXmax << "\n";
|
||||
S << myYmin << " " << myYmax << "\n";
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Drawable3D::Whatis(Draw_Interpretor& S) const
|
||||
{
|
||||
S << "drawable 3d";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Is3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_Drawable3D::Is3D() const
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetBounds
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Drawable3D::SetBounds(const Standard_Real xmin,
|
||||
const Standard_Real xmax,
|
||||
const Standard_Real ymin,
|
||||
const Standard_Real ymax)
|
||||
{
|
||||
myXmin = xmin;
|
||||
myXmax = xmax;
|
||||
myYmin = ymin;
|
||||
myYmax = ymax;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Bounds
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Drawable3D::Bounds(Standard_Real& xmin,
|
||||
Standard_Real& xmax,
|
||||
Standard_Real& ymin,
|
||||
Standard_Real& ymax) const
|
||||
{
|
||||
xmin = myXmin;
|
||||
xmax = myXmax;
|
||||
ymin = myYmin;
|
||||
ymax = myYmax;
|
||||
}
|
||||
|
||||
|
35
src/Draw/Draw_Drawable3D.lxx
Executable file
35
src/Draw/Draw_Drawable3D.lxx
Executable file
@@ -0,0 +1,35 @@
|
||||
// File: Draw_Drawable3D.lxx
|
||||
// Created: Tue Feb 28 13:35:31 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
inline Standard_Boolean Draw_Drawable3D::Visible() const
|
||||
{
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
inline void Draw_Drawable3D::Visible(const Standard_Boolean V)
|
||||
{
|
||||
isVisible = V;
|
||||
}
|
||||
|
||||
inline Standard_Boolean Draw_Drawable3D::Protected() const
|
||||
{
|
||||
return isProtected;
|
||||
}
|
||||
|
||||
inline void Draw_Drawable3D::Protected(const Standard_Boolean V)
|
||||
{
|
||||
isProtected = V;
|
||||
}
|
||||
|
||||
inline Standard_CString Draw_Drawable3D::Name() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
inline void Draw_Drawable3D::Name(const Standard_CString N)
|
||||
{
|
||||
myName = N;
|
||||
}
|
||||
|
992
src/Draw/Draw_GraphicCommands.cxx
Executable file
992
src/Draw/Draw_GraphicCommands.cxx
Executable file
@@ -0,0 +1,992 @@
|
||||
// File: Draw_GraphicCommands.cxx
|
||||
// **************************************************************
|
||||
// Created: Thu Feb 23 18:27:18 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
|
||||
// Modif : DFO 05/11/96
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Draw.ixx>
|
||||
#include <Draw_Appli.hxx>
|
||||
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Grid.hxx>
|
||||
#include <Draw_Display.hxx>
|
||||
#include <Draw_Text3D.hxx>
|
||||
#include <Draw_Text2D.hxx>
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef WNT
|
||||
extern Draw_Viewer dout;
|
||||
extern Standard_Boolean Draw_Batch;
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
extern Standard_Boolean Draw_BlackBackGround;
|
||||
|
||||
|
||||
#define DEFROTATE (5 * PI/ 180.)
|
||||
#define DEFMAGNIFY 1.1
|
||||
#define DEFPANNING 0.1
|
||||
#define DEFFOCAL 1.1
|
||||
#define DEFFRAME 10
|
||||
#define DEFGRIDSTEP 100.0
|
||||
static Standard_Real steprot = DEFROTATE;
|
||||
static Standard_Real steppan = DEFPANNING;
|
||||
static Standard_Real stepmagnify = DEFMAGNIFY;
|
||||
static Standard_Real stepfocal = DEFFOCAL;
|
||||
static Standard_Real frame = DEFFRAME;
|
||||
static Standard_Real DefaultGridStep = DEFGRIDSTEP ;
|
||||
|
||||
#define FONTLENGTH
|
||||
static char Draw_fontname[FONTLENGTH]="Helvetica";
|
||||
static char Draw_fontsize[FONTLENGTH]="150";
|
||||
static char Draw_fontnamedefault[FONTLENGTH]="Helvetica";
|
||||
static char Draw_fontsizedefault[FONTLENGTH]="150";
|
||||
|
||||
// *******************************************************************
|
||||
// Graphic commands
|
||||
// *******************************************************************
|
||||
|
||||
static Standard_Integer ViewId(const Standard_CString a)
|
||||
{
|
||||
Standard_Integer id = atoi(a);
|
||||
if ((id < 0) || (id >= MAXVIEW)) {
|
||||
cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
|
||||
return -1;
|
||||
}
|
||||
if (!dout.HasView(id)) {
|
||||
cout <<"View "<<id<<" does not exist."<<endl;
|
||||
return -1;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
static void SetTitle(const Standard_Integer id)
|
||||
{
|
||||
if (dout.HasView(id)) {
|
||||
char title[255];
|
||||
sprintf(title,"%d : %s - Zoom %f",id,dout.GetType(id),dout.Zoom(id));
|
||||
dout.SetTitle(id,title);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : zoom
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer zoom(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
// one argument -> All Views
|
||||
// two argument -> First is the view
|
||||
Standard_Boolean z2d = !strcasecmp(a[0],"2dzoom");
|
||||
if (n == 2) {
|
||||
Standard_Real z = atof(a[1]);
|
||||
for (Standard_Integer id = 0; id < MAXVIEW; id++) {
|
||||
if (dout.HasView(id)) {
|
||||
if ((z2d && !dout.Is3D(id)) || (!z2d && dout.Is3D(id))) {
|
||||
dout.SetZoom(id,z);
|
||||
SetTitle(id);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (n >= 3) {
|
||||
Standard_Integer id = ViewId(a[1]);
|
||||
if (id < 0) return 1;
|
||||
Standard_Real z = atof(a[2]);
|
||||
dout.SetZoom(id,z);
|
||||
dout.RepaintView(id);
|
||||
SetTitle(id);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : wzoom
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer wzoom(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer id1,X1,Y1,b;
|
||||
Standard_Integer X2,Y2;
|
||||
Standard_Real dX1,dY1,dX2,dY2;
|
||||
di << "Pick first corner"<<"\n";
|
||||
dout.Select(id1,X1,Y1,b);
|
||||
|
||||
gp_Trsf T;
|
||||
gp_Pnt P0(0,0,0);
|
||||
dout.GetTrsf(id1,T);
|
||||
T.Invert();
|
||||
P0.Transform(T);
|
||||
Standard_Real z = dout.Zoom(id1);
|
||||
|
||||
dX1=X1; dY1=Y1;
|
||||
dX1-=P0.X(); dY1-=P0.Y();
|
||||
dX1/=z; dY1/=z;
|
||||
|
||||
if (b != 1) return 0;
|
||||
if (id1 < 0) return 0;
|
||||
Draw_Display d = dout.MakeDisplay(id1);
|
||||
d.SetColor(Draw_blanc);
|
||||
d.SetMode(10);
|
||||
Standard_Real dOX2 = dX1;
|
||||
Standard_Real dOY2 = dY1;
|
||||
d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
|
||||
d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
|
||||
d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
|
||||
d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
|
||||
d.Flush();
|
||||
Standard_Real zx,zy;
|
||||
Standard_Integer X,Y,W,H;
|
||||
dout.GetPosSize(id1,X,Y,W,H);
|
||||
di << "Pick second corner"<<"\n";
|
||||
b = 0;
|
||||
while (b == 0) {
|
||||
dout.Select(id1,X2,Y2,b,Standard_False);
|
||||
dX2=X2; dY2=Y2;
|
||||
dX2-=P0.X(); dY2-=P0.Y();
|
||||
dX2/=z; dY2/=z;
|
||||
|
||||
d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
|
||||
d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
|
||||
d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
|
||||
d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
|
||||
d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dY2));
|
||||
d.Draw(gp_Pnt2d(dX1,dY2),gp_Pnt2d(dX2,dY2));
|
||||
d.Draw(gp_Pnt2d(dX2,dY2),gp_Pnt2d(dX2,dY1));
|
||||
d.Draw(gp_Pnt2d(dX2,dY1),gp_Pnt2d(dX1,dY1));
|
||||
d.Flush();
|
||||
dOX2 = dX2;
|
||||
dOY2 = dY2;
|
||||
}
|
||||
d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
|
||||
d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
|
||||
d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
|
||||
d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
|
||||
d.Flush();
|
||||
if (b != 1) return 0;
|
||||
|
||||
if ((X1 == X2) || (Y1 == Y2)) return 0;
|
||||
|
||||
zx = (Standard_Real) Abs(X2-X1) / (Standard_Real) W;
|
||||
zy = (Standard_Real) Abs(Y2-Y1) / (Standard_Real) H;
|
||||
if (zy > zx) zx = zy;
|
||||
zx = 1/zx;
|
||||
if (X2 < X1) X1 = X2;
|
||||
if (Y2 > Y1) Y1 = Y2;
|
||||
X1 = (Standard_Integer ) (X1*zx);
|
||||
Y1 = (Standard_Integer ) (Y1*zx);
|
||||
d.SetMode(0);
|
||||
dout.SetZoom(id1,zx*dout.Zoom(id1));
|
||||
dout.SetPan(id1,-X1,-Y1);
|
||||
dout.RepaintView(id1);
|
||||
SetTitle(id1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : wclick
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer wclick(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
{
|
||||
Standard_Integer id1,X1,Y1,b;
|
||||
dout.Flush();
|
||||
di << "Just click."<<"\n";
|
||||
dout.Select(id1,X1,Y1,b);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : view
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer view(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (Draw_Batch) return 1;
|
||||
|
||||
if ((n >= 3) && (n != 4)) {
|
||||
Standard_Integer id = atoi(a[1]);
|
||||
if ((id < 0) || (id >= MAXVIEW)) {
|
||||
di <<"View-id must be in 0.."<<MAXVIEW-1<<"\n";
|
||||
return 1;
|
||||
}
|
||||
Standard_Integer X = 0;
|
||||
Standard_Integer Y = 0;
|
||||
Standard_Integer W = 500;
|
||||
Standard_Integer H = 500;
|
||||
// if view exist, get old values
|
||||
if (dout.HasView(id))
|
||||
dout.GetPosSize(id,X,Y,W,H);
|
||||
if (n >= 4)
|
||||
X = atoi(a[3]);
|
||||
if (n >= 5)
|
||||
Y = atoi(a[4]);
|
||||
if (n >= 6)
|
||||
W = atoi(a[5]);
|
||||
if (n >= 7)
|
||||
H = atoi(a[6]);
|
||||
dout.MakeView(id,a[2],X,Y,W,H);
|
||||
if (!dout.HasView(id)) {
|
||||
di << "View creation failed"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
SetTitle(id);
|
||||
dout.DisplayView(id);
|
||||
return 0;
|
||||
}
|
||||
else if (n == 4) {
|
||||
// create a view on a given window
|
||||
Standard_Integer id = atoi(a[1]);
|
||||
if ((id < 0) || (id >= MAXVIEW)) {
|
||||
di <<"View-id must be in 0.."<<MAXVIEW-1<<"\n";
|
||||
return 1;
|
||||
}
|
||||
dout.MakeView(id,a[2],a[3]);
|
||||
if (!dout.HasView(id)) {
|
||||
di << "View creation failed"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
SetTitle(id);
|
||||
dout.DisplayView(id);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : delview
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer delview(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n == 1) {
|
||||
for (Standard_Integer id = 0; id < MAXVIEW; id++)
|
||||
dout.DeleteView(id);
|
||||
return 0;
|
||||
}
|
||||
else if (n >= 2) {
|
||||
Standard_Integer id = ViewId(a[1]);
|
||||
if (id < 0) return 1;
|
||||
dout.DeleteView(id);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : fit
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer fit(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
Standard_Boolean f2d = !strcasecmp(a[0],"2dfit");
|
||||
if (n == 1) {
|
||||
Standard_Real zoom = RealLast();
|
||||
Standard_Integer id;
|
||||
for ( id = 0; id < MAXVIEW; id++) {
|
||||
if (dout.HasView(id)) {
|
||||
if ((f2d && !dout.Is3D(id)) || (!f2d && dout.Is3D(id))) {
|
||||
// dout.FitView(id,frame);
|
||||
dout.FitView(id,(Standard_Integer ) frame);
|
||||
if (dout.Zoom(id) < zoom) zoom = dout.Zoom(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (id = 0; id < MAXVIEW; id++) {
|
||||
if (dout.HasView(id)) {
|
||||
if ((f2d && !dout.Is3D(id)) || (!f2d && dout.Is3D(id))) {
|
||||
dout.SetZoom(id,zoom);
|
||||
dout.RepaintView(id);
|
||||
SetTitle(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (n >= 2) {
|
||||
Standard_Integer id = ViewId(a[1]);
|
||||
if (id < 0) return 1;
|
||||
// dout.FitView(id,frame);
|
||||
dout.FitView(id,(Standard_Integer ) frame);
|
||||
dout.RepaintView(id);
|
||||
SetTitle(id);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : focal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer focal(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
Standard_Integer start = 0;
|
||||
Standard_Integer end = MAXVIEW-1;
|
||||
if (n >= 2) {
|
||||
Standard_Integer anid = ViewId(a[1]);
|
||||
if (anid < 0) return 1;
|
||||
start = end = anid;
|
||||
}
|
||||
Standard_Real df = 1.;
|
||||
if (!strcasecmp(a[0],"fu"))
|
||||
df = stepfocal;
|
||||
if (!strcasecmp(a[0],"fd"))
|
||||
df = 1./stepfocal;
|
||||
|
||||
for (Standard_Integer id = start; id <= end; id++) {
|
||||
if (!strcasecmp(dout.GetType(id),"PERS")) {
|
||||
dout.SetFocal(id,dout.Focal(id) * df);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setfocal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer setfocal(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n == 1) {
|
||||
for (Standard_Integer id = 0; id < MAXVIEW; id++) {
|
||||
if (!strcasecmp(dout.GetType(id),"PERS"))
|
||||
di << "Focal view "<<id<<" is "<<dout.Focal(id)<<"\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_Real f = atof(a[1]);
|
||||
for (Standard_Integer id = 0; id < MAXVIEW; id++) {
|
||||
if (!strcasecmp(dout.GetType(id),"PERS"))
|
||||
dout.SetFocal(id,f);
|
||||
}
|
||||
dout.RepaintAll();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : magnify
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
//static Standard_Integer magnify(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
static Standard_Integer magnify(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
Standard_Integer start = 0;
|
||||
Standard_Integer end = MAXVIEW-1;
|
||||
if (n >= 2) {
|
||||
Standard_Integer anid = ViewId(a[1]);
|
||||
if (anid < 0) return 1;
|
||||
start = end = anid;
|
||||
}
|
||||
Standard_Boolean v2d = (a[0][0] == '2'); // 2dmu, 2dmd
|
||||
const char* com = a[0];
|
||||
if (v2d) com += 2;
|
||||
Standard_Real dz = 1.;
|
||||
if (!strcasecmp(com,"mu")) // mu, 2dmu
|
||||
dz = stepmagnify;
|
||||
else // md, 2dmd
|
||||
dz = 1/stepmagnify;
|
||||
|
||||
for (Standard_Integer id = start; id <= end; id++) {
|
||||
if (dout.HasView(id)) {
|
||||
if ((v2d && !dout.Is3D(id)) || (!v2d && dout.Is3D(id))) {
|
||||
dout.SetZoom(id,dout.Zoom(id) * dz);
|
||||
SetTitle(id);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Standard_EXPORT Standard_Integer Draw_magnify(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
return magnify(di,n,a);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : rotate
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer rotate(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
Standard_Integer start = 0;
|
||||
Standard_Integer end = MAXVIEW-1;
|
||||
if (n >= 2) {
|
||||
Standard_Integer anid = ViewId(a[1]);
|
||||
if (anid < 0) return 1;
|
||||
start = end = anid;
|
||||
}
|
||||
|
||||
gp_Dir2d D;
|
||||
Standard_Real ang=0;
|
||||
if (!strcasecmp(a[0],"u")) {
|
||||
D.SetCoord(1.,0.);
|
||||
ang = -steprot;
|
||||
}
|
||||
if (!strcasecmp(a[0],"d")) {
|
||||
D.SetCoord(1.,0.);
|
||||
ang = steprot;
|
||||
}
|
||||
if (!strcasecmp(a[0],"l")) {
|
||||
D.SetCoord(0.,1.);
|
||||
ang = -steprot;
|
||||
}
|
||||
if (!strcasecmp(a[0],"r")) {
|
||||
D.SetCoord(0.,1.);
|
||||
ang = steprot;
|
||||
}
|
||||
|
||||
for (Standard_Integer id = start; id <= end; id++) {
|
||||
if ((!strcasecmp(dout.GetType(id),"AXON")) ||
|
||||
(!strcasecmp(dout.GetType(id),"PERS"))) {
|
||||
dout.RotateView(id,D,ang);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : panning
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer panning(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
Standard_Integer start = 0;
|
||||
Standard_Integer end = MAXVIEW-1;
|
||||
if (n >= 2) {
|
||||
Standard_Integer anid = ViewId(a[1]);
|
||||
if (anid < 0) return 1;
|
||||
start = end = anid;
|
||||
}
|
||||
Standard_Integer DX = 0;
|
||||
Standard_Integer DY = 0;
|
||||
Standard_Integer X,Y,W,H;
|
||||
|
||||
Standard_Boolean v2d = (a[0][0] == '2'); // pu2d, pd2d, pr2d, pl2d
|
||||
const char* com = a[0];
|
||||
if (v2d) com += 2;
|
||||
|
||||
if (!strcasecmp(com,"pu")) // pu , 2dpu
|
||||
DY = 1;
|
||||
if (!strcasecmp(com,"pd")) // pd , 2dpd
|
||||
DY = -1;
|
||||
if (!strcasecmp(com,"pl")) // pl , 2dpl
|
||||
DX = -1;
|
||||
if (!strcasecmp(com,"pr")) // pr , 2dpr
|
||||
DX = 1;
|
||||
|
||||
for (Standard_Integer id = start; id <= end; id++) {
|
||||
if (dout.HasView(id)) {
|
||||
if ((v2d && !dout.Is3D(id)) || (!v2d && dout.Is3D(id))) {
|
||||
dout.GetPosSize(id,X,Y,W,H);
|
||||
// dout.PanView(id,W * DX * steppan, H * DY * steppan);
|
||||
dout.PanView(id,(Standard_Integer )( W * DX * steppan),(Standard_Integer )( H * DY * steppan));
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ptv
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer ptv(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
Standard_Real X,Y,Z;
|
||||
Standard_Integer start = 0;
|
||||
Standard_Integer end = MAXVIEW-1;
|
||||
if (n < 4) return 1;
|
||||
if (n >= 5) {
|
||||
Standard_Integer anid = ViewId(a[1]);
|
||||
if (anid < 0) return 1;
|
||||
start = end = anid;
|
||||
X = atof(a[2]);
|
||||
Y = atof(a[3]);
|
||||
Z = atof(a[4]);
|
||||
}
|
||||
else {
|
||||
X = atof(a[1]);
|
||||
Y = atof(a[2]);
|
||||
Z = atof(a[3]);
|
||||
}
|
||||
|
||||
for (Standard_Integer id = start; id <= end; id++) {
|
||||
gp_Trsf T;
|
||||
dout.GetTrsf(id,T);
|
||||
T.SetTranslationPart(gp_Vec(0,0,0));
|
||||
gp_Trsf T1;
|
||||
T1.SetTranslationPart(gp_Vec(-X,-Y,-Z));
|
||||
gp_Trsf aLocalTrsf(T*T1);
|
||||
dout.SetTrsf(id,aLocalTrsf);
|
||||
// dout.SetTrsf(id,T*T1);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : dptv
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer dptv(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
Standard_Real DX,DY,DZ;
|
||||
Standard_Integer start = 0;
|
||||
Standard_Integer end = MAXVIEW-1;
|
||||
if (n < 4) return 1;
|
||||
if (n >= 5) {
|
||||
Standard_Integer anid = ViewId(a[1]);
|
||||
if (anid < 0) return 1;
|
||||
start = end = anid;
|
||||
DX = atof(a[2]);
|
||||
DY = atof(a[3]);
|
||||
DZ = atof(a[4]);
|
||||
}
|
||||
else {
|
||||
DX = atof(a[1]);
|
||||
DY = atof(a[2]);
|
||||
DZ = atof(a[3]);
|
||||
}
|
||||
|
||||
for (Standard_Integer id = start; id <= end; id++) {
|
||||
gp_Trsf T;
|
||||
dout.GetTrsf(id,T);
|
||||
gp_Trsf T1;
|
||||
T1.SetTranslationPart(gp_Vec(-DX,-DY,-DZ));
|
||||
gp_Trsf M = T*T1;
|
||||
dout.SetTrsf(id,M);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : color
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer color(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 3) {
|
||||
Draw_BlackBackGround = !Draw_BlackBackGround;
|
||||
}
|
||||
else if (!dout.DefineColor(atoi(a[1]),a[2])) {
|
||||
di << "Could not allocate color "<<a[2]<<"\n";
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : hardcopy
|
||||
//purpose : hardcopy --> hardcopy of view 1
|
||||
// in file a4.ps
|
||||
// in format a4
|
||||
// hardcopy name view --> hardcopy of view <view>
|
||||
// in file <name>
|
||||
// in format a4
|
||||
// hardcopy name view format --> hardcopy of view <view>
|
||||
// in file <name>
|
||||
// in format <a4,a3,a2,a1,a0>
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer hardcopy(Draw_Interpretor& ,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
// Inch = 25.40001969 mm.
|
||||
// 28.4 pixels / mm.
|
||||
// format par default papier a4 210 297 mm avec marge de 3 mm.
|
||||
|
||||
Standard_Real rap = 28.4;
|
||||
Standard_Real cad = 3;
|
||||
Standard_Real dx = 210;
|
||||
Standard_Real dy = 210 * Sqrt(2.);
|
||||
|
||||
Standard_Integer iview = 1;
|
||||
const char* file = "a4.ps";
|
||||
if (n >= 2) {
|
||||
file = a[1];
|
||||
if (n >= 3) {
|
||||
iview = ViewId(a[2]);
|
||||
if (iview < 0) return 1;
|
||||
if (n >= 4) {
|
||||
if (!strcmp(a[3],"a7")) {
|
||||
cad = cad / (2 * Sqrt(2));
|
||||
dx = dx / (2 * Sqrt(2));
|
||||
dy = dy / (2 * Sqrt(2));
|
||||
}
|
||||
else if (!strcmp(a[3],"a6")) {
|
||||
cad = cad / 2;
|
||||
dx = dx / 2;
|
||||
dy = dy / 2;
|
||||
}
|
||||
else if (!strcmp(a[3],"a5")) {
|
||||
cad = cad / Sqrt(2);
|
||||
dx = dx / Sqrt(2);
|
||||
dy = dy / Sqrt(2);
|
||||
}
|
||||
else if (!strcmp(a[3],"a4")) {
|
||||
cad = cad;
|
||||
dx = dx;
|
||||
dy = dy;
|
||||
}
|
||||
else if (!strcmp(a[3],"a3")) {
|
||||
cad = cad * Sqrt(2);
|
||||
dx = dx * Sqrt(2);
|
||||
dy = dy * Sqrt(2);
|
||||
}
|
||||
else if (!strcmp(a[3],"a2")) {
|
||||
cad = cad * 2;
|
||||
dx = dx * 2;
|
||||
dy = dy * 2;
|
||||
}
|
||||
else if (!strcmp(a[3],"a1")) {
|
||||
cad = cad * 2 * Sqrt(2);
|
||||
dx = dx * 2 * Sqrt(2);
|
||||
dy = dy * 2 * Sqrt(2);
|
||||
}
|
||||
else if (!strcmp(a[3],"a0")) {
|
||||
cad = cad * 4;
|
||||
dx = dx * 4;
|
||||
dy = dy * 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer pxmin = (Standard_Integer)(cad * rap);
|
||||
Standard_Integer pymin = (Standard_Integer)(cad * rap);
|
||||
Standard_Integer pxmax = (Standard_Integer)((dx - cad) * rap);
|
||||
Standard_Integer pymax = (Standard_Integer)((dy - cad) * rap);
|
||||
|
||||
ofstream os(file);
|
||||
|
||||
Standard_Integer vxmin,vymin,vxmax,vymax;
|
||||
if (dout.HasView(iview)) {
|
||||
dout.GetFrame(iview,vxmin,vymin,vxmax,vymax);
|
||||
Standard_Real kx = (Standard_Real) (pxmax - pxmin) / (vxmax - vxmin);
|
||||
Standard_Real ky = (Standard_Real) (pymax - pymin) / (vymax - vymin);
|
||||
Standard_Real k = Min(Abs(kx),Abs(ky));
|
||||
kx = (kx > 0) ? k : -k;
|
||||
ky = (ky > 0) ? k : -k;
|
||||
pxmax = (Standard_Integer )( pxmin + kx * (vxmax - vxmin));
|
||||
pymax = (Standard_Integer )( pymin + ky * (vymax - vymin));
|
||||
|
||||
// si on veut choisir l'orientation : 90 rotate
|
||||
|
||||
// ecriture du header
|
||||
|
||||
os << "%!PS-Adobe-3.0 EPSF-3.0\n";
|
||||
os << "%%BoundingBox: " << pxmin << " " << pymin << " "
|
||||
<< pxmax << " " << pymax << "\n";
|
||||
os << "%%Pages: 1\n";
|
||||
os << "%%DocumentFonts: "<<Draw_fontname<<"\n";
|
||||
os << "%%EndComments\n";
|
||||
|
||||
os << "/"<<Draw_fontname<<" findfont\n"<<Draw_fontsize<<" scalefont\nsetfont\n";
|
||||
os << "/m {moveto} bind def\n";
|
||||
os << "/l {lineto} bind def\n";
|
||||
os <<".1 .1 scale\n";
|
||||
|
||||
// draw the frame
|
||||
|
||||
os <<"3 setlinewidth\n0 setgray\nnewpath\n";
|
||||
os << pxmin << " " << pymin << " m\n";
|
||||
os << pxmax << " " << pymin << " l\n";
|
||||
os << pxmax << " " << pymax << " l\n";
|
||||
os << pxmin << " " << pymax << " l\n";
|
||||
os << "closepath\nstroke\n";
|
||||
|
||||
// frame the view
|
||||
|
||||
os <<"newpath\n";
|
||||
os << pxmin << " " << pymin << " m\n";
|
||||
os << pxmax << " " << pymin << " l\n";
|
||||
os << pxmax << " " << pymax << " l\n";
|
||||
os << pxmin << " " << pymax << " l\n";
|
||||
os << "closepath\nclip\n";
|
||||
|
||||
dout.PostScriptView(iview,
|
||||
vxmin,vymin,vxmax,vymax,
|
||||
pxmin,pymin,pxmax,pymax,os);
|
||||
os <<"showpage\n";
|
||||
os <<"%%EOF\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer dfont(Draw_Interpretor& di,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n == 1 ) {
|
||||
strcpy(Draw_fontname, Draw_fontnamedefault);
|
||||
strcpy(Draw_fontsize, Draw_fontsizedefault);
|
||||
} else if ( n == 2 ) {
|
||||
strcpy(Draw_fontname, a[1]);
|
||||
} else if ( n == 3 ) {
|
||||
strcpy(Draw_fontname, a[1]);
|
||||
strcpy(Draw_fontsize, a[2]);
|
||||
}
|
||||
di<<Draw_fontname<<" "<<Draw_fontsize<<"\n";
|
||||
return 0;
|
||||
} // dfont
|
||||
|
||||
//=======================================================================
|
||||
//function : hcolor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer hcolor(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 4) {
|
||||
di << "code de couleur (Draw.cxx) : " << "\n" ;
|
||||
di << "0 = White,\t 1 = Red,\t 2 = Green,\t 3 = Blue" << "\n" ;
|
||||
di << "4 = Cyan,\t 5 = Gold,\t 6 = Magenta,\t 7 = Maroon" << "\n" ;
|
||||
di << "8 = Orange,\t 9 = Pink,\t 10 = Salmon,\t 11 = Violet" << "\n" ;
|
||||
di << "12 = Yellow,\t 13 = Khaki,\t 14 = Coral" << "\n" ;
|
||||
di << "1 <= width <= 11, 0 (noir) <= gray <= 1 (blanc)" << "\n" ;
|
||||
} else {
|
||||
dout.PostColor(atoi(a[1]),atoi(a[2]),atof(a[3]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : xwd
|
||||
//purpose : xwd file from a view
|
||||
//=======================================================================
|
||||
|
||||
extern void Draw_RepaintNowIfNecessary();
|
||||
|
||||
static Standard_Integer xwd(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
// enforce repaint if necessary
|
||||
Draw_RepaintNowIfNecessary();
|
||||
|
||||
Standard_Integer id = 1;
|
||||
const char* file = a[1];
|
||||
if (n > 2) {
|
||||
id = atoi(a[1]);
|
||||
file = a[2];
|
||||
}
|
||||
if (!dout.SaveView(id,file))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : grid
|
||||
//purpose : Creation/Suppression d'une grille.
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer grid (Draw_Interpretor& , Standard_Integer NbArg, const char **Arg)
|
||||
{
|
||||
Standard_Real StepX, StepY, StepZ ;
|
||||
|
||||
switch (NbArg) {
|
||||
case 1 :
|
||||
StepX = DefaultGridStep ;
|
||||
StepY = DefaultGridStep ;
|
||||
StepZ = DefaultGridStep ;
|
||||
break ;
|
||||
case 2 :
|
||||
StepX = Abs (atof (Arg[1])) ;
|
||||
StepY = Abs (atof (Arg[1])) ;
|
||||
StepZ = Abs (atof (Arg[1])) ;
|
||||
break ;
|
||||
case 3 :
|
||||
StepX = Abs (atof (Arg[1])) ;
|
||||
StepY = Abs (atof (Arg[2])) ;
|
||||
StepZ = Abs (atof (Arg[2])) ;
|
||||
break ;
|
||||
case 4 :
|
||||
StepX = Abs (atof (Arg[1])) ;
|
||||
StepY = Abs (atof (Arg[2])) ;
|
||||
StepZ = Abs (atof (Arg[3])) ;
|
||||
break ;
|
||||
default :
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
#ifdef HPUX
|
||||
const char *temp = "grid";
|
||||
#else
|
||||
char temp1[] = "grid";
|
||||
const char *temp = temp1;
|
||||
#endif
|
||||
Handle (Draw_Grid) Grille = Handle(Draw_Grid)::DownCast (Draw::Get(temp)) ;
|
||||
|
||||
Grille->Steps (StepX, StepY, StepZ) ;
|
||||
dout.RepaintAll () ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : dflush
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer dflush (Draw_Interpretor& , Standard_Integer, const char **)
|
||||
{
|
||||
dout.Flush();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : dtext
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer dtext(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
gp_Pnt P;
|
||||
Standard_Boolean is3d;
|
||||
if (n == 2) {
|
||||
Standard_Integer id,X,Y,b;
|
||||
di << "Pick position with button 1, other button escape"<<"\n";
|
||||
dout.Select(id,X,Y,b);
|
||||
if (b != 1)
|
||||
return 0;
|
||||
Standard_Real z = dout.Zoom(id);
|
||||
P.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0);
|
||||
gp_Trsf T;
|
||||
dout.GetTrsf(id,T);
|
||||
T.Invert();
|
||||
P.Transform(T);
|
||||
is3d = dout.Is3D(id);
|
||||
}
|
||||
else if (n >= 4) {
|
||||
is3d = n > 4;
|
||||
P.SetCoord(atof(a[1]),atof(a[2]),is3d ? atof(a[3]) : 0);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
if (is3d) {
|
||||
Handle(Draw_Text3D) D = new Draw_Text3D(P,a[n-1],Draw_vert);
|
||||
dout << D;
|
||||
}
|
||||
else {
|
||||
Handle(Draw_Text2D) D = new Draw_Text2D(gp_Pnt2d(P.X(),P.Y()),
|
||||
a[n-1],Draw_vert);
|
||||
dout << D;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Draw::GraphicCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean Done = Standard_False;
|
||||
if (Done) return;
|
||||
Done = Standard_True;
|
||||
|
||||
const char* g = "DRAW Graphic Commands";
|
||||
theCommands.Add("wclick","wait for a mouse click",
|
||||
__FILE__,wclick,g);
|
||||
theCommands.Add("zoom","zoom [view-id] z, or zoom z for all 3d views",
|
||||
__FILE__,zoom,g);
|
||||
theCommands.Add("2dzoom","2dzoom [view-id] z, or zoom2d z for all 2d views",
|
||||
__FILE__,zoom,g);
|
||||
theCommands.Add("wzoom","zoom on a window",
|
||||
__FILE__,wzoom,g);
|
||||
theCommands.Add("view","view view-id type X(0) Y(0) W(500) H(500)",
|
||||
__FILE__,view,g);
|
||||
theCommands.Add("delete","delete [view-id]",
|
||||
__FILE__,delview,g);
|
||||
theCommands.Add("fit","fit [view-id]",
|
||||
__FILE__,fit,g);
|
||||
theCommands.Add("2dfit","2dfit [view-id]",
|
||||
__FILE__,fit,g);
|
||||
theCommands.Add("fu","fu [view-id], focal up",
|
||||
__FILE__,focal,g);
|
||||
theCommands.Add("fd","fd [view-id], focal down",
|
||||
__FILE__,focal,g);
|
||||
theCommands.Add("focal","focal [f]",
|
||||
__FILE__,setfocal,g);
|
||||
theCommands.Add("mu","mu [view-id], magnify up",
|
||||
__FILE__,magnify,g);
|
||||
theCommands.Add("2dmu","2dmu [view-id], magnify up",
|
||||
__FILE__,magnify,g);
|
||||
theCommands.Add("md","md [view-id], magnify down",
|
||||
__FILE__,magnify,g);
|
||||
theCommands.Add("2dmd","2dmd [view-id], magnify down",
|
||||
__FILE__,magnify,g);
|
||||
theCommands.Add("u","u [view-id], rotate up",
|
||||
__FILE__,rotate,g);
|
||||
theCommands.Add("d","d [view-id], rotate down",
|
||||
__FILE__,rotate,g);
|
||||
theCommands.Add("l","l [view-id], rotate left",__FILE__,rotate,g);
|
||||
theCommands.Add("r","r [view-id], rotate right",__FILE__,rotate,g);
|
||||
theCommands.Add("pu","pu [view-id], panning up",__FILE__,panning,g);
|
||||
theCommands.Add("pd","pd [view-id], panning down",__FILE__,panning,g);
|
||||
theCommands.Add("pl","pl [view-id], panning left",__FILE__,panning,g);
|
||||
theCommands.Add("pr","pr [view-id], panning right",__FILE__,panning,g);
|
||||
theCommands.Add("2dpu","2dpu [view-id], panning up",__FILE__,panning,g);
|
||||
theCommands.Add("2dpd","2dpd [view-id], panning down",__FILE__,panning,g);
|
||||
theCommands.Add("2dpl","2dpl [view-id], panning left",__FILE__,panning,g);
|
||||
theCommands.Add("2dpr","2dpr [view-id], panning right",__FILE__,panning,g);
|
||||
theCommands.Add("ptv","ptv [view-id], X , Y , Z",
|
||||
__FILE__,ptv,g);
|
||||
theCommands.Add("dptv","dptv [view-id], dX , dY , dZ",
|
||||
__FILE__,dptv,g);
|
||||
theCommands.Add("color","color i colorname, define color i",
|
||||
__FILE__,color,g);
|
||||
theCommands.Add("hardcopy","hardcopy [file = a4.ps] [view-id = 1] [format = a4]", __FILE__,hardcopy,g);
|
||||
theCommands.Add("xwd","xwd [id = 1] <filename>.{png|bmp|jpg|gif}\n\t\t: Dump contents of viewer window to PNG, BMP, JPEG or GIF file",
|
||||
__FILE__,xwd,g);
|
||||
theCommands.Add("hcolor","hcolor icol width gray (< 1, 0 black)",
|
||||
__FILE__,hcolor,g);
|
||||
theCommands.Add("grid", "grid [stepX(100) [stepY [stepZ]]] / 0",
|
||||
__FILE__,grid, g);
|
||||
theCommands.Add("dflush","dflush, flush the viewer",
|
||||
__FILE__,dflush,g);
|
||||
theCommands.Add("dtext","dtext [x y [z]] string",
|
||||
__FILE__,dtext,g);
|
||||
theCommands.Add("dfont","dfont [name size] : set name and size of Draw font, or reset to default",
|
||||
__FILE__,dfont,g);
|
||||
}
|
||||
|
82
src/Draw/Draw_Grid.cdl
Executable file
82
src/Draw/Draw_Grid.cdl
Executable file
@@ -0,0 +1,82 @@
|
||||
-- File: Draw_Grid.cdl
|
||||
-- Created: Thu Feb 3 15:29:46 1994
|
||||
-- Author: Jean Marc LACHAUME
|
||||
-- <jml@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
class Grid from Draw inherits Drawable3D from Draw
|
||||
|
||||
uses
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
|
||||
---Purpose: Creates a grid.
|
||||
|
||||
returns mutable Grid from Draw ;
|
||||
|
||||
|
||||
Steps (me : mutable; StepX, StepY, StepZ : Real from Standard)
|
||||
|
||||
---Purpose: Sets the steps along the X, Y & Z axis.
|
||||
|
||||
is static ;
|
||||
|
||||
|
||||
StepX (me)
|
||||
|
||||
---Purpose: Returns the step along the X axis.
|
||||
|
||||
---C++: inline
|
||||
|
||||
returns Real from Standard
|
||||
is static ;
|
||||
|
||||
|
||||
StepY (me)
|
||||
|
||||
---Purpose: Returns the step along the Y axis.
|
||||
|
||||
---C++: inline
|
||||
|
||||
returns Real from Standard
|
||||
is static ;
|
||||
|
||||
|
||||
StepZ (me)
|
||||
|
||||
---Purpose: Returns the step along the Z axis.
|
||||
|
||||
---C++: inline
|
||||
|
||||
returns Real from Standard
|
||||
is static ;
|
||||
|
||||
|
||||
IsActive (me)
|
||||
|
||||
---Purpose: Returns if the grid is active or not.
|
||||
|
||||
---C++: inline
|
||||
|
||||
returns Boolean from Standard
|
||||
is static ;
|
||||
|
||||
|
||||
DrawOn (me; Out : in out Display from Draw)
|
||||
|
||||
---Purpose: Displays the grid.
|
||||
|
||||
is static ;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myStepX : Real from Standard ;
|
||||
myStepY : Real from Standard ;
|
||||
myStepZ : Real from Standard ;
|
||||
myIsActive : Boolean from Standard ;
|
||||
|
||||
end Grid ;
|
126
src/Draw/Draw_Grid.cxx
Executable file
126
src/Draw/Draw_Grid.cxx
Executable file
@@ -0,0 +1,126 @@
|
||||
// File: Draw_Grid.cxx
|
||||
// Created: Thu Feb 3 15:30:25 1994
|
||||
// Author: Jean Marc LACHAUME
|
||||
// <jml@phylox>
|
||||
|
||||
|
||||
#include <Draw_Grid.ixx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_ColorKind.hxx>
|
||||
#include <Draw_Color.hxx>
|
||||
|
||||
static Standard_Real MinimumStep = 1.e-3 ;
|
||||
static Standard_Real Ratio = 200.0 ;
|
||||
|
||||
//#ifdef WNT
|
||||
extern Draw_Viewer dout;
|
||||
//#endif
|
||||
|
||||
//=======================================================================
|
||||
// Function : Draw_Grid
|
||||
// Purpose : Constructor.
|
||||
//=======================================================================
|
||||
|
||||
Draw_Grid::Draw_Grid () :
|
||||
myStepX (0.0) ,
|
||||
myStepY (0.0) ,
|
||||
myStepZ (0.0) ,
|
||||
myIsActive (Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function : Steps
|
||||
// Purpose : Sets the steps along the X, Y & Z axis.
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Grid::Steps (const Standard_Real StepX,
|
||||
const Standard_Real StepY,
|
||||
const Standard_Real StepZ)
|
||||
{
|
||||
myStepX = Abs (StepX) ;
|
||||
myStepY = Abs (StepY) ;
|
||||
myStepZ = Abs (StepZ) ;
|
||||
myIsActive = myStepX > MinimumStep
|
||||
&& myStepY > MinimumStep
|
||||
&& myStepZ > MinimumStep ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function : DrawOn
|
||||
// Purpose : Displays the grid.
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Grid::DrawOn (Draw_Display& Out) const
|
||||
{
|
||||
if (!myIsActive) return ;
|
||||
|
||||
Standard_Integer xmin, xmax, ymin, ymax ;
|
||||
Standard_Integer IndexX, IndexY ;
|
||||
Standard_Real StepX, StepY ;
|
||||
Standard_Integer MinIndexX, MaxIndexX, MinIndexY, MaxIndexY ;
|
||||
Standard_Real Offset ;
|
||||
Standard_Real zoom, Xmin, Xmax, Ymin, Ymax ;
|
||||
gp_Trsf T ;
|
||||
gp_Pnt Pnt1, Pnt2 ;
|
||||
|
||||
Standard_Integer IdtView ;
|
||||
char *Type ;
|
||||
|
||||
IdtView = Out.ViewId () ;
|
||||
if (!dout.HasView (IdtView)) return ;
|
||||
Type = dout.GetType (IdtView) ;
|
||||
switch (*(Type+1)) {
|
||||
case 'X' : StepX = myStepX ; break ;
|
||||
case 'Y' : StepX = myStepY ; break ;
|
||||
case 'Z' : StepX = myStepZ ; break ;
|
||||
default : StepX = 0.0 ; break ;
|
||||
}
|
||||
switch (*(Type+3)) {
|
||||
case 'X' : StepY = myStepX ; break ;
|
||||
case 'Y' : StepY = myStepY ; break ;
|
||||
case 'Z' : StepY = myStepZ ; break ;
|
||||
default : StepY = 0.0 ; break ;
|
||||
}
|
||||
|
||||
if (StepX > MinimumStep && StepY > MinimumStep) {
|
||||
|
||||
dout.GetFrame (IdtView, xmin, ymin, xmax, ymax) ;
|
||||
dout.GetTrsf (IdtView, T) ; T.Invert () ;
|
||||
zoom = dout.Zoom (IdtView) ;
|
||||
|
||||
Xmin = ((Standard_Real) xmin) / zoom ;
|
||||
Xmax = ((Standard_Real) xmax) / zoom ;
|
||||
Ymin = ((Standard_Real) ymin) / zoom ;
|
||||
Ymax = ((Standard_Real) ymax) / zoom ;
|
||||
|
||||
Offset = Min (Xmax - Xmin, Ymax - Ymin) / Ratio ;
|
||||
|
||||
MinIndexX = (Standard_Integer) (Xmin / StepX) ;
|
||||
MaxIndexX = (Standard_Integer) (Xmax / StepX) ;
|
||||
MinIndexY = (Standard_Integer) (Ymin / StepY) ;
|
||||
MaxIndexY = (Standard_Integer) (Ymax / StepY) ;
|
||||
|
||||
for (IndexX = MinIndexX ; IndexX <= MaxIndexX ; IndexX++) {
|
||||
for (IndexY = MinIndexY ; IndexY <= MaxIndexY ; IndexY++) {
|
||||
Standard_Real X = ((Standard_Real) IndexX) * StepX ;
|
||||
Standard_Real Y = ((Standard_Real) IndexY) * StepY ;
|
||||
|
||||
Pnt1.SetCoord (X - Offset, Y, 0.0) ; Pnt1.Transform (T) ;
|
||||
Pnt2.SetCoord (X + Offset, Y, 0.0) ; Pnt2.Transform (T) ;
|
||||
Out.SetColor (Draw_Color (Draw_bleu)) ;
|
||||
Out.Draw (Pnt1, Pnt2) ;
|
||||
|
||||
Pnt1.SetCoord (X, Y - Offset, 0.0) ; Pnt1.Transform (T) ;
|
||||
Pnt2.SetCoord (X, Y + Offset, 0.0) ; Pnt2.Transform (T) ;
|
||||
Out.SetColor (Draw_Color (Draw_bleu)) ;
|
||||
Out.Draw (Pnt1, Pnt2) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
44
src/Draw/Draw_Grid.lxx
Executable file
44
src/Draw/Draw_Grid.lxx
Executable file
@@ -0,0 +1,44 @@
|
||||
// File: Draw_Grid.lxx
|
||||
// Created: Thu Feb 3 15:30:54 1994
|
||||
// Author: Jean Marc LACHAUME
|
||||
// <jml@phylox>
|
||||
|
||||
//=======================================================================
|
||||
// Function : StepX
|
||||
// Purpose : Returns the step along the X axis.
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real Draw_Grid::StepX () const
|
||||
{
|
||||
return myStepX ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function : StepY
|
||||
// Purpose : Returns the step along the Y axis.
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real Draw_Grid::StepY () const
|
||||
{
|
||||
return myStepY ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function : StepZ
|
||||
// Purpose : Returns the step along the Z axis.
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real Draw_Grid::StepZ () const
|
||||
{
|
||||
return myStepZ ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function : IsActive
|
||||
// Purpose : Returns if the grid is active or not.
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean Draw_Grid::IsActive () const
|
||||
{
|
||||
return myIsActive ;
|
||||
}
|
137
src/Draw/Draw_Interpretor.cdl
Executable file
137
src/Draw/Draw_Interpretor.cdl
Executable file
@@ -0,0 +1,137 @@
|
||||
-- File: Draw_Interpretor.cdl
|
||||
-- Created: Thu Feb 23 16:59:40 1995
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@bravox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class Interpretor from Draw
|
||||
|
||||
---Purpose: Provides an encapsulation of the TCL interpretor
|
||||
-- to define Draw commands.
|
||||
|
||||
uses
|
||||
|
||||
PInterp from Draw,
|
||||
CommandFunction from Draw,
|
||||
AsciiString from TCollection,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Create returns Interpretor from Draw;
|
||||
|
||||
Init(me : in out);
|
||||
|
||||
Add(me : in out; Command : CString;
|
||||
Help : CString;
|
||||
Function : CommandFunction from Draw;
|
||||
Group : CString = "User Commands");
|
||||
---Purpose: Creates a new command with name <Command>, help
|
||||
-- string <Help> in group <Group>.
|
||||
-- <Function> implement the function.
|
||||
|
||||
Add(me : in out; Command : CString;
|
||||
Help : CString;
|
||||
FileName : CString ;
|
||||
Function : CommandFunction from Draw;
|
||||
Group : CString = "User Commands");
|
||||
---Purpose: Creates a new command with name <Command>, help
|
||||
-- string <Help> in group <Group>. <Function>
|
||||
-- implement the function.
|
||||
-- <FileName> is the name of the file that contains
|
||||
-- the implementation of the command
|
||||
--
|
||||
|
||||
Remove(me : in out; Command : CString)
|
||||
returns Boolean;
|
||||
---Purpose: Removes <Command>, returns true if success (the
|
||||
-- command existed).
|
||||
|
||||
--
|
||||
-- The result
|
||||
--
|
||||
|
||||
Result(me) returns CString;
|
||||
|
||||
Reset(me : in out);
|
||||
---Purpose: Resets the result to empty string
|
||||
|
||||
Append(me : in out; Result : CString) returns Interpretor from Draw;
|
||||
---Purpose: Appends to the result
|
||||
---C++: return &
|
||||
---C++: alias operator<<
|
||||
|
||||
Append(me : in out; Result : AsciiString from TCollection)
|
||||
returns Interpretor from Draw;
|
||||
---Purpose: Appends to the result
|
||||
---C++: return &
|
||||
---C++: alias operator<<
|
||||
|
||||
Append(me : in out; Result : ExtendedString from TCollection)
|
||||
returns Interpretor from Draw;
|
||||
---Purpose: Appends to the result
|
||||
---C++: return &
|
||||
---C++: alias operator<<
|
||||
|
||||
Append(me : in out; Result : Integer) returns Interpretor from Draw;
|
||||
---Purpose: Appends to the result
|
||||
---C++: return &
|
||||
---C++: alias operator<<
|
||||
|
||||
Append(me : in out; Result : Real) returns Interpretor from Draw;
|
||||
---Purpose: Appends to the result
|
||||
---C++: return &
|
||||
---C++: alias operator<<
|
||||
|
||||
Append(me : in out; Result : SStream) returns Interpretor from Draw;
|
||||
---Purpose: Appends to the result
|
||||
---C++: return &
|
||||
---C++: alias operator<<
|
||||
|
||||
AppendElement(me : in out; Result : CString);
|
||||
---Purpose: Appends to the result the string as a list element
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Interpetation
|
||||
--
|
||||
|
||||
Eval(me : in out; Script : CString)
|
||||
returns Integer;
|
||||
---Purpose: Eval the script and returns OK = 0, ERROR = 1
|
||||
|
||||
RecordAndEval(me : in out; Script : CString; Flags : Integer = 0)
|
||||
returns Integer;
|
||||
---Purpose: Eval the script and returns OK = 0, ERROR = 1
|
||||
-- Store the script in the history record.
|
||||
|
||||
EvalFile(me : in out; FileName : CString)
|
||||
returns Integer;
|
||||
---Purpose: Eval the content on the file and returns status
|
||||
|
||||
Complete(myclass; Script : CString) returns Boolean;
|
||||
---Purpose: Returns True if the script is complete, no pending
|
||||
-- closing braces. (})
|
||||
|
||||
Destroy(me : in out);
|
||||
---C++: alias ~
|
||||
|
||||
--
|
||||
-- Access to Tcl_Interp
|
||||
--
|
||||
|
||||
Create(anInterp : PInterp from Draw)
|
||||
returns Interpretor from Draw;
|
||||
|
||||
Set(me : in out; anInterp : PInterp from Draw);
|
||||
|
||||
Interp (me) returns PInterp from Draw;
|
||||
|
||||
fields
|
||||
|
||||
isAllocated : Boolean from Standard;
|
||||
myInterp : PInterp from Draw;
|
||||
|
||||
end Interpretor;
|
519
src/Draw/Draw_Interpretor.cxx
Executable file
519
src/Draw/Draw_Interpretor.cxx
Executable file
@@ -0,0 +1,519 @@
|
||||
// File: Draw_Interpretor.cxx
|
||||
// Created: Thu Feb 23 17:53:09 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
|
||||
#include <Draw_Interpretor.ixx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Standard_SStream.hxx>
|
||||
#include <Standard_RangeError.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <tcl.h>
|
||||
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 1)))
|
||||
#define TCL_USES_UTF8
|
||||
#endif
|
||||
|
||||
//
|
||||
// Auxiliary tool to convert strings in command arguments from UTF-8
|
||||
// (Tcl internal encoding since Tcl 8.1) to system local encoding,
|
||||
// normally extended Ascii as expected by OCC commands
|
||||
//
|
||||
class TclUTFToLocalStringSentry {
|
||||
public:
|
||||
|
||||
#ifdef TCL_USES_UTF8
|
||||
TclUTFToLocalStringSentry (int argc, const char **argv) :
|
||||
nb(0),
|
||||
TclArgv(new Tcl_DString[argc]),
|
||||
Argv(new char*[argc])
|
||||
{
|
||||
for (; nb < argc; nb++ ) {
|
||||
Tcl_UtfToExternalDString ( NULL, argv[nb], -1, &TclArgv[nb] );
|
||||
Argv[nb] = Tcl_DStringValue ( &TclArgv[nb] );
|
||||
}
|
||||
}
|
||||
|
||||
~TclUTFToLocalStringSentry ()
|
||||
{
|
||||
delete[] Argv;
|
||||
while ( nb-- >0 ) Tcl_DStringFree ( &TclArgv[nb] );
|
||||
delete[] TclArgv;
|
||||
}
|
||||
#else
|
||||
TclUTFToLocalStringSentry (int, const char **argv) : Argv((char**)argv) {}
|
||||
#endif
|
||||
|
||||
const char **GetArgv () const { return (const char **)Argv; }
|
||||
|
||||
private:
|
||||
int nb;
|
||||
Tcl_DString *TclArgv;
|
||||
char **Argv;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Call backs for TCL
|
||||
//
|
||||
|
||||
struct CData {
|
||||
CData(Draw_CommandFunction ff, Draw_Interpretor* ii) : f(ff), i(ii) {}
|
||||
Draw_CommandFunction f;
|
||||
Draw_Interpretor* i;
|
||||
};
|
||||
|
||||
// MKV 29.03.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
||||
static Standard_Integer CommandCmd
|
||||
(ClientData clientData, Tcl_Interp *interp,
|
||||
Standard_Integer argc, const char* argv[])
|
||||
#else
|
||||
static Standard_Integer CommandCmd
|
||||
(ClientData clientData, Tcl_Interp *interp,
|
||||
Standard_Integer argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
static Standard_Integer code;
|
||||
code = TCL_OK;
|
||||
CData* C = (CData*) clientData;
|
||||
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
|
||||
// OCC63: Convert strings from UTF-8 to local encoding, normally expected by OCC commands
|
||||
TclUTFToLocalStringSentry anArgs ( argc, (const char**)argv );
|
||||
|
||||
Draw_Interpretor& di = *(C->i);
|
||||
Standard_Integer fres = C->f ( di, argc, anArgs.GetArgv() );
|
||||
if (fres != 0)
|
||||
code = TCL_ERROR;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
|
||||
Handle(Standard_Failure) E = Standard_Failure::Caught();
|
||||
|
||||
// fail if Draw_ExitOnCatch is set
|
||||
// MKV 29.03.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
||||
const char* cc = Tcl_GetVar(interp,
|
||||
"Draw_ExitOnCatch",TCL_GLOBAL_ONLY);
|
||||
#else
|
||||
char* const cc = Tcl_GetVar(interp,
|
||||
"Draw_ExitOnCatch",TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
cout << "An exception was caught " << E << endl;
|
||||
|
||||
if (cc && atoi(cc)) {
|
||||
#ifdef WNT
|
||||
Tcl_Exit(0);
|
||||
#else
|
||||
Tcl_Eval(interp,"exit");
|
||||
#endif
|
||||
}
|
||||
|
||||
// get the error message
|
||||
Standard_SStream ss;
|
||||
ss << "** Exception ** " << E << ends ;
|
||||
#ifdef USE_STL_STREAM
|
||||
Tcl_SetResult(interp,(char*)(ss.str().c_str()),TCL_VOLATILE);
|
||||
#else
|
||||
Tcl_SetResult(interp,(char*)(ss.str()),TCL_VOLATILE);
|
||||
#endif
|
||||
code = TCL_ERROR;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
static void CommandDelete (ClientData clientData)
|
||||
{
|
||||
CData *C = (CData*) clientData;
|
||||
delete C;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Interpretor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor::Draw_Interpretor() :
|
||||
isAllocated(Standard_False)
|
||||
{
|
||||
// On ne cree pas tout de suite l'interpreteur tcl car s'il est detenu
|
||||
// par une variable globale il est cree et ecrase avant le main().
|
||||
myInterp = NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose : Il faut appeler cette fonction
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Interpretor::Init()
|
||||
{
|
||||
if (isAllocated)
|
||||
Tcl_DeleteInterp(myInterp);
|
||||
isAllocated=Standard_True;
|
||||
myInterp=Tcl_CreateInterp();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Interpretor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor::Draw_Interpretor(const Draw_PInterp& p) :
|
||||
isAllocated(Standard_False),
|
||||
myInterp(p)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//#ifdef WNT
|
||||
void Draw_Interpretor::Add(const Standard_CString n,
|
||||
const Standard_CString help,
|
||||
const Draw_CommandFunction f,
|
||||
const Standard_CString group)
|
||||
//#else
|
||||
//void Draw_Interpretor::Add(const Standard_CString n,
|
||||
// const Standard_CString help,
|
||||
// const Draw_CommandFunction& f,
|
||||
// const Standard_CString group)
|
||||
//#endif
|
||||
{
|
||||
Standard_PCharacter pN, pHelp, pGroup;
|
||||
//
|
||||
pN=(Standard_PCharacter)n;
|
||||
pHelp=(Standard_PCharacter)help;
|
||||
pGroup=(Standard_PCharacter)group;
|
||||
//
|
||||
if (myInterp==NULL) Init();
|
||||
|
||||
CData* C = new CData(f,this);
|
||||
|
||||
Tcl_CreateCommand(myInterp, pN ,CommandCmd, (ClientData) C, CommandDelete);
|
||||
|
||||
// add the help
|
||||
Tcl_SetVar2(myInterp,"Draw_Helps", pN, pHelp, TCL_GLOBAL_ONLY);
|
||||
Tcl_SetVar2(myInterp,"Draw_Groups",pGroup,pN,
|
||||
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Draw_Interpretor::Add(const Standard_CString n,
|
||||
const Standard_CString help,
|
||||
const Standard_CString file_name,
|
||||
const Draw_CommandFunction f,
|
||||
const Standard_CString group)
|
||||
{
|
||||
Standard_PCharacter pN, pHelp, pGroup, pFileName;
|
||||
//
|
||||
pN=(Standard_PCharacter)n;
|
||||
pHelp=(Standard_PCharacter)help;
|
||||
pGroup=(Standard_PCharacter)group;
|
||||
pFileName=(Standard_PCharacter)file_name;
|
||||
//
|
||||
if (myInterp==NULL) Init();
|
||||
|
||||
CData* C = new CData(f,this);
|
||||
Standard_Integer length, num_slashes, ii, jj, kk;
|
||||
Tcl_CreateCommand(myInterp,pN,CommandCmd, (ClientData) C, CommandDelete);
|
||||
|
||||
// add the help
|
||||
Tcl_SetVar2(myInterp,"Draw_Helps",pN,pHelp,TCL_GLOBAL_ONLY);
|
||||
Tcl_SetVar2(myInterp,"Draw_Groups",pGroup,pN,
|
||||
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
|
||||
length = strlen(pFileName) ;
|
||||
char * a_string =
|
||||
new char[length + 1] ;
|
||||
jj = 0 ;
|
||||
num_slashes = 0 ;
|
||||
ii = length ;
|
||||
while (num_slashes < 3 && ii >= 0) {
|
||||
if (file_name[ii] == '/') {
|
||||
num_slashes += 1 ;
|
||||
}
|
||||
ii -= 1 ;
|
||||
}
|
||||
jj = 0 ;
|
||||
for (kk = ii+2 , jj =0 ; kk < length ; kk++) {
|
||||
a_string[jj] = file_name[kk] ;
|
||||
jj += 1 ;
|
||||
}
|
||||
a_string[jj] = '\0' ;
|
||||
|
||||
Tcl_SetVar2(myInterp,"Draw_Files",pN,a_string,TCL_GLOBAL_ONLY);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Remove
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_Interpretor::Remove(Standard_CString const n)
|
||||
{
|
||||
Standard_PCharacter pN;
|
||||
//
|
||||
pN=(Standard_PCharacter)n;
|
||||
|
||||
Standard_Integer result = Tcl_DeleteCommand(myInterp,pN);
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Result
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_CString Draw_Interpretor::Result() const
|
||||
{
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5)))
|
||||
return Tcl_GetStringResult(myInterp);
|
||||
#else
|
||||
return myInterp->result;
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Reset
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Interpretor::Reset()
|
||||
{
|
||||
Tcl_ResetResult(myInterp);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Append
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor& Draw_Interpretor::Append(const Standard_CString s)
|
||||
{
|
||||
#ifdef TCL_USES_UTF8
|
||||
// Convert string to UTF-8 format for Tcl
|
||||
Tcl_DString TclString;
|
||||
Tcl_ExternalToUtfDString ( NULL, s, -1, &TclString );
|
||||
Tcl_AppendResult ( myInterp, Tcl_DStringValue ( &TclString ), (Standard_CString)0 );
|
||||
Tcl_DStringFree ( &TclString );
|
||||
#else
|
||||
Tcl_AppendResult(myInterp,s,(Standard_CString)0);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Append
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor& Draw_Interpretor::Append(const TCollection_AsciiString& s)
|
||||
{
|
||||
return Append (s.ToCString());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Append
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor& Draw_Interpretor::Append(const TCollection_ExtendedString& theString)
|
||||
{
|
||||
#ifdef TCL_USES_UTF8
|
||||
// Convert string to UTF-8 format for Tcl
|
||||
char *str = new char[theString.LengthOfCString()+1];
|
||||
theString.ToUTF8CString (str);
|
||||
Tcl_AppendResult ( myInterp, str, (Standard_CString)0 );
|
||||
delete[] str;
|
||||
#else
|
||||
// put as ascii string, replacing non-ascii characters by '?'
|
||||
TCollection_AsciiString str (theString, '?');
|
||||
Tcl_AppendResult(myInterp,str.ToCString(),(Standard_CString)0);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Append
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor& Draw_Interpretor::Append(const Standard_Integer i)
|
||||
{
|
||||
char c[100];
|
||||
sprintf(c,"%d",i);
|
||||
Tcl_AppendResult(myInterp,c,(Standard_CString)0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Append
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor& Draw_Interpretor::Append(const Standard_Real r)
|
||||
{
|
||||
char s[100];
|
||||
sprintf(s,"%.17g",r);
|
||||
Tcl_AppendResult(myInterp,s,(Standard_CString)0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Append
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor& Draw_Interpretor::Append(const Standard_SStream& s)
|
||||
{
|
||||
#ifdef USE_STL_STREAM
|
||||
return Append (s.str().c_str());
|
||||
#else
|
||||
// Note: use dirty tricks -- unavoidable with old streams
|
||||
TCollection_AsciiString aStr (((Standard_SStream&)AReason).str(), AReason.pcount());
|
||||
((Standard_SStream&)AReason).freeze (false);
|
||||
return Append (aStr.ToCString());
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AppendElement
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Interpretor::AppendElement(const Standard_CString s)
|
||||
{
|
||||
#ifdef TCL_USES_UTF8
|
||||
// Convert string to UTF-8 format for Tcl
|
||||
Tcl_DString TclString;
|
||||
Tcl_ExternalToUtfDString ( NULL, s, -1, &TclString );
|
||||
Tcl_AppendElement ( myInterp, Tcl_DStringValue ( &TclString ) );
|
||||
Tcl_DStringFree ( &TclString );
|
||||
#else
|
||||
#ifdef IRIX
|
||||
//AppendElement is declared as (Tcl_Interp *interp, char *string)
|
||||
//on SGI 32
|
||||
Tcl_AppendElement(myInterp,(char*) s);
|
||||
#else
|
||||
Tcl_AppendElement(myInterp, s);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Eval
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer Draw_Interpretor::Eval(const Standard_CString line)
|
||||
{
|
||||
Standard_PCharacter pLine;
|
||||
//
|
||||
pLine=(Standard_PCharacter)line;
|
||||
//
|
||||
return Tcl_Eval(myInterp,pLine);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Eval
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer Draw_Interpretor::RecordAndEval(const Standard_CString line,
|
||||
const Standard_Integer flags)
|
||||
{
|
||||
Standard_PCharacter pLine;
|
||||
//
|
||||
pLine=(Standard_PCharacter)line;
|
||||
return Tcl_RecordAndEval(myInterp,pLine,flags);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : EvalFile
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer Draw_Interpretor::EvalFile(const Standard_CString fname)
|
||||
{
|
||||
Standard_PCharacter pfname;
|
||||
//
|
||||
pfname=(Standard_PCharacter)fname;
|
||||
return Tcl_EvalFile(myInterp,pfname);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :Complete
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_Interpretor::Complete(const Standard_CString line)
|
||||
{
|
||||
Standard_PCharacter pLine;
|
||||
//
|
||||
pLine=(Standard_PCharacter)line;
|
||||
return Tcl_CommandComplete(pLine);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Destroy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Interpretor::Destroy()
|
||||
{
|
||||
// MKV 01.02.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
Tcl_Exit(0);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
#ifdef DEB
|
||||
cout <<"Tcl_Exit have an exeption" << endl;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#ifdef WNT
|
||||
Tcl_Exit(0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Interp
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_PInterp Draw_Interpretor::Interp() const
|
||||
{
|
||||
Standard_DomainError_Raise_if (myInterp==NULL , "No call for Draw_Interpretor::Init()");
|
||||
return myInterp;
|
||||
}
|
||||
|
||||
void Draw_Interpretor::Set(const Draw_PInterp& PIntrp)
|
||||
{
|
||||
if (isAllocated)
|
||||
Tcl_DeleteInterp(myInterp);
|
||||
isAllocated = Standard_False;
|
||||
myInterp = PIntrp;
|
||||
}
|
179
src/Draw/Draw_Main.cxx
Executable file
179
src/Draw/Draw_Main.cxx
Executable file
@@ -0,0 +1,179 @@
|
||||
// File: Draw_Main.cxx
|
||||
// Created: Thu Dec 30 10:40:46 1999
|
||||
// Author: Roman LYGIN
|
||||
// <rln@burnax.nnov.matra-dtv.fr>
|
||||
|
||||
// *******************************************************************
|
||||
// RLN 06 January 2000
|
||||
// *******************************************************************
|
||||
// This file is built from former NTMain.pxx duplicated in many executables
|
||||
// extending DRAW Test Harness.
|
||||
// Now is implemented only in one instance.
|
||||
|
||||
// Differences between CAS.CADE versions:
|
||||
// - in C21 Draw_Appli is defined in Draw.cxx (DRAW UL) and calls externally
|
||||
// defined Draw_InitAppli. Moreover, on WNT Draw_Appli was not declared as
|
||||
// Standard_EXPORT and therefore it has to be duplicated explicitly in this
|
||||
// code as in Draw.cxx.
|
||||
// - in C30 Draw_Appli accepts Draw_InitAppli as parameter which is given to
|
||||
// it in each executable. Draw_Appli is declared as Standard_EXPORT and
|
||||
// therefore it needs not to be duplicated.
|
||||
|
||||
// To have only one instance of this file and to call it from all the executables
|
||||
// thereare defined macros in .hxx that replace main/WinMain functions and which
|
||||
// calls _main_/_WinMain_ defined in this file with specified Draw_InitAppli.
|
||||
// To avoid Unresolved symbols on WNT, Draw_InitAppli is explicitly defined in this
|
||||
// file as simple invoker of the function statically stored in this file and which
|
||||
// is initialized by main/_WinMain_.
|
||||
|
||||
// WARNING: Although versions C21 and C30 are synchronised as much as they can,
|
||||
// there are two versions of this file for both configurations. This is explained by:
|
||||
// - Standard_IMPOR is differently defined,
|
||||
// - Draw_Appli is differently declared.
|
||||
|
||||
|
||||
// *******************************************************************
|
||||
// CKY 18 Juilet 1997
|
||||
// *******************************************************************
|
||||
// MAIN a la sauce WNT
|
||||
// EXPLICATION : un MAIN sous NT, c est quelque chose ... different de sous UNIX
|
||||
// ilya un tas de trucs a initialiser
|
||||
// Deux aspects : le main et Draw_Appli
|
||||
// le main est specifique : arguments, creation de "console"
|
||||
// Draw_Appli aussi, mais comme certains peuvent le redefinir, et que
|
||||
// NT ne permet pas cela, eh be il est duplique dans chaque main ...
|
||||
// Ceci a l identique. Youpi
|
||||
//
|
||||
// Ce source comprend :
|
||||
// - un main repris : WinMain, qui en particlier definit une "console"
|
||||
// - un Draw_Appli repris
|
||||
// - la plupart des ifdef WNT sont laisses pour memoire
|
||||
// MAIS CE CODE N EST COMPILABLE QU EN NT
|
||||
//
|
||||
// MODE D EMPLOI
|
||||
// Dans le source de l exec .cxx, Inclure ce gros paquet (NTMain.pxx)
|
||||
// a la place des includes courants et du main, en ifdef WNT of course
|
||||
//
|
||||
// On laisse les includes specifiques ainsi que le Draw_InitAppli
|
||||
// qui lui aussi est specifique
|
||||
//
|
||||
// ATTENTION, avant de faire umake, taper cette commande magique (?)
|
||||
// setenv (WOK_EXETYPE) W
|
||||
// *******************************************************************
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef WNT
|
||||
#include <windows.h> /* SW_SHOW */
|
||||
#endif
|
||||
|
||||
#include <Draw_Main.hxx>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <OSD.hxx>
|
||||
|
||||
#include <tcl.h>
|
||||
|
||||
#ifdef WNT
|
||||
#include <sys/stat.h>
|
||||
#include <Draw_Window.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
extern Draw_Viewer dout;
|
||||
|
||||
static char* ColorNames[MAXCOLOR] = {
|
||||
"White","Red","Green","Blue","Cyan","Gold","Magenta",
|
||||
"Maroon","Orange","Pink","Salmon","Violet","Yellow","Khaki","Coral"
|
||||
};
|
||||
|
||||
static Standard_Boolean XLoop;
|
||||
|
||||
// extern Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C21
|
||||
Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C30
|
||||
// true if complete command
|
||||
|
||||
// necessary for WNT in C21 only
|
||||
static FDraw_InitAppli theDraw_InitAppli; //pointer to the Draw_InitAppli
|
||||
static void Draw_InitAppli(Draw_Interpretor& theCommands)
|
||||
{
|
||||
theDraw_InitAppli (theCommands);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WNT
|
||||
//=======================================================================
|
||||
//NOTE: OCC11
|
||||
// On Windows NT, both console (UNIX-like) and windowed (classical on
|
||||
// WNT, with three separated windows - input, output and graphic)
|
||||
// modes are supported.
|
||||
// Depending on compilation mode of executable (CONSOLE or WINDOWS),
|
||||
// either _main_ or _WinMain_ becomes entry point;
|
||||
// the further different behaviour of DRAW is determined by variable
|
||||
// Draw_IsConsoleSubsystem which is set by _main_ only
|
||||
//=======================================================================
|
||||
|
||||
|
||||
extern Standard_Boolean Draw_IsConsoleSubsystem;
|
||||
|
||||
//=======================================================================
|
||||
//function : _main_
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer _main_ (int argc, char* argv[], char* envp[], const FDraw_InitAppli fDraw_InitAppli)
|
||||
{
|
||||
Draw_IsConsoleSubsystem = Standard_True;
|
||||
//return _WinMain_(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
|
||||
theDraw_InitAppli = fDraw_InitAppli;
|
||||
Standard_Boolean CONSOLE = Standard_True;
|
||||
//ParseCommandLine(GetCommandLine());
|
||||
|
||||
// MKV 01.02.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
|
||||
Tcl_FindExecutable(argv[0]);
|
||||
#endif
|
||||
|
||||
Draw_Appli(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : _WinMain_
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer _WinMain_ (HINSTANCE hInstance, HINSTANCE hPrevinstance, LPSTR lpCmdLine, int nCmdShow, const FDraw_InitAppli fDraw_InitAppli)
|
||||
{
|
||||
// theDraw_InitAppli = fDraw_InitAppli;
|
||||
// ParseCommandLine (lpCmdLine);
|
||||
// Draw_Appli(hInstance, hPrevinstance, lpCmdLine, nCmdShow, Draw_InitAppli); // for C30;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
//=======================================================================
|
||||
//function : _main_
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer _main_ (Standard_Integer argc, char* argv[], const FDraw_InitAppli fDraw_InitAppli)
|
||||
{
|
||||
// MKV 01.02.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
|
||||
Tcl_FindExecutable(argv[0]);
|
||||
#endif
|
||||
Draw_Appli(argc, argv, fDraw_InitAppli);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
58
src/Draw/Draw_Main.hxx
Executable file
58
src/Draw/Draw_Main.hxx
Executable file
@@ -0,0 +1,58 @@
|
||||
// File: Draw_Main.hxx
|
||||
// Created: Thu Dec 30 10:40:39 1999
|
||||
// Author: data exchange team
|
||||
// <det@burnax.nnov.matra-dtv.fr>
|
||||
|
||||
// Defines common framework for declaration of main/WinMain functions
|
||||
// for executbales on UNIX and WNT that extends DRAW Test Harness.
|
||||
|
||||
// In order to create executable in DRAW environment, in the executable
|
||||
// the following line should be added:
|
||||
// DRAW_MAIN
|
||||
|
||||
#ifndef Draw_Main_HeaderFile
|
||||
#define Draw_Main_HeaderFile
|
||||
|
||||
#ifndef _Standard_TypeDef_HeaderFile
|
||||
#include <Standard_TypeDef.hxx>
|
||||
#endif
|
||||
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Standard_PCharacter.hxx>
|
||||
|
||||
typedef void (*FDraw_InitAppli)(Draw_Interpretor&);
|
||||
|
||||
#ifndef WNT
|
||||
Standard_EXPORT Standard_Integer _main_ (Standard_Integer argc,
|
||||
Standard_PCharacter argv[],
|
||||
const FDraw_InitAppli Draw_InitAppli);
|
||||
#else
|
||||
#include <windows.h>
|
||||
Standard_EXPORT Standard_Integer _WinMain_ (HINSTANCE hInstance,
|
||||
HINSTANCE hPrevinstance,
|
||||
LPSTR lpCmdLine,
|
||||
Standard_Integer nCmdShow,
|
||||
const FDraw_InitAppli Draw_InitAppli);
|
||||
|
||||
Standard_EXPORT Standard_Integer _main_ (int argc,
|
||||
char* argv[],
|
||||
char* envp[],
|
||||
const FDraw_InitAppli Draw_InitAppli);
|
||||
#endif
|
||||
|
||||
// Declarations of macros DRAW_MAIN to be used in executables instead of explicit main/WinMain
|
||||
#ifndef WNT
|
||||
// main()
|
||||
#define DRAW_MAIN int main (Standard_Integer argc, char* argv[])\
|
||||
{return _main_ (argc, argv, Draw_InitAppli);}
|
||||
#else
|
||||
// WinMain() and main()
|
||||
#define DRAW_MAIN Standard_Integer PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevinstance, LPSTR lpCmdLine, Standard_Integer nCmdShow)\
|
||||
{return _WinMain_ (hInstance, hPrevinstance, lpCmdLine, nCmdShow, Draw_InitAppli);}\
|
||||
\
|
||||
int main (int argc, char* argv[], char* envp[])\
|
||||
{return _main_ (argc, argv, envp, Draw_InitAppli);}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
44
src/Draw/Draw_Marker2D.cdl
Executable file
44
src/Draw/Draw_Marker2D.cdl
Executable file
@@ -0,0 +1,44 @@
|
||||
-- File: Draw_Marker2D.cdl
|
||||
-- Created: Mon Apr 18 18:07:08 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class Marker2D from Draw inherits Drawable2D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Pnt2d from gp,
|
||||
Color from Draw,
|
||||
MarkerShape from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
Create(P : Pnt2d from gp; T : MarkerShape from Draw; C : Color from Draw;
|
||||
Size : Integer = 5) returns mutable Marker2D from Draw;
|
||||
|
||||
Create(P : Pnt2d from gp; T : MarkerShape from Draw; C : Color from Draw;
|
||||
RSize : Real) returns mutable Marker2D from Draw;
|
||||
|
||||
ChangePos(me : mutable) returns Pnt2d from gp;
|
||||
---C++: return &
|
||||
---Purpose: myPos field
|
||||
|
||||
DrawOn(me; dis : in out Display from Draw);
|
||||
|
||||
PickReject(me; X,Y,Prec : Real) returns Boolean
|
||||
---Purpose: Returs always false
|
||||
is redefined;
|
||||
|
||||
|
||||
fields
|
||||
myPos : Pnt2d from gp;
|
||||
myCol : Color from Draw;
|
||||
myTyp : MarkerShape from Draw;
|
||||
mySiz : Integer;
|
||||
myRSiz : Real;
|
||||
myIsRSiz : Boolean;
|
||||
|
||||
end Marker2D;
|
64
src/Draw/Draw_Marker2D.cxx
Executable file
64
src/Draw/Draw_Marker2D.cxx
Executable file
@@ -0,0 +1,64 @@
|
||||
// File: Draw_Marker2D.cxx
|
||||
// Created: Thu Apr 23 18:47:43 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
|
||||
|
||||
#include <Draw_Marker2D.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Marker2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Marker2D::Draw_Marker2D(const gp_Pnt2d& P, const Draw_MarkerShape T,
|
||||
const Draw_Color& C, const Standard_Integer S) :
|
||||
myPos(P), myCol(C), myTyp(T),mySiz(S)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Marker2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Marker2D::Draw_Marker2D(const gp_Pnt2d& P, const Draw_MarkerShape T,
|
||||
const Draw_Color& C, const Standard_Real RSize) :
|
||||
myPos(P), myCol(C), myTyp(T), myRSiz(RSize), myIsRSiz(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Marker2D::DrawOn(Draw_Display& D) const
|
||||
{
|
||||
D.SetColor(myCol);
|
||||
D.DrawMarker(myPos,myTyp,mySiz);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangePos
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt2d& Draw_Marker2D::ChangePos()
|
||||
{
|
||||
return myPos;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PickReject
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_Marker2D::PickReject(const Standard_Real,
|
||||
const Standard_Real,
|
||||
const Standard_Real) const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
44
src/Draw/Draw_Marker3D.cdl
Executable file
44
src/Draw/Draw_Marker3D.cdl
Executable file
@@ -0,0 +1,44 @@
|
||||
-- File: Marker3D.cdl
|
||||
-- Created: Thu Apr 23 17:01:50 1992
|
||||
-- Author: Modelistation
|
||||
-- <model@sdsun1>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Marker3D from Draw inherits Drawable3D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Pnt from gp,
|
||||
Color from Draw,
|
||||
MarkerShape from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
Create(P : Pnt from gp; T : MarkerShape from Draw; C : Color from Draw;
|
||||
ISize : Integer = 5) returns mutable Marker3D from Draw;
|
||||
|
||||
Create(P : Pnt from gp; T : MarkerShape from Draw; C : Color from Draw;
|
||||
RSize : Real) returns mutable Marker3D from Draw;
|
||||
|
||||
ChangePos(me : mutable) returns Pnt from gp;
|
||||
---C++: return &
|
||||
---Purpose: myPos field
|
||||
|
||||
DrawOn(me; dis : in out Display from Draw);
|
||||
|
||||
PickReject(me; X,Y,Prec : Real) returns Boolean
|
||||
---Purpose: Returs always false
|
||||
is redefined;
|
||||
|
||||
fields
|
||||
|
||||
myPos : Pnt from gp;
|
||||
myCol : Color from Draw;
|
||||
myTyp : MarkerShape from Draw;
|
||||
mySiz : Integer;
|
||||
myRSiz : Real;
|
||||
myIsRSiz : Boolean;
|
||||
|
||||
end Marker3D;
|
65
src/Draw/Draw_Marker3D.cxx
Executable file
65
src/Draw/Draw_Marker3D.cxx
Executable file
@@ -0,0 +1,65 @@
|
||||
// File: Draw_Marker3D.cxx
|
||||
// Created: Thu Apr 23 18:47:43 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
|
||||
|
||||
#include <Draw_Marker3D.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Marker3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Marker3D::Draw_Marker3D(const gp_Pnt& P, const Draw_MarkerShape T,
|
||||
const Draw_Color& C, const Standard_Integer S) :
|
||||
myPos(P), myCol(C), myTyp(T), mySiz(S), myIsRSiz(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Marker3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Marker3D::Draw_Marker3D(const gp_Pnt& P, const Draw_MarkerShape T,
|
||||
const Draw_Color& C, const Standard_Real RSize) :
|
||||
myPos(P), myCol(C), myTyp(T), myRSiz(RSize), myIsRSiz(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Marker3D::DrawOn(Draw_Display& D) const
|
||||
{
|
||||
D.SetColor(myCol);
|
||||
if(myIsRSiz) D.DrawMarker(myPos,myTyp,myRSiz);
|
||||
else D.DrawMarker(myPos,myTyp,mySiz);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangePos
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt& Draw_Marker3D::ChangePos()
|
||||
{
|
||||
return myPos;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PickReject
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_Marker3D::PickReject(const Standard_Real,
|
||||
const Standard_Real,
|
||||
const Standard_Real) const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
46
src/Draw/Draw_Number.cdl
Executable file
46
src/Draw/Draw_Number.cdl
Executable file
@@ -0,0 +1,46 @@
|
||||
-- File: Draw_Number.cdl
|
||||
-- Created: Mon Aug 16 09:37:03 1993
|
||||
-- Author: Bruno DUMORTIER
|
||||
-- <dub@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class Number from Draw inherits Drawable3D from Draw
|
||||
|
||||
---Purpose: To store nummbers in variables.
|
||||
|
||||
uses
|
||||
Display from Draw,
|
||||
OStream,
|
||||
Interpretor from Draw
|
||||
|
||||
is
|
||||
Create (V : Real) returns mutable Number from Draw;
|
||||
|
||||
Value(me) returns Real
|
||||
is static;
|
||||
|
||||
Value(me : mutable; V : Real)
|
||||
is static;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
---Purpose: Does nothhing,
|
||||
|
||||
Copy(me) returns mutable Drawable3D from Draw
|
||||
---Purpose: For variable copy.
|
||||
is redefined;
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
---Purpose: For variable dump.
|
||||
is redefined;
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw) is redefined;
|
||||
---Purpose: For variable whatis command. Set as a result the
|
||||
-- type of the variable.
|
||||
|
||||
fields
|
||||
|
||||
myValue : Real;
|
||||
|
||||
end Number;
|
83
src/Draw/Draw_Number.cxx
Executable file
83
src/Draw/Draw_Number.cxx
Executable file
@@ -0,0 +1,83 @@
|
||||
// File: Draw_Number.cxx
|
||||
// Created: Mon Aug 16 09:49:50 1993
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@phylox>
|
||||
|
||||
|
||||
#include <Draw_Number.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Number
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Number::Draw_Number(const Standard_Real V) :
|
||||
myValue(V)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real Draw_Number::Value()const
|
||||
{
|
||||
return myValue;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Number::Value(const Standard_Real V)
|
||||
{
|
||||
myValue = V;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Number::DrawOn(Draw_Display&)const
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) Draw_Number::Copy()const
|
||||
{
|
||||
Handle(Draw_Number) D = new Draw_Number(myValue);
|
||||
return D;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Number::Dump(Standard_OStream& S)const
|
||||
{
|
||||
S << myValue;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Number::Whatis(Draw_Interpretor& S)const
|
||||
{
|
||||
S << "numeric";
|
||||
}
|
18
src/Draw/Draw_PInterp.hxx
Executable file
18
src/Draw/Draw_PInterp.hxx
Executable file
@@ -0,0 +1,18 @@
|
||||
// File: Draw_PInterp.hxx
|
||||
// Created: Thu Feb 23 17:31:31 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
|
||||
#ifndef _Draw_PInterp_HeaderFile
|
||||
#define _Draw_PInterp_HeaderFile
|
||||
|
||||
struct Tcl_Interp;
|
||||
|
||||
typedef Tcl_Interp *Draw_PInterp;
|
||||
|
||||
|
||||
#include <Standard_Type.hxx>
|
||||
inline const Handle(Standard_Type)& STANDARD_TYPE(Draw_PInterp) {return *((Handle(Standard_Type)*)0);}
|
||||
|
||||
#endif
|
259
src/Draw/Draw_PloadCommands.cxx
Executable file
259
src/Draw/Draw_PloadCommands.cxx
Executable file
@@ -0,0 +1,259 @@
|
||||
// File: Draw_PloadCommands.cxx
|
||||
// Created: Thu Oct 9 12:27:26 2003
|
||||
// Author: Mikhail KUZMITCHEV
|
||||
// <mkv@russox>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <Resource_Manager.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_MapOfAsciiString.hxx>
|
||||
#include <Draw.hxx>
|
||||
|
||||
static Handle(Resource_Manager) myResources;
|
||||
|
||||
//=======================================================================
|
||||
//function : FindPluginFile
|
||||
//purpose : Searches for the existence of the plugin file according to its name thePluginName:
|
||||
// - if thePluginName is empty then it defaults to DrawPlugin
|
||||
// - the search directory is defined according to the variable
|
||||
// CSF_<filename>Defaults (if it is omitted then it defaults to
|
||||
// $CASROOT/src/DrawResources)
|
||||
// - finally existence of the file is verified in the search directory
|
||||
// - if the file exists but corresponding variable (CSF_...) has not been
|
||||
// explicitly set, it is forced to (for further reuse by Resource_Manager)
|
||||
// Returns True if the file exists, otherwise - False.
|
||||
//=======================================================================
|
||||
|
||||
#define FAILSTR "Failed to load plugin: "
|
||||
|
||||
//static Standard_Boolean FindPluginFile (TCollection_AsciiString& thePluginName)
|
||||
static Standard_Boolean FindPluginFile (TCollection_AsciiString& thePluginName, TCollection_AsciiString& aPluginDir)
|
||||
{
|
||||
Standard_Boolean aResult = Standard_True;
|
||||
|
||||
// check if the file name has been specified and use default value if not
|
||||
if (thePluginName.IsEmpty()) {
|
||||
thePluginName += "DrawPlugin";
|
||||
#ifdef DEB
|
||||
cout << "Plugin file name has not been specified. Defaults to " << thePluginName.ToCString() << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//TCollection_AsciiString aPluginDir; // the search directory
|
||||
Standard_Boolean aDirFound = Standard_True, aToSetCSFVariable = Standard_False;
|
||||
|
||||
// the order of search : by CSF_<PluginFileName>Defaults and then by CASROOT
|
||||
TCollection_AsciiString aCSFVariable = TCollection_AsciiString ("CSF_") + thePluginName + "Defaults";
|
||||
aPluginDir = getenv (aCSFVariable.ToCString());
|
||||
|
||||
if (aPluginDir.IsEmpty()) {
|
||||
// now try by CASROOT
|
||||
aPluginDir = getenv("CASROOT");
|
||||
|
||||
if ( !aPluginDir.IsEmpty() ) {
|
||||
aPluginDir +="/src/DrawResources" ;
|
||||
aToSetCSFVariable = Standard_True; //CSF variable to be set later
|
||||
} else {
|
||||
aResult = aDirFound = Standard_False;
|
||||
cout << FAILSTR "Neither " << aCSFVariable.ToCString() << ", nor CASROOT variables have been set" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (aDirFound) {
|
||||
// search directory name has been constructed, now check whether it and the file exist
|
||||
|
||||
TCollection_AsciiString aPluginFileName = aPluginDir + "/" + thePluginName;
|
||||
OSD_File PluginFile ( aPluginFileName );
|
||||
if ( PluginFile.Exists() ) {
|
||||
if (aToSetCSFVariable) {
|
||||
OSD_Environment aCSFVarEnv ( aCSFVariable, aPluginDir );
|
||||
aCSFVarEnv.Build();
|
||||
#ifdef DEB
|
||||
cout << "Variable " << aCSFVariable.ToCString() << " has not been explicitly defined. Set to " << aPluginDir.ToCString() << endl;
|
||||
#endif
|
||||
if ( aCSFVarEnv.Failed() ) {
|
||||
aResult = Standard_False;
|
||||
cout << FAILSTR "Failed to initialize " << aCSFVariable.ToCString() << " with " << aPluginDir.ToCString() << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
aResult = Standard_False;
|
||||
cout << FAILSTR "File " << aPluginFileName.ToCString() << " not found" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Parse
|
||||
//purpose : Parse the input keys to atomic keys (<key> --> <akey>[<akey> ..])
|
||||
//=======================================================================
|
||||
|
||||
static void Parse (Draw_MapOfAsciiString& theMap)
|
||||
{
|
||||
Draw_MapOfAsciiString aMap, aMap2;
|
||||
Standard_Integer j, k;
|
||||
Standard_Integer aMapExtent, aMap2Extent;
|
||||
aMapExtent = theMap.Extent();
|
||||
for(j = 1; j <= aMapExtent; j++) {
|
||||
if (!myResources.IsNull()) {
|
||||
const TCollection_AsciiString& aKey = theMap.FindKey(j);
|
||||
TCollection_AsciiString aResource = aKey;
|
||||
if(myResources->Find(aResource.ToCString())) {
|
||||
#ifdef DEB
|
||||
cout << "Parse Value ==> " << myResources->Value(aResource.ToCString()) << endl;
|
||||
#endif
|
||||
TCollection_AsciiString aValue(myResources->Value(aResource.ToCString()));
|
||||
// parse aValue string
|
||||
Standard_Integer i=1;
|
||||
for(;;) {
|
||||
TCollection_AsciiString aCurKey = aValue.Token(" \t,", i++);
|
||||
#ifdef DEB
|
||||
cout << "Parse aCurKey = " << aCurKey.ToCString() << endl;
|
||||
#endif
|
||||
if(aCurKey.IsEmpty()) break;
|
||||
if(!myResources->Find(aCurKey.ToCString())) {
|
||||
// It is toolkit
|
||||
aMap.Add(aResource);
|
||||
}
|
||||
else
|
||||
aMap2.Add(aCurKey);
|
||||
}
|
||||
} else
|
||||
cout <<"Pload : Resource = " << aResource << " is not found" << endl;
|
||||
if(!aMap2.IsEmpty())
|
||||
Parse(aMap2);
|
||||
//
|
||||
aMap2Extent = aMap2.Extent();
|
||||
for(k = 1; k <= aMap2Extent; k++) {
|
||||
aMap.Add(aMap2.FindKey(k));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
theMap.Assign(aMap);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Pload
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer Pload (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** argv)
|
||||
{
|
||||
char adef[] = "-";
|
||||
TCollection_AsciiString aPluginFileName("");
|
||||
TCollection_AsciiString aPluginDir(""), aPluginDir2("");
|
||||
Standard_Integer aStart = 0;
|
||||
Standard_Integer aFinish = n - 1;
|
||||
|
||||
if (n == 1) {
|
||||
// Load DEFAULT key
|
||||
aStart = 0;
|
||||
} else {
|
||||
if(argv[1][0] == adef[0]) {
|
||||
aPluginFileName = argv[1];
|
||||
aPluginFileName.Remove(1,1);
|
||||
if (n == 2) {
|
||||
// Load DEFAULT key from aPluginFileName file
|
||||
aStart = 0;
|
||||
aFinish = n - 2;
|
||||
} else {
|
||||
aStart = 2;
|
||||
}
|
||||
} else {
|
||||
aStart = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//if ( !FindPluginFile (aPluginFileName) ) {
|
||||
if ( !FindPluginFile (aPluginFileName, aPluginDir) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Draw_MapOfAsciiString aMap;
|
||||
TCollection_AsciiString aDEFAULT("DEFAULT");
|
||||
//for(Standard_Integer i = aStart; i < n; i++)
|
||||
for(Standard_Integer i = aStart; i <= aFinish; i++)
|
||||
if (i == 0) {
|
||||
// Load DEFAULT key
|
||||
aMap.Add(aDEFAULT);
|
||||
} else {
|
||||
TCollection_AsciiString aTK(argv[i]);
|
||||
aMap.Add(aTK);
|
||||
}
|
||||
|
||||
//myResources = new Resource_Manager(aPluginFileName.ToCString());
|
||||
myResources = new Resource_Manager(aPluginFileName.ToCString(), aPluginDir, aPluginDir2, Standard_False);
|
||||
|
||||
Parse(aMap);
|
||||
Standard_Integer j;
|
||||
Standard_Integer aMapExtent;
|
||||
aMapExtent = aMap.Extent();
|
||||
for(j = 1; j <= aMapExtent; j++) {
|
||||
const TCollection_AsciiString& aKey = aMap.FindKey(j);
|
||||
TCollection_AsciiString aResource = aKey;
|
||||
#ifdef DEB
|
||||
cout << "aResource = " << aResource << endl;
|
||||
#endif
|
||||
if(myResources->Find(aResource.ToCString())) {
|
||||
const TCollection_AsciiString& aValue = myResources->Value(aResource.ToCString());
|
||||
#ifdef DEB
|
||||
cout << "Value ==> " << aValue << endl;
|
||||
#endif
|
||||
|
||||
//Draw::Load(di, aKey, aPluginFileName);
|
||||
Draw::Load(di, aKey, aPluginFileName, aPluginDir, aPluginDir2, Standard_False);
|
||||
|
||||
// Load TclScript
|
||||
TCollection_AsciiString aCSFVariable ("CSF_DrawPluginTclDir");
|
||||
TCollection_AsciiString aTclScriptDir;
|
||||
aTclScriptDir = getenv (aCSFVariable.ToCString());
|
||||
TCollection_AsciiString aTclScriptFileName;
|
||||
TCollection_AsciiString aTclScriptFileNameDefaults;
|
||||
aTclScriptFileName = aTclScriptDir + "/" + aValue + ".tcl";
|
||||
aTclScriptFileNameDefaults = aPluginDir + "/" + aValue + ".tcl";
|
||||
OSD_File aTclScriptFile ( aTclScriptFileName );
|
||||
OSD_File aTclScriptFileDefaults ( aTclScriptFileNameDefaults );
|
||||
if (!aTclScriptDir.IsEmpty() && aTclScriptFile.Exists()) {
|
||||
#ifdef DEB
|
||||
cout << "Load " << aTclScriptFileName << " TclScript" << endl;
|
||||
#endif
|
||||
di.EvalFile( aTclScriptFileName.ToCString() );
|
||||
} else if (!aPluginDir.IsEmpty() && aTclScriptFileDefaults.Exists()) {
|
||||
#ifdef DEB
|
||||
cout << "Load " << aTclScriptFileNameDefaults << " TclScript" << endl;
|
||||
#endif
|
||||
di.EvalFile( aTclScriptFileNameDefaults.ToCString() );
|
||||
}
|
||||
|
||||
} else
|
||||
cout <<"Pload : Resource = " << aResource << " is not found" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PloadCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw::PloadCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean Done = Standard_False;
|
||||
if (Done) return;
|
||||
Done = Standard_True;
|
||||
|
||||
const char* g = "Draw Plugin";
|
||||
|
||||
theCommands.Add("pload" , "pload [-PluginFilename] [[Key1] [Key2] ...]: Loads Draw plugins " ,
|
||||
__FILE__, Pload, g);
|
||||
}
|
15
src/Draw/Draw_PluginMacro.hxx
Executable file
15
src/Draw/Draw_PluginMacro.hxx
Executable file
@@ -0,0 +1,15 @@
|
||||
// File: Draw_PluginMacro.hxx
|
||||
// Created: Thu Aug 14 14:15:00 2003
|
||||
// Author: Sergey ZARITCHNY <szy@nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#ifndef _Draw_PluginMacro_HeaderFile
|
||||
#define _Draw_PluginMacro_HeaderFile
|
||||
|
||||
#define DPLUGIN(name) \
|
||||
extern "C" {Standard_EXPORT void PLUGINFACTORY(Draw_Interpretor&);} \
|
||||
void PLUGINFACTORY(Draw_Interpretor& theDI) { \
|
||||
name::Factory(theDI);} \
|
||||
\
|
||||
|
||||
#endif
|
50
src/Draw/Draw_Printer.cdl
Executable file
50
src/Draw/Draw_Printer.cdl
Executable file
@@ -0,0 +1,50 @@
|
||||
-- File: Draw_Printer.cdl
|
||||
-- Created: Tue Jul 31 19:12:06 2007
|
||||
-- Author: OCC Team
|
||||
---Copyright: Open CASCADE S.A. 2007
|
||||
|
||||
|
||||
class Printer from Draw inherits Printer from Message
|
||||
|
||||
---Purpose: Implementation of Printer class with output directed to Draw_Interpretor
|
||||
|
||||
uses
|
||||
|
||||
Interpretor from Draw,
|
||||
Gravity from Message,
|
||||
AsciiString from TCollection,
|
||||
ExtendedString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Create (theTcl : Interpretor from Draw);
|
||||
---Purpose: Creates a printer connected to the interpretor.
|
||||
|
||||
Send (me; theString: ExtendedString from TCollection;
|
||||
theGravity: Gravity from Message;
|
||||
putEndl: Boolean) is redefined;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter putEndl specified whether end-of-line
|
||||
-- should be added to the end of the message.
|
||||
-- This method must be redefined in descentant.
|
||||
|
||||
Send (me; theString: CString; theGravity: Gravity from Message;
|
||||
putEndl: Boolean) is redefined;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter putEndl specified whether end-of-line
|
||||
-- should be added to the end of the message.
|
||||
-- Default implementation calls first method Send().
|
||||
|
||||
Send (me; theString: AsciiString from TCollection;
|
||||
theGravity: Gravity from Message;
|
||||
putEndl: Boolean) is redefined;
|
||||
---Purpose: Send a string message with specified trace level.
|
||||
-- The parameter putEndl specified whether end-of-line
|
||||
-- should be added to the end of the message.
|
||||
-- Default implementation calls first method Send().
|
||||
|
||||
fields
|
||||
|
||||
myTcl : Address from Standard; -- pointer to interpretor
|
||||
|
||||
end Printer;
|
67
src/Draw/Draw_Printer.cxx
Executable file
67
src/Draw/Draw_Printer.cxx
Executable file
@@ -0,0 +1,67 @@
|
||||
// File: Draw_Printer.cxx
|
||||
// Created: Tue Jul 31 19:26:55 2007
|
||||
// Author: OCC Team
|
||||
// Copyright: Open CASCADE S.A. 2007
|
||||
|
||||
#include <Draw_Printer.ixx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Printer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Printer::Draw_Printer (const Draw_Interpretor& theTcl)
|
||||
: myTcl((Standard_Address)&theTcl)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Send
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Printer::Send (const TCollection_ExtendedString& theString,
|
||||
const Message_Gravity /*theGravity*/,
|
||||
const Standard_Boolean putEndl) const
|
||||
{
|
||||
if ( ! myTcl )
|
||||
return;
|
||||
(*(Draw_Interpretor*)myTcl) << theString;
|
||||
if ( putEndl )
|
||||
(*(Draw_Interpretor*)myTcl) << '\n';
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Send
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Printer::Send (const Standard_CString theString,
|
||||
const Message_Gravity /*theGravity*/,
|
||||
const Standard_Boolean putEndl) const
|
||||
{
|
||||
if ( ! myTcl )
|
||||
return;
|
||||
(*(Draw_Interpretor*)myTcl) << theString;
|
||||
if ( putEndl )
|
||||
(*(Draw_Interpretor*)myTcl) << '\n';
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Send
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Printer::Send (const TCollection_AsciiString& theString,
|
||||
const Message_Gravity /*theGravity*/,
|
||||
const Standard_Boolean putEndl) const
|
||||
{
|
||||
if ( ! myTcl )
|
||||
return;
|
||||
(*(Draw_Interpretor*)myTcl) << theString;
|
||||
if ( putEndl )
|
||||
(*(Draw_Interpretor*)myTcl) << '\n';
|
||||
}
|
79
src/Draw/Draw_ProgressIndicator.cdl
Executable file
79
src/Draw/Draw_ProgressIndicator.cdl
Executable file
@@ -0,0 +1,79 @@
|
||||
-- File: Draw_ProgressIndicator.cdl
|
||||
-- Created: Wed Jun 25 16:31:08 2008
|
||||
-- Author: data exchange team
|
||||
-- <det@friendox>
|
||||
---Copyright: Matra Datavision 2008
|
||||
|
||||
class ProgressIndicator from Draw inherits ProgressIndicator from Message
|
||||
|
||||
---Purpose: Implements ProgressIndicator (interface provided by Message)
|
||||
-- for DRAW, with possibility to output to TCL window
|
||||
-- and/or trace file
|
||||
|
||||
uses
|
||||
Interpretor from Draw
|
||||
|
||||
is
|
||||
Create (di: Interpretor from Draw; updateTime: Integer = 0)
|
||||
returns ProgressIndicator from Draw;
|
||||
---Purpose: Creates a progress indicator and remembers pointer to
|
||||
-- Draw_Interpretor
|
||||
-- The updateTime, if given, defines time interval between
|
||||
-- updates of the indicator (in seconds)
|
||||
|
||||
Destroy (me: mutable);
|
||||
---C++: alias ~
|
||||
---Purpose: Destructor; calls Reset()
|
||||
|
||||
SetTextMode(me : mutable; theTextMode : Boolean);
|
||||
---Purpose: Sets text output mode (on/off)
|
||||
|
||||
GetTextMode(me) returns Boolean;
|
||||
---Purpose: Gets text output mode (on/off)
|
||||
|
||||
SetGraphMode(me : mutable; theGraphMode : Boolean);
|
||||
---Purpose: Sets graphical output mode (on/off)
|
||||
|
||||
GetGraphMode(me) returns Boolean;
|
||||
---Purpose: Gets graphical output mode (on/off)
|
||||
|
||||
---Scope: Redefined methods
|
||||
|
||||
Reset (me: mutable) is redefined;
|
||||
---Purpose: Clears/erases opened TCL windows if any
|
||||
-- and sets myBreak to False
|
||||
|
||||
Show (me: mutable; force: Boolean = Standard_True)
|
||||
returns Boolean is redefined;
|
||||
---Purpose: Defines method Show of Progress Indicator
|
||||
|
||||
UserBreak (me: mutable) returns Boolean is redefined;
|
||||
---Purpose: Redefines method UserBreak of Progress Indicator
|
||||
|
||||
---Scope: Class methods maintaining static data
|
||||
|
||||
DefaultTextMode (myclass) returns Boolean;
|
||||
---C++: return &
|
||||
DefaultGraphMode (myclass) returns Boolean;
|
||||
---C++: return &
|
||||
---Purpose: Get/Set default values for output modes
|
||||
|
||||
StopIndicator (myclass) returns Integer;
|
||||
---C++: return &
|
||||
---Purpose: Internal method for implementation of UserBreak mechanism
|
||||
|
||||
fields
|
||||
|
||||
myTextMode : Boolean; -- text output mode (on/off)
|
||||
myGraphMode : Boolean; -- graphical output mode (on/off)
|
||||
|
||||
myDraw: Address; -- pointer to Draw_Interpretor (!!!)
|
||||
myShown: Boolean; -- whether graphical window is shown
|
||||
myBreak: Boolean; -- whether user break was signaled
|
||||
|
||||
myUpdateTime: Integer; -- Time interval for update (in sec)
|
||||
myLastUpdate: Size; -- Start time (first call to Show())
|
||||
myStartTime: Size; -- Start time (first call to Show())
|
||||
|
||||
end ProgressIndicator;
|
||||
|
217
src/Draw/Draw_ProgressIndicator.cxx
Executable file
217
src/Draw/Draw_ProgressIndicator.cxx
Executable file
@@ -0,0 +1,217 @@
|
||||
#include <Draw_ProgressIndicator.ixx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Message_ProgressScale.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Message.hxx>
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_ProgressIndicator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_ProgressIndicator::Draw_ProgressIndicator(const Draw_Interpretor &di,
|
||||
const Standard_Integer updateTime) :
|
||||
myTextMode ( DefaultTextMode() ),
|
||||
myGraphMode ( DefaultGraphMode() ),
|
||||
myDraw ( (Standard_Address)&di ),
|
||||
myShown ( Standard_False ),
|
||||
myBreak ( Standard_False ),
|
||||
myUpdateTime ( updateTime ),
|
||||
myLastUpdate ( 0 ), myStartTime ( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Destroy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_ProgressIndicator::Destroy()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Reset
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_ProgressIndicator::Reset()
|
||||
{
|
||||
Message_ProgressIndicator::Reset();
|
||||
if ( myShown ) {
|
||||
((Draw_Interpretor*)myDraw)->Eval ( "destroy .xprogress" );
|
||||
myShown = Standard_False;
|
||||
}
|
||||
myBreak = Standard_False;
|
||||
myLastUpdate = myStartTime = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Show
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_ProgressIndicator::Show(const Standard_Boolean force)
|
||||
{
|
||||
if ( ! myGraphMode && ! myTextMode ) return Standard_False;
|
||||
time_t aTimeT;
|
||||
time ( &aTimeT );
|
||||
Standard_Size aTime = (Standard_Size)aTimeT;
|
||||
if ( ! myStartTime ) myStartTime = aTime;
|
||||
if ( ! force && myUpdateTime >0 && aTime < myLastUpdate + myUpdateTime && GetPosition() < 1. )
|
||||
return Standard_False; // return if update interval has not elapsed
|
||||
myLastUpdate = aTime;
|
||||
|
||||
// Prepare textual progress info
|
||||
char text[2048];
|
||||
Standard_Integer n = 0;
|
||||
n += sprintf ( &text[n], "Progress: %.0f%%", 100. * GetPosition() );
|
||||
for ( Standard_Integer i=GetNbScopes(); i >=1; i-- ) {
|
||||
const Message_ProgressScale &scale = GetScope ( i );
|
||||
if ( scale.GetName().IsNull() ) continue; // skip unnamed scopes
|
||||
// if scope has subscopes, print end of subscope as its current position
|
||||
Standard_Real locPos = ( i >1 ? GetScope ( i-1 ).GetLast() : GetPosition() );
|
||||
// print progress info differently for finite and infinite scopes
|
||||
if ( scale.GetInfinite() )
|
||||
n += sprintf ( &text[n], " %s: %.0f", scale.GetName()->ToCString(),
|
||||
scale.BaseToLocal ( locPos ) );
|
||||
else
|
||||
n += sprintf ( &text[n], " %s: %.0f / %.0f", scale.GetName()->ToCString(),
|
||||
scale.BaseToLocal ( locPos ), scale.GetMax() );
|
||||
}
|
||||
|
||||
// In addition, write elapsed/estimated/remaining time
|
||||
if ( GetPosition() > 0.01 ) {
|
||||
n += sprintf ( &text[n], "\nElapsed/estimated time: %ld/%.0f sec",
|
||||
(long)(aTime - myStartTime), ( aTime - myStartTime ) / GetPosition() );
|
||||
}
|
||||
|
||||
// Show graphic progress bar
|
||||
if ( myGraphMode ) {
|
||||
if ( ! myShown ) {
|
||||
char command[1024];
|
||||
sprintf ( command, "toplevel .xprogress -height 100 -width 410;"
|
||||
"wm title .xprogress \"Progress\";"
|
||||
"set xprogress_stop 0;"
|
||||
"canvas .xprogress.bar -width 402 -height 22;"
|
||||
".xprogress.bar create rectangle 2 2 2 21 -fill blue -tags progress;"
|
||||
".xprogress.bar create rectangle 2 2 2 21 -outline black -tags progress_next;"
|
||||
"message .xprogress.text -width 400 -text \"Progress 0%%\";"
|
||||
"button .xprogress.stop -text \"Break\" -relief groove -width 9 -command {XProgress -stop %ld};"
|
||||
"pack .xprogress.bar .xprogress.text .xprogress.stop -side top;",
|
||||
(long)(void*)this );
|
||||
((Draw_Interpretor*)myDraw)->Eval ( command );
|
||||
myShown = Standard_True;
|
||||
}
|
||||
char command[1024];
|
||||
Standard_Integer num = 0;
|
||||
num += sprintf ( &command[num], ".xprogress.bar coords progress 2 2 %.0f 21;",
|
||||
1+400*GetPosition() );
|
||||
num += sprintf ( &command[num], ".xprogress.bar coords progress_next 2 2 %.0f 21;",
|
||||
1+400*GetScope(1).GetLast() );
|
||||
num += sprintf ( &command[num], ".xprogress.text configure -text \"%s\";", text );
|
||||
num += sprintf ( &command[num], "update" );
|
||||
((Draw_Interpretor*)myDraw)->Eval ( command );
|
||||
}
|
||||
|
||||
// Print textual progress info
|
||||
if ( myTextMode )
|
||||
Message::DefaultMessenger()->Send (text, Message_Info);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UserBreak
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_ProgressIndicator::UserBreak()
|
||||
{
|
||||
if ( StopIndicator() == (long)(void*)this ) {
|
||||
// cout << "Progress Indicator - User Break: " << StopIndicator() << ", " << (void*)this << endl;
|
||||
myBreak = Standard_True;
|
||||
((Draw_Interpretor*)myDraw)->Eval ( "XProgress -stop 0" );
|
||||
}
|
||||
return myBreak;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTextMode
|
||||
//purpose : Sets text output mode (on/off)
|
||||
//=======================================================================
|
||||
|
||||
void Draw_ProgressIndicator::SetTextMode(const Standard_Boolean theTextMode)
|
||||
{
|
||||
myTextMode = theTextMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetTextMode
|
||||
//purpose : Returns text output mode (on/off)
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_ProgressIndicator::GetTextMode() const
|
||||
{
|
||||
return myTextMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetGraphMode
|
||||
//purpose : Sets graphical output mode (on/off)
|
||||
//=======================================================================
|
||||
|
||||
void Draw_ProgressIndicator::SetGraphMode(const Standard_Boolean theGraphMode)
|
||||
{
|
||||
myGraphMode = theGraphMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetGraphMode
|
||||
//purpose : Returns graphical output mode (on/off)
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Draw_ProgressIndicator::GetGraphMode() const
|
||||
{
|
||||
return myGraphMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DefaultTextMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean &Draw_ProgressIndicator::DefaultTextMode ()
|
||||
{
|
||||
static Standard_Boolean defTextMode = Standard_False;
|
||||
return defTextMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DefaultGraphMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean &Draw_ProgressIndicator::DefaultGraphMode ()
|
||||
{
|
||||
static Standard_Boolean defGraphMode = Standard_False;
|
||||
return defGraphMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : StopIndicator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer &Draw_ProgressIndicator::StopIndicator ()
|
||||
{
|
||||
static Standard_Integer stopIndicator = 0;
|
||||
return stopIndicator;
|
||||
}
|
||||
|
||||
|
60
src/Draw/Draw_Replace.tcl
Executable file
60
src/Draw/Draw_Replace.tcl
Executable file
@@ -0,0 +1,60 @@
|
||||
|
||||
|
||||
proc Draw_Replace:AdmFileType {} {
|
||||
return "dbadmfile";
|
||||
}
|
||||
|
||||
proc Draw_Replace:OutputDirTypeName {} {
|
||||
return "dbtmpfile";
|
||||
}
|
||||
|
||||
|
||||
proc Draw_Replace:HandleInputFile { ID } {
|
||||
|
||||
scan $ID "%\[^:\]:%\[^:\]:%\[^:\]" unit type name
|
||||
|
||||
switch $name {
|
||||
Draw_Interpretor.hxx {return 1;}
|
||||
default {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc Draw_Replace:Execute { unit args } {
|
||||
|
||||
global tcl_interactive
|
||||
|
||||
set tcl_interactive 1
|
||||
package require Wokutils
|
||||
|
||||
msgprint -i -c "Draw_Replace:Execute" "Copying of Draw includes"
|
||||
|
||||
if { [wokparam -e %Station $unit] != "wnt" } {
|
||||
set copycmd "cp -p "
|
||||
set replstr "/"
|
||||
} {
|
||||
set copycmd "cmd /c copy"
|
||||
set replstr "\\\\\\\\"
|
||||
}
|
||||
|
||||
foreach file $args {
|
||||
scan $file "%\[^:\]:%\[^:\]:%\[^:\]" Unit type name
|
||||
|
||||
regsub ".hxx" $name "_proto.hxx" sourcename
|
||||
|
||||
set source [woklocate -p Draw:source:$sourcename [wokinfo -N $unit]]
|
||||
set vistarget [woklocate -p Draw:pubinclude:$name [wokinfo -N $unit]]
|
||||
set target [wokinfo -p pubinclude:$name $unit]
|
||||
|
||||
regsub -all "/" " $source $target" $replstr TheArgs
|
||||
|
||||
msgprint -i -c "Draw_Replace:Execute" "Copy $source to $target"
|
||||
if { [file exist $target] && [wokparam -e %Station] != "wnt" } {
|
||||
eval exec "chmod u+w $target"
|
||||
}
|
||||
eval exec "$copycmd $TheArgs"
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
52
src/Draw/Draw_Segment2D.cdl
Executable file
52
src/Draw/Draw_Segment2D.cdl
Executable file
@@ -0,0 +1,52 @@
|
||||
-- File: Draw_Segment2D.cdl
|
||||
-- Created: Mon Apr 18 18:06:10 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
|
||||
|
||||
class Segment2D from Draw inherits Drawable2D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Pnt2d from gp,
|
||||
Color from Draw,
|
||||
Display from Draw,
|
||||
Interpretor from Draw
|
||||
|
||||
is
|
||||
|
||||
Create(p1,p2 : Pnt2d; col : Color)
|
||||
returns mutable Segment2D;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
First(me) returns Pnt2d from gp
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
First(me : mutable; P : Pnt2d from gp)
|
||||
is static;
|
||||
|
||||
Last(me) returns Pnt2d from gp
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
Last(me : mutable; P : Pnt2d from gp)
|
||||
is static;
|
||||
|
||||
Dump(me; S : in out OStream)
|
||||
is redefined;
|
||||
|
||||
Whatis(me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
|
||||
fields
|
||||
|
||||
myFirst : Pnt2d;
|
||||
myLast : Pnt2d;
|
||||
myColor : Color;
|
||||
|
||||
end Segment2D;
|
98
src/Draw/Draw_Segment2D.cxx
Executable file
98
src/Draw/Draw_Segment2D.cxx
Executable file
@@ -0,0 +1,98 @@
|
||||
// Copyright: Matra-Datavision 1991
|
||||
// File: Draw_Segment2D.cxx
|
||||
// Created: Thu Apr 25 11:25:22 1991
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <Draw_Segment2D.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Segment2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Segment2D::Draw_Segment2D(const gp_Pnt2d& p1,
|
||||
const gp_Pnt2d& p2,
|
||||
const Draw_Color& col) :
|
||||
myFirst(p1),
|
||||
myLast(p2),
|
||||
myColor(col)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Segment2D::DrawOn(Draw_Display& dis)const
|
||||
{
|
||||
dis.SetColor(myColor);
|
||||
dis.Draw(myFirst,myLast);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : First
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const gp_Pnt2d& Draw_Segment2D::First() const
|
||||
{
|
||||
return myFirst;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : First
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Segment2D::First(const gp_Pnt2d& P)
|
||||
{
|
||||
myFirst = P;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Last
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const gp_Pnt2d& Draw_Segment2D::Last() const
|
||||
{
|
||||
return myLast;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Last
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Segment2D::Last(const gp_Pnt2d& P)
|
||||
{
|
||||
myLast = P;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Segment2D::Whatis(Draw_Interpretor& S) const
|
||||
{
|
||||
S << "segment 2d";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Segment2D::Dump(Standard_OStream& S) const
|
||||
{
|
||||
S << setw(17) << myFirst.X() << " " << setw(17) << myFirst.Y() << " - "
|
||||
<< setw(17) << myLast.X() << " " << setw(17) << myLast.Y() << "\n";
|
||||
}
|
43
src/Draw/Draw_Segment3D.cdl
Executable file
43
src/Draw/Draw_Segment3D.cdl
Executable file
@@ -0,0 +1,43 @@
|
||||
-- File: Segment3D.cdl
|
||||
-- Created: Thu Apr 25 10:27:04 1991
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@topsn2>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
class Segment3D from Draw inherits Drawable3D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Pnt from gp,
|
||||
Color from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
|
||||
Create(p1,p2 : Pnt; col : Color)
|
||||
returns mutable Segment3D;
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
First(me) returns Pnt from gp
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
First(me : mutable; P : Pnt from gp)
|
||||
is static;
|
||||
|
||||
Last(me) returns Pnt from gp
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
Last(me : mutable; P : Pnt from gp)
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
myFirst : Pnt;
|
||||
myLast : Pnt;
|
||||
myColor : Color;
|
||||
|
||||
end Segment3D;
|
79
src/Draw/Draw_Segment3D.cxx
Executable file
79
src/Draw/Draw_Segment3D.cxx
Executable file
@@ -0,0 +1,79 @@
|
||||
// Copyright: Matra-Datavision 1991
|
||||
// File: Draw_Segment3D.cxx
|
||||
// Created: Thu Apr 25 11:25:22 1991
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <Draw_Segment3D.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Segment3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Segment3D::Draw_Segment3D(const gp_Pnt& p1,
|
||||
const gp_Pnt& p2,
|
||||
const Draw_Color& col) :
|
||||
myFirst(p1),
|
||||
myLast(p2),
|
||||
myColor(col)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Segment3D::DrawOn(Draw_Display& dis)const
|
||||
{
|
||||
dis.SetColor(myColor);
|
||||
dis.Draw(myFirst,myLast);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : First
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const gp_Pnt& Draw_Segment3D::First() const
|
||||
{
|
||||
return myFirst;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : First
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Segment3D::First(const gp_Pnt& P)
|
||||
{
|
||||
myFirst = P;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Last
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const gp_Pnt& Draw_Segment3D::Last() const
|
||||
{
|
||||
return myLast;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Last
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Segment3D::Last(const gp_Pnt& P)
|
||||
{
|
||||
myLast = P;
|
||||
}
|
||||
|
||||
|
40
src/Draw/Draw_Text2D.cdl
Executable file
40
src/Draw/Draw_Text2D.cdl
Executable file
@@ -0,0 +1,40 @@
|
||||
-- File: Draw_Text2D.cdl
|
||||
-- Created: Mon Apr 18 18:10:20 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
|
||||
|
||||
class Text2D from Draw inherits Drawable2D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Pnt2d from gp,
|
||||
Color from Draw,
|
||||
Display from Draw,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Create(p : Pnt2d; T : CString; col : Color)
|
||||
returns mutable Text2D from Draw;
|
||||
|
||||
Create(p : Pnt2d; T : CString; col : Color;
|
||||
moveX : Integer; moveY : Integer)
|
||||
returns mutable Text2D from Draw;
|
||||
|
||||
SetPnt2d(me : mutable; p : Pnt2d);
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
fields
|
||||
|
||||
myPoint : Pnt2d from gp;
|
||||
myColor : Color from Draw;
|
||||
myText : AsciiString from TCollection;
|
||||
mymoveX : Integer from Standard;
|
||||
mymoveY : Integer from Standard;
|
||||
|
||||
end Text2D;
|
52
src/Draw/Draw_Text2D.cxx
Executable file
52
src/Draw/Draw_Text2D.cxx
Executable file
@@ -0,0 +1,52 @@
|
||||
// File: Draw_Text2D.cxx
|
||||
// Created: Wed Apr 29 15:37:27 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
|
||||
#include <Draw_Text2D.ixx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Text2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Text2D::Draw_Text2D(const gp_Pnt2d& p, const Standard_CString T,
|
||||
const Draw_Color& col) :
|
||||
myPoint(p), myColor(col), myText(T), mymoveX(0), mymoveY(0)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Text2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Text2D::Draw_Text2D(const gp_Pnt2d& p, const Standard_CString T,
|
||||
const Draw_Color& col, const Standard_Integer moveX, const Standard_Integer moveY) :
|
||||
myPoint(p), myColor(col), myText(T), mymoveX(moveX), mymoveY(moveY)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPnt2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Text2D::SetPnt2d(const gp_Pnt2d& p)
|
||||
{
|
||||
myPoint = p;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Text2D::DrawOn(Draw_Display& dis) const
|
||||
{
|
||||
dis.SetColor(myColor);
|
||||
dis.DrawString(myPoint,myText.ToCString(),
|
||||
(Standard_Real)mymoveX, (Standard_Real)mymoveY);
|
||||
}
|
39
src/Draw/Draw_Text3D.cdl
Executable file
39
src/Draw/Draw_Text3D.cdl
Executable file
@@ -0,0 +1,39 @@
|
||||
-- File: Text3D.cdl
|
||||
-- Created: Wed Apr 29 15:29:05 1992
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@sdsun1>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
|
||||
class Text3D from Draw inherits Drawable3D from Draw
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Pnt from gp,
|
||||
Color from Draw,
|
||||
Display from Draw,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Create(p : Pnt; T : CString; col : Color)
|
||||
returns mutable Text3D from Draw;
|
||||
|
||||
Create(p : Pnt; T : CString; col : Color;
|
||||
moveX : Real; moveY : Real)
|
||||
returns mutable Text3D from Draw;
|
||||
|
||||
SetPnt(me : mutable; p : Pnt);
|
||||
|
||||
DrawOn(me; dis : in out Display);
|
||||
|
||||
fields
|
||||
|
||||
myPoint : Pnt from gp;
|
||||
myColor : Color from Draw;
|
||||
myText : AsciiString from TCollection;
|
||||
mymoveX : Real from Standard;
|
||||
mymoveY : Real from Standard;
|
||||
|
||||
end Text3D;
|
53
src/Draw/Draw_Text3D.cxx
Executable file
53
src/Draw/Draw_Text3D.cxx
Executable file
@@ -0,0 +1,53 @@
|
||||
// File: Draw_Text3D.cxx
|
||||
// Created: Wed Apr 29 15:37:27 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
|
||||
#include <Draw_Text3D.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Text3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Text3D::Draw_Text3D(const gp_Pnt& p, const Standard_CString T,
|
||||
const Draw_Color& col) :
|
||||
myPoint(p), myColor(col), myText(T), mymoveX(0.0), mymoveY(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Text3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Text3D::Draw_Text3D(const gp_Pnt& p, const Standard_CString T,
|
||||
const Draw_Color& col,
|
||||
const Standard_Real moveX, const Standard_Real moveY) :
|
||||
myPoint(p), myColor(col), myText(T), mymoveX(moveX), mymoveY(moveY)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPnt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Text3D::SetPnt(const gp_Pnt& p)
|
||||
{
|
||||
myPoint = p;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Text3D::DrawOn(Draw_Display& dis) const
|
||||
{
|
||||
dis.SetColor(myColor);
|
||||
dis.DrawString(myPoint,myText.ToCString(),
|
||||
mymoveX, mymoveY);
|
||||
}
|
||||
|
152
src/Draw/Draw_UnitCommands.cxx
Executable file
152
src/Draw/Draw_UnitCommands.cxx
Executable file
@@ -0,0 +1,152 @@
|
||||
// File: Draw_UnitCommands.cxx
|
||||
// Created: Thu Feb 23 18:21:17 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
#include <Draw.ixx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Units_Token.hxx>
|
||||
#include <Units_UnitSentence.hxx>
|
||||
#include <Units_TokensSequence.hxx>
|
||||
#include <UnitsAPI.hxx>
|
||||
#include <Units.hxx>
|
||||
#include <Units_UnitsDictionary.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : parsing
|
||||
//purpose : parsing of unit's expression
|
||||
//=======================================================================
|
||||
static Standard_Integer parsing
|
||||
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
di << "Usage : " << argv[0] << " string [nbiter]" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aStrTok(argv[1]);
|
||||
Standard_Integer nbIter =1;
|
||||
if(argc >2)
|
||||
nbIter = atoi(argv[2]);
|
||||
UnitsAPI::SetLocalSystem();
|
||||
Handle(Units_Token) atoken;
|
||||
Units_UnitSentence aUnitSent(aStrTok.ToCString());
|
||||
|
||||
if(!aUnitSent.IsDone()) {
|
||||
di<<"can not create a sentence"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Integer i =1;
|
||||
for( ; i <= nbIter; i++) {
|
||||
aUnitSent.Analyse();
|
||||
//aUnitSent.Dump();
|
||||
Handle(Units_TokensSequence) aseq = aUnitSent.Sequence();
|
||||
}
|
||||
atoken = aUnitSent.Evaluate();
|
||||
di<<"Token word : "<<atoken->Word().ToCString()<<"\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : unitsdico
|
||||
//purpose : dump dictionary of units
|
||||
//=======================================================================
|
||||
static Standard_Integer unitsdico
|
||||
(Draw_Interpretor& /* di */, Standard_Integer /*argc*/, const char** /*argv*/)
|
||||
{
|
||||
UnitsAPI::SetLocalSystem();
|
||||
Standard_Integer mode = 2;
|
||||
Units::DictionaryOfUnits(Standard_False)->Dump(mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : converttoSI
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer converttoSI
|
||||
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
di<<"Invalid number of parameter, use: unitconvtoSI real string"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Real aData = atof(argv[1]);
|
||||
Standard_CString aUnit = argv[2];
|
||||
|
||||
Standard_Real res = UnitsAPI::AnyToSI(aData,aUnit);
|
||||
di<<"result: "<<res<<"\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : converttoMDTV
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer converttoMDTV
|
||||
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
di<<"Invalid number of parameter, use: unitconvtoMDTV real string"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Real aData = atof(argv[1]);
|
||||
Standard_CString aUnit = argv[2];
|
||||
|
||||
UnitsAPI::SetLocalSystem(UnitsAPI_MDTV);
|
||||
Standard_Real res = UnitsAPI::AnyToLS(aData,aUnit);
|
||||
di<<"result: "<<res<<"\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : unit
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer unit(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
if(n == 4) {
|
||||
cout << Units::Convert(atof(a[1]), a[2], a[3]) << endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnitCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw::UnitCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean Done = Standard_False;
|
||||
if (Done) return;
|
||||
Done = Standard_True;
|
||||
|
||||
const char* g = "DRAW Unit Commands";
|
||||
|
||||
theCommands.Add("unitparsing", "unitparsing string [nbiter]",
|
||||
__FILE__,parsing,g);
|
||||
theCommands.Add("unitsdico","unitsdico",
|
||||
__FILE__,unitsdico,g);
|
||||
theCommands.Add("unitconvtoSI","unitconvtoSI real string",
|
||||
__FILE__,converttoSI,g);
|
||||
theCommands.Add("unitconvtoMDTV","unitconvtoMDTV real string",
|
||||
__FILE__,converttoMDTV,g);
|
||||
theCommands.Add("unit","unit value unitfrom unitto",
|
||||
__FILE__,unit,g);
|
||||
}
|
1259
src/Draw/Draw_VariableCommands.cxx
Executable file
1259
src/Draw/Draw_VariableCommands.cxx
Executable file
File diff suppressed because it is too large
Load Diff
2022
src/Draw/Draw_Viewer.cxx
Executable file
2022
src/Draw/Draw_Viewer.cxx
Executable file
File diff suppressed because it is too large
Load Diff
167
src/Draw/Draw_Viewer.hxx
Executable file
167
src/Draw/Draw_Viewer.hxx
Executable file
@@ -0,0 +1,167 @@
|
||||
// File: Draw_Viewer.hxx
|
||||
// Created: Mon Apr 6 13:12:09 1992
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@sdsun1>
|
||||
|
||||
|
||||
#ifndef Draw_Viewer_HeaderFile
|
||||
#define Draw_Viewer_HeaderFile
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <gp_Dir2d.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_SequenceOfDrawable3D.hxx>
|
||||
#include <Draw_Color.hxx>
|
||||
|
||||
#ifdef WNT
|
||||
#include <windows.h>
|
||||
#if !defined(__Draw_API) && !defined(HAVE_NO_DLL)
|
||||
# ifdef __Draw_DLL
|
||||
# define __Draw_API __declspec( dllexport )
|
||||
# else
|
||||
# define __Draw_API /*__declspec( dllimport )*/
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define __Draw_API
|
||||
#endif
|
||||
const Standard_Integer MAXVIEW = 30;
|
||||
|
||||
class Draw_View;
|
||||
|
||||
class Draw_Viewer {
|
||||
|
||||
public :
|
||||
__Draw_API Draw_Viewer ();
|
||||
__Draw_API Standard_Boolean DefineColor (const Standard_Integer i,
|
||||
const char* colname);
|
||||
__Draw_API void MakeView (const Standard_Integer id,
|
||||
const char* typ,
|
||||
const Standard_Integer X, const Standard_Integer Y,
|
||||
const Standard_Integer W, const Standard_Integer H);
|
||||
// build a view on a given window
|
||||
#ifdef WNT
|
||||
__Draw_API void MakeView (const Standard_Integer id,
|
||||
const char* typ,
|
||||
const Standard_Integer X, const Standard_Integer Y,
|
||||
const Standard_Integer W, const Standard_Integer H,
|
||||
HWND win,
|
||||
const Standard_Boolean useBuffer = Standard_False);
|
||||
#endif
|
||||
__Draw_API void MakeView (const Standard_Integer id,
|
||||
const char* typ,
|
||||
const char* window);
|
||||
__Draw_API void SetTitle (const Standard_Integer id,
|
||||
const char* name);
|
||||
__Draw_API void ResetView (const Standard_Integer id);
|
||||
__Draw_API void SetZoom (const Standard_Integer id,
|
||||
const Standard_Real z);
|
||||
__Draw_API void RotateView (const Standard_Integer id,
|
||||
const gp_Dir2d&,
|
||||
const Standard_Real);
|
||||
__Draw_API void RotateView (const Standard_Integer id,
|
||||
const gp_Pnt&,
|
||||
const gp_Dir&,
|
||||
const Standard_Real);
|
||||
__Draw_API void SetFocal (const Standard_Integer id,
|
||||
const Standard_Real FocalDist);
|
||||
__Draw_API char* GetType (const Standard_Integer id) const;
|
||||
__Draw_API Standard_Real Zoom (const Standard_Integer id) const;
|
||||
__Draw_API Standard_Real Focal (const Standard_Integer id) const;
|
||||
__Draw_API void SetTrsf (const Standard_Integer id,
|
||||
gp_Trsf& T);
|
||||
__Draw_API void GetTrsf (const Standard_Integer id,
|
||||
gp_Trsf& T) const;
|
||||
__Draw_API void GetPosSize (const Standard_Integer id,
|
||||
Standard_Integer& X, Standard_Integer& Y,
|
||||
Standard_Integer& W, Standard_Integer& H);
|
||||
__Draw_API Standard_Boolean Is3D (const Standard_Integer id) const;
|
||||
__Draw_API void GetFrame (const Standard_Integer id,
|
||||
Standard_Integer& xmin, Standard_Integer& ymin,
|
||||
Standard_Integer& xmax, Standard_Integer& ymax);
|
||||
__Draw_API void FitView (const Standard_Integer id, const Standard_Integer frame);
|
||||
__Draw_API void PanView (const Standard_Integer id,
|
||||
const Standard_Integer DX, const Standard_Integer DY);
|
||||
__Draw_API void SetPan (const Standard_Integer id,
|
||||
const Standard_Integer DX, const Standard_Integer DY);
|
||||
__Draw_API void GetPan (const Standard_Integer id,
|
||||
Standard_Integer& DX, Standard_Integer& DY);
|
||||
__Draw_API Standard_Boolean HasView (const Standard_Integer id) const;
|
||||
__Draw_API void DisplayView (const Standard_Integer id) const;
|
||||
__Draw_API void HideView (const Standard_Integer id) const;
|
||||
__Draw_API void ClearView (const Standard_Integer id) const;
|
||||
__Draw_API void RemoveView (const Standard_Integer id) ;
|
||||
__Draw_API void RepaintView (const Standard_Integer id) const;
|
||||
#ifdef WNT
|
||||
__Draw_API void ResizeView (const Standard_Integer id) const;
|
||||
__Draw_API void UpdateView (const Standard_Integer id, const Standard_Boolean forced = Standard_False) const;
|
||||
#endif
|
||||
__Draw_API void ConfigView (const Standard_Integer id) const;
|
||||
__Draw_API void PostScriptView (const Standard_Integer id,
|
||||
const Standard_Integer VXmin,
|
||||
const Standard_Integer VYmin,
|
||||
const Standard_Integer VXmax,
|
||||
const Standard_Integer VYmax,
|
||||
const Standard_Integer PXmin,
|
||||
const Standard_Integer PYmin,
|
||||
const Standard_Integer PXmax,
|
||||
const Standard_Integer PYmax,
|
||||
ostream& sortie) const;
|
||||
__Draw_API void PostColor(const Standard_Integer icol,
|
||||
const Standard_Integer width,
|
||||
const Standard_Real gray);
|
||||
__Draw_API Standard_Boolean SaveView(const Standard_Integer id, const char* filename);
|
||||
__Draw_API void RepaintAll () const;
|
||||
__Draw_API void Repaint2D () const;
|
||||
__Draw_API void Repaint3D () const;
|
||||
__Draw_API unsigned long GetWindow (const Standard_Integer id) const;
|
||||
__Draw_API void DeleteView (const Standard_Integer id);
|
||||
__Draw_API void Clear ();
|
||||
__Draw_API void Clear2D ();
|
||||
__Draw_API void Clear3D ();
|
||||
__Draw_API void Flush ();
|
||||
|
||||
__Draw_API void DrawOnView (const Standard_Integer id,
|
||||
const Handle(Draw_Drawable3D)& D) const;
|
||||
__Draw_API void HighlightOnView (const Standard_Integer id,
|
||||
const Handle(Draw_Drawable3D)& D,
|
||||
const Draw_ColorKind C = Draw_blanc) const;
|
||||
__Draw_API void AddDrawable (const Handle(Draw_Drawable3D)& D);
|
||||
__Draw_API void RemoveDrawable (const Handle(Draw_Drawable3D)& D);
|
||||
__Draw_API Draw_Display MakeDisplay (const Standard_Integer id) const;
|
||||
|
||||
__Draw_API void Select (Standard_Integer& id, // View, -1 if none
|
||||
Standard_Integer& X, // Pick coordinates
|
||||
Standard_Integer& Y,
|
||||
Standard_Integer& Button, // Button pressed, 0 if none
|
||||
Standard_Boolean waitclick = Standard_True
|
||||
);
|
||||
|
||||
__Draw_API Standard_Integer Pick(const Standard_Integer id, // returns the index (or 0)
|
||||
const Standard_Integer X,
|
||||
const Standard_Integer Y,
|
||||
const Standard_Integer Prec,
|
||||
Handle(Draw_Drawable3D)& D,
|
||||
const Standard_Integer First = 0) const; // search after this drawable
|
||||
|
||||
__Draw_API void LastPick(gp_Pnt& P1, gp_Pnt& P2, Standard_Real& Param);
|
||||
// returns the extremities and parameter of the last picked segment
|
||||
|
||||
__Draw_API ~Draw_Viewer();
|
||||
__Draw_API Draw_Viewer& operator<<(const Handle(Draw_Drawable3D)&);
|
||||
__Draw_API const Draw_SequenceOfDrawable3D& GetDrawables();
|
||||
|
||||
private :
|
||||
|
||||
Draw_View* myViews[MAXVIEW];
|
||||
Draw_SequenceOfDrawable3D myDrawables;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
4
src/Draw/Draw_WOKSteps.edl
Executable file
4
src/Draw/Draw_WOKSteps.edl
Executable file
@@ -0,0 +1,4 @@
|
||||
|
||||
@ifdefined ( %Draw_WOKSteps_EDL) then
|
||||
@set %WOKSteps_XcppGroup = " xcpp.fill xcpp.src xcpp.header obj.cgen obj.inc";
|
||||
@endif;
|
2247
src/Draw/Draw_Window.cxx
Executable file
2247
src/Draw/Draw_Window.cxx
Executable file
File diff suppressed because it is too large
Load Diff
333
src/Draw/Draw_Window.hxx
Executable file
333
src/Draw/Draw_Window.hxx
Executable file
@@ -0,0 +1,333 @@
|
||||
// File: Draw_Window.hxx
|
||||
// Created: Wed Jul 27 14:57:29 1994
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
#ifndef Draw_Window_HeaderFile
|
||||
#define Draw_Window_HeaderFile
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
|
||||
#ifndef WNT
|
||||
|
||||
const Standard_Integer MAXCOLOR = 15;
|
||||
|
||||
typedef unsigned long Window;
|
||||
typedef unsigned long Pixmap;
|
||||
typedef unsigned long Drawable;
|
||||
|
||||
// Definition de la class Base_Window (Definie dans Draw_Window.cxx)
|
||||
//===================================
|
||||
class Base_Window;
|
||||
|
||||
// Definition de la classe Segment
|
||||
//================================
|
||||
struct Segment
|
||||
{
|
||||
short xx1;
|
||||
short yy1;
|
||||
short xx2;
|
||||
short yy2;
|
||||
|
||||
void Init(short x1, short y1, short x2, short y2) {
|
||||
xx1 = x1; yy1 = y1; xx2 = x2; yy2 = y2;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Definition de la structure Event
|
||||
//=================================
|
||||
typedef struct Event
|
||||
{
|
||||
Standard_Integer type;
|
||||
Window window;
|
||||
Standard_Integer button;
|
||||
Standard_Integer x;
|
||||
Standard_Integer y;
|
||||
} Event;
|
||||
|
||||
// Definition de la classe Draw_Window
|
||||
//====================================
|
||||
class Draw_Window
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
Draw_Window (); // the window is not initialized
|
||||
Draw_Window (const char* title,
|
||||
Standard_Integer X, Standard_Integer Y = 0,
|
||||
Standard_Integer DX = 50, Standard_Integer DY = 50);
|
||||
|
||||
Draw_Window (Window mother);
|
||||
Draw_Window (Window mother,char* title,
|
||||
Standard_Integer X = 0, Standard_Integer Y = 0,
|
||||
Standard_Integer DX = 50, Standard_Integer DY = 50);
|
||||
Draw_Window(const char *window);
|
||||
|
||||
void Init (Standard_Integer X = 0, Standard_Integer Y = 0,
|
||||
Standard_Integer DX = 50, Standard_Integer DY = 50);
|
||||
|
||||
void Init (Window mother,
|
||||
Standard_Integer X = 0, Standard_Integer Y = 0,
|
||||
Standard_Integer DX = 50, Standard_Integer DY = 50);
|
||||
|
||||
|
||||
void StopWinManager();
|
||||
|
||||
void SetPosition (Standard_Integer NewXpos,
|
||||
Standard_Integer NewYpos);
|
||||
|
||||
void SetDimension(Standard_Integer NewDx,
|
||||
Standard_Integer NewDy);
|
||||
|
||||
void GetPosition(Standard_Integer &PosX,
|
||||
Standard_Integer &PosY);
|
||||
|
||||
Standard_Integer HeightWin() const;
|
||||
Standard_Integer WidthWin() const;
|
||||
|
||||
void SetTitle(const char* title);
|
||||
char* GetTitle();
|
||||
|
||||
void DisplayWindow();
|
||||
void Hide();
|
||||
void Destroy();
|
||||
void Clear();
|
||||
void Wait(Standard_Boolean wait = Standard_True);
|
||||
|
||||
Drawable GetDrawable() const;
|
||||
// Initializes off-screen image buffer according to current window size
|
||||
void InitBuffer();
|
||||
|
||||
static Standard_Boolean DefineColor(const Standard_Integer, const char*);
|
||||
void SetColor(int);
|
||||
void SetMode(int);
|
||||
void DrawString(int, int, char*);
|
||||
void DrawSegments(Segment* ,int);
|
||||
void Redraw();
|
||||
static void Flush();
|
||||
|
||||
// save snapshot
|
||||
Standard_Boolean Save(const char* theFileName) const;
|
||||
|
||||
virtual ~Draw_Window ();
|
||||
|
||||
// X Event management
|
||||
virtual void WExpose();
|
||||
virtual void WButtonPress(const Standard_Integer X,
|
||||
const Standard_Integer Y,
|
||||
const Standard_Integer& button);
|
||||
virtual void WButtonRelease(const Standard_Integer X,
|
||||
const Standard_Integer Y,
|
||||
const Standard_Integer& button);
|
||||
//virtual void WKeyPress(char, KeySym& );
|
||||
virtual void WMotionNotify(const Standard_Integer X,
|
||||
const Standard_Integer Y);
|
||||
|
||||
virtual void WConfigureNotify(const Standard_Integer X,
|
||||
const Standard_Integer Y,
|
||||
const Standard_Integer dx,
|
||||
const Standard_Integer dy);
|
||||
|
||||
virtual void WUnmapNotify();
|
||||
|
||||
Base_Window& base;
|
||||
Window win;
|
||||
Window myMother; // default : myMother is the root window
|
||||
Pixmap myBuffer;
|
||||
|
||||
static Draw_Window* firstWindow;
|
||||
Draw_Window* next;
|
||||
Draw_Window* previous;
|
||||
|
||||
Standard_Boolean myUseBuffer;
|
||||
Standard_Boolean withWindowManager;
|
||||
|
||||
};
|
||||
|
||||
//======================================================
|
||||
// funtion : Run_Appli
|
||||
// purpose : run the application
|
||||
// interp will be called to interpret a command
|
||||
// and return True if the command is complete
|
||||
//======================================================
|
||||
|
||||
void Run_Appli(Standard_Boolean (*inteprete) (char*));
|
||||
|
||||
//======================================================
|
||||
// funtion : Init_Appli
|
||||
// purpose :
|
||||
//======================================================
|
||||
Standard_Boolean Init_Appli();
|
||||
|
||||
//======================================================
|
||||
// funtion : Destroy_Appli()
|
||||
// purpose :
|
||||
//======================================================
|
||||
void Destroy_Appli();
|
||||
|
||||
//======================================================
|
||||
// funtion : GetNextEvent()
|
||||
// purpose :
|
||||
//======================================================
|
||||
void GetNextEvent(Event&);
|
||||
|
||||
#else
|
||||
// Specifique WNT
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define DRAWCLASS "DRAWWINDOW"
|
||||
#define DRAWTITLE "Draw View"
|
||||
#define MAXCOLOR 15
|
||||
|
||||
#if !defined(__Draw_API) && !defined(HAVE_NO_DLL)
|
||||
# ifdef __Draw_DLL
|
||||
# define __Draw_API __declspec( dllexport )
|
||||
# else
|
||||
# define __Draw_API __declspec( dllimport )
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// definition de la classe Segment
|
||||
|
||||
class DrawWindow;
|
||||
class Segment
|
||||
{
|
||||
friend class DrawWindow;
|
||||
public :
|
||||
//constructeur
|
||||
Segment () {}
|
||||
//destructeur
|
||||
~Segment () {}
|
||||
|
||||
//methods
|
||||
void Init(Standard_Integer,
|
||||
Standard_Integer,
|
||||
Standard_Integer,
|
||||
Standard_Integer);
|
||||
private:
|
||||
//atributs :
|
||||
Standard_Integer x1;
|
||||
Standard_Integer y1;
|
||||
Standard_Integer x2;
|
||||
Standard_Integer y2;
|
||||
};
|
||||
|
||||
//definition de la classe DRAWWINDOW
|
||||
|
||||
class DrawWindow
|
||||
{
|
||||
//constructeur
|
||||
public:
|
||||
__Draw_API DrawWindow();
|
||||
__Draw_API DrawWindow(char*, Standard_Integer, Standard_Integer,
|
||||
Standard_Integer, Standard_Integer);
|
||||
__Draw_API DrawWindow(char*, Standard_Integer, Standard_Integer,
|
||||
Standard_Integer, Standard_Integer, HWND);
|
||||
//destructeur
|
||||
__Draw_API ~DrawWindow();
|
||||
|
||||
//methods
|
||||
public:
|
||||
__Draw_API void Init(Standard_Integer, Standard_Integer,
|
||||
Standard_Integer, Standard_Integer);
|
||||
|
||||
__Draw_API void SetUseBuffer(Standard_Boolean);
|
||||
// Turns on/off usage of off-screen image buffer (can be used for redrawing optimization)
|
||||
|
||||
__Draw_API Standard_Boolean GetUseBuffer() const { return myUseBuffer; }
|
||||
// Returns Standard_True if off-screen image buffer is being used
|
||||
|
||||
//taille et position
|
||||
__Draw_API void SetPosition (Standard_Integer,Standard_Integer);
|
||||
__Draw_API void SetDimension(Standard_Integer,Standard_Integer);
|
||||
__Draw_API void GetPosition (Standard_Integer&,Standard_Integer&);
|
||||
__Draw_API Standard_Integer HeightWin() const;
|
||||
__Draw_API Standard_Integer WidthWin() const;
|
||||
|
||||
//Title
|
||||
__Draw_API void SetTitle(char*);
|
||||
__Draw_API char* GetTitle();
|
||||
|
||||
//Affichage
|
||||
__Draw_API void DisplayWindow();
|
||||
__Draw_API void Hide();
|
||||
__Draw_API void Destroy();
|
||||
__Draw_API void Clear();
|
||||
__Draw_API static void Flush() {} ;
|
||||
|
||||
// save snapshot
|
||||
__Draw_API Standard_Boolean Save(const char* theFileName) const;
|
||||
|
||||
//Dessin
|
||||
__Draw_API void DrawString(int,int,char*);
|
||||
__Draw_API void DrawSegments(Segment*,int);
|
||||
|
||||
__Draw_API void InitBuffer();
|
||||
// Initializes off-screen image buffer according to current window size
|
||||
|
||||
__Draw_API void Redraw();
|
||||
// Copies an image from memory buffer to screen
|
||||
|
||||
//Couleur
|
||||
__Draw_API void SetColor(Standard_Integer);
|
||||
__Draw_API void SetMode(int);
|
||||
__Draw_API static Standard_Boolean DefineColor ( const Standard_Integer,const char*);
|
||||
|
||||
//Gestion des Messages
|
||||
__Draw_API virtual void WExpose ();
|
||||
__Draw_API virtual void WButtonPress(const Standard_Integer,const Standard_Integer,
|
||||
const Standard_Integer&);
|
||||
__Draw_API virtual void WButtonRelease(const Standard_Integer,const Standard_Integer,
|
||||
const Standard_Integer&);
|
||||
__Draw_API virtual void WMotionNotify(const Standard_Integer,const Standard_Integer);
|
||||
__Draw_API virtual void WConfigureNotify(const Standard_Integer,const Standard_Integer,
|
||||
const Standard_Integer,const Standard_Integer);
|
||||
__Draw_API virtual void WUnmapNotify();
|
||||
|
||||
//Gestion souris
|
||||
__Draw_API static void SelectWait (HANDLE&,int&,int&,int&);
|
||||
__Draw_API static void SelectNoWait (HANDLE&,int&,int&,int&);
|
||||
|
||||
// Procedure de fenetre
|
||||
__Draw_API static LONG APIENTRY DrawProc (HWND,UINT,WPARAM,LONG);
|
||||
|
||||
private:
|
||||
|
||||
__Draw_API static HWND CreateDrawWindow(HWND,int);
|
||||
__Draw_API HDC GetMemDC(HDC);
|
||||
__Draw_API void ReleaseMemDC(HDC);
|
||||
|
||||
//atributs
|
||||
public:
|
||||
HWND win;
|
||||
static HWND hWndClientMDI;
|
||||
|
||||
private:
|
||||
static DrawWindow* firstWindow;
|
||||
DrawWindow* next;
|
||||
DrawWindow* previous;
|
||||
HBITMAP myMemHbm;
|
||||
HBITMAP myOldHbm;
|
||||
Standard_Boolean myUseBuffer;
|
||||
Standard_Integer myCurrPen;
|
||||
Standard_Integer myCurrMode;
|
||||
};
|
||||
|
||||
typedef DrawWindow Draw_Window;
|
||||
typedef enum {
|
||||
STOP_CONSOLE,
|
||||
WAIT_CONSOLE_COMMAND,
|
||||
HAS_CONSOLE_COMMAND} console_semaphore_value;
|
||||
|
||||
// PROCEDURE DE DRAW WINDOW
|
||||
|
||||
__Draw_API Standard_Boolean Init_Appli(HINSTANCE,HINSTANCE,int,HWND&);
|
||||
__Draw_API void Run_Appli(HWND);
|
||||
__Draw_API void Destroy_Appli(HINSTANCE);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
25
src/Draw/Draw_WindowBase.hxx
Executable file
25
src/Draw/Draw_WindowBase.hxx
Executable file
@@ -0,0 +1,25 @@
|
||||
// File: Draw_WindowBase.hxx
|
||||
// Created: Fri Mar 17 15:31:19 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@phobox>
|
||||
|
||||
|
||||
#ifndef _Draw_WindowBase_HeaderFile
|
||||
#define _Draw_WindowBase_HeaderFile
|
||||
|
||||
#ifndef WNT
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#endif
|
||||
|
||||
// Definition de la class Base_Window
|
||||
//===================================
|
||||
struct Base_Window
|
||||
{
|
||||
GC gc;
|
||||
XSetWindowAttributes xswa;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
6
src/Draw/EXTERNLIB
Executable file
6
src/Draw/EXTERNLIB
Executable file
@@ -0,0 +1,6 @@
|
||||
CSF_TclLibs
|
||||
CSF_TclTkLibs
|
||||
CSF_gdi32
|
||||
CSF_advapi32
|
||||
CSF_user32
|
||||
|
29
src/Draw/FILES
Executable file
29
src/Draw/FILES
Executable file
@@ -0,0 +1,29 @@
|
||||
umake.ini
|
||||
EXTERNLIB
|
||||
Draw_CMPLRS.edl
|
||||
Draw_Replace.tcl
|
||||
Draw_Commands.cxx
|
||||
Draw_BasicCommands.cxx
|
||||
Draw_VariableCommands.cxx
|
||||
Draw_GraphicCommands.cxx
|
||||
Draw_UnitCommands.cxx
|
||||
Draw_Appli.hxx
|
||||
Draw_Viewer.cxx
|
||||
Draw_Viewer.hxx
|
||||
Draw_Viewer.hxx
|
||||
Draw_Window.cxx
|
||||
Draw_Window.hxx
|
||||
Draw_WindowBase.hxx
|
||||
Draw_PInterp.hxx
|
||||
Draw_CommandFunction.hxx
|
||||
DrawRessource.h
|
||||
init.h
|
||||
MAINWINDOW.h
|
||||
MainWindow.cxx
|
||||
CommandWindow.cxx
|
||||
COMMANDWINDOW.h
|
||||
init.cxx
|
||||
Draw_Main.hxx
|
||||
Draw_Main.cxx
|
||||
Draw_PluginMacro.hxx
|
||||
Draw_PloadCommands.cxx
|
19
src/Draw/MAINWINDOW.h
Executable file
19
src/Draw/MAINWINDOW.h
Executable file
@@ -0,0 +1,19 @@
|
||||
/****************************************************\
|
||||
* MainWindow.h
|
||||
\****************************************************/
|
||||
#ifdef WNT
|
||||
|
||||
#define CLIENTWND 0
|
||||
|
||||
/*
|
||||
** PROCEDURES DE MAIN WINDOW
|
||||
*/
|
||||
#include <Windows.h>
|
||||
|
||||
LONG APIENTRY WndProc(HWND, UINT, WPARAM, LONG);
|
||||
BOOL CreateProc(HWND);
|
||||
VOID DestroyProc(HWND);
|
||||
BOOL CommandProc(HWND, WPARAM, LPARAM);
|
||||
|
||||
|
||||
#endif
|
137
src/Draw/MainWindow.cxx
Executable file
137
src/Draw/MainWindow.cxx
Executable file
@@ -0,0 +1,137 @@
|
||||
// File: MainWindow.cxx
|
||||
// Created: Thu Aug 6 10:00:35 1998
|
||||
// Author: Administrateur Atelier MDL
|
||||
// <mdl@efalakox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
|
||||
#ifdef WNT
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <DrawRessource.h>
|
||||
#include <init.h>
|
||||
#include <MainWindow.h>
|
||||
#include <Draw_Window.hxx>
|
||||
#include <CommandWindow.h>
|
||||
|
||||
Standard_Boolean Draw_Interprete(char* command); // Implemente dans Draw.cxx
|
||||
extern Standard_Boolean Draw_IsConsoleSubsystem;
|
||||
|
||||
//extern "C" int compat_unlink(const char *fname); // Implemente dans TCL
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| CLIENT WINDOW PROCEDURE
|
||||
|
|
||||
|
|
||||
\*--------------------------------------------------------*/
|
||||
LONG APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LONG lParam )
|
||||
{
|
||||
HWND hWndClient;
|
||||
switch(wMsg)
|
||||
{
|
||||
case WM_CREATE :
|
||||
{
|
||||
CreateProc(hWndFrame);
|
||||
hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
|
||||
DrawWindow::hWndClientMDI = hWndClient;
|
||||
if (!Draw_IsConsoleSubsystem)
|
||||
CreateCommandWindow(hWndFrame,0);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND :
|
||||
CommandProc(hWndFrame, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_DESTROY :
|
||||
Draw_Interprete("exit");
|
||||
DestroyProc(hWndFrame);
|
||||
break;
|
||||
|
||||
default :
|
||||
hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
|
||||
return(DefFrameProc(hWndFrame, hWndClient, wMsg, wParam, lParam));
|
||||
}
|
||||
return(0l);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*\
|
||||
| CLIENT CREATE PROCEDURE
|
||||
| Handler pour le message WM_CREATE. Creation de la fenetre de control MDI
|
||||
|
|
||||
\*--------------------------------------------------------------------------*/
|
||||
BOOL CreateProc(HWND hWndFrame)
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
// Enregistre le hWnd dans la fenetre principale dans extra memory en 0
|
||||
if (hWnd = CreateMDIClientWindow(hWndFrame))
|
||||
SetWindowLong(hWndFrame, CLIENTWND, (LONG)hWnd);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*\
|
||||
| COMMAND PROCEDURE
|
||||
| Handler pour le message WM_COMMAND
|
||||
|
|
||||
\*--------------------------------------------------------------------------*/
|
||||
BOOL CommandProc(HWND hWndFrame, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hWndClient; // Handle sur la fenetre MDI
|
||||
HWND hWndActive;
|
||||
|
||||
hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDM_WINDOW_NEXT :
|
||||
if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
|
||||
hWndActive = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0l);
|
||||
SendMessage(hWndClient, WM_MDINEXT, (WPARAM)hWndActive, 0l);
|
||||
break;
|
||||
|
||||
case IDM_WINDOW_CASCADE :
|
||||
if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
|
||||
SendMessage(hWndClient, WM_MDICASCADE, 0, 0l);
|
||||
break;
|
||||
|
||||
case IDM_WINDOW_TILEHOR :
|
||||
if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
|
||||
SendMessage(hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
|
||||
break;
|
||||
|
||||
case IDM_WINDOW_TILEVERT :
|
||||
if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
|
||||
SendMessage(hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
|
||||
break;
|
||||
|
||||
case IDM_FILE_EXIT :
|
||||
Draw_Interprete("exit");
|
||||
//compat_unlink(NULL);
|
||||
|
||||
DestroyProc(hWndFrame);
|
||||
break;
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*\
|
||||
| CLIENT DESTROY PROCEDURE
|
||||
| Handler pour le message WM_DESTROY.
|
||||
|
|
||||
\*--------------------------------------------------------------------------*/
|
||||
VOID DestroyProc(HWND hWnd)
|
||||
{
|
||||
#ifndef _WIN64
|
||||
HINSTANCE hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
|
||||
#else
|
||||
HINSTANCE hInst = (HINSTANCE)GetWindowLong(hWnd, GWLP_HINSTANCE);
|
||||
#endif
|
||||
Destroy_Appli(hInst);
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
#endif
|
||||
|
143
src/Draw/init.cxx
Executable file
143
src/Draw/init.cxx
Executable file
@@ -0,0 +1,143 @@
|
||||
// File: init.cxx
|
||||
// Created: Thu Aug 6 10:02:25 1998
|
||||
// Author: Administrateur Atelier MDL
|
||||
// <mdl@efalakox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#ifdef WNT
|
||||
|
||||
// include windows.h first to have all definitions available
|
||||
#include <windows.h>
|
||||
|
||||
#include "Draw_Window.hxx"
|
||||
#include "DrawRessource.h"
|
||||
#include "init.h"
|
||||
#include "MainWindow.h"
|
||||
#include "CommandWindow.h"
|
||||
|
||||
|
||||
#define USEDEFAULT 200
|
||||
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| REGISTER APPLICATION CLASS
|
||||
| Enregistrement des classes de fenetres de l'application
|
||||
|
|
||||
d\*--------------------------------------------------------*/
|
||||
|
||||
BOOL RegisterAppClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASS wndClass;
|
||||
|
||||
// Parametres communs aux classes
|
||||
//-----
|
||||
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC;
|
||||
wndClass.cbClsExtra = 0;
|
||||
wndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
wndClass.hInstance = hInstance;
|
||||
|
||||
// Enregistrement de la fenetre principale
|
||||
//-----
|
||||
wndClass.cbWndExtra = sizeof(LONG);
|
||||
wndClass.lpfnWndProc = (WNDPROC)WndProc;
|
||||
wndClass.hIcon = (HICON)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
|
||||
wndClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
|
||||
wndClass.lpszMenuName = MAKEINTRESOURCE(APPMENU);
|
||||
wndClass.lpszClassName = APPCLASS;
|
||||
|
||||
if(!RegisterClass(&wndClass))
|
||||
return(FALSE);
|
||||
|
||||
// Enregistrement de la fenetre DrawWindow
|
||||
//------
|
||||
wndClass.cbWndExtra = sizeof(LONG); // Extra Memory
|
||||
wndClass.lpfnWndProc = (WNDPROC)DrawWindow::DrawProc;
|
||||
wndClass.hIcon = 0;
|
||||
wndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
|
||||
wndClass.lpszMenuName = NULL;
|
||||
wndClass.lpszClassName = DRAWCLASS;
|
||||
|
||||
if(!RegisterClass(&wndClass))
|
||||
{
|
||||
UnregisterClass(APPCLASS, hInstance);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
// Enregistrement de la fenetre CommandWindow
|
||||
//------
|
||||
wndClass.lpfnWndProc = (WNDPROC)CommandProc((HWND)WndProc,(WPARAM)342,(LPARAM)443);
|
||||
//wndClass.lpfnWndProc = (WNDPROC)CommandProc;
|
||||
wndClass.hIcon = 0;
|
||||
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wndClass.lpszMenuName = NULL;
|
||||
wndClass.lpszClassName = COMMANDCLASS;
|
||||
|
||||
if(!RegisterClass(&wndClass))
|
||||
{
|
||||
UnregisterClass(APPCLASS, hInstance);
|
||||
UnregisterClass(DRAWCLASS, hInstance);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| UNREGISTER APPLICATION CLASS
|
||||
| Suppression des classes de fenetres de l'application
|
||||
|
|
||||
\*--------------------------------------------------------*/
|
||||
VOID UnregisterAppClass(HINSTANCE hInstance)
|
||||
{
|
||||
UnregisterClass(APPCLASS, hInstance);
|
||||
UnregisterClass(DRAWCLASS, hInstance);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| CREATE APPLICATION WINDOW
|
||||
| Creation de la fenetre Top-Level
|
||||
|
|
||||
\*--------------------------------------------------------*/
|
||||
HWND CreateAppWindow(HINSTANCE hInstance)
|
||||
{
|
||||
return(CreateWindow(APPCLASS, APPTITLE,
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
||||
400,0,
|
||||
623,767,
|
||||
NULL, NULL, hInstance, NULL));
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
| CREATE MDI CLIENT WINDOW
|
||||
| Creation de la fenetre qui contient des fenetres MDI
|
||||
|
|
||||
\*--------------------------------------------------------*/
|
||||
HWND CreateMDIClientWindow(HWND hWndFrame)
|
||||
{
|
||||
HWND hWndClient;
|
||||
HANDLE hInstance;
|
||||
CLIENTCREATESTRUCT ccs;
|
||||
|
||||
// Initialisation de la structure client
|
||||
ccs.hWindowMenu = NULL;
|
||||
ccs.idFirstChild = 0;
|
||||
|
||||
#ifndef _WIN64
|
||||
hInstance = (HANDLE)GetWindowLong(hWndFrame, GWL_HINSTANCE);
|
||||
#else
|
||||
hInstance = (HANDLE)GetWindowLong(hWndFrame, GWLP_HINSTANCE);
|
||||
#endif
|
||||
|
||||
hWndClient = CreateWindow("MDICLIENT",NULL,
|
||||
WS_CHILD | WS_CLIPSIBLINGS |
|
||||
WS_VISIBLE | MDIS_ALLCHILDSTYLES,
|
||||
0, 0, 1, 1,
|
||||
hWndFrame, NULL,
|
||||
(HINSTANCE)hInstance, (LPVOID)&ccs);
|
||||
return(hWndClient);
|
||||
}
|
||||
#endif
|
13
src/Draw/init.h
Executable file
13
src/Draw/init.h
Executable file
@@ -0,0 +1,13 @@
|
||||
#ifdef WNT
|
||||
|
||||
#define APPCLASS "TDRAW"
|
||||
#define APPTITLE "Windows NT TDRAW"
|
||||
#include <windows.h>
|
||||
|
||||
BOOL RegisterAppClass(HINSTANCE);
|
||||
VOID UnregisterAppClass(HINSTANCE);
|
||||
HWND CreateAppWindow(HINSTANCE);
|
||||
HWND CreateMDIClientWindow(HWND);
|
||||
|
||||
|
||||
#endif
|
6
src/Draw/umake.ini
Executable file
6
src/Draw/umake.ini
Executable file
@@ -0,0 +1,6 @@
|
||||
#ifdef sun
|
||||
CMPLRS_CXX_OPT "-I/usr/openwin/include $CMPLRS_CXX_OPT"
|
||||
#endif
|
||||
#ifdef hp
|
||||
CMPLRS_CXX_OPT "-I/usr/include/X11R5 $CMPLRS_CXX_OPT"
|
||||
#endif
|
Reference in New Issue
Block a user