void SliceEditView::SetSupportTool(QString tool) { PopSupportButtons(); if(tool == "nextTool") { if(pDrawingContext->currSupportTool == "circle") { SetSupportTool("square"); } else if(pDrawingContext->currSupportTool == "square") { SetSupportTool("triangle"); } else if(pDrawingContext->currSupportTool == "triangle") { SetSupportTool("diamond"); } else if(pDrawingContext->currSupportTool == "diamond") { SetSupportTool("circle"); } return; } if(tool == "currTool") { tool = pDrawingContext->currSupportTool; } if(tool == "circle") { QImage img = SimpleSupport(st_CIRCLE,pDrawingContext->supportSize).getCursorImage(); pDrawingContext->setCursor(QCursor(QPixmap().fromImage(img))); ui.actionCircle->setChecked(true); } else if(tool == "square") { QImage img = SimpleSupport(st_SQUARE,pDrawingContext->supportSize).getCursorImage(); pDrawingContext->setCursor(QCursor(QPixmap().fromImage(img))); ui.actionSquare->setChecked(true); } else if(tool == "triangle") { QImage img = SimpleSupport(st_TRIANGLE,pDrawingContext->supportSize).getCursorImage(); pDrawingContext->setCursor(QCursor(QPixmap().fromImage(img))); ui.actionTriangle_2->setChecked(true); } else if(tool == "diamond") { QImage img = SimpleSupport(st_DIAMOND,pDrawingContext->supportSize).getCursorImage(); pDrawingContext->setCursor(QCursor(QPixmap().fromImage(img))); ui.actionDiamond->setChecked(true); } pDrawingContext->currSupportTool = tool; }
///////////////////////////////// //Public ///////////////////////////////// SliceEditView::SliceEditView(QWidget *parent, /*Qt::WFlags flags*/ Qt::WindowFlags flags ) : QMainWindow(parent, flags) { //ui.setupUi(this); bGrid = false; supportMode = false; pCPJ = NULL; backupIndx = 0; m_xOffset = 0; m_yOffset = 0; currSlice = 0; setWindowIcon(QIcon(":/B9JobBuilder/icons/edit.png")); setStatusBar(0); //green timer connections greenTimer.setSingleShot(true); greenTimer.setInterval(0); greenTimer.stop(); QObject::connect(&greenTimer,SIGNAL(timeout()),this,SLOT(RefreshWithGreen())); pDrawingContext = new DrawingContext(this); pDrawingContext->pEditView = this; SetSupportTool("circle"); SetDrawTool("penfill"); //fixed_csh /*ui.actionPrepare_Base_Gap->setEnabled(false); ui.menuSupports->setEnabled(false); ui.scrollArea->setWidget(pDrawingContext); ui.scrollArea->setFocusPolicy(Qt::NoFocus);*/ QObject::connect(this,SIGNAL(sliceDirtied(QImage*, int)),parent,SLOT(PatchJobData(QImage*, int))); //toolbars //fixed_csh /*ui.toolBar->addAction(ui.actionSupport_Mode); ui.toolBar->addSeparator(); ui.toolBar->addAction(ui.actionWhite_Pen); ui.toolBar->addAction(ui.actionBlack_Pen); ui.toolBar->addAction(ui.actionFlood_Fill); ui.toolBar->addAction(ui.actionFlood_Void); ui.toolBar->addSeparator(); ui.toolBar->addAction(ui.actionCircle); ui.toolBar->addAction(ui.actionSquare); ui.toolBar->addAction(ui.actionTriangle_2); ui.toolBar->addAction(ui.actionDiamond);*/ ShowSupportButtons(false); }
//////////////////////////////// //Protected //////////////////////////////// void SliceEditView::keyPressEvent(QKeyEvent * pEvent) { if(pEvent->key() == Qt::Key_PageUp) { PgUpSlice(10); } else if(pEvent->key() == Qt::Key_PageDown) { PgDownSlice(10); } else if(pEvent->key() == Qt::Key_Control) { pDrawingContext->fastsupportmode = false; } else if(pEvent->key() == Qt::Key_C) { SetSupportTool("nextTool"); } else if(pEvent->key() == Qt::Key_Delete) { if(supportMode) { QPixmap bucket(":/Cursors/icons/delete.png","PNG"); pDrawingContext->setCursor(QCursor(bucket)); pDrawingContext->deletemode = true; } } else if(pEvent->key() == Qt::Key_Shift) { pDrawingContext->supportSize = pDrawingContext->supportSize * 0.5; SetSupportTool("currTool"); } else { QWidget::keyPressEvent(pEvent); } }
void SliceEditView::keyReleaseEvent(QKeyEvent * pEvent) { if(pEvent->key() == Qt::Key_Control) { pDrawingContext->fastsupportmode = true; } else if(pEvent->key() == Qt::Key_Shift) { pDrawingContext->supportSize = pDrawingContext->supportSize*2; SetSupportTool("currTool"); } else if(pEvent->key() == Qt::Key_Delete) { if(supportMode) { SetSupportTool("currTool"); pDrawingContext->deletemode = false; } } else { QWidget::keyPressEvent(pEvent); } }
//public slots void SliceEditView::TogSupportMode() { supportMode = !supportMode; if(supportMode)//going INTO support mode { //fixed_csh /*ui.actionSupport_Mode->setText("Enter Image Mode"); ui.menuDrawing->setEnabled(false); ui.menuSupports->setEnabled(true); ui.actionCopy->setEnabled(false); ui.actionPaste->setEnabled(false);*/ ShowDrawButtons(false); ShowSupportButtons(true); //ui.actionPrepare_Base_Gap->setEnabled(true); SetSupportTool("currTool"); pCPJ->showSupports(true); DeCompressIntoContext(); pDrawingContext->GenerateLogicImage(); RefreshWithGreen(); } else//comming OUT of support mode { //fixed_csh /*ui.actionSupport_Mode->setText("Enter Support Mode"); ui.menuDrawing->setEnabled(true); ui.menuSupports->setEnabled(false); ui.actionCopy->setEnabled(true); ui.actionPaste->setEnabled(true);*/ ShowDrawButtons(true); ShowSupportButtons(false); // ui.actionPrepare_Base_Gap->setEnabled(false); SetDrawTool("currTool"); pCPJ->showSupports(false); DeCompressIntoContext(); } UpdateWidgets(); }
void SliceEditView::on_actionDiamond_activated() { SetSupportTool("diamond"); }
void SliceEditView::on_actionTriangle_2_activated() { SetSupportTool("triangle"); }
void SliceEditView::on_actionSquare_activated() { SetSupportTool("square"); }
void SliceEditView::on_actionCircle_activated() { SetSupportTool("circle"); }