Ejemplo n.º 1
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();
}
Ejemplo n.º 2
0
bool PC_TransparencySpec::TransparencySetup()
{
    int nobj = plotDef.plotObjList.Size();
    objectIsTransparent.AllocAndFill(nobj, false);

    int nanno = plotDef.annoObjList.Size();
    annoIsTransparent.AllocAndFill(nanno, false);
    if (!useTransparency)
        return false;

    // get initial counts & objects
    int tranCount = 0;
    for (int i = 0; i < nobj; i++)
    {
        const PlotObjC& nextObj = plotDef.plotObjList.GetRef(i);

        if (nextObj.doPlot && nextObj.StatusOK() && nextObj.SupportsTransparency())
        {
            int objCount = nextObj.GetnTransObjects();
            if ((objCount > 0) &&
                    (transparencyGroups[nextObj.GetTransGroup()].groupIsTransparent))
            {
                objectIsTransparent[i] = true;
                tranCount += objCount;
            }
        }
    }

    int annoTranCount = 0;
    for (int i = 0; i < nanno; i++)
    {
        const AnnoObjC& nextObj = plotDef.annoObjList.GetRef(i);

        if (nextObj.doPlot && nextObj.StatusOK() && nextObj.SupportsTransparency())
        {
            if (transparencyGroups[nextObj.GetTransGroup()].groupIsTransparent)
            {
                annoIsTransparent[i] = true;
                annoTranCount++;
            }
        }
    }

    annoOnly = (tranCount == 0);
    if (annoOnly)
        return (annoTranCount > 0);

    PC_View currView = plotDef.GetCurrentView();

    Coord3D zeroOffset(0.0, 0.0, 0.0);
    Coord3D minCoord = plotDef.GetNormalizedCoord(currView.viewLimits.minLim, zeroOffset);
    Coord3D maxCoord = plotDef.GetNormalizedCoord(currView.viewLimits.maxLim, zeroOffset);;

    Line3D tempLine(minCoord, maxCoord);
    double maxLength = tempLine.Length() * 2.0;
    Coord3D lookAtPoint = tempLine.PointOnLine(0.5);

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

    double dz = maxLength * sin(elevAngle);
    double xylen = maxLength * cos(elevAngle);

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

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

    tranObjectList.Alloc(tranCount);
    tranCount = 0;
    Coord3D objCoord;
    double minDist, maxDist;
    for (int i = 0; i < nobj; i++)
        if (objectIsTransparent[i])
        {
            PlotObjC& nextObj = plotDef.plotObjList.GetRef(i);
            nextObj.SetupForGetCoord();
            int objCount = nextObj.GetnTransObjects();
            for (int j = 0; j < objCount; j++)
            {
                ObjectTransDesc& nextDesc = tranObjectList[tranCount];
                objCoord = nextObj.GetTransObjectCoord(j);
                if (objCoord.CoordIsNull())
                    continue;

                objCoord = plotDef.GetNormalizedCoord(objCoord, nextObj.offsetCoord);
                if (objCoord.CoordIsNull())
                    continue;

                double nextDist = objCoord.Distance(eyeCoord);
                if (tranCount == 0)
                {
                    minDist = nextDist;
                    maxDist = nextDist;
                }
                else
                {
                    if (nextDist < minDist)
                        minDist = nextDist;
                    else if (nextDist > maxDist)
                        maxDist = nextDist;
                }

                nextDesc.objDist = nextDist;
                nextDesc.objRef = &nextObj;
                nextDesc.objIndex = j;
                nextDesc.objGroup = nextObj.GetTransGroup();
                tranCount++;
            }
        }

    if (tranCount == 0)
    {
        annoOnly = (annoTranCount > 0);
        objectIsTransparent.FillToAlloc(false);
        return annoOnly;
    }

    int ndistanceGroups = tranCount / 500;

    // now place in buckets for sorting
    if (ndistanceGroups < 2)
    {
        ndistanceGroups = 1;
        // easy just use 1 bucket
        objectSortArray.AllocAndSetSize(1);
        objectSortArray[0].Alloc(tranCount);
        for (int i = 0; i < tranCount; i++)
            objectSortArray[0] += &(tranObjectList[i]);
    }
    else
    {
        if (ndistanceGroups > 5000)
            ndistanceGroups = 5000;
        if (ndistanceGroups < 100)
            ndistanceGroups = 100;

        objectSortArray.AllocAndSetSize(ndistanceGroups);
        for (int i = 0; i < ndistanceGroups; i++)
            objectSortArray[i].SetResizable(tranCount / ndistanceGroups * 5);

        double deltaDist = (maxDist - minDist) / double(ndistanceGroups);
        for (int i = 0; i < tranCount; i++)
        {
            ObjectTransDesc& nextDesc = tranObjectList[i];
            int currGroup = int((nextDesc.objDist - minDist) / deltaDist);
            if (currGroup >= ndistanceGroups)
                currGroup = ndistanceGroups - 1;
            if (currGroup < 0)
                currGroup = 0;
            objectSortArray[currGroup] += &nextDesc;
        }
    }

    // now sort each
    for (int k = 0; k < objectSortArray.Size(); k++)
    {
        ObjPtrList& currList = objectSortArray[k];
        QSort(currList, 0, currList.UpperBound());
    }

    return true;
}