<commit_before>// @(#)root/g3d:$Name: v3-03-09 $:$Id: TPadOpenGLView.cxx,v 1.8 2002/06/13 13:43:27 rdm Exp $
// Author: <NAME>(<EMAIL>)   08/05/97

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TPadOpenGLView                                                       //
//                                                                      //
// TPadOpenGLView is a window in which an OpenGL representation of a    //
// pad is viewed.                                                       //
//                                                                      //
// Seven different OpenGL lists are used to draw a 3D object:           //
//                                                                      //
// fGLList + kLightOpt   - defines the "light" options to build thr GL  //
//                         light model                                  //
// fGLList + kColorOpt   - defines the "color" options                  //
// fGLList + kScene      - defines the common object for the resize and //
//                         re-paint operations                          //
// fGLList + kProject    - defines the "Projection" transformation.     //
//                         It is affected by the rotate operations.     //
// fGLList + kView       - defines the "Viewing" transformation         //
// fGLList + kUpdateView - defines the corrections for the "Viewing"    //
//                         transformation                               //
// fGLList + kModel      - defines the "Modeling" transformations       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TVirtualGL.h"
#include "TPadOpenGLView.h"
#include "TVirtualPad.h"
#include "TView.h"
#include "TGLViewerImp.h"
#include "TGeometry.h"
#include "TPolyMarker3D.h"
#include "TPolyLine3D.h"
#include "TNode.h"
#include "TStopwatch.h"
#include "TSystem.h"

// ClassImp(TPadOpenGLView)

//____________________________________________________________________________
TPadOpenGLView::TPadOpenGLView(TVirtualPad *pad) : TPadView3D(pad), fGLViewerImp(0)
{
   fGLViewerImp = gVirtualGL->CreateGLViewerImp(this,pad->GetTitle(), pad->GetWw(), pad->GetWh());
   fGLViewerImp->CreateContext();
   fGLViewerImp->MakeCurrent();

   Int_t i;
   for (i=0;i<3;i++) {
      fExtraAngles[i] = 0;
      fExtraTranslate[i] = 0;
      fAnglFactor[i] = 1;
   }

//    fExtraAngles[1] = -90;
    fScale = 1.0;

    fSpeedMove   = 0.02;
    fResetView   = kTRUE;
    fPerspective = kFALSE;
    fStereoFlag  = kFALSE;

    SetPad(pad);

    MapOpenGL();

//*-* Set the indentity matrix as a extra rotations
    for (i=1;i<15;i++)  fExtraRotMatrix[i] = 0;
    for (i=0;i<16;i+=5) fExtraRotMatrix[i] = 1.0;
}

//____________________________________________________________________________
TPadOpenGLView::~TPadOpenGLView()
{
    // Protect implementation

    TGLViewerImp *viewer = fGLViewerImp;
    fGLViewerImp = 0;
    // break the view / viewer relationship
    if (viewer) viewer->Disconnect();
    if (!fParent) {
       delete viewer;
       return;
    }
//*-*  Delete OpenGL lists;
   if (viewer) {
#ifdef STEREO_GL
      if (fStereoFlag) {
         const char *turnStereo = gSystem->Getenv("OffRootStereo");
         if (turnStereo) gSystem->Exec(turnStereo);
         fStereoFlag = kFALSE;
      }
#endif
      if (fGLList) {
         // causes crash if more than one viewer is open at a time
         //gVirtualGL->DeleteGLLists(fGLList,kGLListSize);
         fGLList =0;
      }
      delete viewer;
   }
}

//____________________________________________________________________________
void TPadOpenGLView::ExecuteEvent(Int_t event, Int_t px, Int_t py)
{

    if (GetPad() && !GetPad()->IsEditable()) return;

    switch ((EEventType)event)
    {
    case kButton1Down:
//*-* Save the start coordinates
        fMouseInit=kTRUE;
        fMouseX = px;
        fMouseY = py;
        break;
    case kKeyPress :
        {
            Char_t chCharCode = (Char_t) px;
//            if (chCharCode != '+' || chCharCode != '-') chCharCode |= 0x20;
            MoveModelView(chCharCode, py);
            break;
        }
    case kButton1Up:
        if (!fMouseInit) break;
        fMouseInit=kFALSE;
        RotateView(px,py);
        fMouseX = px;
        fMouseY = py;
        PaintScene();
        break;
    case kButton1Motion:
        if (!fMouseInit) break;
        RotateView(px,py);
        fMouseX = px;
        fMouseY = py;
        PaintScene();
        break;
    default:
        break;
    };
}

//____________________________________________________________________________
void TPadOpenGLView::MapOpenGL()
{
//*-* Set the default attributes
   gVirtualGL->EnableGL(kDEPTH_TEST);
   gVirtualGL->EnableGL(kCULL_FACE);

   gVirtualGL->PolygonGLMode(kFRONT,kFILL);

#ifdef Inventor
   // "Default light" with Inventor is "native" Inventor
   gVirtualGL->SetRootLight(kFALSE);
#else
   // "Default light" with no Inventor is "ROOT artificial" light
   gVirtualGL->SetRootLight(kTRUE);
#endif


   gVirtualGL->FrontGLFace(kCCW);
<commit_msg>add ifdef for R__QT to set lightsource (same as for Inventor).<commit_after>// @(#)root/g3d:$Name:  $:$Id: TPadOpenGLView.cxx,v 1.9 2002/11/13 07:55:48 brun Exp $
// Author: <NAME>(<EMAIL>)   08/05/97

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TPadOpenGLView                                                       //
//                                                                      //
// TPadOpenGLView is a window in which an OpenGL representation of a    //
// pad is viewed.                                                       //
//                                                                      //
// Seven different OpenGL lists are used to draw a 3D object:           //
//                                                                      //
// fGLList + kLightOpt   - defines the "light" options to build thr GL  //
//                         light model                                  //
// fGLList + kColorOpt   - defines the "color" options                  //
// fGLList + kScene      - defines the common object for the resize and //
//                         re-paint operations                          //
// fGLList + kProject    - defines the "Projection" transformation.     //
//                         It is affected by the rotate operations.     //
// fGLList + kView       - defines the "Viewing" transformation         //
// fGLList + kUpdateView - defines the corrections for the "Viewing"    //
//                         transformation                               //
// fGLList + kModel      - defines the "Modeling" transformations       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TVirtualGL.h"
#include "TPadOpenGLView.h"
#include "TVirtualPad.h"
#include "TView.h"
#include "TGLViewerImp.h"
#include "TGeometry.h"
#include "TPolyMarker3D.h"
#include "TPolyLine3D.h"
#include "TNode.h"
#include "TStopwatch.h"
#include "TSystem.h"

// ClassImp(TPadOpenGLView)

//____________________________________________________________________________
TPadOpenGLView::TPadOpenGLView(TVirtualPad *pad) : TPadView3D(pad), fGLViewerImp(0)
{
   fGLViewerImp = gVirtualGL->CreateGLViewerImp(this,pad->GetTitle(), pad->GetWw(), pad->GetWh());
   fGLViewerImp->CreateContext();
   fGLViewerImp->MakeCurrent();

   Int_t i;
   for (i=0;i<3;i++) {
      fExtraAngles[i] = 0;
      fExtraTranslate[i] = 0;
      fAnglFactor[i] = 1;
   }

//    fExtraAngles[1] = -90;
    fScale = 1.0;

    fSpeedMove   = 0.02;
    fResetView   = kTRUE;
    fPerspective = kFALSE;
    fStereoFlag  = kFALSE;

    SetPad(pad);

    MapOpenGL();

//*-* Set the indentity matrix as a extra rotations
    for (i=1;i<15;i++)  fExtraRotMatrix[i] = 0;
    for (i=0;i<16;i+=5) fExtraRotMatrix[i] = 1.0;
}

//____________________________________________________________________________
TPadOpenGLView::~TPadOpenGLView()
{
    // Protect implementation

    TGLViewerImp *viewer = fGLViewerImp;
    fGLViewerImp = 0;
    // break the view / viewer relationship
    if (viewer) viewer->Disconnect();
    if (!fParent) {
       delete viewer;
       return;
    }
//*-*  Delete OpenGL lists;
   if (viewer) {
#ifdef STEREO_GL
      if (fStereoFlag) {
         const char *turnStereo = gSystem->Getenv("OffRootStereo");
         if (turnStereo) gSystem->Exec(turnStereo);
         fStereoFlag = kFALSE;
      }
#endif
      if (fGLList) {
         // causes crash if more than one viewer is open at a time
         //gVirtualGL->DeleteGLLists(fGLList,kGLListSize);
         fGLList =0;
      }
      delete viewer;
   }
}

//____________________________________________________________________________
void TPadOpenGLView::ExecuteEvent(Int_t event, Int_t px, Int_t py)
{

    if (GetPad() && !GetPad()->IsEditable()) return;

    switch ((EEventType)event)
    {
    case kButton1Down:
//*-* Save the start coordinates
        fMouseInit=kTRUE;
        fMouseX = px;
        fMouseY = py;
        break;
    case kKeyPress :
        {
            Char_t chCharCode = (Char_t) px;
//            if (chCharCode != '+' || chCharCode != '-') chCharCode |= 0x20;
            MoveModelView(chCharCode, py);
            break;
        }
    case kButton1Up:
        if (!fMouseInit) break;
        fMouseInit=kFALSE;
        RotateView(px,py);
        fMouseX = px;
        fMouseY = py;
        PaintScene();
        break;
    case kButton1Motion:
        if (!fMouseInit) break;
        RotateView(px,py);
        fMouseX = px;
        fMouseY = py;
        PaintScene();
        break;
    default:
        break;
    };
}

//____________________________________________________________________________
void TPadOpenGLView::MapOpenGL()
{
//*-* Set the default attributes
   gVirtualGL->EnableGL(kDEPTH_TEST);
   gVirtualGL->EnableGL(kCULL_FACE);

   gVirtualGL->PolygonGLMode(kFRONT,kFILL);

#ifdef defined(Inventor) || defined(R__QT)
   // "Default light" with Inventor is "native" Inventor
   gVirtualGL->SetRootLight(kFALSE);
#else
   // "Default light" with no Inventor is "ROOT artificial" light
   gVirtualGL->SetRootLight(kTRUE);
#endif


   gVirtualGL->FrontGLFace(kCCW);

{'fraction_non_alphanumeric': 0.15591258529843655, 'fraction_numerical': 0.012006564740433618, 'mean_word_length': 1.5959641255605381, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 50, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2236003', 'n_tokens_mistral': 3308, 'n_tokens_neox': 3157, 'n_words': 720}