Skip to content
Snippets Groups Projects
Commit 4baa7029 authored by Rene Brun's avatar Rene Brun
Browse files

From Timur

Several improvements


git-svn-id: http://root.cern.ch/svn/root/trunk@10090 27541ba8-7e3a-0410-8455-c3a389f83636
parent ce038cec
No related branches found
No related tags found
No related merge requests found
// @(#)root/gl:$Name: $:$Id: TArcBall.h,v 1.4 2004/09/03 12:52:42 brun Exp $ // @(#)root/gl:$Name: $:$Id: TArcBall.h,v 1.5 2004/09/14 15:37:34 rdm Exp $
// Author: Timur Pocheptsov 03/08/2004 // Author: Timur Pocheptsov 03/08/2004
/************************************************************************* /*************************************************************************
...@@ -51,5 +51,44 @@ public: ...@@ -51,5 +51,44 @@ public:
} }
}; };
class TEqRow {
private:
Double_t fData[4];
public:
TEqRow();
TEqRow(const Double_t *source);
void SetRow(const Double_t *source);
Double_t &operator [] (UInt_t ind)
{
return fData[ind];
}
Double_t operator [] (UInt_t ind)const
{
return fData[ind];
}
TEqRow &operator *= (Double_t x);
TEqRow &operator /= (Double_t x);
TEqRow &operator += (const TEqRow &row);
};
TEqRow operator * (const TEqRow &row, Double_t x);
TEqRow operator * (Double_t x, const TEqRow &row);
TEqRow operator / (const TEqRow &row, Double_t x);
TEqRow operator + (const TEqRow &row1, const TEqRow &row2);
class TToySolver {
private:
TEqRow fMatrix[3];
Int_t fBase[3];
public:
TToySolver(const Double_t *source);
void GetSolution(Double_t *sink);
private:
void AddNewBV(UInt_t i, UInt_t j);
};
#endif #endif
// @(#)root/gl:$Name: $:$Id: TViewerOpenGL.h,v 1.11 2004/09/14 15:37:34 rdm Exp $ // @(#)root/gl:$Name: $:$Id: TViewerOpenGL.h,v 1.12 2004/09/15 14:26:58 brun Exp $
// Author: Timur Pocheptsov 03/08/2004 // Author: Timur Pocheptsov 03/08/2004
/************************************************************************* /*************************************************************************
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#endif #endif
class TGLRenderArea; class TGLRenderArea;
class TContextMenu;
class TGLSelection; class TGLSelection;
class TGVSplitter; class TGVSplitter;
class TGPopupMenu; class TGPopupMenu;
...@@ -80,14 +81,13 @@ private: ...@@ -80,14 +81,13 @@ private:
enum EMode{kNav, kPick}; enum EMode{kNav, kPick};
enum EViews{kXOY, kXOZ, kYOZ, kPERSP}; enum EViews{kXOY, kXOZ, kYOZ, kPERSP};
enum EActivePlane{kAPXOY, kAPXOZ, kAPYOZ};
EViews fConf; EViews fConf;
EMode fMode; EMode fMode;
EActivePlane fActivePlane;
TContextMenu *fContextMenu;
TGLSceneObject *fSelectedObj; TGLSceneObject *fSelectedObj;
Color_t fRGBA[4]; Color_t fRGBA[4];
public: public:
TViewerOpenGL(TVirtualPad * pad); TViewerOpenGL(TVirtualPad * pad);
......
// @(#)root/gl:$Name: $:$Id: TArcBall.cxx,v 1.3 2004/08/10 14:11:40 brun Exp $ // @(#)root/gl:$Name: $:$Id: TArcBall.cxx,v 1.4 2004/09/03 12:52:42 brun Exp $
// Author: Timur Pocheptsov 03/08/2004 // Author: Timur Pocheptsov 03/08/2004
/************************************************************************* /*************************************************************************
...@@ -263,3 +263,124 @@ void TArcBall::ResetMatrices() ...@@ -263,3 +263,124 @@ void TArcBall::ResetMatrices()
Matrix3dSetIdentity(fLastRot); Matrix3dSetIdentity(fLastRot);
Matrix3dSetIdentity(fThisRot); Matrix3dSetIdentity(fThisRot);
} }
//______________________________________________________________________________
TEqRow::TEqRow()
:fData()
{
}
//______________________________________________________________________________
TEqRow::TEqRow(const Double_t *source)
{
fData[0] = source[0];
fData[1] = source[1];
fData[2] = source[2];
fData[3] = source[3];
}
//______________________________________________________________________________
void TEqRow::SetRow(const Double_t *source)
{
fData[0] = source[0];
fData[1] = source[1];
fData[2] = source[2];
fData[3] = source[3];
}
//______________________________________________________________________________
TEqRow &TEqRow::operator *= (Double_t x)
{
fData[0] *= x;
fData[1] *= x;
fData[2] *= x;
fData[3] *= x;
return *this;
}
//______________________________________________________________________________
TEqRow &TEqRow::operator /= (Double_t x)
{
fData[0] /= x;
fData[1] /= x;
fData[2] /= x;
fData[3] /= x;
return *this;
}
//______________________________________________________________________________
TEqRow &TEqRow::operator += (const TEqRow &row)
{
fData[0] += row.fData[0];
fData[1] += row.fData[1];
fData[2] += row.fData[2];
fData[3] += row.fData[3];
return *this;
}
//______________________________________________________________________________
TEqRow operator * (const TEqRow &row, Double_t x)
{
return TEqRow(row) *= x;
}
//______________________________________________________________________________
TEqRow operator * (Double_t x, const TEqRow &row)
{
return TEqRow(row) *= x;
}
//______________________________________________________________________________
TEqRow operator / (const TEqRow &row, Double_t x)
{
return TEqRow(row) /= x;
}
//______________________________________________________________________________
TEqRow operator + (const TEqRow &r1, const TEqRow &r2)
{
return TEqRow(r1)+=r2;
}
//______________________________________________________________________________
TToySolver::TToySolver(const Double_t *source)
{
fMatrix[0].SetRow(source);
fMatrix[1].SetRow(source + 4);
fMatrix[2].SetRow(source + 8);
fBase[0] = fBase[1] = fBase[2] = -1;
}
//______________________________________________________________________________
void TToySolver::GetSolution(Double_t *sink)
{
for (UInt_t i = 0; i < 3; ++i) {
for (UInt_t j = 0; j < 3; ++j) {
if (fMatrix[i][j] != 0.) AddNewBV(i, j);
}
}
//j for vc 6.0 :))
for (UInt_t j = 0; j < 3; ++j) {
if (fBase[j] >= 0)sink[fBase[j]] = fMatrix[j][3];
}
}
//______________________________________________________________________________
void TToySolver::AddNewBV(UInt_t row, UInt_t col)
{
Double_t tmp1 = fMatrix[row][col];
fMatrix[row] /= tmp1;
for (UInt_t i = 0; i < 3; ++i) {
if (i != row) {
Double_t tmp2 = fMatrix[i][col];
fMatrix[i] += -tmp2 * fMatrix[row];
}
}
fBase[row] = col;
}
// @(#)root/gl:$Name: $:$Id: TViewerOpenGL.cxx,v 1.21 2004/09/15 14:26:58 brun Exp $ // @(#)root/gl:$Name: $:$Id: TViewerOpenGL.cxx,v 1.22 2004/09/17 08:33:33 rdm Exp $
// Author: Timur Pocheptsov 03/08/2004 // Author: Timur Pocheptsov 03/08/2004
/************************************************************************* /*************************************************************************
...@@ -104,7 +104,7 @@ TViewerOpenGL::TViewerOpenGL(TVirtualPad * vp) ...@@ -104,7 +104,7 @@ TViewerOpenGL::TViewerOpenGL(TVirtualPad * vp)
fNbShapes = 0; fNbShapes = 0;
fConf = kPERSP; fConf = kPERSP;
fMode = kNav; fMode = kNav;
fActivePlane = kAPXOY; fContextMenu = 0;
fSelectedObj = 0; fSelectedObj = 0;
static struct Init { static struct Init {
...@@ -229,6 +229,7 @@ TViewerOpenGL::~TViewerOpenGL() ...@@ -229,6 +229,7 @@ TViewerOpenGL::~TViewerOpenGL()
delete fL2; delete fL2;
delete fL3; delete fL3;
delete fL4; delete fL4;
delete fContextMenu;
} }
//______________________________________________________________________________ //______________________________________________________________________________
...@@ -285,6 +286,8 @@ Bool_t TViewerOpenGL::HandleContainerButton(Event_t *event) ...@@ -285,6 +286,8 @@ Bool_t TViewerOpenGL::HandleContainerButton(Event_t *event)
if ((fSelectedObj = TestSelection(event))) { if ((fSelectedObj = TestSelection(event))) {
fSelectedObj->GetColor(fRGBA[0], fRGBA[1], fRGBA[2], fRGBA[3]); fSelectedObj->GetColor(fRGBA[0], fRGBA[1], fRGBA[2], fRGBA[3]);
fEditor->SetRGBA(fRGBA[0], fRGBA[1], fRGBA[2], fRGBA[3]); fEditor->SetRGBA(fRGBA[0], fRGBA[1], fRGBA[2], fRGBA[3]);
if (!fContextMenu) fContextMenu = new TContextMenu("glcm", "glcm");
fContextMenu->Popup(event->fXRoot, event->fYRoot, fSelectedObj->GetRealObject());
} else { } else {
fEditor->GetButton()->SetState(kButtonDisabled); fEditor->GetButton()->SetState(kButtonDisabled);
fEditor->Stop(); fEditor->Stop();
...@@ -297,6 +300,9 @@ Bool_t TViewerOpenGL::HandleContainerButton(Event_t *event) ...@@ -297,6 +300,9 @@ Bool_t TViewerOpenGL::HandleContainerButton(Event_t *event)
gVirtualGL->EndMovement(&fRender); gVirtualGL->EndMovement(&fRender);
DrawObjects(); DrawObjects();
} }
} else if(event->fCode == kButton3) {
// delete fContextMenu;
// fContextMenu = 0;
} }
} }
...@@ -367,11 +373,10 @@ Bool_t TViewerOpenGL::HandleContainerMotion(Event_t *event) ...@@ -367,11 +373,10 @@ Bool_t TViewerOpenGL::HandleContainerMotion(Event_t *event)
TGLWindow *glWin = fCanvasContainer->GetGLWindow(); TGLWindow *glWin = fCanvasContainer->GetGLWindow();
Double_t xshift = (event->fX - fLastPos.fX) / Double_t(glWin->GetWidth()); Double_t xshift = (event->fX - fLastPos.fX) / Double_t(glWin->GetWidth());
Double_t yshift = (event->fY - fLastPos.fY) / Double_t(glWin->GetHeight()); Double_t yshift = (event->fY - fLastPos.fY) / Double_t(glWin->GetHeight());
xshift *= fViewVolume[0] * 1.9 * fZoom[fConf];
yshift *= fViewVolume[1] * 1.9 * fZoom[fConf];
if (fConf != kPERSP) { if (fConf != kPERSP) {
xshift *= fViewVolume[0] * 1.9 * fZoom[fConf];
yshift *= fViewVolume[1] * 1.9 * fZoom[fConf];
MakeCurrent(); MakeCurrent();
switch (fConf) { switch (fConf) {
case kXOY: case kXOY:
...@@ -387,6 +392,15 @@ Bool_t TViewerOpenGL::HandleContainerMotion(Event_t *event) ...@@ -387,6 +392,15 @@ Bool_t TViewerOpenGL::HandleContainerMotion(Event_t *event)
break; break;
} }
} else { } else {
const Double_t *rotM = fArcBall->GetRotMatrix();
Double_t matrix[3][4] = {{rotM[0], -rotM[8], rotM[4], xshift},
{rotM[1], -rotM[9], rotM[5], -yshift},
{rotM[2], -rotM[10], rotM[6], 0.}};
TToySolver tr(*matrix);
Double_t shift[3] = {0.};
tr.GetSolution(shift);
gVirtualGL->MoveSelected(&fRender, shift[0], shift[1], shift[2]);
} }
DrawObjects(); DrawObjects();
...@@ -594,11 +608,6 @@ Bool_t TViewerOpenGL::ProcessMessage(Long_t msg, Long_t parm1, Long_t) ...@@ -594,11 +608,6 @@ Bool_t TViewerOpenGL::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
break; break;
case kGLPickMode: case kGLPickMode:
fMode = kPick; fMode = kPick;
if (fConf == kPERSP) {
fConf = kXOY;
fRender.SetActive(fConf);
DrawObjects();
}
break; break;
case kGLXOY: case kGLXOY:
...@@ -631,8 +640,6 @@ Bool_t TViewerOpenGL::ProcessMessage(Long_t msg, Long_t parm1, Long_t) ...@@ -631,8 +640,6 @@ Bool_t TViewerOpenGL::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
fConf = kPERSP; fConf = kPERSP;
fRender.SetActive(fConf); fRender.SetActive(fConf);
DrawObjects(); DrawObjects();
if(fMode != kNav)
fMode = kNav;
} }
break; break;
case kGLExit: case kGLExit:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment