コード例 #1
0
ファイル: dcprint.cpp プロジェクト: EdgarTx/wx
wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
{
#if !wxMAC_USE_CORE_GRAPHICS
    ::GetPort( & m_macPrintFormerPort ) ;
#endif
    m_err = noErr ;
    wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) data->GetNativeData() ;

    PMRect rPage;
    m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
    if ( m_err != noErr )
        return;

    m_maxX = wxCoord(rPage.right - rPage.left) ;
    m_maxY = wxCoord(rPage.bottom - rPage.top);

    PMResolution res;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 
    PMPrinter printer;
    PMSessionGetCurrentPrinter(native->m_macPrintSession, &printer);
    PMPrinterGetOutputResolution( printer, native->m_macPrintSettings, &res) ;
#else
    m_err = PMGetResolution((PMPageFormat) (native->m_macPageFormat), &res);
#endif
    m_ppi = wxSize(int(res.hRes), int(res.vRes));
}
コード例 #2
0
    virtual void go() {
        release();
        param *p = param::instance();
        update_values(p);

        Iso_rectangle_2 bbox = get_bbox(p);
        std::string ndvi_file = p->get<boost::filesystem::path>("ndvi").string();
        std::string  dsm_file = p->get<boost::filesystem::path>("dsm" ).string();
        clip_bbox(bbox,ndvi_file);
        clip_bbox(bbox,dsm_file );

        gradient_functor gf(p->get<double>("sigmaD"));
        oriented_gradient_view grad_view(dsm_file,  bbox, gf);
        oriented_ndvi_view     ndvi_view(ndvi_file, bbox);

        m_confg_visitor->add_layer(ndvi_file);
        m_confg_visitor->add_layer(dsm_file);
        set_bbox(p,bbox);
        wxPoint p0(wxCoord(bbox.min().x()),wxCoord(bbox.min().y()));
        wxPoint p1(wxCoord(bbox.max().x()),wxCoord(bbox.max().y()));
        m_confg_visitor->set_bbox(wxRect(p0,p1));

        init_visitor        (p,*m_visitor);
        create_configuration(p,grad_view,ndvi_view,m_config);
        create_sampler      (p,m_sampler);
        create_schedule     (p,m_schedule);
        create_end_test     (p,m_end_test);

        m_thread = new boost::thread(
                simulated_annealing::optimize<configuration,sampler,schedule,end_test,visitor>,
                boost::ref(*m_config), boost::ref(*m_sampler),
                boost::ref(*m_schedule), boost::ref(*m_end_test),
                boost::ref(*m_visitor) );
    }
コード例 #3
0
ファイル: dcprint.cpp プロジェクト: iokto/newton-dynamics
wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
{
    m_err = noErr ;
    wxOSXPrintData *native = (wxOSXPrintData*) data->GetNativeData() ;

    PMRect rPage;
    m_err = PMGetAdjustedPageRect(native->GetPageFormat(), &rPage);
    if ( m_err != noErr )
        return;

    m_maxX = wxCoord(rPage.right - rPage.left) ;
    m_maxY = wxCoord(rPage.bottom - rPage.top);

    PMResolution res;
    PMPrinter printer;
    m_err = PMSessionGetCurrentPrinter(native->GetPrintSession(), &printer);
    if ( m_err == noErr )
    {
        m_err = PMPrinterGetOutputResolution( printer, native->GetPrintSettings(), &res) ;
        if ( m_err == -9589 /* kPMKeyNotFound */ )
        {
            m_err = noErr ;
            res.hRes = res.vRes = 300;
        }
    }
    else
    {
        res.hRes = res.vRes = 300;
    }

    m_maxX = wxCoord((double)m_maxX * res.hRes / 72.0);
    m_maxY = wxCoord((double)m_maxY * res.vRes / 72.0);

    m_ppi = wxSize(int(res.hRes), int(res.vRes));
}
コード例 #4
0
bool wxMacCarbonPrinterDC::StartDoc(  wxPrinterDC* dc , const wxString& message  )
{
    if ( m_err )
        return false ;

    wxPrinterDCImpl *impl = (wxPrinterDCImpl*) dc->GetImpl();
    wxOSXPrintData *native = (wxOSXPrintData*) impl->GetPrintData().GetNativeData() ;

    PMPrintSettingsSetJobName(native->GetPrintSettings(), wxCFStringRef(message));

    m_err = PMSessionBeginCGDocumentNoDialog(native->GetPrintSession(),
              native->GetPrintSettings(),
              native->GetPageFormat());
    if ( m_err != noErr )
        return false;

    PMRect rPage;
    m_err = PMGetAdjustedPageRect(native->GetPageFormat(), &rPage);
    if ( m_err != noErr )
        return false ;

    m_maxX = wxCoord(rPage.right - rPage.left) ;
    m_maxY = wxCoord(rPage.bottom - rPage.top);

    PMResolution res;
    PMPrinter printer;

    m_err = PMSessionGetCurrentPrinter(native->GetPrintSession(), &printer);
    if (m_err == noErr)
    {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
        if ( PMPrinterGetOutputResolution != NULL )
        {
            m_err = PMPrinterGetOutputResolution( printer, native->GetPrintSettings(), &res) ;
            if ( m_err == -9589 /* kPMKeyNotFound */ )
            {
                m_err = noErr ;
                res.hRes = res.vRes = 300;
            }
        }
        else
#endif
        {
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
            if ( PMPrinterGetPrinterResolution(printer, kPMCurrentValue, &res) != noErr )
            {
                res.hRes = res.vRes = 300;
            }
#endif
        }
    }
    
    m_maxX = wxCoord((double)m_maxX * res.hRes / 72.0);
    m_maxY = wxCoord((double)m_maxY * res.vRes / 72.0);

    m_ppi = wxSize(int(res.hRes), int(res.vRes));
    return true ;
}
コード例 #5
0
ファイル: dcgraph.cpp プロジェクト: animecomico/wxWidgets
void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
                               double angle)
{
    wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );

    if ( text.empty() )
        return;
    if ( !m_logicalFunctionSupported )
        return;

    // we test that we have some font because otherwise we should still use the
    // "else" part below to avoid that DrawRotatedText(angle = 180) and
    // DrawRotatedText(angle = 0) use different fonts (we can't use the default
    // font for drawing rotated fonts unfortunately)
    if ( (angle == 0.0) && m_font.IsOk() )
    {
        DoDrawText(text, x, y);
        
        // Bounding box already updated by DoDrawText(), no need to do it again.
        return;
    }
            
    // Get extent of whole text.
    wxCoord w, h, heightLine;
    GetOwner()->GetMultiLineTextExtent(text, &w, &h, &heightLine);
    
    // Compute the shift for the origin of the next line.
    const double rad = wxDegToRad(angle);
    const double dx = heightLine * sin(rad);
    const double dy = heightLine * cos(rad);
    
    // Draw all text line by line
    const wxArrayString lines = wxSplit(text, '\n', '\0');
    for ( size_t lineNum = 0; lineNum < lines.size(); lineNum++ )
    {
        // Calculate origin for each line to avoid accumulation of
        // rounding errors.
        if ( m_backgroundMode == wxTRANSPARENT )
            m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ));
        else
            m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ), m_graphicContext->CreateBrush(m_textBackgroundColour) );
   }
            
    // call the bounding box by adding all four vertices of the rectangle
    // containing the text to it (simpler and probably not slower than
    // determining which of them is really topmost/leftmost/...)
    
    // "upper left" and "upper right"
    CalcBoundingBox(x, y);
    CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
    
    // "bottom left" and "bottom right"
    x += (wxCoord)(h*sin(rad));
    y += (wxCoord)(h*cos(rad));
    CalcBoundingBox(x, y);
    CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
}
コード例 #6
0
ファイル: dcprint.cpp プロジェクト: Bluehorn/wxPython
wxRect wxPrinterDC::GetPaperRect()
{
    wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) m_printData.GetNativeData() ;
    OSStatus err = noErr ;
    PMRect rPaper;
    err = PMGetAdjustedPaperRect(native->m_macPageFormat, &rPaper);
    if ( err != noErr )
        return pageRect;
    return wxRect(wxCoord(rPaper.left), wxCoord(rPaper.top),
        wxCoord(rPaper.right - rPaper.left), wxCoord(rPaper.bottom - rPaper.top));
}
コード例 #7
0
ファイル: dcprint.cpp プロジェクト: beanhome/dev
wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
{
    m_err = noErr ;
    wxOSXPrintData *native = (wxOSXPrintData*) data->GetNativeData() ;

    PMRect rPage;
    m_err = PMGetAdjustedPageRect(native->GetPageFormat(), &rPage);
    if ( m_err != noErr )
        return;

    m_maxX = wxCoord(rPage.right - rPage.left) ;
    m_maxY = wxCoord(rPage.bottom - rPage.top);

    PMResolution res;
    PMPrinter printer;
    m_err = PMSessionGetCurrentPrinter(native->GetPrintSession(), &printer);
    if ( m_err == noErr )
    {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
        if ( PMPrinterGetOutputResolution != NULL )
        {
            {
                m_err = PMPrinterGetOutputResolution( printer, native->GetPrintSettings(), &res) ;
                if ( m_err == -9589 /* kPMKeyNotFound */ )
                {
                    m_err = noErr ;
                    res.hRes = res.vRes = 300;
                }
            }
        }
        else
#endif
        {
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
            m_err = PMPrinterGetPrinterResolution(printer, kPMCurrentValue, &res);
            if ( m_err != noErr )
            {
                m_err = PMGetResolution((PMPageFormat) (native->GetPageFormat()), &res);
            }
#endif
        }
    }
    else
    {
        res.hRes = res.vRes = 300;
    }

    m_maxX = wxCoord((double)m_maxX * res.hRes / 72.0);
    m_maxY = wxCoord((double)m_maxY * res.vRes / 72.0);

    m_ppi = wxSize(int(res.hRes), int(res.vRes));
}
コード例 #8
0
ファイル: dcprint.cpp プロジェクト: Bluehorn/wxPython
wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
{
    ::GetPort( & m_macPrintFormerPort ) ;

    m_err = noErr ;
    wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) data->m_nativePrintData ;

    PMRect rPage;
    m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
    if ( m_err != noErr )
        return;

    m_maxX = wxCoord(rPage.right - rPage.left) ;
    m_maxY = wxCoord(rPage.bottom - rPage.top);
}
コード例 #9
0
ファイル: dcprint.cpp プロジェクト: EdgarTx/wx
bool wxMacCarbonPrinterDC::StartDoc(  wxPrinterDC* dc , const wxString& WXUNUSED(message)  )
{
    if ( m_err )
        return false ;

    wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ;

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4 && wxMAC_USE_CORE_GRAPHICS
    {
        CFStringRef s[1] = { kPMGraphicsContextCoreGraphics };
        CFArrayRef  graphicsContextsArray = CFArrayCreate(NULL, (const void**)s, 1, &kCFTypeArrayCallBacks);
        PMSessionSetDocumentFormatGeneration(native->m_macPrintSession, kPMDocumentFormatPDF, graphicsContextsArray, NULL);
        CFRelease(graphicsContextsArray);
    }
#endif
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 && wxMAC_USE_CORE_GRAPHICS
    m_err = PMSessionBeginCGDocument(native->m_macPrintSession,
              native->m_macPrintSettings,
              native->m_macPageFormat);
#else
    m_err = PMSessionBeginDocument(native->m_macPrintSession,
              native->m_macPrintSettings,
              native->m_macPageFormat);

#endif

    if ( m_err != noErr )
        return false;

    PMRect rPage;
    m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
    if ( m_err != noErr )
        return false ;

    m_maxX = wxCoord(rPage.right - rPage.left) ;
    m_maxY = wxCoord(rPage.bottom - rPage.top);

    PMResolution res;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 
    PMPrinter printer;
    PMSessionGetCurrentPrinter(native->m_macPrintSession, &printer);
    PMPrinterGetOutputResolution( printer, native->m_macPrintSettings, &res) ;
#else
    m_err = PMGetResolution((PMPageFormat) (native->m_macPageFormat), &res);
#endif
    m_ppi = wxSize(int(res.hRes), int(res.vRes));
    return true ;
}
コード例 #10
0
ファイル: AlListBox.cpp プロジェクト: anonbeat/guayadeque
// -------------------------------------------------------------------------------- //
wxCoord guAlListBox::OnMeasureItem( size_t n ) const
{
    // Code taken from the generic/listctrl.cpp file
    guAlListBox * self = wxConstCast( this, guAlListBox );

    self->SetItemHeight( ALLISTBOX_ITEM_SIZE );
    return wxCoord( ALLISTBOX_ITEM_SIZE );
}
コード例 #11
0
wxRect wxPrinterDCImpl::GetPaperRect() const
{
    wxCoord w, h;
    GetOwner()->GetSize(&w, &h);
    wxRect pageRect(0, 0, w, h);
    wxOSXPrintData *native = (wxOSXPrintData*) m_printData.GetNativeData() ;
    OSStatus err = noErr ;
    PMRect rPaper;
    err = PMGetAdjustedPaperRect(native->GetPageFormat(), &rPaper);
    if ( err != noErr )
        return pageRect;

    wxSize ppi = GetOwner()->GetPPI();
    rPaper.right *= (ppi.x / 72.0);
    rPaper.bottom *= (ppi.y / 72.0);
    rPaper.left *= (ppi.x / 72.0);
    rPaper.top *= (ppi.y / 72.0);

    return wxRect(wxCoord(rPaper.left), wxCoord(rPaper.top),
        wxCoord(rPaper.right - rPaper.left), wxCoord(rPaper.bottom - rPaper.top));
}
コード例 #12
0
void ddPolyLineHandle::draw(wxBufferedDC& context, ddDrawingView *view)
{
    //DD-TODO: set graphic style
    ddRect copy = getDisplayBox();
    view->CalcScrolledPosition(copy.x,copy.y,&copy.x,&copy.y);

    double middle=copy.width/2;
    context.DrawCircle(
        wxPoint(copy.x+middle,copy.y+middle),
        wxCoord(middle)
    );
    //DD-TODO: improve this draw
}
コード例 #13
0
void hdPolyLineHandle::draw(wxBufferedDC &context, hdDrawingView *view)
{
	//A Handle at polyline figure without a respetive flexibility point at line
	//Hack to allow handles of polylines reuse between different versions of same line.
	if(getOwner() && indx < (((hdPolyLineFigure *) getOwner())->countPointsAt(view->getIdx()) - 1) ) //indx 0 is first, count first is 1
	{
		hdRect copy = getDisplayBox(view->getIdx());
		view->CalcScrolledPosition(copy.x, copy.y, &copy.x, &copy.y);

		/* Uncomment this for testing purposes of handles in a polyline figure
		wxString pos = wxString::Format(_("%d"),indx);
		double middle2 = copy.width / 2;
		context.DrawText(pos,copy.x + middle2+3, copy.y + middle2);
		*/

		double middle = copy.width / 2;
		context.DrawCircle(
		    wxPoint(copy.x + middle, copy.y + middle),
		    wxCoord(middle)
		);
	}
}
コード例 #14
0
wxCoord ComicalBrowser::OnMeasureItem(size_t n) const
{
    return wxCoord(m_iThumbMaxWidth * 0.6f);
}
コード例 #15
0
void GraphPane::PartialRefresh()
{
    wxClientDC dc(this);

    wxCoord width, height;
    this->GetSize(&width, &height);

    // Set the origin at the centre
    dc.SetDeviceOrigin(wxCoord(width/2), wxCoord(height/2));

    if (GraphInfoVector != NULL & !GraphInfoVector->empty()) {
        // Declare iterators for each set of coordinates --> Loop through all trails/sets of coordinates
        std::vector<GraphInfo*>::const_iterator CoordSetIt;

        // Declare iterators for each trail
        std::deque<double>::const_iterator XCoordIt;
        std::deque<double>::const_iterator YCoordIt;

        //Begin iterating
        CoordSetIt = GraphInfoVector->begin();

        wxPen BGPen = wxPen(BlackBG ? *wxBLACK : *wxWHITE, 1);
        wxBrush BGBrush = wxBrush(BlackBG ? *wxBLACK : *wxWHITE);

        while (CoordSetIt != GraphInfoVector->end()) {
            dc.SetPen(BGPen);
            // Erase terminator circle
            if ((*CoordSetIt)->XCoordinate.size() > unsigned(NewPoints) + 1) {
                XCoordIt = (*CoordSetIt)->XCoordinate.end() - NewPoints - 1;
                YCoordIt = (*CoordSetIt)->YCoordinate.end() - NewPoints - 1;
            } else {
                XCoordIt = (*CoordSetIt)->XCoordinate.begin();
                YCoordIt = (*CoordSetIt)->YCoordinate.begin();
            }
            dc.SetBrush(BGBrush);
            if ((*CoordSetIt)->TermSize > 0) {
                dc.DrawEllipse(wxCoord((*XCoordIt) * ScalingFactor - (*CoordSetIt)->TermSize), wxCoord((*YCoordIt) * ScalingFactor* (-1) - (*CoordSetIt)->TermSize),
                                   (*CoordSetIt)->TermSize * 2, (*CoordSetIt)->TermSize * 2);
            }

            // Draw back points
            if ((*CoordSetIt)->XCoordinate.size() > unsigned(NewPoints) + (*CoordSetIt)->TermSize + 1) {
                XCoordIt -= (*CoordSetIt)->TermSize;
                YCoordIt -= (*CoordSetIt)->TermSize;
            } else {
                XCoordIt = (*CoordSetIt)->XCoordinate.begin();
                YCoordIt = (*CoordSetIt)->YCoordinate.begin();
            }

            if ((*CoordSetIt)->TrailColour == *wxBLACK && BlackBG) {
                dc.SetBrush(wxBrush(*wxBLACK));
                dc.SetPen(wxPen(*wxBLACK, 1));
            } else {
                dc.SetBrush(wxBrush((*CoordSetIt)->TrailColour));
                dc.SetPen(wxPen((*CoordSetIt)->TrailColour, 1));
            }

            while (XCoordIt != (*CoordSetIt)->XCoordinate.end()) {
                dc.DrawPoint(wxCoord((*XCoordIt) * ScalingFactor), wxCoord((*YCoordIt) * ScalingFactor* (-1)));
                ++XCoordIt;
                ++YCoordIt;
            }

            --XCoordIt;
            --YCoordIt;

            // Draw terminator circle
            if ((*CoordSetIt)->TermSize > 0) {
                dc.DrawEllipse(wxCoord((*XCoordIt) * ScalingFactor - (*CoordSetIt)->TermSize),
                               wxCoord((*YCoordIt) * ScalingFactor* (-1) - (*CoordSetIt)->TermSize),
                               (*CoordSetIt)->TermSize * 2, (*CoordSetIt)->TermSize * 2);
            }

            ++CoordSetIt;
        }
    }
}
コード例 #16
0
void GraphPane::FullRefresh(wxDC& dc)
{
    // Erase Background
    wxCoord width, height;
    this->GetSize(&width, &height);

    dc.SetPen((BlackBG ? *wxBLACK_PEN : *wxWHITE_PEN));
    dc.SetBrush(BlackBG ? *wxBLACK_BRUSH : *wxWHITE_BRUSH);
    dc.DrawRectangle(0, 0, width, height);

    // Set the origin at the centre
    dc.SetDeviceOrigin(wxCoord(width/2), wxCoord(height/2));


    wxPen pen((BlackBG ? *wxWHITE : *wxBLACK), 1);
    wxBrush brush((BlackBG ? *wxBLACK_BRUSH : *wxWHITE_BRUSH));
    dc.SetPen(pen);

    if (GraphInfoVector != NULL && !(GraphInfoVector->empty())) {

        // Declare iterators for each set of coordinates --> Loop through all trails/sets of coordinates
        std::vector<GraphInfo*>::const_iterator CoordSetIt;

        // Declare iterators for each trail
        std::deque<double>::const_iterator XCoordIt;
        std::deque<double>::const_iterator YCoordIt;

        //Begin iterating
        CoordSetIt = GraphInfoVector->begin();

        while (CoordSetIt != GraphInfoVector->end()) {
            // Set Colour
            if ((*CoordSetIt)->TrailColour == *wxBLACK && BlackBG) {
                    pen = wxPen(*wxWHITE, 1);
            } else {
                    pen = wxPen((*CoordSetIt)->TrailColour, 1);
            }
            dc.SetPen(pen);

            // Iterate through all coordinates
            if ((*CoordSetIt)->XCoordinate.size() > unsigned(NewPoints)) {
                XCoordIt = (*CoordSetIt)->XCoordinate.begin() + NewPoints - 1;
                YCoordIt = (*CoordSetIt)->YCoordinate.begin() + NewPoints - 1;
            }
            else {
                XCoordIt = (*CoordSetIt)->XCoordinate.begin();
                YCoordIt = (*CoordSetIt)->YCoordinate.begin();
            }


            while (XCoordIt != (*CoordSetIt)->XCoordinate.end()) {
                dc.DrawPoint(wxCoord((*XCoordIt) * ScalingFactor), wxCoord((*YCoordIt) * ScalingFactor* (-1)));
                XCoordIt++;
                YCoordIt++;
            }


            // If terminator size > 0, draw circle terminator at last coordinate.
            if ((*CoordSetIt)->TermSize > 0) {
                XCoordIt--;
                YCoordIt--;

                if ((*CoordSetIt)->TrailColour == *wxBLACK && BlackBG) {
                    brush.SetColour(*wxWHITE);
                } else {
                    brush.SetColour((*CoordSetIt)->TrailColour);
                }
                dc.SetBrush(brush);
                dc.DrawEllipse(wxCoord((*XCoordIt) * ScalingFactor - (*CoordSetIt)->TermSize),
                               wxCoord((*YCoordIt) * ScalingFactor* (-1) - (*CoordSetIt)->TermSize),
                               (*CoordSetIt)->TermSize * 2, (*CoordSetIt)->TermSize * 2);
            }

            ++CoordSetIt;
        }
    }
}
コード例 #17
0
ファイル: calreview_dialog.cpp プロジェクト: AndresPozo/phd2
// Build the calibration "step" graph which will appear on the lefthand side of the panels
wxBitmap CalReviewDialog::CreateGraph(bool AO)
{
    wxMemoryDC memDC;
    wxBitmap bmp(CALREVIEW_BITMAP_SIZE, CALREVIEW_BITMAP_SIZE, -1);
    wxPen axisPen("GREY", 3, wxCROSS_HATCH);
    wxColour raColor = pFrame->pGraphLog->GetRaOrDxColor();
    wxColour decColor = pFrame->pGraphLog->GetDecOrDyColor();
    wxPen raPen(raColor, 3, wxSOLID);
    wxPen decPen(decColor, 3, wxSOLID);
    wxBrush raBrush(raColor, wxSOLID);
    wxBrush decBrush(decColor, wxSOLID);
    CalibrationDetails calDetails;
    double scaleFactor;
    int ptRadius;

    if (!pSecondaryMount)
    {
        pMount->GetCalibrationDetails(&calDetails);                              // Normal case, no AO
    }
    else
    {
        if (AO)
        {
            pMount->GetCalibrationDetails(&calDetails);                          // AO tab, use AO details
        }
        else
        {
            pSecondaryMount->GetCalibrationDetails(&calDetails);                 // Mount tab, use mount details
        }
    }

    // Find the max excursion from the origin in order to scale the points to fit the bitmap
    double biggestVal = -100.0;
    for (std::vector<wxRealPoint>::const_iterator it = calDetails.raSteps.begin(); it != calDetails.raSteps.end(); ++it)
    {
        biggestVal = wxMax(biggestVal, fabs(it->x));
        biggestVal = wxMax(biggestVal, fabs(it->y));
    }

    for (std::vector<wxRealPoint>::const_iterator it = calDetails.decSteps.begin(); it != calDetails.decSteps.end(); ++it)
    {
        biggestVal = wxMax(biggestVal, fabs(it->x));
        biggestVal = wxMax(biggestVal, fabs(it->y));
    }

    if (biggestVal > 0.0)
        scaleFactor = ((CALREVIEW_BITMAP_SIZE - 5) / 2) / biggestVal;           // Leave room for circular point
    else
        scaleFactor = 1.0;

    memDC.SelectObject(bmp);
    memDC.SetBackground(*wxBLACK_BRUSH);
    memDC.Clear();
    memDC.SetPen(axisPen);
    // Draw the axes
    memDC.SetDeviceOrigin(wxCoord(CALREVIEW_BITMAP_SIZE / 2), wxCoord(CALREVIEW_BITMAP_SIZE / 2));
    memDC.DrawLine(-CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2, 0);               // x
    memDC.DrawLine(0, -CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2);               // y

    if (calDetails.raStepCount > 0)
    {
        // Draw the RA data
        memDC.SetPen(raPen);
        memDC.SetBrush(raBrush);
        ptRadius = 2;

        // Scale the points, then plot them individually
        for (int i = 0; i < (int) calDetails.raSteps.size(); i++)
        {
            if (i == calDetails.raStepCount + 2)        // Valid even for "single-step" calibration
            {
                memDC.SetPen(wxPen(raColor, 1));         // 1-pixel-thick outline
                memDC.SetBrush(wxNullBrush);           // Outline only for "return" data points
                ptRadius = 3;
            }
            memDC.DrawCircle(IntPoint(calDetails.raSteps.at(i), scaleFactor), ptRadius);
        }
        // Show the line PHD2 will use for the rate
        memDC.SetPen(raPen);
        if ((int)calDetails.raSteps.size() > calDetails.raStepCount)         // New calib, includes return values
            memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor), IntPoint(calDetails.raSteps.at(calDetails.raStepCount), scaleFactor));
        else
            memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor), IntPoint(calDetails.raSteps.at(calDetails.raStepCount - 1), scaleFactor));
    }

    // Handle the Dec data
    memDC.SetPen(decPen);
    memDC.SetBrush(decBrush);
    ptRadius = 2;
    if (calDetails.decStepCount > 0)
    {
    for (int i = 0; i < (int) calDetails.decSteps.size(); i++)
        {
            if (i == calDetails.decStepCount + 2)
            {
                memDC.SetPen(wxPen(decColor, 1));         // 1-pixel-thick outline
                memDC.SetBrush(wxNullBrush);           // Outline only for "return" data points
                ptRadius = 3;
            }
            memDC.DrawCircle(IntPoint(calDetails.decSteps.at(i), scaleFactor), ptRadius);
        }
        // Show the line PHD2 will use for the rate
        memDC.SetPen(decPen);
        if ((int)calDetails.decSteps.size() > calDetails.decStepCount)         // New calib, includes return values
            memDC.DrawLine(IntPoint(calDetails.decSteps.at(0), scaleFactor), IntPoint(calDetails.decSteps.at(calDetails.decStepCount), scaleFactor));
        else
        memDC.DrawLine(IntPoint(calDetails.decSteps.at(0), scaleFactor), IntPoint(calDetails.decSteps.at(calDetails.decStepCount - 1), scaleFactor));
    }

    memDC.SelectObject(wxNullBitmap);
    return bmp;
}
コード例 #18
0
ファイル: dc.cpp プロジェクト: EEmmanuel7/wxWidgets
wxCoord wxQtDCImpl::GetCharWidth() const
{
    //FIXME: Returning max width, instead of average
    QFontMetrics metrics(m_qtPainter->font());
    return wxCoord( metrics.maxWidth() );
}
コード例 #19
0
ファイル: dc.cpp プロジェクト: EEmmanuel7/wxWidgets
wxCoord wxQtDCImpl::GetCharHeight() const
{
    QFontMetrics metrics(m_qtPainter->font());
    return wxCoord( metrics.height() );
}
コード例 #20
0
void WSortView::paint(wxDC& dc, const wxSize& dcsize)
{
    dc.SetBackground(*wxBLACK_BRUSH);
    dc.Clear();

    if (size() == 0) return;

    size_t fwidth = dcsize.GetWidth();
    size_t fheight = dcsize.GetHeight();

    size_t width = fwidth - 20;
    size_t height = fheight - 20;

    dc.SetDeviceOrigin(10,10);

    // *** draw array element bars

    // draw | | | |  bars: each bar is width w, separation is w/2
    // thus n bars need n * w + (n-1) * w/2 width

    // 1st variant: space is 0.5 of bar size
    //double wbar = width / (size() + (size()-1) / 2.0);
    //double bstep = 1.5 * wbar;

    // 2nd variant: one pixel between bars
    double wbar = (width - (size()-1)) / (double)size();
    if (width <= (size()-1)) wbar = 0.0;

    double bstep = wbar + 1.0;

    // special case for bstep = 2 pixel -> draw 2 pixel bars instead of 1px
    // bar/1px gaps.
    if ( fabs(wbar - 1.0) < 0.1 && fabs(bstep - 2.0) < 0.1 ) wbar = 2, bstep = 2;

    static const wxPen pens[] = {
        *wxWHITE_PEN,
        *wxRED_PEN,
        *wxGREEN_PEN,
        *wxCYAN_PEN,
        wxPen(wxColour(255,255,0)),   //  4 yellow
        wxPen(wxColour(255,0,255)),   //  5 magenta
        wxPen(wxColour(255,192,128)), //  6 orange
        wxPen(wxColour(255,128,192)), //  7 pink
        wxPen(wxColour(128,192,255)), //  8 darker cyan
        wxPen(wxColour(192,255,128)), //  9 darker green
        wxPen(wxColour(192,128,255)), // 10 purple
        wxPen(wxColour(128,255,192)), // 11 light green
        wxPen(wxColour(128,128,255)), // 12 blue
        wxPen(wxColour(192,128,192)), // 13 dark purple
        wxPen(wxColour(128,192,192)), // 14 dark cyan
        wxPen(wxColour(192,192,128)), // 15 dark yellow
        wxPen(wxColour(0,128,255)),   // 16 blue/cyan mix
    };

    static const wxBrush brushes[] = {
        *wxWHITE_BRUSH,
        *wxRED_BRUSH,
        *wxGREEN_BRUSH,
        *wxCYAN_BRUSH,
        wxBrush(wxColour(255,255,0)),   //  4 yellow
        wxBrush(wxColour(255,0,255)),   //  5 magenta
        wxBrush(wxColour(255,192,128)), //  6 orange
        wxBrush(wxColour(255,128,192)), //  7 pink
        wxBrush(wxColour(128,192,255)), //  8 darker cyan
        wxBrush(wxColour(192,255,128)), //  9 darker green
        wxBrush(wxColour(192,128,255)), // 10 purple
        wxBrush(wxColour(128,255,192)), // 11 light green
        wxBrush(wxColour(128,128,255)), // 12 blue
        wxBrush(wxColour(192,128,192)), // 13 dark purple
        wxBrush(wxColour(128,192,192)), // 14 dark cyan
        wxBrush(wxColour(192,192,128)), // 15 dark yellow
        wxBrush(wxColour(0,128,255)),   // 16 blue/cyan mix
    };

    wxMutexLocker lock(m_mutex);
    ASSERT(lock.IsOk());

    for (size_t i = 0; i < size(); ++i)
    {
        int clr;

        // select color
        if (i == m_access1.index)
        {
            clr = m_access1.color;
        }
        else if (i == m_access2.index)
        {
            clr = m_access2.color;
        }
        else if ( (clr = InWatchList(i)) != 0 )
        {
            // clr already set
        }
        else if (m_mark[i] != 0)
        {
            clr = m_mark[i];
        }
        else if ( (clr = InAccessList(i)) >= 0 )
        {
        }
        else
        {
            clr = 0;
        }

        ASSERT(clr < (int)(sizeof(brushes) / sizeof(brushes[0])));
        dc.SetPen( pens[clr] );
        dc.SetBrush( brushes[clr] );

        dc.DrawRectangle(i*bstep, height,
                         wxMax(1, // draw at least 1 pixel
                               (wxCoord((i+1)*bstep) - wxCoord(i*bstep)) // integral gap to next bar
                               - (bstep - wbar)    // space between bars
                             ),
                         -(double)height * m_array[i].get_direct() / m_array_max);
    }
}