bool Printer::Move(string axis, double distance, bool relative ) { if ( m_model == NULL ) return false; if ( IsPrinting() ) { alert(_("Can't move while printing")); return false; } Settings *settings = &m_model->settings; float speed = 0.0; if ( axis == "X" || axis == "Y" ) speed = settings->get_double("Hardware","MaxMoveSpeedXY") * 60; else if(axis == "Z") speed = settings->get_double("Hardware","MaxMoveSpeedZ") * 60; else alert (_("Move called with unknown axis")); ostringstream os; if ( relative ) os << "G91\n"; os << "G1 " << axis << distance << " F" << speed; if ( relative ) os << "\nG90"; return Send( os.str() ); }
bool Printer::SwitchPower( bool on ) { if ( IsPrinting() ) { alert(_("Can't switch power while printing")); return false; } string resp; if ( on ) return Send( "M80" ); return Send( "M81" ); }
bool Printer::StopPrinting( bool wait ) { bool ret = ThreadedPrinterSerial::StopPrinting( wait ); if ( ret && wait ) { prev_line = 0; was_printing = IsPrinting(); signal_printing_changed.emit(); } return ret; }
bool Printer::Home( string axis ) { if( IsPrinting() ) { alert(_("Can't go home while printing")); return false; } if ( axis == "X" || axis == "Y" || axis == "Z" ) { return Send("G28 "+axis+"0"); } else if ( axis == "ALL" ) { return Send("G28"); } alert(_("Home called with unknown axis")); return false; }
bool Printer::StartPrinting( string commands, unsigned long start_line, unsigned long stop_line ) { bool ret = ThreadedPrinterSerial::StartPrinting( commands, start_line, stop_line ); if ( ret ) { prev_line = start_line; was_printing = IsPrinting(); signal_printing_changed.emit(); if ( start_line > 0 ) signal_now_printing.emit( start_line ); } return ret; }
bool Printer::CheckPrintingProgress( void ) { bool is_printing = IsPrinting(); unsigned long line = GetPrintingProgress(); if ( is_printing != was_printing ) { prev_line = line; signal_printing_changed.emit(); was_printing = is_printing; } else if ( is_printing && line != prev_line ) { prev_line = line; if ( line > 0 ) signal_now_printing.emit( line ); } return true; }
bool Printer::RunExtruder( double extruder_speed, double extruder_length, bool reverse, int extruder_no ) { if ( IsPrinting() ) { alert(_("Can't manually extrude while printing")); return false; } if ( extruder_no >= 0 ) if ( !SelectExtruder(extruder_no ) ) return false; ostringstream os; os << "M83\n"; os << "G1 E" << ( reverse ? -extruder_length : extruder_length ) << " F" << extruder_speed << "\n"; os << "M82\n"; os << "G1 F1500"; return Send( os.str() ); }
CDrawContext::CDrawContext( const CRect *prcClip, HDC hdc, bool bIsPrinting /*= false */ ) : m_bWeCreatedDC( false ) , m_hdc( hdc ) , m_pFontInfo( NULL ) , m_bBrushSelected( false ) , m_bPenSelected( false ) , m_cxDeviceScaleNumer( 1 ) , m_cxDeviceScaleDenom( 1 ) , m_cyDeviceScaleNumer( 1 ) , m_cyDeviceScaleDenom( 1 ) , m_crCurrentText( 0 ) , m_bIsPrinting( bIsPrinting ) { if( prcClip ) m_rcClip = *prcClip; else m_rcClip.Set(0,0,0,0); if( !m_hdc ) { m_hdc = ::GetDC( g_hwnd ); m_bWeCreatedDC = true; } // Set the device scale if needed if( IsPrinting() ) { HDC screenDC = ::GetDC(g_hwnd); m_cxDeviceScaleNumer = ::GetDeviceCaps(m_hdc, LOGPIXELSX); m_cxDeviceScaleDenom = ::GetDeviceCaps(screenDC, LOGPIXELSX); m_cyDeviceScaleNumer = ::GetDeviceCaps(m_hdc, LOGPIXELSY); m_cyDeviceScaleDenom = ::GetDeviceCaps(screenDC, LOGPIXELSY); ::ReleaseDC(g_hwnd, screenDC); } VAPI( ::SaveDC( m_hdc ) ); ::SetBkMode( m_hdc, TRANSPARENT ); }