../dox/Applications.dox

BasicStructure
GUI-GTK                        Userinterface
Userinteractions               Keyboard, Selections
ApplicationObjects
ApplicationData

BasicStructure

Howto create a new plugin:

cp Demosimple.c myProg.c
cp Demosimple.mak myProg.mak
change "Demosimple" into "myProg" in myProg.mak
link the plugin (must be linked manually for the first time) with:
make -f myProg.mak "OS=Linux32"
start gCAD3D
activate Options/compile DLL's  (or start gCAD3D with option "comp")
  (this automatically recompiles and links the plugin before starting)
start the plugin (select it in the list in the upper-right corner)
modify myProg.c
restart myProg (now with Ctrl-P)
..

//

Example:

//  Demosimple.c                   Simple-DLL-Demo  (minimum)


#include "MS_Def1.h"

#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      WC_modnam[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",WC_modnam);


  // finish application
  gCad_fini ();

  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  ==================================

Userinteractions

-keyboard
-selections



  //----------------------------------------------------------------
  // Example:
  // prototypes fuer user-functions (selection-callback, keyboard-callback):
  int my_selection_callback (int src, long dl_ind);
  int my_key_CB (int key) {

  int gCad_main () {
    // attach selection-callback to function my_selection_callback
    AP_UserSelection_get (my_selection_callback);
    // attach keyboard-callback to function my_key_CB
    AP_UserKeyIn_get (my_key_CB);
    ..
  }



  //----------------------------------------------------------------
  // callback-Funktion for the selections:
  #include "../gr/ut_DL.h"               // DL_GetAtt
  #include "../gr/ut_GL.h"               // GL_GetViewPos
  #include "../ut/ut_geo.h"              // Point, TYP_EvMouseL ..

  int my_selection_callback (int src, long dl_ind) {
    // Input:
    //   src: TYP_EvMouseL = left mousebutton, TYP_EvMouseM = middle, TYP_EvMouseR
    //   dl_ind - displayListIndex of the selected object

    Point  pt1;
    DL_Att att1;

    // exit w. right mousebutton
    if(src == TYP_EvMouseL) {
      gCad_fini();
      return 0;
    }

    if(dl_ind < -1) {    // indicate; no objekt selected ..
      pt1 = GL_GetViewPos ();    // get curr. cursorposition as Point
      UT3D_stru_dump (Typ_PT, &pt1, "indicatedPos=");
      printf("%s\n",UI_GR_get_actPos_());  // get curPos as string "<x> <y> <z>"


    } else {                     // user has selected obj
      att1 = DL_GetAtt(dl_ind);  // get the dispListRecord
      printf("selected objectTyp =  %d\n",att1.typ);
      printf("DB-Index of selected object = %d\n",att1.ind);
    }

  }

  // see DevDoc ResolveObjects/Get_DispListObject \ref Get_DispListObject



  //----------------------------------------------------------------
  // callback-Funktion for keyboard-input:
  #include <gdk/gdkkeysyms.h>          // GDK_Escape ..

  int my_key_CB (int key) {
    // input = keycode

    switch (key) {
      case GDK_Escape:
        gCad_fini ();
        break;

      case 'q':
        gCad_fini ();
        break;
    }
  }



  //----------------------------------------------------------------
  int gCad_fini () {
    // reset all interactions with:
    AP_User_reset ();
    ..
  }


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






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;


// 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:
  dla = DL_GetAtt(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

../dox/ApplicationData.dox



Daten für Zusatzanwendungen können in einem Block "ApplicationData"
  gespeichert werden. ApplicationData werden mit den nativen Modelldaten
  gespeichert.
  Die Applikation muss beim Verlassen der Anwendung die Daten in eine
    Datei <tempDir>/<appNam>.appdat schreiben.
  Der Applikationsname <appNam> ist frei wählbar.


Format of data:
<parameterName> <parametervalue>
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



Funktionen:
#define APP_NAME  "TestApp1"
char    fNam[256], parval[160];
// Write: UTX_setup_add     TO-BE-DONE !
// Read:
sprintf(fNam, "%s%s.appdat",OS_get_tmp_dir(),APP_NAME);
UTX_setup_get (parval, "parametername", fNam);



affected functions:
Mod_kill__     löschen
Mod_load__     laden
Mod_sav__      speichern

Generated on Fri Apr 6 09:40:11 2012 for gCAD3D by  doxygen 1.6.3