@@ -79,6 +79,9 @@ namespace SCIRun {
7979 // ------------------------------------------------------------------------------
8080 SRInterface::SRInterface (std::shared_ptr<Gui::GLContext> context,
8181 int frameInitLimit) :
82+ orientSize (1.0 ),
83+ orientPosX (0.5 ),
84+ orientPosY (0.5 ),
8285 mSelectedID (0 ),
8386 mZoomSpeed (65 ),
8487 mMouseMode (MOUSE_OLDSCIRUN),
@@ -565,6 +568,43 @@ namespace SCIRun {
565568 showOrientation_ = value;
566569 }
567570
571+ // ------------------------------------------------------------------------------
572+ void SRInterface::setOrientSize (int size)
573+ {
574+ // Remap from 1:100 to 0.1:10
575+ orientSize = ((float )size)/10 .0f ;
576+ }
577+
578+ // ------------------------------------------------------------------------------
579+ void SRInterface::setOrientPosX (int pos)
580+ {
581+ // Remap 0:100 to -0.5:0.5
582+ float x = ((float )pos-50 )/100 ;
583+ orientPosX = x;
584+ }
585+
586+ // ------------------------------------------------------------------------------
587+ void SRInterface::setOrientPosY (int pos)
588+ {
589+ // Remap 0:100 to -0.5:0.5
590+ float y = ((float )pos-50 )/100 ;
591+ orientPosY = y;
592+ }
593+
594+ // ------------------------------------------------------------------------------
595+ void SRInterface::setDefaultOrientPos ()
596+ {
597+ float y = 0 .5f ;
598+ float x = 0 .5f ;
599+ }
600+
601+ // ------------------------------------------------------------------------------
602+ void SRInterface::setCenterOrientPos ()
603+ {
604+ float y = 0 .0f ;
605+ float x = 0 .0f ;
606+ }
607+
568608 // ------------------------------------------------------------------------------
569609 void SRInterface::setBackgroundColor (QColor color)
570610 {
@@ -1626,16 +1666,37 @@ namespace SCIRun {
16261666 // variable.
16271667 gen::StaticScreenDims* dims = mCore .getStaticComponent <gen::StaticScreenDims>();
16281668 float aspect = static_cast <float >(dims->width ) / static_cast <float >(dims->height );
1629- glm::mat4 projection = glm::perspective (0 .59f , aspect, 1 .0f , 2000 .0f );
1630-
1669+ // Project onto a orthographic plane with respect to aspect ratio
1670+ glm::mat4 projection = glm::ortho (-aspect/2 , aspect/2 , -0 .5f , 0 .5f , 0 .0f , 2 .0f );
1671+
16311672 // Build world transform for all axes. Rotates about uninverted camera's
16321673 // view, then translates to a specified corner on the screen.
16331674 glm::mat4 axesRot = mCamera ->getWorldToView ();
16341675 axesRot[3 ][0 ] = 0 .0f ;
16351676 axesRot[3 ][1 ] = 0 .0f ;
16361677 axesRot[3 ][2 ] = 0 .0f ;
1637- glm::mat4 invCamTrans = glm::translate (glm::mat4 (1 .0f ), glm::vec3 (0 .375f * aspect, 0 .37f , -1 .5f ));
1638- glm::mat4 axesScale = glm::scale (glm::mat4 (1 .0f ), glm::vec3 (0 .8f ));
1678+
1679+ // Remap x and y position(-0.5 to 0.5) so the edge doesn't pass the margin, regardless of size
1680+ float margin = orientSize / 10 .0f ;
1681+ float xLow2 = -aspect/2 + margin;
1682+ float xHigh2 = aspect/2 - margin;
1683+ float yLow2 = -0.5 + margin;
1684+ float yHigh2 = 0.5 - margin;
1685+ float xPos, yPos;
1686+
1687+ // If the scale is larger than the width, the scale centers at 0
1688+ if (xLow2 > 0 && xHigh2 < 0 )
1689+ {
1690+ xPos = 0 ;
1691+ }
1692+ else
1693+ {
1694+ xPos = xLow2 + (orientPosX + 0 .5f ) * (xHigh2 - xLow2);
1695+ }
1696+ yPos = yLow2 + (orientPosY + 0 .5f ) * (yHigh2 - yLow2);
1697+
1698+ glm::mat4 invCamTrans = glm::translate (glm::mat4 (1 .0f ), glm::vec3 (xPos, yPos, -1 .5f ));
1699+ glm::mat4 axesScale = glm::scale (glm::mat4 (1 .0f ), glm::vec3 (orientSize));
16391700 glm::mat4 axesTransform = axesScale * axesRot;
16401701
16411702 GLint locCamViewVec = glGetUniformLocation (shader, " uCamViewVec" );
0 commit comments