Пример #1
0
Limit3D PFO_Scatterplot::GetPlotObjLimits()
{
    Limit3D  currLimits;
    DoStatusChk();
    if (StatusNotOK() || (!doPlot))
        return currLimits;

    bool xLin, yLin;
    GetAxesTypes(xLin, yLin);

    {
        const SC_DoubleArray& xData = scatterDataDC->dataTable[plotIVIndx];
        const SC_DoubleArray& yData = scatterDataDC->dataTable[plotDVIndx + nplotIV];

        for (int j = 0; j < xData.Size(); j++)
        {
            double xVal = xData[j];
            double yVal = yData[j];
            if ((xLin || (xVal > stdEps)) && (yLin || (yVal > stdEps)))
                currLimits.AddToLimits(Coord3D(xVal, yVal, nullReal));
        }
    }

    if (plotXGridLines)
    {
        const SC_DoubleArray& xData = xGridLinesDC->dataTable[plotIVIndx];
        for (int j = 0; j < xData.Size(); j++)
        {
            double xVal = xData[j];
            if ((!RealIsNull(xVal)) && (xLin || (xVal > stdEps)))
                currLimits.AddToLimits(Coord3D(xVal, nullReal, nullReal));
        }
    }

    if (plotYGridLines)
    {
        const SC_DoubleArray& yData = yGridLinesDC->dataTable[plotDVIndx];

        for (int j = 0; j < yData.Size(); j++)
        {
            double yVal = yData[j];
            if ((!RealIsNull(yVal)) && (yLin || (yVal > stdEps)))
                currLimits.AddToLimits(Coord3D(nullReal, yVal, nullReal));
        }
    }


    return currLimits;
}
Пример #2
0
void PlotDefC::ChangeView(const Coord3D&  scaleFactor)
{
    Coord3D viewCenter = GetNewViewCenter();
    if (viewCenter.CoordIsNull())
        return;

    Limit3D oldLimits = GetCurrentViewLimits();
    Limit3D newLimits;

    PC_ViewOpRec axesSettings = GetPlotViewOps();

    DoOp(axesSettings.xOp, viewCenter.cX,
                           oldLimits.minLim.cX, oldLimits.maxLim.cX,
                           scaleFactor.cX,
                           newLimits.minLim.cX, newLimits.maxLim.cX);
    DoOp(axesSettings.yOp, viewCenter.cY,
                           oldLimits.minLim.cY, oldLimits.maxLim.cY,
                           scaleFactor.cY,
                           newLimits.minLim.cY, newLimits.maxLim.cY);
    DoOp(axesSettings.zOp, viewCenter.cZ,
                           oldLimits.minLim.cZ, oldLimits.maxLim.cZ,
                           scaleFactor.cZ,
                           newLimits.minLim.cZ, newLimits.maxLim.cZ);

    // keep existing 3D az/scale/el
    PC_View currView = GetCurrentView();

    //  clear translations
    currView.translation = Coord3D(0.0);

    //  set new limits
    currView.viewLimits = newLimits;
    plotViews.PushStack(currView);
    ResetView();
}
Пример #3
0
Coord3D OGL3DBase::GetExtrusionScale(bool pixelSizing) const
{
    // pixel sizing assumed
    Coord3D minLim, maxLim;
    GetTransformedLimits(minLim, maxLim);
    Coord3D deltaLim = maxLim - minLim;

    return Coord3D(xOrthoSpan / deltaLim.cX,yOrthoSpan / deltaLim.cY, zOrthoSpan / deltaLim.cZ);
}
Пример #4
0
 inline
 Coord3D repulsionForce(const Coord3D& a, const Coord3D& b, float repulsion, float natlength)
 {
   Coord3D diff = a - b;
   float r = repulsion;
   r /= cube((std::max)(diff.size() / 2.0f, natlength / 10));
   diff = diff * r + Coord3D(frand(-0.01f, 0.01f), frand(-0.01f, 0.01f), frand(-0.01f, 0.01f));
   return diff;
 }
Пример #5
0
bool PD_2D::ProcessRubberbandRegion(const PC_ObjLimitRect& rubberbandRegion)
{
    int dx, dy;
    rubberbandRegion.GetWidthHeight(dx, dy);

    //  skip tiny zooms
    if ((dx  < 3) || (dy <  3))
        return false;

    Point2D stAxes, endAxes;

    if (PixelXYtoUserXY(rubberbandRegion.ulXpos, rubberbandRegion.lrYpos, stAxes) &&
        PixelXYtoUserXY(rubberbandRegion.lrXpos, rubberbandRegion.ulYpos, endAxes))
    {
        PC_View newView;
        newView.viewLimits.minLim = Coord3D(stAxes);
        newView.viewLimits.maxLim = Coord3D(endAxes);
        ChangeView(newView);
        return true;
    }

    return false;
}
Пример #6
0
void Camera::SetFromDrawable(const Drawable & drawable, const double scale,
		const int _upwardAngle)
{
	double d;
	aspectRatio = 4./3.; // on force un format 4/3
	upwardAngle = _upwardAngle;
	nearplan = 10;

	d = FastMath::max(scale * drawable.radius+ nearplan, FastMath::max(scale
			* drawable.radius/ FastMath::fastTan(upwardAngle), scale
			* drawable.radius* aspectRatio / FastMath::fastTan(upwardAngle) ));
	farplan = 2 * d - nearplan;

	int angle = -90; // correction de l'orientation initiale des objets
	Set(Coord3D( -d, 0, 0), Rotation( 1, 0, 0, 0, FastMath::fastCos(angle),
			FastMath::fastSin(angle), 0, -FastMath::fastSin(angle),
			FastMath::fastCos(angle)));

}
Пример #7
0
// scaling for axes independent data like symbols and stroke fonts
Coord3D OGL3DBase::GetIndependentScale(const double& inSize) const
{
    if (inAnnoView)
    {
        return Coord3D(xPerPixel * inSize, yPerPixel * inSize, 1.0);
    }

    // compensate for window size - base is 640x480
    int ixAvail, iyAvail;
    plotBase.CalcAvailablePixels(ixAvail, iyAvail);

    double xAvail = double(ixAvail);
    double yAvail = double(iyAvail);
    double winDiag = 800.0 / sqrt(xAvail * xAvail  +  yAvail * yAvail);

    double maxSpan = sqrt(xOrthoSpan * xOrthoSpan + yOrthoSpan * yOrthoSpan + zOrthoSpan * zOrthoSpan);

    Coord3D scale(winDiag * maxSpan * inSize);

    Limit3D lim = currView.viewLimits;
    TransformForAxes(lim.minLim);
    TransformForAxes(lim.maxLim);

    scale *= (lim.maxLim - lim.minLim);

    double currScale = currView.scale;

    if (!plot3Dbase.ProjectionIsOrtho())
//        currScale = 90.0 / plot3Dbase.fieldOfView;
            currScale = 1.0;

    scale /= currScale;

    scale.cX /= xOrthoSpan;
    scale.cY /= yOrthoSpan;
    scale.cZ /= zOrthoSpan;

    return scale;
}
Пример #8
0
void  PFO_3DTableSeriesGL :: DrawPlotObject()
{
    if (!InitDrawObject())
        return;

    int maxCol = objTableData->GetNCols();
    if ((xDataIndx < maxCol) && (yDataIndx < maxCol) && (zDataIndx < maxCol))
    {
        SC_DoubleArray& xData = objTableData->dataTable[xDataIndx];
        SC_DoubleArray& yData = objTableData->dataTable[yDataIndx];
        SC_DoubleArray& zData = objTableData->dataTable[zDataIndx];

        int nrows = xData.Size() - startRow;
        SC_CoordArray xyzData(nrows);
        for (int i = startRow; i < xData.Size(); i++)
            xyzData[i - startRow] = Coord3D(xData[i], yData[i], zData[i]);

        GL_Symbol currSeries;
        currSeries.DrawSeriesSpec(xyzSeries, xyzData, polyOffset, 0);
    }

    CloseDrawObject();
}
Пример #9
0
  void SpringLayout::apply()
  {
    m_nforces.resize(m_graph.nodeCount());
    m_hforces.resize(m_graph.edgeCount());
    m_lforces.resize(m_graph.edgeCount());
    m_sforces.resize(m_graph.nodeCount());

    for (size_t n = 0; n < m_graph.nodeCount(); ++n)
    {
      m_nforces[n] = Coord3D(0, 0, 0);
      for (size_t m = 0; m < n; ++m)
      {
        Coord3D diff = repulsionForce(m_graph.node(n).pos, m_graph.node(m).pos, m_repulsion, m_natLength);
        m_nforces[n] += diff;
        m_nforces[m] -= diff;
      }
      m_sforces[n] = (this->*m_forceCalculation)(m_graph.node(n).pos, m_graph.stateLabel(n).pos, 0.0);
    }

    for (size_t n = 0; n < m_graph.edgeCount(); ++n)
    {
      Edge e = m_graph.edge(n);
      Coord3D f;
      // Variables for repulsion calculations

      m_hforces[n] = Coord3D(0, 0, 0);
      m_lforces[n] = Coord3D(0, 0, 0);

      if (e.from == e.to)
      {
        m_hforces[n] += repulsionForce(m_graph.handle(n).pos, m_graph.node(e.from).pos, m_repulsion, m_natLength);
      }

      f = (this->*m_forceCalculation)(m_graph.node(e.to).pos, m_graph.node(e.from).pos, m_natLength);
      m_nforces[e.from] += f;
      m_nforces[e.to] -= f;

      f = (this->*m_forceCalculation)((m_graph.node(e.to).pos + m_graph.node(e.from).pos) / 2.0, m_graph.handle(n).pos, 0.0);
      m_hforces[n] += f;

      f = (this->*m_forceCalculation)(m_graph.handle(n).pos, m_graph.transitionLabel(n).pos, 0.0);
      m_lforces[n] += f;

      for (size_t m = 0; m < n; ++m)
      {
        // Handles
        f = repulsionForce(m_graph.handle(n).pos, m_graph.handle(m).pos, m_repulsion * m_controlPointWeight, m_natLength);
        m_hforces[n] += f;
        m_hforces[m] -= f;

        // Labels
        f = repulsionForce(m_graph.transitionLabel(n).pos, m_graph.transitionLabel(m).pos, m_repulsion * m_controlPointWeight, m_natLength);
        m_lforces[n] += f;
        m_lforces[m] -= f;
      }
    }

    for (size_t n = 0; n < m_graph.nodeCount(); ++n)
    {
      if (!m_graph.node(n).anchored)
      {
        m_graph.node(n).pos = m_graph.node(n).pos + m_nforces[n] * m_speed;
        m_graph.node(n).pos.clip(m_clipMin, m_clipMax);
      }
      if (!m_graph.stateLabel(n).anchored)
      {
        m_graph.stateLabel(n).pos = m_graph.stateLabel(n).pos + m_sforces[n] * m_speed;
        m_graph.stateLabel(n).pos.clip(m_clipMin, m_clipMax);
      }
    }

    for (size_t n = 0; n < m_graph.edgeCount(); ++n)
    {
      if (!m_graph.handle(n).anchored)
      {
        m_graph.handle(n).pos = m_graph.handle(n).pos + m_hforces[n] * m_speed;
        m_graph.handle(n).pos.clip(m_clipMin, m_clipMax);
      }
      if (!m_graph.transitionLabel(n).anchored)
      {
        m_graph.transitionLabel(n).pos = m_graph.transitionLabel(n).pos + m_lforces[n] * m_speed;
        m_graph.transitionLabel(n).pos.clip(m_clipMin, m_clipMax);
      }
    }
  }
Пример #10
0
/** \brief Superpose mob on ref
Calculates a 4x4 transformation Matrix that should be applied on 'mob' in order to minimize
RMSD between mob and ref.
Algorithm taken from Sippl et Stegbuchner. Computers Chem. Vol 15, No. 1, p 73-78, 1991.
*/
Superpose_t superpose(const Rigidbody& ref, const Rigidbody& mob, int verbosity)
{

    Rigidbody reference(ref); //copie de ref pour pouvoir centrer
    Rigidbody mobile(mob); // copie de mobile

    if (ref.Size()!=mob.Size()) {std::cout << "Error in superpose.cpp: \
                                       the two AtomSelection objects must have\
                                       the same size !" << std::endl;  abort();};


    Mat33 rot;
    Mat33 ident;
    for (uint i=0; i<3; i++)
        for(uint j=0; j<3; j++)
        if (i!=j) {ident[i][j]=0;} else {ident[i][j]=1;} ;


    //find the translational component 
    Coord3D t0 = ref.FindCenter();
    Coord3D t1 = mob.FindCenter();


    //centre les deux objets:
    reference.CenterToOrigin();
    mobile.CenterToOrigin();


    Mat33 U; //mixed tensor
    MakeTensor(reference, mobile, U);

    for(uint i=0; i<35; i++)
    {

        double arg1,arg2;

        arg1 = U[2][1] - U[1][2] ;
        arg2 = U[1][1] + U[2][2];
        double alpha = atan2(arg1 , arg2 );

        XRotMatrix(-alpha, rot);
        Mat33xMat33(rot,ident,ident);

        //------------------------------------


        Mat33xMat33(rot,U,U);

        arg1 = U[2][0]-U[0][2];
        arg2 = U[0][0]+U[2][2];

        double beta = atan2(arg1,arg2);
        YRotMatrix(beta,rot);
        Mat33xMat33(rot,ident,ident);

        //--------------------------------------


        Mat33xMat33(rot,U,U);

        arg1 = U[1][0] - U[0][1];
        arg2 = U[0][0] + U[1][1];
        double gamma = atan2(arg1,arg2);

        ZRotMatrix(-gamma,rot);
        Mat33xMat33(rot,ident,ident);


        Mat33xMat33(rot,U,U);

    }

    //creates a 4x4 matrix that tracks transformations for mobile
    Mat44 tracker;
    MakeTranslationMat44(Coord3D()-t1,tracker);

    //copy the 3x3 matrix into a 4x4 matrix
    Mat44 rotation;
    MakeTranslationMat44(Coord3D(),rotation); //identity matrix;
    for (int i=0; i<3; i++)
      for (int j=0; j<3; j++)
         rotation[i][j]=ident[i][j];



    mat44xmat44(rotation, tracker, tracker);

    MakeTranslationMat44(t0, rotation);
    mat44xmat44(rotation, tracker, tracker);

    Matrix output(4,4);

    for (int i=0; i<4; i++)
     for (int j=0; j<4;j++)
       output(i,j)=tracker[i][j];

    Superpose_t sup;
    sup.matrix = output;

    Rigidbody probe(mob);
    probe.ApplyMatrix(output);

    sup.rmsd = Rmsd(ref,probe);
    return sup;



//     screw = MatTrans2screw(ident, t0, t1);
//     screw.point = screw.point + t1 ;




/*
    if (verbosity==1)
    {


        Rigidbody newmob(mob);
        Rigidbody newref(ref);
        selref.setRigid(newref);
        selmob.setRigid(newmob);
        newmob.transform(screw);

        std::cout << "verif screw, rmsdca = " << rmsd(selmob && CA(newmob),selref && CA(newref)) << std::endl ;

    }
*/

//     return screw;
}


}
Пример #11
0
void PlotDefC::ChangeView(double scaleFactor)
{
    Coord3D sc3D = Coord3D(scaleFactor);
    ChangeView(sc3D);
}
Пример #12
0
	virtual Coord3D minRGB()
	{
		return Coord3D((float)minR/255.0f, (float)minG/255.0f, (float)minB/255.0f);
	}
Пример #13
0
// Vissage MatTrans2screw(Mat33 rotmatrix, Coord3D t0, Coord3D t1)
Screw MatTrans2screw(const Matrix& mat)
{

    Coord3D trans;
    Mat33 rotmatrix;

    trans.x = mat(0,3);
    trans.y = mat(1,3);
    trans.z = mat(2,3);


//     Coord3D trans = t0-t1;


    for(int i=0; i<3; i++)
      for(int j=0; j<3; j++)
          rotmatrix[i][j]=mat(i,j);

//     std::cout << trans.toString();

    Screw screw;
    Coord3D eigenvect;

    Coord3D x,y,z;
    x.x = rotmatrix[0][0] ; x.y = rotmatrix[1][0]; x.z=rotmatrix[2][0];
    y.x = rotmatrix[0][1] ; y.y = rotmatrix[1][1]; y.z=rotmatrix[2][1];
    z.x = rotmatrix[0][2] ; z.y = rotmatrix[1][2]; z.z=rotmatrix[2][2];

    Coord3D pt ; //un point de l'axe de rotation


    double a = rotmatrix[0][0] ; // Xx
    double b = rotmatrix[1][1] ; // Yy
    double c = rotmatrix[2][2] ; // Zz

    if (fabs(1+a-b-c) > EPSILON)
    {
        eigenvect.x = x.x + 1 - b - c ;
        eigenvect.y = x.y + y.x ;
        eigenvect.z = x.z + z.x ;
        screw.unitVector = eigenvect / Norm(eigenvect);
        screw.normtranslation = ScalProd(screw.unitVector,trans);

        Coord3D s = trans - screw.normtranslation*screw.unitVector ;
        screw.point.x = 0 ;
        screw.point.y = s.z*z.y + s.y*(1-z.z) ;
        screw.point.z = s.y*y.z+s.z*(1-y.y);
        screw.point = screw.point/(1+x.x-y.y-z.z) ;


    }
    else if (fabs(1-a+b-c)> EPSILON)
    {
        eigenvect.x = y.x + x.y;
        eigenvect.y = y.y + 1 - x.x - z.z ;
        eigenvect.z = y.z + z.y ;

        screw.unitVector = eigenvect / Norm(eigenvect);
        screw.normtranslation = ScalProd(screw.unitVector,trans);

        Coord3D s = trans - screw.normtranslation*screw.unitVector ;
        screw.point.x =  s.z*z.x + s.x*(1-z.z);
        screw.point.y =  0 ;
        screw.point.z =  s.x*x.z + s.z*(1-x.x);
        screw.point = screw.point/(1-x.x+y.y-z.z) ;
    }
    else if (fabs(1-a-b+c)>EPSILON)
    {
        eigenvect.x = z.x + x.z ;
        eigenvect.y = z.y + y.z ;
        eigenvect.z = z.z + 1 - x.x - y.y ;

        screw.unitVector = eigenvect / Norm(eigenvect);
        screw.normtranslation = ScalProd(screw.unitVector,trans);

        Coord3D s = trans - screw.normtranslation*screw.unitVector ;
        screw.point.x = s.y*y.x + s.x*(1-y.y) ;
        screw.point.y = s.x*x.y + s.y*(1-x.x) ;
        screw.point.z =  0 ;
        screw.point = screw.point/(1-x.x-y.y+z.z) ;

    }
    else     // angle=0
      { 
            screw.point = Coord3D(0,0,0);
            if(Norm(trans)!=0)
            {
            screw.unitVector=trans /Norm(trans);
            }
            else {  screw.unitVector =  Coord3D(0,0,1); /*axe arbitraire*/ }
            screw.normtranslation=Norm(trans);
            screw.angle=0;
            return screw;


    }

    //creation d'un vecteur non aligne avec screw.unitVector:
    Coord3D v (1,0,0);
    if (fabs(Angle(screw.unitVector,v)) < 0.1) v= Coord3D(0,0,1); //v et axe colin�aires: on change v


    Coord3D u = v - ScalProd(v,screw.unitVector)*screw.unitVector ;
    u = u/Norm(u);

    Coord3D uprime;
    Mat33xcoord3D(rotmatrix,u,uprime);

    double cost = ScalProd(u,uprime);

    Coord3D usec;
    VectProd(screw.unitVector,u,usec);
    double sint = ScalProd(usec,uprime);

    
    if (cost < -1 ) cost=-1;
    if (cost >1 ) cost= 1 ; 
    screw.angle = acos(cost);
    if (sint < 0) screw.angle = -screw.angle ;

    screw.angle *= -1;
    return screw ;
}
Пример #14
0
// scaling for axes independent data like symbols and stroke fonts
Coord3D OGL2DBase::GetIndependentScale(const double& inSize) const
{
    return Coord3D(xPerPixel * inSize, yPerPixel * inSize, 1.0);
}
Пример #15
0
	virtual Coord3D maxRGB()
	{
		return Coord3D((float)maxR/255.0f, (float)maxG/255.0f, (float)maxB/255.0f);
	}
Пример #16
0
Coord3D operator-(int i, Coord3D &o) { return Coord3D(i - o.x, i - o.y, i - o.z); }
Пример #17
0
Coord3D operator+(int i, Coord3D &o) { return Coord3D(i + o.x, i + o.y, i + o.z); }
Пример #18
0
void PFO_GridContour:: CalcOutput(FOcalcType  calcType)
{
    DoStatusChk();
    if (StatusNotOK())
        return;

    SC_DoubleArray contourData;
    gridData->GetData(contourData);

    if (contourSpec.doLogContours)
        contourData.Log10();

    if (contourData.GetnDataOK() < 3)
    {
        SetObjErrMsg("less than 3 valid data");
        return;
    }

    SC_Triangulation& currTri = gridData->GetTriangulation();

    contourLines.Alloc(contourSpec.Size());
    SC_IntArray  orderedPoints;
    Line3D       cLine;
    Coord3D      nextPoint;

    for (int i = 0; i < contourSpec.Size(); i++)
    {
        double currVal = contourSpec[i].contourVal;
        if (contourSpec.doLogContours)
            currVal = log10(currVal);

        if (currTri.GetConnectedEdgeList(contourData, currVal, orderedPoints))
        {
            contourLines[i].Alloc(orderedPoints.Size());
            for (int j = 0; j < orderedPoints.Size(); j++)
            {
                int edgeIndex = orderedPoints[j];
                if (edgeIndex < 0)
                {
                    nextPoint = Coord3D();
                }
                else
                {
                    const SC_Triangulation::TriangleEdge& currEdge = currTri.GetEdge(edgeIndex);
                    currTri.GetNodeCoord(currEdge.stNode, cLine.stPt);
                    currTri.GetNodeCoord(currEdge.endNode, cLine.endPt);

                    // slight kluge: if Z is same, honor log stuff
                    if ((zvalueSource == zvs_Same) && contourSpec.doLogContours)
                    {
                        cLine.stPt.cZ = contourData[currEdge.stNode];
                        cLine.endPt.cZ = contourData[currEdge.endNode];
                        nextPoint = cLine.PointOnLine(currEdge.cPos);
                        nextPoint.cZ = InvLgt(nextPoint.cZ);
                    }
                    else
                    {
                        cLine.stPt.cZ = GetZVal(currEdge.stNode, *gridData);
                        cLine.endPt.cZ = GetZVal(currEdge.endNode, *gridData);
                        nextPoint = cLine.PointOnLine(currEdge.cPos);
                    }

                    // just affects X & Y
                    gridData->UnTransformCoord(nextPoint);
                    MapCoords(nextPoint);
                }


                contourLines[i] += nextPoint;
            }
        }
    }
    contourLines.SetSize(contourSpec.Size());
}
Пример #19
0
void OGL3DBase::PerspectiveSetup(double eyeSepMult)
{
    Coord3D zeroOffset(0.0, 0.0, 0.0);
    Coord3D minCoord = plotBase.GetNormalizedCoord(currView.viewLimits.minLim, zeroOffset);
    Coord3D maxCoord = plotBase.GetNormalizedCoord(currView.viewLimits.maxLim, zeroOffset);;

    double maxSceneWidth = minCoord.Distance(maxCoord);
    double sceneWidth = maxSceneWidth / currView.scale;
    double fovRadians = Radians(plot3Dbase.fieldOfView);
    double focalLength = sceneWidth / 2.0 / tan(fovRadians / 2.0);

    double nearDist = focalLength / 5.0;
    double farDist  = focalLength + maxSceneWidth * 4.0;
    double wd2 = nearDist * tan(fovRadians);
    double ndfl = nearDist / focalLength;
    double eyeSep = focalLength * eyeSepMult;

    int width, height;
    plotBase.CalcAvailablePixels(width, height);
    double aspect = double(width)/ double(height);

    double left  = -aspect * wd2 + eyeSep * ndfl;
    double right = aspect * wd2 + eyeSep * ndfl;
    double top    =   wd2;
    double bottom = - wd2;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(left, right, bottom, top, nearDist, farDist);

    Coord3D spanOffset((1.0 - xOrthoSpan)/ 2.0 , (1.0 - yOrthoSpan)/ 2.0 , (1.0 - zOrthoSpan)/ 2.0 );
    Coord3D translation = currView.translation + spanOffset;
    translation *= (maxCoord - minCoord);

    Coord3D lookAtPoint = (minCoord + maxCoord) / 2.0;
    lookAtPoint -= translation;

    double elevAngle = Radians(currView.elevation);
    double rotAngle = Radians(currView.azimuth);

    double dz = focalLength * sin(elevAngle);
    double xylen = focalLength * cos(elevAngle);
    double dx = - xylen * sin(rotAngle);
    double dy = - xylen * cos(rotAngle);

    Coord3D eyeCoord = lookAtPoint;
    eyeCoord.cX += dx;
    eyeCoord.cY += dy;
    eyeCoord.cZ += dz;

    Coord3D upVec(0.0, 0.0, 1.0);
    if (fabs(sin(elevAngle)) > 0.95)
    {
        upVec = Coord3D(sin(rotAngle), cos(rotAngle), 0.0);
        upVec.Normalize();
    }

    if (eyeSep > stdEps)
    {
        Coord3D rsep = CrossProduct(eyeCoord, upVec);
        rsep.Normalize();
        rsep *= eyeSep;
        eyeCoord += rsep;
    }

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(eyeCoord.cX, eyeCoord.cY, eyeCoord.cZ,
              lookAtPoint.cX, lookAtPoint.cY, lookAtPoint.cZ,
              upVec.cX, upVec.cY, upVec.cZ);

    // denormalize
    // scale for normalizations
    glScaled(xOrthoSpan / normSpan.cX, yOrthoSpan / normSpan.cY, zOrthoSpan / normSpan.cZ);

    // translate again for normalizations
    glTranslated(-normMin.cX, -normMin.cY, -normMin.cZ);
}
Пример #20
0
Coord3D PSC_TransparentObject::GetTransPolyCentroid(const SC_CoordArray& inPoly)
{
    if (!transLimits.WithinLimits(inPoly))
        return Coord3D();
    return inPoly.CalcPolyCentroid();
}
Пример #21
0
void OGL3DBase::DrawAxesLabels(const SC_DoubleArray& xMajorIncs,
                                const SC_DoubleArray& xtranMajorIncs,
                                const SC_DoubleArray& yMajorIncs,
                                const SC_DoubleArray& ytranMajorIncs,
                                const SC_DoubleArray& zMajorIncs,
                                const SC_DoubleArray& ztranMajorIncs,
                                const SC_RealFormat&     xFormat,
                                const SC_RealFormat&     yFormat,
                                const SC_RealFormat&     zFormat)
{
    PC_3DAxesLabel&      axesLabel  = plot3Dbase.axesLabel;
    if (!(axesLabel.plotIncrementLabel || axesLabel.plotAxesLabel))
        return;

    PC_3DAxesFormat&     axesFormat = plot3Dbase.axesFormat;


    if (axesLabel.autoPositionLabels)
    {
        axesLabel.xyLabIsVert = (fabs(currView.elevation) < 45.0);
        axesLabel.xLabYPosIsMax = (fabs(currView.azimuth) >= 90.0);
        axesLabel.yLabXPosIsMax = (currView.azimuth < 0.0);
        axesLabel.zLabYPosIsMax = !axesLabel.yLabXPosIsMax;
        axesLabel.zLabXPosIsMax = axesLabel.xLabYPosIsMax;

        if (fabs(currView.azimuth) >= 135.0)
            axesLabel.zLabOrientation = PC_3DAxesLabel::zloXZr;
        else if (currView.azimuth < -45.0)
            axesLabel.zLabOrientation = PC_3DAxesLabel::zloYZn;
        else if (currView.azimuth < 45.0)
            axesLabel.zLabOrientation = PC_3DAxesLabel::zloXZn;
        else
            axesLabel.zLabOrientation = PC_3DAxesLabel::zloYZr;
    }


    SetDrawColor(plot3Dbase.defaultPenSet->GetColor(axesFormat.majorPen));
    double fontRatio = double(axesLabel.incrementFont.fontSize) / double(axesLabel.labelFont.fontSize);

    char labStr[80];
    Coord3D labLoc;
    int i;
    bool adjSt, adjEnd;

    Coord3D minLim, maxLim;
    GetTransformedLimits(minLim, maxLim);
    Coord3D offComp = GetPixelComponents(axesFormat.axesOffset);

    //  x axis first
    SetAlignmentAdjust(xtranMajorIncs, minLim.cX, maxLim.cX, adjSt, adjEnd);
    labLoc = Coord3D(0.0, minLim.cY - offComp.cY, minLim.cZ - offComp.cZ);
    if (axesLabel.xLabYPosIsMax)
        labLoc.cY = maxLim.cY + offComp.cY;

    double rotVal = 0.0;
    if ((!axesLabel.xyLabIsVert) && axesLabel.xLabYPosIsMax)
        rotVal = 180.0;
    bool mirror = (axesLabel.xyLabIsVert) && axesLabel.xLabYPosIsMax;
    Plane3D txtPlane = p3D_XY;
    if (axesLabel.xyLabIsVert)
        txtPlane = p3D_XZ;
    HorizontalTextAlignment halign = hta_Center;
    if (adjSt)
        if (axesLabel.xLabYPosIsMax)
            halign = hta_Right;
        else
            halign = hta_Left;

    bool xyExponents = (xFormat.format > ncf_Scientific) || (yFormat.format > ncf_Scientific);
    double xyIncOffset = -0.25;
    if (xyExponents)
        xyIncOffset = -0.40;

    if (axesLabel.plotIncrementLabel)
    {
        for (i = 0; i < xMajorIncs.Size(); i++)
        {
            labLoc.cX = xtranMajorIncs[i];
            if (Limit::WithinOneLimit(minLim.cX, maxLim.cX, labLoc.cX))
            {
                xFormat.RealToString(xMajorIncs[i], labStr, 80);
                if (adjEnd && (i == (xMajorIncs.Size() - 1)))
                    if (axesLabel.xLabYPosIsMax)
                        halign = hta_Left;
                    else
                        halign = hta_Right;

                Axes3DLabel(axesLabel.incrementFont, labLoc,
                                    0.0, xyIncOffset, rotVal, halign, vta_Top, txtPlane, mirror, labStr);
            }
            halign = hta_Center;
        }
    }

//  need to check both X&Y here
    double xyAxOffset = xyIncOffset - 1.15;

    if (axesLabel.plotAxesLabel)
    {
        if (!axesLabel.plotIncrementLabel)
            xyAxOffset = -.25;
        xyAxOffset *= fontRatio;

        double labWidth, xoverTop, yoverTop;
        GetLabelSpecs(axesLabel.labelFont, axesLabel.xaxesLabel, xoverTop, labWidth);
        GetLabelSpecs(axesLabel.labelFont, axesLabel.yaxesLabel, yoverTop, labWidth);

        if (xoverTop > yoverTop)
            xyAxOffset -= xoverTop;
        else
            xyAxOffset -= yoverTop;
    }


    if (axesLabel.plotAxesLabel && (StringLength(axesLabel.xaxesLabel) > 0))
    {
        labLoc.cX = (minLim.cX + maxLim.cX) / 2.0;
        Axes3DLabel(axesLabel.labelFont, labLoc, 0.0, xyAxOffset,
                            rotVal, hta_Center, vta_Top, txtPlane, mirror, axesLabel.xaxesLabel);
    }

    //  y axes
    SetAlignmentAdjust(ytranMajorIncs, minLim.cY, maxLim.cY, adjSt, adjEnd);
    labLoc = Coord3D(minLim.cX - offComp.cX, 0.0, minLim.cZ - offComp.cZ);

    if (axesLabel.yLabXPosIsMax)
        labLoc.cX = maxLim.cX + offComp.cX;

    rotVal = 0.0;
    if (axesLabel.xyLabIsVert)
        txtPlane = p3D_YZ;
    else
        if (axesLabel.yLabXPosIsMax)
            rotVal = 90.0;
        else
           rotVal = -90.0;

    mirror = (axesLabel.xyLabIsVert) && (!axesLabel.yLabXPosIsMax);
    halign = hta_Center;
    if (adjSt)
        if (axesLabel.yLabXPosIsMax)
            halign = hta_Left;
        else
            halign = hta_Right;

    if (axesLabel.plotIncrementLabel)
    {
        for (i = 0; i < yMajorIncs.Size(); i++)
        {
            labLoc.cY = ytranMajorIncs[i];
            if (Limit::WithinOneLimit(minLim.cY, maxLim.cY, labLoc.cY))
            {
                yFormat.RealToString(yMajorIncs[i], labStr, 80);
                if (adjEnd && (i == (yMajorIncs.Size() - 1)))
                    if (axesLabel.yLabXPosIsMax)
                        halign = hta_Right;
                    else
                        halign = hta_Left;

                Axes3DLabel(axesLabel.incrementFont, labLoc,
                                    0.0, xyIncOffset, rotVal, halign, vta_Top, txtPlane, mirror, labStr);
            }
            halign = hta_Center;
        }
    }

    if (axesLabel.plotAxesLabel && (StringLength(axesLabel.yaxesLabel) > 0))
    {
        labLoc.cY = (minLim.cY + maxLim.cY) / 2.0;
        double fontOffset = -1.50;
        if (!axesLabel.plotIncrementLabel)
            fontOffset = -.25;

        Axes3DLabel(axesLabel.labelFont, labLoc,0.0, xyAxOffset,
                    rotVal, hta_Center, vta_Top, txtPlane, mirror, axesLabel.yaxesLabel);
    }

    //  zaxes
    bool doLeft = false;
    switch (axesLabel.zLabOrientation)
    {
        case PC_3DAxesLabel::zloXZn : {
            txtPlane = p3D_XZ;
            mirror = false;
            doLeft = axesLabel.zLabXPosIsMax;
            break;
        }
        case PC_3DAxesLabel::zloXZr : {
            txtPlane = p3D_XZ;
            mirror = true;
            doLeft = !axesLabel.zLabXPosIsMax;
            break;
        }
        case PC_3DAxesLabel::zloYZn : {
            txtPlane = p3D_YZ;
            mirror = false;
            doLeft = axesLabel.zLabYPosIsMax;
            break;
        }
        case PC_3DAxesLabel::zloYZr : {
            txtPlane = p3D_YZ;
            mirror = true;
            doLeft = !axesLabel.zLabYPosIsMax;
            break;
        }
    }

    double offsetMult = 1.0;
    if (doLeft)
        halign = hta_Left;
    else
    {
        halign = hta_Right;
        offsetMult = -1.0;
    }

    if (axesLabel.zLabYPosIsMax)
        labLoc.cY = maxLim.cY + offComp.cY;
    else
        labLoc.cY = minLim.cY - offComp.cY;

    if (axesLabel.zLabXPosIsMax)
        labLoc.cX = maxLim.cX  + offComp.cX;
    else
        labLoc.cX = minLim.cX  - offComp.cX;


    double zAxOffset = 0.0;
    if (axesLabel.plotIncrementLabel)
    {
        for (i = 0; i < zMajorIncs.Size(); i++)
        {
            labLoc.cZ = ztranMajorIncs[i];
            if (Limit::WithinOneLimit(minLim.cZ, maxLim.cZ, labLoc.cZ))
            {
                zFormat.RealToString(zMajorIncs[i], labStr, 80);
                double labLen, overTop;
                GetLabelSpecs(axesLabel.incrementFont, labStr, overTop, labLen);
                if (labLen > zAxOffset)
                    zAxOffset = labLen;

                Axes3DLabel(axesLabel.incrementFont, labLoc,
                                    0.5 * offsetMult, 0.0, 0.0, halign, vta_Center, txtPlane, mirror, labStr);
            }
        }
    }

    if (axesLabel.plotAxesLabel && (StringLength(axesLabel.zaxesLabel) > 0))
    {
        labLoc.cZ = (minLim.cZ + maxLim.cZ) / 2.0;
        double fontOffset = - (zAxOffset + 0.75) * fontRatio * offsetMult;

        VerticalTextAlignment valign = vta_Bottom;
        if (fontOffset < 0.0)
            valign = vta_Top;

        Axes3DLabel(axesLabel.labelFont, labLoc, 0.0, fontOffset,
                             90.0, hta_Center, valign, txtPlane, mirror, axesLabel.zaxesLabel);
    }
}
Пример #22
0
Coord3D PSC_TransparentObject::GetTransObjectCoord(int objIndex)
{
    GenAppInternalError("PSC_TransparentObject::GetObjectCoord");
    return Coord3D();
}