#include "My3DCanvas.h"
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoCube.h>  
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoDirectionalLight.h>
#include <Inventor/nodes/SoMaterial.h>

 My3DCanvas::My3DCanvas(QWidget *parent, const char *name)
        : QWidget(parent,name)
 {
  size=1; 
  SoQt::init(this);
  eviewer = new SoQtExaminerViewer(this);
  root = new SoSeparator;
  SoCube *mycube = new SoCube;
   SoMaterial *myMaterial1 = new SoMaterial;
   mycube->width = 400;
   mycube->height =400;
   mycube->depth =400 ;
   myMaterial1->diffuseColor.setValue(1.0, 0.0, 0.0);
   myMaterial1->transparency = 1.0;
   root->addChild(myMaterial1);
   root->addChild(mycube);      
   SoMaterial *myMaterial = new SoMaterial;
   root->ref();
   root->addChild(new SoDirectionalLight);
   myMaterial->diffuseColor.setValue(0.0, 1.0, 0.0);   //Green 
   root->addChild(myMaterial);
  cube1 = new SoCube;
   cube1->width = size;
   cube1->height =size;
   cube1->depth =size ;
   root->addChild(cube1);
  eviewer->setSceneGraph(root);
  eviewer->show();  

 }
 void My3DCanvas::draw(int s){
  size = s;
   root->enableNotify(FALSE);
   cube1->width = size;
   cube1->height =size;
   cube1->depth =size ;
   root->enableNotify(TRUE);
   root->touch();
  }







