Bazaar/Oce2Upp : added application to import OpenCascade OCE source tree into pp

git-svn-id: svn://ultimatepp.org/upp/trunk@6850 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
micio 2014-02-02 15:46:54 +00:00
parent 9a1716b0b4
commit bc45a542da
13 changed files with 1267 additions and 0 deletions

242
bazaar/Oce2Upp/OCECtrl_CPP Executable file
View file

@ -0,0 +1,242 @@
#include "OCE.h"
INITBLOCK {
#ifdef PLATFORM_POSIX
setenv("MMGT_OPT", "0", 1);
setenv("MMGT_CLEAR", "0", 1);
#else
SetEnvironmentVariable("MMGT_OPT", "0");
SetEnvironmentVariable("MMGT_CLEAR", "0");
#endif
}
/////////////////////////////////////////////////////////////////////////////////////////
// Constructor
OCECtrl::OCECtrl()
{
// closed on creation
opened = false;
// no connected document upon creation
document = NULL;
// Resets view pointer
view.Nullify();
} // END Constructor class CascadeView
/////////////////////////////////////////////////////////////////////////////////////////
// Destructor
OCECtrl::~OCECtrl()
{
// Resets view handle
view.Nullify();
document = NULL;
opened = false;
} // END Destructor class OCECtrl
void OCECtrl::SetDocument(OCEDoc *doc)
{
document = doc;
if(!doc || !opened)
{
view.Nullify();
return;
}
// platform dependent part
#ifdef PLATFORM_WIN32
HWND windowHandle = GetHWND();
// Creates the view object
view = document->GetViewer()->CreateView();
// Creates the OpenCascade window handle
Aspect_Handle aWindowHandle = (Aspect_Handle)windowHandle;
Handle(WNT_Window) hWnd = new WNT_Window(windowHandle);
// Sets window handle in view
view->SetWindow(hWnd);
// Maps the view if needed
if ( !hWnd->IsMapped() )
hWnd->Map();
#elif defined(flagX11)
// Gets the window handle
Window WindowHandle = GetWindow();
// Creates the view object
view = document->GetViewer()->CreateView();
Aspect_Handle aWindowHandle = (Aspect_Handle)WindowHandle;
Handle(Xw_Window) hWnd = new Xw_Window (document->GetGraphicDriver()->GetDisplayConnection(), aWindowHandle);
// Sets window handle in view
view->SetWindow(hWnd);
// Maps the view if needed
if ( !hWnd->IsMapped() )
hWnd->Map();
#elif defined(flagGTK)
#error "GTK platform still not supported"
#else
#error "Invalid platform"
#endif
// platform intependent part
InitView();
}
#ifdef PLATFORM_WIN32
void OCECtrl::State(int reason)
{
if (reason == CLOSE)
if(!view.IsNull())
view.Nullify();
DHCtrl::State(reason);
if (reason == OPEN)
{
opened = true;
// re-sets document (if any) and forces underlying structures creation
SetDocument(document);
}
}
#elif defined(flagX11)
/////////////////////////////////////////////////////////////////////////////////////////
// Method to choose the correct visual
XVisualInfo *OCECtrl::CreateVisual(void)
{
int visualAttr[] =
{
GLX_RGBA,
GLX_DEPTH_SIZE, 1,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER, None
};
XVisualInfo *pVisualInfo = ::glXChooseVisual( Xdisplay, DefaultScreen(Xdisplay), visualAttr );
return pVisualInfo;
} // END OCECtrl::CreateVisual()
/////////////////////////////////////////////////////////////////////////////////////////
// Method for attribute setting
void OCECtrl::SetAttributes(unsigned long &ValueMask, XSetWindowAttributes &attr)
{
ValueMask |=
CWBackPixel
| CWBorderPixel
;
attr.background_pixel = 0;
attr.border_pixel = 0;
} // END OCECtrl::SetAttributes()
/////////////////////////////////////////////////////////////////////////////////////////
// GLInit method
void OCECtrl::AfterInit(bool isError)
{
if(isError)
return;
opened = true;
// re-sets document (if any) and forces underlying structures creation
SetDocument(document);
} // END OCECtrl::AfterInit()
/////////////////////////////////////////////////////////////////////////////////////////
// These is called just before termination
void OCECtrl::BeforeTerminate(void)
{
if(!view.IsNull())
view.Nullify();
opened = false;
} // END OCECtrl::BeforeTerminate()
#elif defined(flagGTK)
#error "GTK platform still not supported"
#else
#error "Invalid platform"
#endif
/////////////////////////////////////////////////////////////////////////////////////////
// initializes view after platform-dependent init
void OCECtrl::InitView(void)
{
if(!document)
return;
// Sets the background color
view->SetBackgroundColor(Quantity_NOC_BLACK);
// Sets up the triedron
view->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.1, V3d_ZBUFFER);
view->TriedronEcho(Aspect_TOTE_ORIGIN); // ???
// Activate the grid
document->GetViewer()->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines);
document->GetViewer()->SetGridEcho(Standard_True);
view->SetTransparency();
// Signals resize needed
view->MustBeResized();
} // END OCECtrl::InitView()
/////////////////////////////////////////////////////////////////////////////////////////
// Paint method
void OCECtrl::Paint(Draw &draw)
{
if(view.IsNull())
return;
view->MustBeResized();
view->Redraw();
} // END OCECtrl::Paint()
/////////////////////////////////////////////////////////////////////////////////////////
// Handle layout events and propagates to embedded window
void OCECtrl::Layout(void)
{
if(view.IsNull())
return;
view->MustBeResized();
} // END OCECtrl::Resize()
/////////////////////////////////////////////////////////////////////////////////////////
// Fit all in view
void OCECtrl::FitAll()
{
if(view.IsNull())
return;
view->FitAll();
view->ZFitAll();
view->Redraw();
} // END OCECtrl::FitAll()

68
bazaar/Oce2Upp/OCECtrl_H Executable file
View file

@ -0,0 +1,68 @@
#ifndef _OCE_OCECtrl_h_
#define _OCE_OCECtrl_h_
class OCEDoc;
class OCECtrl : public DHCtrl
{
private:
// The associated document
Ptr<OCEDoc> document;
bool opened;
protected:
// The view object
Handle(V3d_View) view;
#ifdef PLATFORM_WIN32
// state handler, to catch init and terminate
void State(int reason);
#elif defined(flagX11)
// Method to choose the correct visual
virtual XVisualInfo *CreateVisual(void);
// Method for attribute setting
virtual void SetAttributes(unsigned long &ValueMask, XSetWindowAttributes &attr);
// These is called just after initialization
virtual void AfterInit(bool Error) ;
// These is called just before termination
virtual void BeforeTerminate(void) ;
#elif defined(flagGTK)
#error "GTK platform still not supported"
#else
#error "Invalid platform"
#endif
// initializes view after platform-dependent init
void InitView(void);
// Handle layout events and propagates to embedded window
virtual void Layout(void) ;
// Paint function with context
virtual void Paint(Draw &draw) ;
////////////////////////////////////////////////////////////////////////////////////////////
public:
typedef OCECtrl CLASSNAME;
// Constructor class OCECtrl
OCECtrl();
// Destructor class OCECtrl
~OCECtrl();
// connects control to document
void SetDocument(OCEDoc *doc);
// Fit all in view
void FitAll();
}; // END Class OCECtrl
#endif

64
bazaar/Oce2Upp/OCEDoc_CPP Executable file
View file

@ -0,0 +1,64 @@
#include "OCE.h"
/////////////////////////////////////////////////////////////////////////////////////////
// Static members initialization
Handle(Graphic3d_GraphicDriver) OCEDoc::graphicDriver = 0;
int OCEDoc::instances = 0;
/////////////////////////////////////////////////////////////////////////////////////////
// Constructor
OCEDoc::OCEDoc()
{
// CREATES THE GRAPHIC DEVICE
if( graphicDriver.IsNull() )
{
Handle(Aspect_DisplayConnection) conn = new Aspect_DisplayConnection;
graphicDriver = new OpenGl_GraphicDriver (conn);
}
// CREATES THE VIEWER
TCollection_ExtendedString a3DName("Visu3D");
viewer = new V3d_Viewer(
graphicDriver, // the graphic device
a3DName.ToExtString(), // view name
"", // domain (?)
1000.0, // view size
V3d_XposYnegZpos, // View projection
Quantity_NOC_GRAY30,
V3d_ZBUFFER,
V3d_GOURAUD,
V3d_WAIT,
Standard_True, // Computed mode (?)
Standard_True, // Default Computed mode (?)
V3d_TEX_NONE // (?)
);
// INITIALIZES THE VIEWER
viewer->SetDefaultLights();
viewer->SetLightOn();
// CREATES THE INTERACTIVE CONTEXT
context = new AIS_InteractiveContext(viewer);
// COUNTS THE INSTANCES OF CascadeCtrl
// THAT'S USED TO FREE GraphicDevice ON LAST CascadeCtrl DELETION
instances++;
} // END Constructor class OCEDoc
/////////////////////////////////////////////////////////////////////////////////////////
// Destructor
OCEDoc::~OCEDoc()
{
// FREES THE CONTEXT
context.Nullify();
// FREES THE VIEWER
viewer.Nullify();
// DECREMENT INSTANCE COUNTER, IF NULL FREES GraphicDevice
//ASSERT(Instances > 0);
if(!--instances)
graphicDriver.Nullify();
} // END Destructor class OCEDoc

39
bazaar/Oce2Upp/OCEDoc_H Executable file
View file

@ -0,0 +1,39 @@
#ifndef _OCE_OCEDoc_h_
#define _OCE_OCEDoc_h_
// OCE document class
class OCEDoc : public Pte<OCEDoc>
{
private:
// THE GRAPHIC DRIVER -- STATIC, COMMON TO ALL CascadeDocuments
static Handle(Graphic3d_GraphicDriver) graphicDriver;
// THE VIEWER
Handle(V3d_Viewer) viewer;
// THE INTERACTIVE CONTEXT
Handle(AIS_InteractiveContext) context;
// NUMBER OF CREATED INSTANCES
static int instances;
public:
// Constructor
OCEDoc();
// Destructor
~OCEDoc();
// Graphic driver property
Handle(Graphic3d_GraphicDriver) const &GetGraphicDriver() {return graphicDriver; };
// Viewer property
Handle(V3d_Viewer) const &GetViewer() { return viewer; };
// Interactive context property
Handle(AIS_InteractiveContext) const &GetContext() { return context; };
}; // END Class OCEDoc
#endif

83
bazaar/Oce2Upp/OCE_H Executable file
View file

@ -0,0 +1,83 @@
#ifndef _OCE_H
#define _OCE_H
#include <GLCtrl/GLCtrl.h>
#undef HAVE_CONFIG_H
#ifdef PLATFORM_POSIX
#define OCE_HAVE_FSTREAM
#define OCE_HAVE_IOSTREAM
#define OCE_HAVE_IOMANIP
#define OCE_HAVE_IOS
#define OCE_HAVE_LIMITS_H
#define HAVE_SYS_STAT_H
#define HAVE_STRING_H
#define HAVE_UNISTD_H
#define HAVE_SIGNAL_H
#define HAVE_SYS_SEM_H
#define HAVE_STATFS\
#define HAVE_SYS_VFS_H
#define HAVE_SYS_TIME_H
#define HAVE_SYS_TIMES_H
#define HAVE_DIRENT_H
#define HAVE_DLFCN_H
#define HAVE_PWD_H
#define HAVE_SYS_UTSNAME_H
#define HAVE_NETDB_H
#define HAVE_SYS_MMAN_H
#define OCE_LIBRARY_PREFIX "lib"
#define OCE_LIBRARY_DEBUG_POSTFIX ""
#define OCE_LIBRARY_EXTENSION ""
#else
#define WNT
#define OCE_IS_DUPLICATE_UINT32_T
#ifdef __APPLE__
typedef void *GLhandleARB;
#else
typedef unsigned int GLhandleARB;
#endif
typedef char GLcharARB;
#define OCE_LIBRARY_PREFIX ""
#define OCE_LIBRARY_DEBUG_POSTFIX "d"
#define OCE_LIBRARY_EXTENSION "lib"
#endif
#define CSFDB
#ifdef WIN32
#include <WNT_Window.hxx>
#else
#define Time XTime
#define Font XFont
#define Display XDisplay
#define Picture XPicture
#define Status int
#include <GL/glx.h>
#include <Xw_Window.hxx>
#undef Status
#undef Picture
#undef Time
#undef Font
#undef Display
#endif
#include <OpenGl_GraphicDriver.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
#include <AIS_InteractiveContext.hxx>
#ifdef PLATFORM_WIN32
#elif defined(flagX11)
#elif defined(flagGTK)
#error "GTK platform still not supported"
#else
#error "Invalid platform"
#endif
using namespace Upp;
#include "OCECtrl.h"
#include "OCEDoc.h"
#endif

19
bazaar/Oce2Upp/OCE_UPP Executable file
View file

@ -0,0 +1,19 @@
noblitz;
library
"TKAdvTools TKMath TKernel TKBRep TKG2d TKG3d TKGeomBase TKBO TKBool TKFeat TKFillet TKGeomAlgo TKHLR TKMesh TKOffset TKPrim TKShHealing TKTopAlgo TKXMesh TKMeshVS TKNIS TKOpenGl TKService TKV3d TKVoxel FWOSPlugin PTKernel TKBin TKBinL TKBinTObj TKCAF TKCDF TKLCAF TKPCAF TKPLCAF TKPShape TKShapeSchema TKStdLSchema TKStdSchema TKTObj TKXml TKXmlL TKXmlTObj TKBinXCAF TKIGES TKSTEP TKSTEP209 TKSTEPAttr TKSTEPBase TKSTL TKVRML TKXCAF TKXCAFSchema TKXDEIGES TKXDESTEP TKXSBase TKXmlXCAF ";
library(POSIX) "GL GLU";
library(WIN32) opengl32;
include
./include;
file
OCE.h,
OCECtrl.h,
OCEDoc.h,
OCECtrl.cpp,
OCEDoc.cpp;

6
bazaar/Oce2Upp/Oce2Upp.brc Executable file
View file

@ -0,0 +1,6 @@
BINARY(OCE_UPP, "OCE_UPP")
BINARY(OCE_H, "OCE_H")
BINARY(OCEDoc_H, "OCEDoc_H")
BINARY(OCEDoc_CPP, "OCEDoc_CPP")
BINARY(OCECtrl_H, "OCECtrl_H")
BINARY(OCECtrl_CPP, "OCECtrl_CPP")

617
bazaar/Oce2Upp/Oce2Upp.cpp Executable file
View file

@ -0,0 +1,617 @@
#include <Core/Core.h>
#include "Oce2Upp.h"
#include "Oce2Upp.brc"
int iTk, numTk;
////////////////////////////////////////////////////////////////////////////////////////////////
// GETS DIRECTORY CONTENT
Vector<String> Oce2Upp::GetDirectoryContent(const String &Path, bool Folders)
{
// GETS INCLUDE FOLDER CONTENTS
Array<FileSystemInfo::FileInfo> DirFiles;
DirFiles = StdFileSystemInfo().Find(Path);
// COPIES ALL NAMES INSIDE AN ARRAY
Vector<String> DirArray;
for(int i = 0 ; i < DirFiles.GetCount() ; i++)
{
if( (Folders && DirFiles[i].is_folder && DirFiles[i].filename != ".svn" && DirFiles[i].filename != ".git") || (!Folders && !DirFiles[i].is_folder) && DirFiles[i].filename != "." && DirFiles[i].filename != "..")
DirArray << DirFiles[i].filename;
}
return DirArray;
} // END OpenCascadePackager::GetDirectoryContent()
// reads an UDLIST file to gather modules/toolkits mapping
bool Oce2Upp::ReadUDLIST(void)
{
FileIn f(AppendFileName(admDir, "UDLIST"));
if(!f)
return false;
// get all toolkits from file
while(!f.IsEof())
{
String l = f.GetLine();
if(!l.StartsWith("t "))
continue;
toolkits.Add(l.Mid(2));
}
return true;
}
// builds database
bool Oce2Upp::BuildDb(void)
{
// read all toolkits names
if(!ReadUDLIST())
return false;
Sort(toolkits);
for(int iTool = 0; iTool < toolkits.GetCount(); iTool++)
{
String tkName = toolkits.GetKey(iTool);
Vector<String> &p = toolkits[iTool];
FileIn f(AppendFileName(srcDir, tkName + "/PACKAGES"));
if(!f)
return false;
while(!f.IsEof())
{
String l = f.GetLine();
if(l == "")
continue;
p.Add(l);
}
f.Close();
Sort(p);
Vector<String> &dep = dependencies.Add(tkName);
f.Open(AppendFileName(srcDir, tkName + "/EXTERNLIB"));
if(!f)
continue; // I guess toolkit can have no dependencies....
while(!f.IsEof())
{
String l = f.GetLine();
if(l == "")
continue;
dep.Add(l);
}
f.Close();
}
return true;
}
// copy include files from inc and various src folders
// in 'include' folder
bool Oce2Upp::CopyIncludes(String const &pacRoot)
{
Vector<String> files;
String destPath = AppendFileName(pacRoot, "include");
RealizeDirectory(destPath);
action = "Copying include files";
Ctrl::ProcessEvents();
files = GetDirectoryContent(AppendFileName(incDir, "*"), false);
numTk = files.GetCount();
iTk = 0;
progress.Set(iTk, numTk);
Ctrl::ProcessEvents();
for(int iFile = 0; iFile < files.GetCount(); iFile++)
{
FileCopy(AppendFileName(incDir, files[iFile]), AppendFileName(destPath, files[iFile]));
iTk++;
progress.Set(iTk, numTk);
Ctrl::ProcessEvents();
}
Vector<String> folders = GetDirectoryContent(AppendFileName(srcDir, "*"), true);
numTk = folders.GetCount();
iTk = 0;
progress.Set(iTk, numTk);
Ctrl::ProcessEvents();
for(int iFolder = 0; iFolder < folders.GetCount(); iFolder++)
{
String sPath = AppendFileName(srcDir, folders[iFolder]);
files = GetDirectoryContent(AppendFileName(sPath, "*.hxx"), false);
files.Append(GetDirectoryContent(AppendFileName(sPath, "*.h"), false));
files.Append(GetDirectoryContent(AppendFileName(sPath, "*.lxx"), false));
files.Append(GetDirectoryContent(AppendFileName(sPath, "*.gxx"), false));
for(int iFile = 0; iFile < files.GetCount(); iFile++)
FileCopy(AppendFileName(sPath, files[iFile]), AppendFileName(destPath, files[iFile]));
iTk++;
progress.Set(iTk, numTk);
Ctrl::ProcessEvents();
}
return true;
}
// create the config file
// this file will be force included on each copiler call
// using -FI (MSC) or -include (GCC), so we shall keep short
bool Oce2Upp::BuildConfig(String const &pacRoot)
{
// build OCE.h file
FileOut f(AppendFileName(pacRoot, "OCE_UPP_CONFIG.h"));
f <<
"#ifndef _OCE_UPP_CONFIG_H\n"
"#define _OCE_UPP_CONFIG_H\n"
"#ifndef _CPPRTTI\n"
"#define _CPPRTTI\n"
"#endif\n"
"#include <Core/config.h>\n"
"#ifdef PLATFORM_POSIX\n"
"#define OCE_HAVE_FSTREAM\n"
"#define OCE_HAVE_IOSTREAM\n"
"#define OCE_HAVE_IOMANIP\n"
"#define OCE_HAVE_IOS\n"
"#define OCE_HAVE_LIMITS_H\n"
"#define HAVE_SYS_STAT_H\n"
"#define HAVE_STRING_H\n"
"#define HAVE_UNISTD_H\n"
"#define HAVE_SIGNAL_H\n"
"#define HAVE_SYS_SEM_H\n"
"#define HAVE_STATFS\n"
"#define HAVE_SYS_VFS_H\n"
"#define HAVE_SYS_TIME_H\n"
"#define HAVE_SYS_TIMES_H\n"
"#define HAVE_DIRENT_H\n"
"#define HAVE_DLFCN_H\n"
"#define HAVE_PWD_H\n"
"#define HAVE_SYS_UTSNAME_H\n"
"#define HAVE_NETDB_H\n"
"#define HAVE_SYS_MMAN_H\n"
"#define OCE_LIBRARY_PREFIX \"lib\"\n"
"#define OCE_LIBRARY_DEBUG_POSTFIX \"\"\n"
"#define OCE_LIBRARY_EXTENSION \"\"\n"
"#else\n"
"#define WNT\n"
"#define OCE_IS_DUPLICATE_UINT32_T\n"
"#ifdef __APPLE__\n"
"typedef void *GLhandleARB;\n"
"#else\n"
"typedef unsigned int GLhandleARB;\n"
"#endif\n"
"typedef char GLcharARB;\n"
"#define OCE_LIBRARY_PREFIX \"\"\n"
"#define OCE_LIBRARY_DEBUG_POSTFIX \"d\"\n"
"#define OCE_LIBRARY_EXTENSION \"lib\"\n"
"#endif\n"
"#define CSFDB\n"
"#endif\n"
;
f.Close();
return true;
}
// create a main package file -- by now, dummy, just to avoid build error
bool Oce2Upp::BuildMain(String const &pacRoot)
{
FileOut f(AppendFileName(pacRoot, builderName + ".cpp"));
f <<
"int main()\n"
"{\n"
" return 0;\n"
"}\n"
;
f.Close();
return true;
}
// creates the UPP package
bool Oce2Upp::MakeBuilderPackage(void)
{
String builderFolder = AppendFileName(destRoot, builderName);
RealizeDirectory(builderFolder);
CopyIncludes(builderFolder);
// create upp package file and populate starting part
FileOut uppFile(AppendFileName(builderFolder, builderName + ".upp"));
if(!uppFile)
return false;
uppFile << "noblitz;\n";
uppFile
<< "options(MSC) \"-FI \\\"OCE_UPP_CONFIG.h\\\"\";\n"
<< "options(GCC) \"--include \\\"OCE_UPP_CONFIG.h\\\"\";\n"
;
uppFile <<
"include\n"
" ./include;\n"
;
uppFile <<
"mainconfig\n"
" \"\" = \"SO MT\";\n"
;
uppFile
<< "file\n"
<< " OCE_UPP_CONFIG.h,\n"
<< " " + builderName + ".cpp;\n"
;
// build dependent toolkits as packages
String sUpp;
action = "Generating packages";
numTk = toolkits.GetCount();
iTk = 0;
progress.Set(iTk, numTk);
Ctrl::ProcessEvents();
for(int iTool = 0; iTool < toolkits.GetCount(); iTool++)
{
iTk++;
progress.Set(iTk);
Ctrl::ProcessEvents();
// get toolkit name
String toolkit = toolkits.GetKey(iTool);
// skip unneeded toolkits
if(
toolkit == "TKDraw"
|| toolkit == "TKViewerTest"
|| toolkit == "TKDCAF"
|| toolkit == "TKQADraw"
|| toolkit == "TKTObjDRAW"
|| toolkit == "TKTopTest"
|| toolkit == "TKXDEDRAW"
|| toolkit == "TKXSDRAW"
)
continue;
// realize toolkit package path
String tkFolder = AppendFileName(destRoot, toolkit);
RealizeDirectory(tkFolder);
// add toolkit 'use' to main package
sUpp << "uses " + toolkit + ";\n";
// create toolkit package file
FileOut tkFile(AppendFileName(tkFolder, toolkit + ".upp"));
if(!tkFile)
return false;
String sTk;
tkFile << "noblitz;\n";
tkFile
<< "options(MSC) \"-FI \\\"../OCE_UPP_CONFIG.h\\\"\";\n"
<< "options(GCC) \"--include \\\"../OCE_UPP_CONFIG.h\\\"\";\n"
;
// opengl toolkit needs GL and GLU libs...
if(toolkit == "TKOpenGl")
tkFile <<
"library(WIN32) \"glu32 opengl32\";\n"
"library(LINUX) \"GL GLU\";\n"
"library(FREEBSD) \"GL GLU\";\n"
;
if(toolkit == "TKernel")
tkFile << "library(WIN32) \"user32 advapi32\";\n";
if(toolkit == "TKGeomAlgo")
tkFile << "options(WIN32) -D__AppBlend_DLL;\n";
if(toolkit == "TKFillet")
tkFile << "options(WIN32) -D__Blend_DLL;\n";
if(toolkit == "TKSTEP")
tkFile << "library(WIN32) \"Ws2_32\";\n";
if(toolkit == "TKV3d")
tkFile << "library(WIN32) \"Gdi32\";\n";
if(toolkit == "TKNIS")
tkFile <<
"library(WIN32) \"glu32 opengl32\";\n"
"library(LINUX) \"GL GLU\";\n"
"library(FREEBSD) \"GL GLU\";\n"
;
// packages (toolkits) used by this one -- aka dependencies
String tkUpp;
Vector<String> const &deps = dependencies.Get(toolkit);
for(int iDep = 0; iDep < deps.GetCount(); iDep++)
{
String const &dep = deps[iDep];
if(!dep.StartsWith("TK") && !dep.StartsWith("PTK"))
continue;
tkUpp << "\t" << dep << ",\n";
}
if(toolkit == "TKService")
tkUpp << "\tFreeType,\n";
if(tkUpp != "")
{
tkUpp = tkUpp.Left(tkUpp.GetCount() - 2) + ";\n";
tkFile << "uses\n" << tkUpp;
}
tkFile <<
"file\n"
;
// gather all packages for this toolkit
Vector<String> &pk = toolkits[iTool];
for(int iPack = 0; iPack < pk.GetCount(); iPack++)
{
String const &package = pk[iPack];
#ifdef PLATFORM_POSIX
if(package == "WNT")
continue;
#else
if(package == "Xw")
continue;
#endif
sTk << " \" PACKAGE:" << package << "\" readonly separator,\n";
// get source folders for current package
String srcPath = AppendFileName(srcDir, package) + "/";
String drvPath = AppendFileName(drvDir, package) + "/";
Vector<String> files;
files = GetDirectoryContent(srcPath + "*.cxx", false);
files.Append(GetDirectoryContent(srcPath + "*.cpp", false));
files.Append(GetDirectoryContent(srcPath + "*.c", false));
Sort(files);
for(int iFile = 0; iFile < files.GetCount(); iFile++)
{
String fName = files[iFile];
sTk << " " << AppendFileName(srcPath, fName) << "\n";
sTk << " options() -I" << srcPath << "\n";
sTk << " options() -I" << drvPath << ",\n";
}
files = GetDirectoryContent(drvPath + "*.cxx", false);
files.Append(GetDirectoryContent(drvPath + "*.cpp", false));
files.Append(GetDirectoryContent(drvPath + "*.c", false));
Sort(files);
for(int iFile = 0; iFile < files.GetCount(); iFile++)
{
String fName = files[iFile];
sTk << " " << AppendFileName(drvPath, fName) << "\n";
sTk << " options() -I" << srcPath << "\n";
sTk << " options() -I" << drvPath << ",\n";
}
}
if(sTk != "")
{
sTk = sTk.Left(sTk.GetCount() - 2) + ";\n";
tkFile << sTk;
}
tkFile.Close();
}
if(sUpp != "")
{
sUpp = sUpp.Left(sUpp.GetCount() - 2) + ";\n";
uppFile << sUpp;
}
uppFile.Close();
// create the config file
BuildConfig(builderFolder);
// create main file
BuildMain(builderFolder);
return true;
}
// creates the UPP OCE package
bool Oce2Upp::MakeOCEPackage(void)
{
String pacFolder = AppendFileName(destRoot, oceName);
RealizeDirectory(pacFolder);
String includeDest = AppendFileName(pacFolder, "include");
RealizeDirectory(includeDest);
// copy all include files from builder package here
// so we don't need them in some system place....
String includeFolder = AppendFileName(destRoot, builderName + "/include");
Vector<String> includes = GetDirectoryContent(AppendFileName(includeFolder, "*"), false);
iTk = 0;
numTk = includes.GetCount();
progress.Set(iTk, numTk);
action = "Copying include files";
Ctrl::ProcessEvents();
for(int iInc = 0; iInc < includes.GetCount(); iInc++)
{
FileCopy(AppendFileName(includeFolder, includes[iInc]), AppendFileName(includeDest, includes[iInc]));
iTk++;
progress.Set(iTk);
Ctrl::ProcessEvents();
}
// patch a file wich clashes with UPP
// problem is in global IsEqual template that clashes with UPP::IsEqual one
String s = LoadFile(AppendFileName(includeDest, "NCollection_DefaultHasher.hxx"));
int pos = s.Find("return IsEqual(theKey1, theKey2);");
if(pos >= 0)
s.Insert(pos+7, "::");
SaveFile(AppendFileName(includeDest, "NCollection_DefaultHasher.hxx"), s);
// build OCE.h file
FileOut f(AppendFileName(pacFolder, "OCE.h"));
f <<
"#ifndef _OCE_H\n"
"#define _OCE_H\n"
"#include \"include/oce-config.h\"\n"
"#endif\n"
;
f.Close();
// create upp package files
action = "Creating package files";
iTk = 0;
numTk = 6;
progress.Set(iTk, numTk);
Ctrl::ProcessEvents();
FileOut uppFile;
uppFile.Open(AppendFileName(pacFolder, oceName + ".upp"));
s = (const char *)OCE_UPP;
uppFile << s;
uppFile.Close();
progress.Set(++iTk);
Ctrl::ProcessEvents();
uppFile.Open(AppendFileName(pacFolder, "OCE.h"));
s = (const char *)OCE_H;
uppFile << s;
uppFile.Close();
progress.Set(++iTk);
Ctrl::ProcessEvents();
uppFile.Open(AppendFileName(pacFolder, "OCEDoc.h"));
s = (const char *)OCEDoc_H;
uppFile << s;
uppFile.Close();
progress.Set(++iTk);
Ctrl::ProcessEvents();
uppFile.Open(AppendFileName(pacFolder, "OCEDoc.cpp"));
s = (const char *)OCEDoc_CPP;
uppFile << s;
uppFile.Close();
progress.Set(++iTk);
Ctrl::ProcessEvents();
uppFile.Open(AppendFileName(pacFolder, "OCECtrl.h"));
s = (const char *)OCECtrl_H;
uppFile << s;
uppFile.Close();
progress.Set(++iTk);
Ctrl::ProcessEvents();
uppFile.Open(AppendFileName(pacFolder, "OCECtrl.cpp"));
s = (const char *)OCECtrl_CPP;
uppFile << s;
uppFile.Close();
progress.Set(++iTk);
Ctrl::ProcessEvents();
return true;
}
// callbacks
void Oce2Upp::cancelCb(void)
{
canceled = true;
Break(0);
}
void Oce2Upp::okCb(void)
{
progress.Set(0, 100);
progress.Show();
action = "";
// check if source folder exists and is an OCE root
if(
!DirectoryExists(~sourceFolder) ||
!DirectoryExists(AppendFileName(~sourceFolder, "inc")) ||
!DirectoryExists(AppendFileName(~sourceFolder, "src")) ||
!DirectoryExists(AppendFileName(~sourceFolder, "drv")) ||
!DirectoryExists(AppendFileName(~sourceFolder, "adm"))
)
{
Exclamation("[= Error&Source folder is not an OCE root]");
return;
}
oceRoot = ~sourceFolder;
destRoot = ~destFolder;
// we got source and dest path, we can proceed
// build various path names
admDir = AppendFileName(oceRoot, "adm");
incDir = AppendFileName(oceRoot, "inc");
srcDir = AppendFileName(oceRoot, "src");
drvDir = AppendFileName(oceRoot, "drv");
progress.Show();
// generated pakages
builderName = "OCEBUILDER";
oceName = "OCE";
destRoot = AppendFileName(destRoot, builderName);
// create database
action = "Creating database";
Ctrl::ProcessEvents();
if(!BuildDb())
{
action = "Error building database";
Ctrl::ProcessEvents();
Exclamation(String(~action));
return;
}
if(!MakeBuilderPackage())
{
action = "ERRROR BUILDING UPP PACKAGE";
Ctrl::ProcessEvents();
return;
}
if(!MakeOCEPackage())
{
action = "ERRROR BUILDING OCE PACKAGE";
Ctrl::ProcessEvents();
return;
}
action = "PACKAGE OCE GENERATED";
Ctrl::ProcessEvents();
}
Oce2Upp::Oce2Upp()
{
CtrlLayout(*this);
goButton.Ok() <<= THISBACK(okCb);
cancelButton.Cancel() <<= THISBACK(cancelCb);
// hide progess and empty action
progress.Hide();
action = "";
// not canceling
canceled = false;
}
Oce2Upp::~Oce2Upp()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////
GUI_APP_MAIN
{
Oce2Upp oce2Upp;
String cfgfile = ConfigFile();
if(FileExists(cfgfile))
LoadFromFile(oce2Upp, cfgfile);
oce2Upp.Run();
StoreToFile(oce2Upp, cfgfile);
}

79
bazaar/Oce2Upp/Oce2Upp.h Executable file
View file

@ -0,0 +1,79 @@
#ifndef _Oce2Upp_Oce2Upp_h
#define _Oce2Upp_Oce2Upp_h
#include <CtrlLib/CtrlLib.h>
#include <Controls4U/Controls4U.h>
using namespace Upp;
#define LAYOUTFILE <Oce2Upp/Oce2Upp.lay>
#include <CtrlCore/lay.h>
class Oce2Upp : public WithSelectorLayout<TopWindow>
{
private:
bool canceled;
// root OCE folder and various subfolders
String oceRoot;
// various needed subfolder
String admDir, incDir, srcDir, drvDir;
// root for generated packages
String destRoot;
// name of builder package (and assembly name too)
String builderName;
// name of OCE user package
String oceName;
// maps toolkits to packages
VectorMap<String, Vector<String> > toolkits;
// packages dependencies
VectorMap<String, Vector<String> > dependencies;
// Gets directory content
Vector<String> GetDirectoryContent(const String &Path, bool Folders);
// reads an UDLIST file to gather modules/toolkits mapping
bool ReadUDLIST(void);
// builds database
bool BuildDb(void);
// copy include files from inc and various src folders
// in 'include' folder
bool CopyIncludes(String const &pacRoot);
// create the oce-config.h
bool BuildConfig(String const &pacRoot);
// create a main package file -- by now, dummy, just to avoid build error
bool BuildMain(String const &pacRoot);
// creates the UPP library builder package
bool MakeBuilderPackage(void);
// creates the UPP OCE package
bool MakeOCEPackage(void);
// callbacks
void okCb(void);
void cancelCb(void);
protected:
public:
typedef Oce2Upp CLASSNAME;
Oce2Upp();
~Oce2Upp();
};
#endif

12
bazaar/Oce2Upp/Oce2Upp.lay Executable file
View file

@ -0,0 +1,12 @@
LAYOUT(SelectorLayout, 576, 200)
ITEM(Label, dv___0, SetLabel(t_("OpenCascade OCE Upp Packager")).SetAlign(ALIGN_CENTER).SetFont(StdFontZ(16).Bold()).RightPosZ(4, 568).TopPosZ(4, 27))
ITEM(Label, dv___1, SetLabel(t_("Generated packages dest folder :")).LeftPosZ(4, 216).TopPosZ(80, 27))
ITEM(Button, cancelButton, SetLabel(t_("Cancel")).RightPosZ(4, 68).BottomPosZ(5, 19))
ITEM(Button, goButton, SetLabel(t_("Generate")).LeftPosZ(4, 68).BottomPosZ(5, 19))
ITEM(EditFolder, destFolder, HSizePosZ(228, 4).TopPosZ(80, 19))
ITEM(ProgressIndicator, progress, HSizePosZ(4, 4).BottomPosZ(36, 24))
ITEM(StaticText, action, HSizePosZ(4, 4).BottomPosZ(64, 20))
ITEM(Label, dv___7, SetLabel(t_("OpenCascade root folder :")).LeftPosZ(4, 216).TopPosZ(44, 27))
ITEM(EditFolder, sourceFolder, HSizePosZ(228, 4).TopPosZ(48, 19))
END_LAYOUT

21
bazaar/Oce2Upp/Oce2Upp.upp Executable file
View file

@ -0,0 +1,21 @@
uses
CtrlLib,
Controls4U;
options(WIN32) -DPIPPO=gigi;
file
OCE_UPP,
OCE_H,
OCEDoc_H,
OCEDoc_CPP,
OCECtrl_H,
OCECtrl_CPP,
Oce2Upp.brc,
Oce2Upp.lay,
Oce2Upp.h,
Oce2Upp.cpp;
mainconfig
"" = "GUI";

12
bazaar/Oce2Upp/Oce2Upp2014.lay Executable file
View file

@ -0,0 +1,12 @@
LAYOUT(SelectorLayout, 576, 200)
ITEM(Label, dv___0, SetLabel(t_("OpenCascade OCE Upp Packager")).SetAlign(ALIGN_CENTER).SetFont(StdFontZ(16).Bold()).RightPosZ(4, 568).TopPosZ(4, 27))
ITEM(Label, dv___1, SetLabel(t_("Generated packages dest folder :")).LeftPosZ(4, 216).TopPosZ(80, 27))
ITEM(Button, cancelButton, SetLabel(t_("Cancel")).RightPosZ(4, 68).BottomPosZ(5, 19))
ITEM(Button, goButton, SetLabel(t_("Generate")).LeftPosZ(4, 68).BottomPosZ(5, 19))
ITEM(EditFolder, destFolder, HSizePosZ(228, 4).TopPosZ(80, 19))
ITEM(ProgressIndicator, progress, HSizePosZ(4, 4).BottomPosZ(36, 24))
ITEM(StaticText, action, HSizePosZ(4, 4).BottomPosZ(64, 20))
ITEM(Label, dv___7, SetLabel(t_("OpenCascade root folder :")).LeftPosZ(4, 216).TopPosZ(44, 27))
ITEM(EditFolder, sourceFolder, HSizePosZ(228, 4).TopPosZ(48, 19))
END_LAYOUT

5
bazaar/Oce2Upp/init Executable file
View file

@ -0,0 +1,5 @@
#ifndef _Oce2Upp_icpp_init_stub
#define _Oce2Upp_icpp_init_stub
#include "CtrlLib/init"
#include "Controls4U/init"
#endif