void DecorateBackgroundPlugin::decorateDoc(QAction *a, MeshDocument &m, RichParameterSet * parset,GLArea *gla, QPainter *, GLLogStream &) { static QString lastname("unitialized"); switch(ID(a)) { case DP_SHOW_CUBEMAPPED_ENV : { if(!cm.IsValid() || (lastname != cubemapFileName ) ) { qDebug( "Current CubeMapPath Dir: %s ",qPrintable(cubemapFileName)); glewInit(); bool ret = cm.Load(qPrintable(cubemapFileName)); lastname=cubemapFileName; if(! ret ) return; //QMessageBox::warning(gla,"Cubemapped background decoration","Warning unable to load cube map images: " + cubemapFileName ); cm.radius=10; } if(!cm.IsValid()) return; Matrix44f tr; glGetv(GL_MODELVIEW_MATRIX,tr); // Remove the translation from the current matrix by simply padding the last column of the matrix tr.SetColumn(3,Point4f(0,0,0,1.0)); //Remove the scaling from the the current matrix by adding an inverse scaling matrix float scale = 1.0/pow(tr.Determinant(),1.0f/3.0f); Matrix44f Scale; Scale.SetDiagonal(scale); tr=tr*Scale; glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); cm.DrawEnvCube(tr); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } break; case DP_SHOW_GRID : { emit this->askViewerShot("me"); Box3f bb=m.bbox(); float scaleBB = parset->getFloat(BoxRatioParam()); float majorTick = parset->getFloat(GridMajorParam()); float minorTick = parset->getFloat(GridMinorParam()); bool gridSnap = parset->getBool(GridSnapParam()); bool backFlag = parset->getBool(GridBackParam()); bool shadowFlag = parset->getBool(ShowShadowParam()); Color4b backColor = parset->getColor4b(GridColorBackParam()); Color4b frontColor = parset->getColor4b(GridColorFrontParam()); bb.Offset((bb.max-bb.min)*(scaleBB-1.0)); DrawGriddedCube(*m.mm(),bb,majorTick,minorTick,gridSnap,backFlag,shadowFlag,backColor,frontColor,gla); } break; } }