Beispiel #1
0
    void Octant::Insert(SceneNode* obj)
    {
        const BoundingBox& box = obj->GetWorldBoundingBox();

        // If drawable is outside the root octant bounds, insert to root
        bool insertHere;
        if (this == root_)
            insertHere = cullingBox_.IsInside(box) != Intersection::INSIDE || CheckFit(box);
        else
            insertHere = CheckFit(box);

        if (insertHere)
        {
            Octant* oldOctant = obj->GetOctant();
            if (oldOctant != this)
            {
                // Add first, then remove, because drawable count going to zero deletes the octree branch in question
                Add(obj);
                if (oldOctant)
                    oldOctant->Remove(obj, false);
            }
        }
        else
        {
            Vector3 boxCenter = box.Center();
            unsigned x = boxCenter.x < center_.x ? 0 : 1;
            unsigned y = boxCenter.y < center_.y ? 0 : 2;
            unsigned z = boxCenter.z < center_.z ? 0 : 4;

            GetOrCreateChild(x + y + z)->Insert(obj);
        }
    }
Beispiel #2
0
double CSurface3DElement::DoOp(double X, double Y, LPCSurface3DElement &pElement)
  {
  if (!m_bFitDone)
    {
    long Ix=0;
    long Iy=0;
    CSurface3DPoint BL(0.0, 0.0, (m_r3D.m_fnZ(m_dMinimumX, m_dMinimumY)));
    CSurface3DPoint BR(1.0, 0.0, (m_r3D.m_fnZ(m_dMaximumX, m_dMinimumY)));
    CSurface3DPoint TL(0.0, 1.0, (m_r3D.m_fnZ(m_dMinimumX, m_dMaximumY)));
    CSurface3DPoint TR(1.0, 1.0, (m_r3D.m_fnZ(m_dMaximumX, m_dMaximumY)));
    CSurface3DPoint CC(0.5, 0.5, (m_r3D.m_fnZ(0.5*(m_dMinimumX+m_dMaximumX), 0.5*(m_dMinimumY+m_dMaximumY))));
    Fit(m_nDivsX, m_nDivsY, BL, BR, TL, TR, CC);
    m_bFitOK=CheckFit();
    }
  if (m_bFitOK)
    {
    double Val=ValueXY(X,Y);
    //dbgpln("== %12.3f %12.3f = %12.3f %s", X,Y,Val, (LPCTSTR)m_3D.m_sName);
    pElement=this;
    return Val;
    }

  if (m_Elements==NULL)
    {
    InitElements();    
    m_r3D.MRU_Remove(this);
    }

  long Ix=X2MapI(X);
  long Iy=Y2MapI(Y);
  CSurface3DElement &E=GetElement(Ix, Iy);
  if (!E.m_bInitDone)
    {
    E.Initialise(m_dMinimumX+Ix*m_dDivWidthX, m_dMinimumX+(Ix+1)*m_dDivWidthX, m_nDivsX,
                 m_dMinimumY+Iy*m_dDivWidthY, m_dMinimumY+(Iy+1)*m_dDivWidthY, m_nDivsY);
    }
  return E.DoOp(X,Y, pElement);
  }
Beispiel #3
0
void wxHtmlPrintout::OnPreparePrinting()
{
    int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h;
    float ppmm_h, ppmm_v;

    GetPageSizePixels(&pageWidth, &pageHeight);
    GetPageSizeMM(&mm_w, &mm_h);
    ppmm_h = (float)pageWidth / mm_w;
    ppmm_v = (float)pageHeight / mm_h;

    int ppiPrinterX, ppiPrinterY;
    GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
    wxUnusedVar(ppiPrinterX);
    int ppiScreenX, ppiScreenY;
    GetPPIScreen(&ppiScreenX, &ppiScreenY);
    wxUnusedVar(ppiScreenX);

    wxDisplaySize(&scr_w, &scr_h);
    GetDC()->GetSize(&dc_w, &dc_h);

    GetDC()->SetUserScale((double)dc_w / (double)pageWidth,
                          (double)dc_h / (double)pageHeight);

    /* prepare headers/footers renderer: */

    m_RendererHdr->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
    m_RendererHdr->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)),
                          (int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom)));
    if (m_Headers[0] != wxEmptyString)
    {
        m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[0], 1));
        m_HeaderHeight = m_RendererHdr->GetTotalHeight();
    }
    else if (m_Headers[1] != wxEmptyString)
    {
        m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[1], 1));
        m_HeaderHeight = m_RendererHdr->GetTotalHeight();
    }
    if (m_Footers[0] != wxEmptyString)
    {
        m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[0], 1));
        m_FooterHeight = m_RendererHdr->GetTotalHeight();
    }
    else if (m_Footers[1] != wxEmptyString)
    {
        m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[1], 1));
        m_FooterHeight = m_RendererHdr->GetTotalHeight();
    }

    /* prepare main renderer: */
    m_Renderer->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);

    const int printAreaW = int(ppmm_h * (mm_w - m_MarginLeft - m_MarginRight));
    int printAreaH = int(ppmm_v * (mm_h - m_MarginTop - m_MarginBottom));
    if ( m_HeaderHeight )
        printAreaH -= int(m_HeaderHeight + m_MarginSpace * ppmm_v);
    if ( m_FooterHeight )
        printAreaH -= int(m_FooterHeight + m_MarginSpace * ppmm_v);

    m_Renderer->SetSize(printAreaW, printAreaH);
    m_Renderer->SetHtmlText(m_Document, m_BasePath, m_BasePathIsDir);

    if ( CheckFit(wxSize(printAreaW, printAreaH),
                  wxSize(m_Renderer->GetTotalWidth(),
                         m_Renderer->GetTotalHeight())) )
    {
        // do paginate the document
        CountPages();
    }
    //else: if we don't call CountPages() m_PageBreaks remains empty and our
    //      GetPageInfo() will return 0 as max page and so nothing will be
    //      printed
}