// $Source: /usr/local/SimSoft/Sfx3D/src/gts/gtsgraf.cpp,v $
// $Revision: 1.2 $
// $Author: baum $
// $Date: 2001/11/29 15:18:10 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-14 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: gtsgraf.cpp,v $
// Revision 1.2  2001/11/29 15:18:10  baum
// -Realzeitsteuerung eingebaut
// -Handsteuerung eingebaut
//

/*** Windows headers ***/
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
//#include <winnt.h>
#endif /*WIN32*/

//#include <stdlib.h>
//#include <string.h>

#include "gtsglob.h"
//#include "gtstgb.h"

#include "XGraph/AllPrims.h"
#include "XGraph/XGraph.h"
#include "XGraph/AllViews.h"

#include "gtsgui.h"
#include "gtsgraf.h"

#include "Messager.h"


int MyMsgHandleFunc (int msgType, const char* txt) {
  char buf[255];
  if (msgType == MSG_WARNING)
    sprintf(buf, "tk_messageBox -title Warning -icon warning "
                 "-type ok -message {%s}", txt);
  else
    sprintf(buf, "tk_messageBox -title Error -icon error "
                 "-type ok -message {%s}", txt);
  if (GTSInterpreter)
    Tcl_Eval (GTSInterpreter, buf);
  return 1;
}

void alt______InitGrafik ()
{
    GTSSpace     = new Space ();

    RGBAColor bgCol(1.0, 1.0, 1.0);

/*    GTSView = new ToglView (0, 0, 150, 150, bgCol, ".action.draw.drawXY.drawX");
    // 1. Kamera-Position
    // 2. BlickrichtungsMittelpunkt
    // 3. Vektor fuer oben
    GTSView->setCameraPos (Vec3D (-20.0, 0.0, 0.0), Vec3D(), EZ);
    GTSSpace->insertView (*GTSView);

    GTSView = new ToglView (0, 0, 150, 150, bgCol, ".action.draw.drawXY.drawY");
    // 1. Kamera-Position
    // 2. BlickrichtungsMittelpunkt
    // 3. Vektor fuer oben
    GTSView->setCameraPos (Vec3D (0.0, -20.0, 0.0), Vec3D(), EZ);
    GTSSpace->insertView (*GTSView);
*/
    // TopView
    GTSView = new ToglView (0, 0, 800, 800, bgCol, ".action.draw.drawZ");
    // 1. Kamera-Position
    // 2. BlickrichtungsMittelpunkt
    // 3. Vektor fuer oben
    GTSView->Camera()->setCamera (Vec3D (0.0, 0.0, 40.0), Vec3D(), EY);
    GTSSpace->insertView (*GTSView);
    GTSView->setGrid (2.0, Vec3D (0.0, 0.0, -0.2), Vec3D (20.0, 20.0, -0.2));
    GTSView->setCallback (&GTSCB);
    GTSView->lightOn ();
} // InitGrafik


typBSTGrafik::typBSTGrafik ()
{ } // typBSTGrafik

typBSTGrafik::~typBSTGrafik ()
{ } // ~typBSTGrafik

void InitGrafik ()
{
  GTSSpace        = new Space ();
//  if (GTSSpace->MySelection()->hasTotalMarkBox())
  GTSSpace->MySelection()->hideTotalMarkBox();
  MainViewHandler = new SFXViewHandler (GTSInterpreter);
  MainViewHandler->createView (0, 0);
  MainViewHandler->poseView();
} // InitGrafik

void ExitGrafik ()
{
  Pattern::clean ();
  delete MainViewHandler;
  delete GTSView;
  delete GTSSpace;
} // ExitGrafik
