gCAD3D 2.40

../../doc/gcad_doxygen/Plugins.dox

BasicStructure
GUI                            Userinterface
ApplicationObjects
ApplicationData
Global-CAD-Datafields
----------------------------------
Constants
Standards-Tolerences-Modelsize

GUI

Sourcefiles_gui

Simple example:

// Demosimple.c Simple-DLL-Demo (minimum)
/*
*
* Copyright (C) 2015 CADCAM-Services Franz Reiter (franz.reiter@cadcam.co.at)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
-----------------------------------------------------
TODO:
..
-----------------------------------------------------
Modifications:
..
-----------------------------------------------------
*//*----------------------------------------
*/
#ifdef _MSC_VER
#include "../xa/MS_Def1.h"
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../ut/ut_TX.h" // TX_Print
#ifdef _MSC_VER
// export this functions
__declspec(dllexport) int gCad_main ();
__declspec(dllexport) int gCad_fini ();
// import functions exported from the core (see gCAD3D.def)
#define extern __declspec(dllimport)
#endif
// ext aus xa.c:
extern char AP_mod_fnam[128]; // der Modelname
//=========================================================
int gCad_main () {
//=========================================================
// user has selected this plugin; starting ...
printf("gCad_main Demosimple 1\n");
// write to Main-Infowindow ..
TX_Print("gCad_main out of Demosimple.dll");
// get modelname from Mainprog
printf("Modelname = %s\n",AP_mod_fnam);
// finish application
return 0;
}
//=========================================================
int gCad_fini () {
//=========================================================
// dll being unloaded - reset Input, kill all open windows !!!
printf("gCad_fini Demosimple\n");
// write to Main-Infowindow ..
TX_Print("...... gCad_fini Demosimple");
AP_User_reset (); // close application
return 0;
}
//================ EOF ==================================

Example with gui:

// Simple-Gtk-Demo (minimum)
/*
*
* Copyright (C) 2015 CADCAM-Services Franz Reiter (franz.reiter@cadcam.co.at)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
-----------------------------------------------------
TODO:
..
-----------------------------------------------------
Modifications:
..
-----------------------------------------------------
*//*----------------------------------------
*/
#ifdef _MSC_VER
#include "../xa/MS_Def1.h"
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../ut/ut_cast.h" // INT_PTR
#include "../ut/ut_types.h" // INT_8 - UINT_64
#include "../ut/ut_umem.h" // Memspc MemObj UME_*
#include "../gui/gui__.h"
#ifdef _MSC_VER
// die folgenden 2 Funktionen exportieren (werden vom Main gerufen):
__declspec(dllexport) int gCad_main ();
__declspec(dllexport) int gCad_fini ();
// nachfolgende externals werden aus dem Main-Exe imported:
#define extern __declspec(dllimport)
#endif
static MemObj win0;
//=========================================================
int gCad_main () {
//=========================================================
// user has selected this plugin; starting ...
TX_Print("gCad_main DemoGtk1");
win1__ (NULL, GUI_SETDAT_E (UI_FuncInit)); // create window
// set EVENT=UI_FuncInit; see ../gui/gui_types.h
return 0;
}
//=========================================================
int gCad_fini () {
//=========================================================
// dll being unloaded - reset Input, kill all open windows !!!
TX_Print("...... gCad_fini DemoGtk1");
GUI_Win_kill (&win0);
AP_User_reset (); // close application
return 0;
}
//=========================================================
int win1__ (MemObj *mo, void **data) {
//=========================================================
MemObj box0;
char *cp1;
printf("win1__ %d\n",GUI_DATA_EVENT);
switch (GUI_DATA_EVENT) {
win0 = GUI_Win__ ("Gtk1", win1__, "");
box0 = GUI_box_v (&win0, "");
GUI_button__ (&box0, "Test Button", win1__, &GUI_FuncUCB1, "");
GUI_Win_go (&win0);
break;
case TYP_EventPress: // 99
if(GUI_DATA_I1 == UI_FuncUCB1) {
printf(" do UI_FuncUCB1\n");
}
break;
case TYP_EventExit: // from GUI_Win__
break;
}
return 0;
}
//================ EOF ==================================

ApplicationObjects

../dox/ApplicationObjects.dox
<h2>ApplicationObjects</h2>
Darstellung von Applikationsspezifischen Objekten in Zusatzanwendungen.
Die Funktion zur Darstellung des Objekts liegt in der Zusatzanwendung.
Die Funktion hat Zugriff auf OpenGL.
Die Objekte sind somit nur mit der Zusatzanwendung darstellbar.
ApplicationObjects werden nicht in der Datenbasis gespeichert,
sie müssen als ApplicationData gespeichert werden oder normalen
Standardobjekten hinterlegt werden.
ApplicationObjects in der DispList: (DL_Att .)
alle: .typ Typ_APPOBJ.
Objekttypspezifisch: .iatt; zB. subTyp; 0=point, 1=line, 2=image ..
Objektspezifisch: .ind; zB. ID, ObjNr.
Funktionen:
AP_UserAppObjNamTab // provide names for application-objects
// wie diese Objects in der Multi-SelektionsListe angezeigt werden ..
Beispiele:
APP_GIS1 gis_DrawPoint gis_DrawEL gis_EL_disp gis_sel_CB
Example:
long dli = -1L; // init; i1=dispList-record not yet exists.
int subTyp = 1; // dla.iatt
int objId = 1; // dla.ind
DL_SetObj (&dli, Typ_APPOBJ, objId, subTyp);
GL_DrawPoly (&dli, Typ_Att_hili1, pNr, pa);
or
// hide obj
DL_unvis_set (dli, 1); // 0=vis, 1=unvis
// delete all appObj's with all objId's with with <subTyp>
GL_Del_om (Typ_APPOBJ, -1L, subTyp);
Examples:
#define APPTYP_XY 0
#define APPTYP_XZ 1
static APP_OBJ_NAM appObjNamTab[]={
{"XY-Obj", APPTYP_XY}, // 0
{"XZ-Obj", APPTYP_XZ}, // 1
{"",-1}
};
long id, dli;
AP_UserAppObjNamTab (appObjNamTab); // provide names for application-objects
// create App-Obj:
id = 123;
// test if App-Obj with this id already exists in the DispList
dli = DL_find_APPOBJ (id, APPTYP_PT);
if(dli >= 0) DL_SetInd (dli); // modify (do not create new DL-Record)
dli = DL_StoreObj (Typ_APPOBJ, id, APPTYP_XY); // create/modify DL-Record
GL_DrawSymB (&id, 2, SYM_TRI_S, &p1); // red triangle
// Test for App-Obj:
DL_get_dla (&dla, dli);
if(dla.typ == Typ_APPOBJ) ..
// Test subTyp of App-Obj:
if(dla.iatt == APPTYP_XY) ..
// get ID of App-Obj:
id = dla.ind;
if(id == 123) ..
// find App-Obj:
id = 123;
dli = DL_find_APPOBJ (id, APPTYP_XY);
// delete App-Obj
if(dli >= 0) GL_Del0 (dli);
// delete all App-Obj's of typ APPTYP_XY:
GL_Del_om (Typ_APPOBJ, -1L, APPTYP_XY);
GL_Regen1 (); // reset DL

ApplicationData

../../doc/gcad_doxygen/ApplicationData.txt
Daten für Zusatzanwendungen (ApplicationData) können im Model gespeichert werden.
ApplicationData werden beim Laden eines Models wieder zur Verfügung gestellt.
Die Applikation muss vor dem Verlassen der Anwendung die Daten schreiben.
Die Daten sind als ascii-text zu schreiben.
ApplicationData is stored with the model (as ascii-text).
Store ApplicationData:
open file with appdat_open__(&fp, "w")
write data (as ascii-text !)
Restore ApplicationData:
open file with appdat_open__(&fp, "r")
read data (as ascii-text !)
See demo-application ../APP/Demo_appDat1.c
Datei <tempDir>/<appNam>.appdat schreiben.
Der Applikationsname <appNam> ist frei wählbar.
------------------------------------------------------------------------
- a direct way to store binary data ..
if value == "BINDATA" + <sizeInBytes>\n then next line is binary data.
------------------------------------------------------------------------
Formatbeschreibung ApplicationData:
Die Zeilen SECTION und SECTIONEND befinden sich nur in der Modelldatei.
SECTION APPDAT <appNam>
.. (data)
SECTIONEND
affected functions:
Mod_kill__ löschen
Mod_sav__ speichern

Global-CAD-Datafields

// def. in ../xa/xa.c or include ../xa/xa.h
extern char WC_modnam[128]; // der Modelname
extern char WC_modact[128]; // name of the active submodel; def="" (main)
extern char AP_printer[80];
extern char AP_browser[64];
extern char AP_dir_open[128];
extern char AP_lang[4]; // en od de ..
// def. in ../xa/xa.c
extern Plane WC_sur_act; // act. constr.plane
extern Mat_4x3 WC_sur_mat; // TrMat of ActiveConstrPlane
extern Mat_4x3 WC_sur_imat; // inverse TrMat of ActiveConstrPlane
// def. in ../ci/NC_Main.c:
extern double APT_ModSiz; // Modelsize; Basiswert fuer Toleranzberechnung
// def. in ../ut/ut_tol_const.h or include ../ut/ut_geo.h
extern double UT_TOL_pt // Tolerance identical points
extern double UT_TOL_ln // Tolerance minimal lineLength
extern double UT_TOL_cv // Toleranz max. Abweichung Berechnung Kurven
extern double UT_DISP_cv // Toleranz max. Abweichung Darstellung Kurven
extern double UT_DISP_ln // length of construction-lines
// ../xa/xa_ui.c:
extern int KeyStatShift;
extern int KeyStatCtrl;