void QImageWidget::setGeometry(int nx, int ny, int nw, int nh) { xx = nx; yy = ny; w = nw; h = nh; //move(xx,yy); //resize(w,h); image = original_image.copy(); QWidget::setGeometry(xx,yy,w,h); if(w > 0 && h > 0 && ( w < image.width() || h < image.height() ) ) { image = image.scaled(w, h, Qt::KeepAspectRatio); clearMask(); perhapsSetMask(); } else if(w > image.width() || h > image.height()) { //qt3 image = image.smoothScale(w,h,Qt::KeepAspectRatio); image.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation); clearMask(); perhapsSetMask(); } repaint(0,0,w,h); }
void setPixmap(QPixmap pm) { if ( pm.mask() ) { setMask( *pm.mask() ); } else { clearMask(); } resize(pm.width(),pm.height()); setErasePixmap(pm); }
void setPixmap(QPixmap pm) { pixmap = pm; if (!pixmap.mask().isNull()) { setMask(pixmap.mask()); } else { clearMask(); } resize(pm.width(),pm.height()); }
void MASK::initMask(int w, int h, int areasize, int level) { delMask(); m = new char[w * h]; m1 = new char[w * h]; this->w = w; this->h = h; this->areasize = areasize; this->level = level; clearMask(); }
void QwtWidgetOverlay::updateMask() { d_data->resetRgbaBuffer(); QRegion mask; if ( d_data->maskMode == QwtWidgetOverlay::MaskHint ) { mask = maskHint(); } else if ( d_data->maskMode == QwtWidgetOverlay::AlphaMask ) { // TODO: the image doesn't need to be larger than // the bounding rectangle of the hint !! QRegion hint = maskHint(); if ( hint.isEmpty() ) hint += QRect( 0, 0, width(), height() ); // A fresh buffer from calloc() is usually faster // than reinitializing an existing one with // QImage::fill( 0 ) or memset() d_data->rgbaBuffer = ( uchar* )::calloc( width() * height(), 4 ); QImage image( d_data->rgbaBuffer, width(), height(), qwtMaskImageFormat() ); QPainter painter( &image ); draw( &painter ); painter.end(); mask = qwtAlphaMask( image, hint.rects() ); if ( d_data->renderMode == QwtWidgetOverlay::DrawOverlay ) { // we don't need the buffer later d_data->resetRgbaBuffer(); } } // A bug in Qt initiates a full repaint of the widget // when we change the mask, while we are visible ! setVisible( false ); if ( mask.isEmpty() ) clearMask(); else setMask( mask ); setVisible( true ); }
/*! Show/Hide the area outside of the frame \param show Show if TRUE, hide if FALSE \sa QwtDial::hasVisibleBackground, QWidget::setMask \warning When QwtDial is a toplevel widget the window border might disappear too. */ void QwtDial::showBackground(bool show) { if ( d_visibleBackground != show ) { d_visibleBackground = show; if ( d_visibleBackground ) clearMask(); else setMask(QRegion(boundingRect(), QRegion::Ellipse)); update(); } }
void MenuBar::updateMask() { // Enable the mask only when compositing is disabled; // As this operation is quite slow, it would be nice to find some // way to workaround it for no-compositing users. if (KWindowSystem::compositingActive()) { clearMask(); Plasma::WindowEffects::overrideShadow(winId(), true); Plasma::WindowEffects::enableBlurBehind(winId(), true, m_background->mask()); m_shadows->addWindow(this, Plasma::FrameSvg::BottomBorder|Plasma::FrameSvg::LeftBorder|Plasma::FrameSvg::RightBorder); } else { setMask(m_background->mask()); } }
void Stack::updateMask() { clearMask(); raise(); if (m_scenes->isVisible()) { QApplication::processEvents(); m_scenes->update(); m_scenes->clearFocus(); m_scenes->setFocus(); } if (m_header_visible || m_footer_visible) { setMask(rect().adjusted(0, m_header_visible, 0, m_footer_visible)); } }
void OSDPretty::Reposition() { QDesktopWidget* desktop = QApplication::desktop(); // Make the OSD the proper size layout()->activate(); resize(sizeHint()); // Work out where to place the OSD. -1 for x or y means "on the right or // bottom edge". QRect geometry(desktop->availableGeometry(popup_display_)); int x = popup_pos_.x() < 0 ? geometry.right() - width() : geometry.left() + popup_pos_.x(); int y = popup_pos_.y() < 0 ? geometry.bottom() - height() : geometry.top() + popup_pos_.y(); #ifndef Q_OS_WIN32 // windows needs negative coordinates for monitors // to the left or above the primary x = qBound(0, x, geometry.right() - width()); y = qBound(0, y, geometry.bottom() - height()); #endif move(x, y); // Create a mask for the actual area of the OSD QBitmap mask(size()); mask.clear(); QPainter p(&mask); p.setBrush(Qt::color1); p.drawRoundedRect(BoxBorder().adjusted(-1, -1, 0, 0), kBorderRadius, kBorderRadius); p.end(); // If there's no compositing window manager running then we have to set an // XShape mask. if (IsTransparencyAvailable()) clearMask(); else { setMask(mask); } #ifdef Q_OS_WIN32 // On windows, enable blurbehind on the masked area QtWin::enableBlurBehindWindow(this, true, QRegion(mask)); #endif }
/* Recreate mini-toolbar mask */ void VBoxMiniToolBar::recreateMask() { int iEdgeShift = height(); int iPoints[8]; switch (m_alignment) { case AlignTop: { iPoints[0] = 0; iPoints[1] = 0; iPoints[2] = iEdgeShift; iPoints[3] = height(); iPoints[4] = width() - iEdgeShift; iPoints[5] = height(); iPoints[6] = width(); iPoints[7] = 0; break; } case AlignBottom: { iPoints[0] = iEdgeShift; iPoints[1] = 0; iPoints[2] = 0; iPoints[3] = height(); iPoints[4] = width(); iPoints[5] = height(); iPoints[6] = width() - iEdgeShift; iPoints[7] = 0; break; } default: break; } /* Make sure any old mask is removed first: */ clearMask(); /* Set the new mask */ QPolygon polygon; polygon.setPoints(4, iPoints); setMask(polygon); }
void MainWin::set_options(MainWinOptions::Settings settings) { ui.toolBar->setVisible(!settings.hide_toolbar); closeToTray = settings.close_to_tray; hideFrame = settings.hide_frame; toolWindow = settings.tool_window; setWindowOpacity(1 - (settings.trans_percent / 100.0)); roundCorners = (settings.round_corners && hideFrame); if(roundCorners && hideFrame) { QRegion r = roundRectRegion(0, 0, width(), height(), 6); setMask(r); } else clearMask(); onTop = settings.on_top; updateFlags(); }
void ToolTip::resizeEvent(QResizeEvent *e) { QWidget::resizeEvent(e); d->background->resizeFrame(size()); if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) { WindowEffects::enableBlurBehind(winId(), true, d->background->mask()); clearMask(); } else { setMask(d->background->mask()); } d->preview->setInfo(); if (isVisible()) { adjustPosition(e->oldSize(), e->size()); } }
void QImageWidget::setImage(const char *filename) { image.load(filename); //#ifdef USE_MAEMO // unlink(filename); //#endif clearMask(); if(w > 0 && h > 0 && ( w < image.width() || h < image.height() ) ) { //printf("set1: setImage %s xy=%d,%d w=%d h=%d width=%d height=%d\n", filename, //x(), y(), w, h, // image.width(),image.height()); image = image.scaled(w, h, Qt::KeepAspectRatio); } else if(w > image.width() || h > image.height()) { //printf("set2: setImage %s xy=%d,%d w=%d h=%d width=%d height=%d\n", filename, //x(),y(),w, h, // image.width(),image.height()); //qt3 image = image.smoothScale(w,h,Qt::KeepAspectRatio); image.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation); } if(strstr(filename,".bmp") != NULL || strstr(filename,".BMP") != NULL) { // it may be a bmp with transparent background #if QT_VERSION < 0x050000 int n = image.numColors(); #else int n = image.colorCount(); #endif for(int icol=0; icol<n; icol++) { QRgb qcol = image.color(icol); if(qRed(qcol) == 1 && qGreen(qcol) == 1 && qBlue(qcol) == 1) { // image has transparent background //image.setAlphaBuffer(true); image.setColor(icol,qRgba(1,1,1,0)); image.createAlphaMask(); } } } perhapsSetMask(); original_image = image.copy(); repaint(); }
void QImageWidget::setImage(const QImage *newimage) { image = newimage->copy(); if(w > 0 && h > 0 && ( w < image.width() || h < image.height() ) ) { image = image.scaled(w, h, Qt::KeepAspectRatio); } else if(w > image.width() || h > image.height()) { //qt3 image = image.smoothScale(w,h,Qt::KeepAspectRatio); image.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation); } clearMask(); perhapsSetMask(); w = image.width(); h = image.height(); original_image = image.copy(); }
void BannerWidgetPrivate::resizeEvent( QResizeEvent* event ) { clearMask(); QFont f = font(); m_textRect = QFontMetrics( f ).boundingRect( text() ); m_textRect.adjust( 0, 0, 0, 5 ); m_transformMatrix.reset(); //Tiny optimization and means math.h doesn't need to be included //and saves some runtime ops. I shouldn't imagine sin(45) is likely to change anytime soon! const float sin45 = 0.707106781186548f; m_transformMatrix.translate( event->size().width() - ((sin45 * m_textRect.width()) + 6 ), (sin45 * m_textRect.height()) - 6 ); m_transformMatrix.rotate( 45 ); QRegion mask = m_transformMatrix.map( QRegion( m_textRect.adjusted( -20, 0, 20, 0 ) ) ); setMask( mask ); }
InstrumentWindowMaskTab::InstrumentWindowMaskTab(InstrumentWindow* instrWindow): QFrame(instrWindow), m_instrumentWindow(instrWindow), m_activity(Select), m_userEditing(true) { m_instrumentDisplay = m_instrumentWindow->getInstrumentDisplay(); // main layout QVBoxLayout* layout=new QVBoxLayout(this); // Create the tool buttons m_move = new QPushButton(); m_move->setCheckable(true); m_move->setAutoExclusive(true); m_move->setIcon(QIcon(":/PickTools/selection-tube.png")); m_move->setToolTip("Move the instrument"); m_pointer = new QPushButton(); m_pointer->setCheckable(true); m_pointer->setAutoExclusive(true); m_pointer->setIcon(QIcon(":/MaskTools/selection-pointer.png")); m_pointer->setToolTip("Select and edit shapes"); m_ellipse = new QPushButton(); m_ellipse->setCheckable(true); m_ellipse->setAutoExclusive(true); m_ellipse->setIcon(QIcon(":/MaskTools/selection-circle.png")); m_ellipse->setToolTip("Draw an ellipse"); m_rectangle = new QPushButton(); m_rectangle->setCheckable(true); m_rectangle->setAutoExclusive(true); m_rectangle->setIcon(QIcon(":/MaskTools/selection-box.png")); m_rectangle->setToolTip("Draw a rectangle"); m_ring_ellipse = new QPushButton(); m_ring_ellipse->setCheckable(true); m_ring_ellipse->setAutoExclusive(true); m_ring_ellipse->setIcon(QIcon(":/MaskTools/selection-circle.png")); m_ring_ellipse->setToolTip("Draw an elliptical ring"); m_ring_rectangle = new QPushButton(); m_ring_rectangle->setCheckable(true); m_ring_rectangle->setAutoExclusive(true); m_ring_rectangle->setIcon(QIcon(":/MaskTools/selection-box.png")); m_ring_rectangle->setToolTip("Draw a rectangular ring "); QHBoxLayout* toolBox = new QHBoxLayout(); toolBox->addWidget(m_move); toolBox->addWidget(m_pointer); toolBox->addWidget(m_ellipse); toolBox->addWidget(m_rectangle); toolBox->addWidget(m_ring_ellipse); toolBox->addWidget(m_ring_rectangle); toolBox->addStretch(); toolBox->setSpacing(2); connect(m_move,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_pointer,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_ellipse,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_rectangle,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_ring_ellipse,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_ring_rectangle,SIGNAL(clicked()),this,SLOT(setActivity())); m_move->setChecked(true); layout->addLayout(toolBox); // Create property browser /* Create property managers: they create, own properties, get and set values */ m_groupManager = new QtGroupPropertyManager(this); m_doubleManager = new QtDoublePropertyManager(this); connect(m_doubleManager,SIGNAL(propertyChanged(QtProperty*)),this,SLOT(doubleChanged(QtProperty*))); /* Create editors and assign them to the managers */ DoubleEditorFactory *doubleEditorFactory = new DoubleEditorFactory(this); m_browser = new QtTreePropertyBrowser(); m_browser->setFactoryForManager(m_doubleManager, doubleEditorFactory); layout->addWidget(m_browser); // Algorithm buttons m_apply = new QPushButton("Apply"); connect(m_apply,SIGNAL(clicked()),this,SLOT(applyMask())); m_clear_all = new QPushButton("Clear All"); connect(m_clear_all,SIGNAL(clicked()),this,SLOT(clearMask())); m_save_as_workspace_include = new QAction("Save As Workspace (include)",this); connect(m_save_as_workspace_include,SIGNAL(activated()),this,SLOT(saveMaskToWorkspaceInclude())); m_save_as_workspace_exclude = new QAction("Save As Workspace (exclude)",this); connect(m_save_as_workspace_exclude,SIGNAL(activated()),this,SLOT(saveMaskToWorkspaceExclude())); m_save_as_file_include = new QAction("Save As File (include)",this); connect(m_save_as_file_include,SIGNAL(activated()),this,SLOT(saveMaskToFileInclude())); m_save_as_file_exclude = new QAction("Save As File (exclude)",this); connect(m_save_as_file_exclude,SIGNAL(activated()),this,SLOT(saveMaskToFileExclude())); QPushButton* saveButton = new QPushButton("Save"); QMenu* saveMenu = new QMenu(this); saveMenu->addAction(m_save_as_workspace_include); saveMenu->addAction(m_save_as_workspace_exclude); saveMenu->addAction(m_save_as_file_include); saveMenu->addAction(m_save_as_file_exclude); saveButton->setMenu(saveMenu); QGridLayout* buttons = new QGridLayout(); buttons->addWidget(m_apply,0,0); buttons->addWidget(m_clear_all,0,1); buttons->addWidget(saveButton,1,0,1,2); layout->addLayout(buttons); }
InstrumentWindowMaskTab::InstrumentWindowMaskTab(InstrumentWindow* instrWindow): InstrumentWindowTab(instrWindow), m_activity(Select), m_hasMaskToApply(false), m_userEditing(true) { // main layout QVBoxLayout* layout=new QVBoxLayout(this); m_activeTool = new QLabel(this); layout->addWidget(m_activeTool); // Create the tool buttons m_move = new QPushButton(); m_move->setCheckable(true); m_move->setAutoExclusive(true); m_move->setIcon(QIcon(":/PickTools/zoom.png")); m_move->setToolTip("Move the instrument (Ctrl+Alt+M)"); m_move->setShortcut(QKeySequence("Ctrl+Alt+M")); m_pointer = new QPushButton(); m_pointer->setCheckable(true); m_pointer->setAutoExclusive(true); m_pointer->setIcon(QIcon(":/MaskTools/selection-edit.png")); m_pointer->setToolTip("Select and edit shapes (Ctrl+Alt+P)"); m_pointer->setShortcut(QKeySequence("Ctrl+Alt+P")); m_ellipse = new QPushButton(); m_ellipse->setCheckable(true); m_ellipse->setAutoExclusive(true); m_ellipse->setIcon(QIcon(":/MaskTools/selection-circle.png")); m_ellipse->setToolTip("Draw an ellipse (Ctrl+Alt+E)"); m_ellipse->setShortcut(QKeySequence("Ctrl+Alt+E")); m_rectangle = new QPushButton(); m_rectangle->setCheckable(true); m_rectangle->setAutoExclusive(true); m_rectangle->setIcon(QIcon(":/MaskTools/selection-box.png")); m_rectangle->setToolTip("Draw a rectangle (Ctrl+Alt+R)"); m_rectangle->setShortcut(QKeySequence("Ctrl+Alt+R")); m_ring_ellipse = new QPushButton(); m_ring_ellipse->setCheckable(true); m_ring_ellipse->setAutoExclusive(true); m_ring_ellipse->setIcon(QIcon(":/MaskTools/selection-circle-ring.png")); m_ring_ellipse->setToolTip("Draw an elliptical ring (Shift+Alt+E)"); m_ring_ellipse->setShortcut(QKeySequence("Shift+Alt+E")); m_ring_rectangle = new QPushButton(); m_ring_rectangle->setCheckable(true); m_ring_rectangle->setAutoExclusive(true); m_ring_rectangle->setIcon(QIcon(":/MaskTools/selection-box-ring.png")); m_ring_rectangle->setToolTip("Draw a rectangular ring (Shift+Alt+R)"); m_ring_rectangle->setShortcut(QKeySequence("Shift+Alt+R")); QHBoxLayout* toolBox = new QHBoxLayout(); toolBox->addWidget(m_move); toolBox->addWidget(m_pointer); toolBox->addWidget(m_ellipse); toolBox->addWidget(m_rectangle); toolBox->addWidget(m_ring_ellipse); toolBox->addWidget(m_ring_rectangle); toolBox->addStretch(); toolBox->setSpacing(2); toolBox->setMargin(0); connect(m_move,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_pointer,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_ellipse,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_rectangle,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_ring_ellipse,SIGNAL(clicked()),this,SLOT(setActivity())); connect(m_ring_rectangle,SIGNAL(clicked()),this,SLOT(setActivity())); m_move->setChecked(true); QFrame* toolGroup = new QFrame(); toolGroup->setLayout(toolBox); layout->addWidget(toolGroup); // create mask/group switch m_masking_on = new QRadioButton("Mask"); m_grouping_on = new QRadioButton("Group"); m_masking_on->setChecked(true); connect(m_masking_on,SIGNAL(toggled(bool)),this,SLOT(toggleMaskGroup(bool))); QHBoxLayout* radioLayout = new QHBoxLayout(); radioLayout->addWidget(m_masking_on); radioLayout->addWidget(m_grouping_on); radioLayout->setMargin(0); QWidget* radioGroup = new QWidget(); radioGroup->setLayout(radioLayout); layout->addWidget(radioGroup); // Create property browser /* Create property managers: they create, own properties, get and set values */ m_groupManager = new QtGroupPropertyManager(this); m_doubleManager = new QtDoublePropertyManager(this); connect(m_doubleManager,SIGNAL(propertyChanged(QtProperty*)),this,SLOT(doubleChanged(QtProperty*))); /* Create editors and assign them to the managers */ DoubleEditorFactory *doubleEditorFactory = new DoubleEditorFactory(this); m_browser = new QtTreePropertyBrowser(); m_browser->setFactoryForManager(m_doubleManager, doubleEditorFactory); layout->addWidget(m_browser); // Algorithm buttons m_apply = new QPushButton("Apply to Data"); m_apply->setToolTip("Apply current mask to the data workspace. Cannot be reverted."); connect(m_apply,SIGNAL(clicked()),this,SLOT(applyMask())); m_apply_to_view = new QPushButton("Apply to View"); m_apply_to_view->setToolTip("Apply current mask to the view."); connect(m_apply_to_view,SIGNAL(clicked()),this,SLOT(applyMaskToView())); m_clear_all = new QPushButton("Clear All"); m_clear_all->setToolTip("Clear all masking that have not been applied to the data."); connect(m_clear_all,SIGNAL(clicked()),this,SLOT(clearMask())); m_save_as_workspace_exclude = new QAction("As Mask to workspace",this); m_save_as_workspace_exclude->setToolTip("Save current mask to mask workspace."); connect(m_save_as_workspace_exclude,SIGNAL(activated()),this,SLOT(saveMaskToWorkspace())); m_save_as_workspace_include = new QAction("As ROI to workspace",this); m_save_as_workspace_include->setToolTip("Save current mask as ROI to mask workspace."); connect(m_save_as_workspace_include,SIGNAL(activated()),this,SLOT(saveInvertedMaskToWorkspace())); m_save_as_file_exclude = new QAction("As Mask to file",this); m_save_as_file_exclude->setToolTip("Save current mask to mask file."); connect(m_save_as_file_exclude,SIGNAL(activated()),this,SLOT(saveMaskToFile())); m_save_as_file_include = new QAction("As ROI to file",this); m_save_as_file_include->setToolTip("Save current mask as ROI to mask file."); connect(m_save_as_file_include,SIGNAL(activated()),this,SLOT(saveInvertedMaskToFile())); m_save_as_cal_file_exclude = new QAction("As Mask to cal file",this); m_save_as_cal_file_exclude->setToolTip("Save current mask to cal file."); connect(m_save_as_cal_file_exclude,SIGNAL(activated()),this,SLOT(saveMaskToCalFile())); m_save_as_cal_file_include = new QAction("As ROI to cal file",this); m_save_as_cal_file_include->setToolTip("Save current mask as ROI to cal file."); connect(m_save_as_cal_file_include,SIGNAL(activated()),this,SLOT(saveInvertedMaskToCalFile())); m_save_as_table_xrange_exclude = new QAction("As Mask to table", this); m_save_as_table_xrange_exclude->setToolTip("Save current mask to a table workspace with x-range. " "The name of output table workspace is 'MaskBinTable'. " "If the output table workspace has alrady exist, then " "the newly masked detectors will be added to output workspace."); connect(m_save_as_table_xrange_exclude, SIGNAL(activated()), this, SLOT(saveMaskToTable())); m_save_group_file_include = new QAction("As include group to file",this); m_save_group_file_include->setToolTip("Save current mask as include group to a file."); connect(m_save_group_file_include,SIGNAL(activated()),this,SLOT(saveIncludeGroupToFile())); m_save_group_file_exclude = new QAction("As exclude group to file",this); m_save_group_file_exclude->setToolTip("Save current mask as exclude group to a file."); connect(m_save_group_file_exclude,SIGNAL(activated()),this,SLOT(saveExcludeGroupToFile())); m_extract_to_workspace = new QAction("Extract detectors to workspace",this); m_extract_to_workspace->setToolTip("Extract detectors to workspace."); connect(m_extract_to_workspace,SIGNAL(activated()),this,SLOT(extractDetsToWorkspace())); m_sum_to_workspace = new QAction("Sum detectors to workspace",this); m_sum_to_workspace->setToolTip("Sum detectors to workspace."); connect(m_sum_to_workspace,SIGNAL(activated()),this,SLOT(sumDetsToWorkspace())); // Save button and its menus m_saveButton = new QPushButton("Apply and Save"); m_saveButton->setToolTip("Save current masking/grouping to a file or a workspace."); m_saveMask = new QMenu(this); m_saveMask->addAction(m_save_as_workspace_include); m_saveMask->addAction(m_save_as_workspace_exclude); m_saveMask->addSeparator(); m_saveMask->addAction(m_save_as_file_include); m_saveMask->addAction(m_save_as_file_exclude); m_saveMask->addSeparator(); m_saveMask->addAction(m_save_as_cal_file_include); m_saveMask->addAction(m_save_as_cal_file_exclude); m_saveMask->addSeparator(); m_saveMask->addAction(m_save_as_table_xrange_exclude); connect(m_saveMask,SIGNAL(hovered(QAction*)),this,SLOT(showSaveMenuTooltip(QAction*))); m_saveButton->setMenu(m_saveMask); m_saveGroup = new QMenu(this); m_saveGroup->addAction(m_extract_to_workspace); m_saveGroup->addAction(m_sum_to_workspace); m_saveGroup->addSeparator(); m_saveGroup->addAction(m_save_group_file_include); m_saveGroup->addAction(m_save_group_file_exclude); connect(m_saveGroup,SIGNAL(hovered(QAction*)),this,SLOT(showSaveMenuTooltip(QAction*))); QGroupBox *box = new QGroupBox("View"); QGridLayout* buttons = new QGridLayout(); buttons->addWidget(m_apply_to_view,0,0,1,2); buttons->addWidget(m_saveButton,1,0); buttons->addWidget(m_clear_all,1,1); box->setLayout(buttons); layout->addWidget(box); box = new QGroupBox("Workspace"); buttons = new QGridLayout(); buttons->addWidget(m_apply,0,0); box->setLayout(buttons); layout->addWidget(box); }
medAlgorithmPaintToolbox::medAlgorithmPaintToolbox(QWidget *parent ) : medSegmentationAbstractToolBox( parent), m_MinValueImage(0), m_MaxValueImage(500), m_strokeRadius(4), m_strokeLabel(1), m_paintState(PaintState::None) { QWidget *displayWidget = new QWidget(this); this->addWidget(displayWidget); this->setTitle(this->name()); QVBoxLayout * layout = new QVBoxLayout(displayWidget); m_strokeButton = new QPushButton( tr("Paint / Erase") , displayWidget); m_strokeButton->setToolTip(tr("Left-click: Start painting with specified label.\nRight-click: Erase painted voxels.")); m_strokeButton->setCheckable(true); m_magicWandButton = new QPushButton(tr("Magic Wand"), displayWidget); QPixmap pixmap(":medSegmentation/pixmaps/magic_wand.png"); QIcon buttonIcon(pixmap); m_magicWandButton->setIcon(buttonIcon); m_magicWandButton->setToolTip(tr("Magic wand to automatically paint similar voxels.")); m_magicWandButton->setCheckable(true); QHBoxLayout * addRemoveButtonLayout = new QHBoxLayout(); addRemoveButtonLayout->addWidget( m_strokeButton ); addRemoveButtonLayout->addWidget( m_magicWandButton ); layout->addLayout( addRemoveButtonLayout ); QHBoxLayout * brushSizeLayout = new QHBoxLayout(); m_brushSizeSlider = new QSlider(Qt::Horizontal, displayWidget); m_brushSizeSlider->setToolTip(tr("Changes the brush radius.")); m_brushSizeSlider->setValue(this->m_strokeRadius); m_brushSizeSlider->setRange(1, 10); m_brushSizeSlider->hide(); m_brushSizeSpinBox = new QSpinBox(displayWidget); m_brushSizeSpinBox->setToolTip(tr("Changes the brush radius.")); m_brushSizeSpinBox->setValue(this->m_strokeRadius); m_brushSizeSpinBox->setMinimum(1); m_brushSizeSpinBox->setMaximum(10); m_brushSizeSpinBox->hide(); m_brushRadiusLabel = new QLabel(tr("Brush Radius"), displayWidget); m_brushRadiusLabel->hide(); connect(m_brushSizeSpinBox, SIGNAL(valueChanged(int)),m_brushSizeSlider,SLOT(setValue(int)) ); connect(m_brushSizeSlider,SIGNAL(valueChanged(int)),m_brushSizeSpinBox,SLOT(setValue(int)) ); brushSizeLayout->addWidget(m_brushRadiusLabel); brushSizeLayout->addWidget( m_brushSizeSlider ); brushSizeLayout->addWidget( m_brushSizeSpinBox ); layout->addLayout( brushSizeLayout ); QHBoxLayout * magicWandLayout = new QHBoxLayout(); m_wandThresholdSizeSlider = new QSlider(Qt::Horizontal, displayWidget); m_wandThresholdSizeSlider->setValue(100); m_wandThresholdSizeSlider->setMinimum(0); m_wandThresholdSizeSlider->setMaximum(1000); m_wandThresholdSizeSlider->hide(); m_wandThresholdSizeSpinBox = new QDoubleSpinBox(displayWidget); m_wandThresholdSizeSpinBox->setMinimum(0); m_wandThresholdSizeSpinBox->setMaximum(1000000); m_wandThresholdSizeSpinBox->setDecimals(2); m_wandThresholdSizeSpinBox->hide(); this->setWandSpinBoxValue(100); connect(m_wandThresholdSizeSpinBox, SIGNAL(valueChanged(double)),this,SLOT(setWandSliderValue(double)) ); connect(m_wandThresholdSizeSlider,SIGNAL(valueChanged(int)),this,SLOT(setWandSpinBoxValue(int)) ); m_wand3DCheckbox = new QCheckBox (tr("3D"), displayWidget); m_wand3DCheckbox->setCheckState(Qt::Unchecked); m_wand3DCheckbox->hide(); magicWandLayout->addWidget( m_wand3DCheckbox ); magicWandLayout->addWidget( m_wandThresholdSizeSlider ); magicWandLayout->addWidget( m_wandThresholdSizeSpinBox ); layout->addLayout( magicWandLayout ); this->generateLabelColorMap(24); QHBoxLayout * labelSelectionLayout = new QHBoxLayout(); m_strokeLabelSpinBox = new QSpinBox(displayWidget); m_strokeLabelSpinBox->setToolTip(tr("Changes the painted label.")); m_strokeLabelSpinBox->setValue(this->m_strokeLabel); m_strokeLabelSpinBox->setMinimum(1); m_strokeLabelSpinBox->setMaximum(24); m_strokeLabelSpinBox->hide(); connect (m_strokeLabelSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setLabel(int))); m_labelColorWidget = new QPushButton(displayWidget); m_labelColorWidget->setToolTip(tr("Current label color")); m_labelColorWidget->setStyleSheet("background-color: rgb(255, 0, 0);border:0;border-radius: 0px;width:20px;height:20px;"); m_labelColorWidget->setCheckable(false); m_labelColorWidget->setText(""); m_labelColorWidget->hide(); connect(m_labelColorWidget, SIGNAL(clicked()), this, SLOT(setLabelColor())); m_colorLabel = new QLabel(tr("Label:"), displayWidget); m_colorLabel->hide(); labelSelectionLayout->addStretch(); labelSelectionLayout->addWidget(m_colorLabel ); labelSelectionLayout->addWidget( m_labelColorWidget ); labelSelectionLayout->addWidget( m_strokeLabelSpinBox ); layout->addLayout( labelSelectionLayout ); m_clearMaskButton = new QPushButton( tr("Clear Mask") , displayWidget); m_clearMaskButton->setToolTip(tr("Resets the mask.")); QHBoxLayout * dataButtonsLayout = new QHBoxLayout(); dataButtonsLayout->addWidget(m_clearMaskButton); layout->addLayout(dataButtonsLayout); connect (m_strokeButton, SIGNAL(pressed()), this, SLOT(activateStroke ())); connect (m_magicWandButton, SIGNAL(pressed()),this,SLOT(activateMagicWand())); connect (m_clearMaskButton, SIGNAL(pressed()), this, SLOT(clearMask())); connect(this->segmentationToolBox(), SIGNAL(inputChanged()), this, SLOT(updateMouseInteraction())); showButtons(false); }