void RS_ActionPrintPreview::commandEvent(RS_CommandEvent* e) { QString c = e->getCommand().trimmed().toLower(); // qDebug()<<"cmd="<<c; if (checkCommand("blackwhite", c)) { setBlackWhite(true); RS_DIALOGFACTORY->commandMessage(tr("Printout in Black/White")); e->accept(); return; } else if (checkCommand("color", c)) { setBlackWhite(false); RS_DIALOGFACTORY->commandMessage(tr("Printout in color")); e->accept(); return; } else if (checkCommand("graphoffset", c)) { m_bPaperOffset=false; RS_DIALOGFACTORY->commandMessage(tr("Printout offset in graph coordinates")); e->accept(); return; } else if (checkCommand("paperoffset", c)) { m_bPaperOffset=true; RS_DIALOGFACTORY->commandMessage(tr("Printout offset in paper coordinates")); e->accept(); return; } else if (checkCommand("help", c)) { RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")+tr(": select printout offset coordinates")+ "\n"+tr("type in offset from command line to offset printout") ); e->accept(); return; } //coordinate event if (c.contains(',')) { if(c.startsWith('@')) { RS_DIALOGFACTORY->commandMessage(tr("Printout offset ignores relative zero. Ignoring '@'")); c.remove(0, 1); } // qDebug()<<"offset by absolute coordinate: "; const int commaPos = c.indexOf(','); bool ok1, ok2; double x = RS_Math::eval(c.left(commaPos), &ok1); double y = RS_Math::eval(c.mid(commaPos+1), &ok2); if (ok1 && ok2) { RS_CoordinateEvent ce(RS_Vector(x,y)); this->coordinateEvent(&ce); e->accept(); } } }
void QG_PrintPreviewOptions::setAction(RS_ActionInterface* a, bool update) { if (a!=NULL && a->rtti()==RS2::ActionPrintPreview) { action = static_cast<RS_ActionPrintPreview*>(a); /** fixed scale **/ if(update){ // std::cout<<__FILE__<<" : "<<__FUNCTION__<<" : line "<<__LINE__<<std::endl; // std::cout<<"update="<<update<<" : updateDisabled="<<updateDisabled <<std::endl; // std::cout<<"update="<<update<<" : action->getPaperScaleFixed()="<<action->getPaperScaleFixed() <<std::endl; if(updateDisabled||action->getPaperScaleFixed()){ if(action->getPaperScaleFixed()==false){ RS_SETTINGS->beginGroup("/PrintPreview"); QString&& s=RS_SETTINGS->readEntry("/PrintScaleValue", "1:1"); RS_SETTINGS->endGroup(); updateDisabled=false; scale(s); } updateDisabled=true; setScaleFixed(true); }else{ double&& currScale = action->getScale(); if( currScale > RS_TOLERANCE) scale (currScale); else fit(); updateScaleBox(); setScaleFixed(false); } }else{ double f=action->getScale(); bool btmp=updateDisabled; updateDisabled = true; cbScale->setDuplicatesEnabled(false); RS2::Unit u = action->getUnit(); if (u==RS2::Inch) { cbScale->insertItems(0,imperialScales); } else { cbScale->insertItems(0,metricScales); } defaultScales=cbScale->count(); updateScaleBox(f); updateDisabled = btmp; setScaleFixed(updateDisabled); } setBlackWhite(blackWhiteDisabled); } else { RS_DEBUG->print(RS_Debug::D_ERROR, "QG_PrintPreviewOptions::setAction: wrong action type"); action = NULL; } }