Пример #1
0
void colorChooser::processProcessing() {

  if (numColorsBox_->value() == 0 && !processMode_.userColorsExist()) {
    QMessageBox::information(this, tr("No colors requested"),
                        tr("There are currently no colors being requested - ") +
                             tr("either set the number of colors box on the toolbar to something larger than 0 ") +
                             tr("or click on at least one color on the image to add it to the \"Clicked colors\" list on the right."));
    return;
  }
  QImage workingImage = winManager()->originalImage().copy();
  if (workingImage.isNull()) {
    qWarning() << "Empty image in processProcessing.";
    return;
  }
  workingImage = workingImage.convertToFormat(QImage::Format_RGB32);
  const triState returnCode =
    processMode_.performProcessing(&workingImage, numColorsBox_->value(),
                                   winManager()->getOriginalImageColorCount());
  //qDebug() << "processing time: " << double(t.elapsed())/1000.;
  if (returnCode != triNoop) {
    const colorCompareSaver saver(-1, 0, processMode_.modeText(),
                                  processMode_.colorList());
    winManager()->addColorCompareImage(workingImage,
                                       processMode_.colorList(),
                                       processMode_.flossMode(),
                                       saver);
  }
  else { // processing cancelled
    return;
  }
  if (returnCode == triTrue) { // update dock
    generatedDockHolder_->setEnabled(true);
    generatedDock_->setColorList(processMode_.generatedColorList());
  }
}
Пример #2
0
// winMgr is used to store the currently loaded image (application wide)
// and is where we send our new image when the user clicks "Process",
// among other things.
colorChooser::colorChooser(windowManager* winMgr)
  : imageZoomWindow("", winMgr), processMode_(), clickedDock_(NULL) {

  imageLabel_ = new imageLabel(this);
  connect(imageLabel_, SIGNAL(announceImageClick(QMouseEvent* )),
          this, SLOT(processColorAdd(QMouseEvent* )));

  imageScroll_ = new QScrollArea(this);
  imageScroll_->installEventFilter(this);
  imageScroll_->viewport()->installEventFilter(this);
  imageScroll_->setWidget(imageLabel_);
  setCentralWidget(imageScroll_);

  constructMenuObjects();
  constructProcessingObjects();
  popDock();
  processProcessChange(0); // set processMode_ to the first box entry

  setStatus(tr("Click the left folder icon to open a new image or "
               "the right folder icon to open a saved project."));
  setPermanentStatus(tr("Click 'Choose colors' to continue."));
  setPermanentStatusEnabled(false);

  setWidgetActive(false);
  winManager()->addColorChooserWindow(this);
}
Пример #3
0
int colorChooser::recreateImage(const colorCompareSaver& saver) {

  // set the widget's current processing mode box
  setModeBox(processMode_.savedModeTextToLocale(saver.creationMode()));

  QImage workingImage = winManager()->originalImage().copy();
  if (workingImage.isNull()) {
    qWarning() << "Empty image in recreateImage.";
    return -1;
  }
  workingImage = workingImage.convertToFormat(QImage::Format_RGB32);
  // we don't need to do processMode_.performProcessing since we already
  // have the color list it would produce
  processMode_.restoreSavedImage(&workingImage, saver.colors(),
                                 winManager()->getOriginalImageColorCount());
  winManager()->addColorCompareImage(workingImage,
                                     saver.colors(),
                                     processMode_.flossMode(),
                                     saver,
                                     saver.index());
  return saver.hidden() ? saver.index() : -1;
}
Пример #4
0
void patternWindow::processDelete() {

  QAction* action =
    ::actionFromImageName(imageListMenu_->actions(),
                          findPatternActionName(curImage_->name()));
  delete action;
  imageListBox_->removeItem(imageListBox_->findText(curImage_->name()));
  int removedImageIndex = imageNameToIndex(curImage_->name());
  curImage_ = patternImagePtr(NULL);
  winManager()->patternWindowImageDeleted(removedImageIndex);
  // find a new image - just show the last image since we have no
  // reason to favor any particular image
  const QAction* lastAction = imageListMenu_->actions().last();
  if (! lastAction->data().isNull() &&
      lastAction->data().canConvert<patternImagePtr>()) {
    setCur(lastAction->data().value<patternImagePtr>());
  }
  else {
    // close up shop if there are no images left
    hide();
    winManager()->patternWindowEmpty();
  }
}
Пример #5
0
patternWindow::patternWindow(windowManager* winMgr)
  : imageSaverWindow(tr("Symbols"), winMgr), pdfSymbolDim_(0),
    curImage_(patternImagePtr(NULL)),
    fontMetrics_(QFontMetrics(font())) {

  installEventFilter(this);
  imageLabel_ = new patternImageLabel(this);
  imageLabel_->setGridColor(Qt::black);
  connect(imageLabel_, SIGNAL(announceImageClick(QMouseEvent* )),
          this, SLOT(imageClickSlot(QMouseEvent* )));
  scroll_ = new QScrollArea(this);
  scroll_->installEventFilter(this);
  scroll_->viewport()->installEventFilter(this);
  scroll_->setWidget(imageLabel_);
  setCentralWidget(scroll_);

  dockImageHolder_ = new QDockWidget(this);
  dockImageHolder_->setFeatures(QDockWidget::NoDockWidgetFeatures);
  dockImage_ = new dockImage(winManager()->originalImage(), this);
  dockImageHolder_->setWidget(dockImage_);
  addDockWidget(Qt::RightDockWidgetArea, dockImageHolder_);
  connect(scroll_->horizontalScrollBar(), SIGNAL(valueChanged(int )),
          this, SLOT(labelScrollChange( )));
  connect(scroll_->verticalScrollBar(), SIGNAL(valueChanged(int )),
          this, SLOT(labelScrollChange( )));
  connect(dockImage_, SIGNAL(viewportUpdated(qreal , qreal, bool , bool )),
          this, SLOT(processDockImageUpdate(qreal , qreal, bool , bool )));

  const QFontMetrics metrics(font());
  basePatternDim_ = (metrics.width("@") > metrics.height()) ?
    metrics.width("@") : metrics.height();
  basePatternDim_ = qMax(basePatternDim_, 30);
  listDock_ = new patternDockWidget(basePatternDim_, this);
  setListDockWidget(listDock_);
  connect(listDock_, SIGNAL(changeSymbol(const triC& )),
          this, SLOT(changeSymbolSlot(const triC& )));

  constructActions();
  constructMenus();
  constructToolbar();
  constructPdfViewerDialog();

  setPermanentStatus(tr("Click the 'To pdf' button to save the pattern as a pdf."));
  setStatus(tr("left click: change symbol; right click: switch between square and symbol images"));
}