Ejemplo n.º 1
0
QmitkHistogramWidget::QmitkHistogramWidget(QWidget * parent, bool showreport)
  : QDialog(parent)
{
  QBoxLayout *layout = new QVBoxLayout(this);

  //***histogram***

  QGroupBox *hgroupbox = new QGroupBox("", this);

  hgroupbox->setMinimumSize(900, 400);

  m_Plot = new QwtPlot(hgroupbox);
  m_Plot->setCanvasBackground(QColor(Qt::white));
  m_Plot->setTitle("Histogram");
  QwtText text = m_Plot->titleLabel()->text();
  text.setFont(QFont("Helvetica", 12, QFont::Normal));

  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->enableYMin(true);
  grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
  grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(m_Plot);

  layout->addWidget(hgroupbox);

  layout->setSpacing(20);

  if (showreport == true)
  {
    //***report***
    QGroupBox *rgroupbox = new QGroupBox("", this);

    rgroupbox->setMinimumSize(900, 400);

    QLabel *label = new QLabel("Gray  Value  Analysis", rgroupbox);
    label->setAlignment(Qt::AlignHCenter);
    label->setFont(QFont("Helvetica", 14, QFont::Bold));

    m_Textedit = new QTextEdit(rgroupbox);
    m_Textedit->setFont(QFont("Helvetica", 12, QFont::Normal));
    m_Textedit->setReadOnly(true);

    layout->addWidget(rgroupbox);
  }

  m_Picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
    QwtPicker::PointSelection, 
    QwtPlotPicker::NoRubberBand, QwtPicker::AlwaysOn, 
    m_Plot->canvas());

  connect(m_Picker, SIGNAL(selected(const QwtDoublePoint &)),
    SLOT(OnSelect(const QwtDoublePoint &)));
}
Ejemplo n.º 2
0
/*protected*/ void ReporterItemPanel::makeDndIconPanel(QHash<QString, NamedIcon*>* /*iconMap*/, QString /*displayKey*/)
{
 if (_update)
 {
  return;
 }
 _reporter = new ReporterIcon(_editor);
 QGroupBox*  panel = new QGroupBox();
 QString borderName = tr("Drag to Panel");
 QString     gbStyleSheet = "QGroupBox { border: 2px solid gray; border-radius: 3px;} QGroupBox::title { /*background-color: transparent;*/  subcontrol-position: top left; /* position at the top left*/  padding:0 0px;} ";
 panel->setLayout(new QHBoxLayout);
 panel->setTitle(borderName);
 panel->setStyleSheet(gbStyleSheet);
 QWidget*  comp;
 DataFlavor* flavor;
 try {
     //comp = getDragger(flavor = new DataFlavor(Editor::POSITIONABLE_FLAVOR));
     comp = getDragger(flavor = new DataFlavor(_reporter,"ReporterIcon"));
     flavor->setMimeTypeParameter("reporter", _reporter->getName());
     comp->setToolTip(tr("Drag an icon from this panel to add it to the control panel"));
 } catch (ClassNotFoundException cnfe) {
     //cnfe.printStackTrace();
     comp = new QWidget();
 }
 comp->setLayout(new FlowLayout);
 comp->layout()->addWidget(_reporter);
 panel->layout()->addWidget(comp);
 //panel.validate();
 int width = qMax(100, panel->sizeHint().width());
 panel->setMinimumSize( QSize(width, panel->minimumSize().height()));
 panel->setToolTip(tr("Drag an icon from this panel to add it to the control panel"));
 _dragIconPanel->layout()->addWidget( panel);
 _dragIconPanel->setToolTip(tr("Drag an icon from this panel to add it to the control panel"));
}
Ejemplo n.º 3
0
/**
*  Note caller must create _iconPanel before calling
*/
/*protected*/ void IconItemPanel::addIconsToPanel(QMap<QString, NamedIcon*>* iconMap)
{
 _iconPanel = new ImagePanel();
 _iconPanel->setLayout(new QHBoxLayout());
 //Iterator<Entry<QString, NamedIcon*>*> it = iconMap.entrySet().iterator();
 QMapIterator<QString, NamedIcon*> it(*iconMap);
 while (it.hasNext())
 {
  //Entry<String, NamedIcon> entry = it.next();
  it.next();
  NamedIcon* icon = new NamedIcon(it.value());    // make copy for possible reduction
  QGroupBox* panel = new QGroupBox();
  panel->setLayout(new QVBoxLayout());
  QString borderName = ItemPalette::convertText(it.key());
  //panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black),
  //                                                 borderName));
  QString     gbStyleSheet = "QGroupBox { border: 2px solid gray; border-radius: 3px;} QGroupBox::title { /*background-color: transparent;*/  subcontrol-position: top left; /* position at the top left*/  padding:0 0px;} ";

  panel->setTitle(borderName);
  panel->setStyleSheet(gbStyleSheet);
  try
  {
   IconDragJLabel* label = new IconDragJLabel(new DataFlavor(Editor::POSITIONABLE_FLAVOR), _level, this);
   label->setName(borderName);
   //panel->layout()->addWidget(label);
   if (icon->getIconWidth()<1 || icon->getIconHeight()<1)
   {
    label->setText(tr("invisibleIcon"));
//               label->setForeground(QColor(Qt::lightGray);
   }
   else
   {
    icon->reduceTo(50, 80, 0.2);
   }
   label->setIcon(icon);
   label->setAlignment(Qt::AlignCenter);
   label->setMargin(6);

   int width = qMax(100, panel->minimumSize().width());
   panel->setMinimumSize(QSize(width, panel->minimumSize().height()));
   ((QBoxLayout*)panel->layout())->addWidget(label,0, Qt::AlignCenter);

  } catch (ClassNotFoundException cnfe) {
           //cnfe.printStackTrace();
  }
  _iconPanel->layout()->addWidget(panel);
 }
 thisLayout->addWidget(_iconPanel/*, 1*/);
 //_iconPanel->addMouseListener(this);
}
Ejemplo n.º 4
0
void QtDensity::setupDisplay(void)  {
    QWidget *window = new QWidget;
    window->setWindowTitle("Qt and RInside demo: density estimation");

    QSpinBox *spinBox = new QSpinBox;
    QSlider *slider = new QSlider(Qt::Horizontal);
    spinBox->setRange(5, 200);
    slider->setRange(5, 200);
    QObject::connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
    QObject::connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
    spinBox->setValue(m_bw);
    QObject::connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(getBandwidth(int)));

    QLabel *cmdLabel = new QLabel("R command for random data creation");
    QLineEdit *cmdEntry = new QLineEdit(m_cmd);
    QObject::connect(cmdEntry,  SIGNAL(textEdited(QString)), this, SLOT(getRandomDataCmd(QString)));
    QObject::connect(cmdEntry,  SIGNAL(editingFinished()), this, SLOT(runRandomDataCmd()));

    QGroupBox *kernelRadioBox = new QGroupBox("Density Estimation kernel");
    QRadioButton *radio1 = new QRadioButton("&Gaussian");
    QRadioButton *radio2 = new QRadioButton("&Epanechnikov");
    QRadioButton *radio3 = new QRadioButton("&Rectangular");
    QRadioButton *radio4 = new QRadioButton("&Triangular");
    QRadioButton *radio5 = new QRadioButton("&Cosine");
    radio1->setChecked(true);
    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(radio1);
    vbox->addWidget(radio2);
    vbox->addWidget(radio3);
    vbox->addWidget(radio4);
    vbox->addWidget(radio5);
    kernelRadioBox->setMinimumSize(260,140);
    kernelRadioBox->setMaximumSize(260,140);
    kernelRadioBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    kernelRadioBox->setLayout(vbox);

    QButtonGroup *kernelGroup = new QButtonGroup;
    kernelGroup->addButton(radio1, 0);
    kernelGroup->addButton(radio2, 1);
    kernelGroup->addButton(radio3, 2);
    kernelGroup->addButton(radio4, 3);
    kernelGroup->addButton(radio5, 4);
    QObject::connect(kernelGroup, SIGNAL(buttonClicked(int)), this, SLOT(getKernel(int)));

    m_svg = new QSvgWidget();
    runRandomDataCmd();         // also calls plot()

    QGroupBox *estimationBox = new QGroupBox("Density estimation bandwidth (scaled by 100)");
    QHBoxLayout *spinners = new QHBoxLayout;
    spinners->addWidget(spinBox);
    spinners->addWidget(slider);
    QVBoxLayout *topright = new QVBoxLayout;
    topright->addLayout(spinners);
    topright->addWidget(cmdLabel);
    topright->addWidget(cmdEntry);
    estimationBox->setMinimumSize(360,140);
    estimationBox->setMaximumSize(360,140);
    estimationBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    estimationBox->setLayout(topright);
    QHBoxLayout *upperlayout = new QHBoxLayout;
    upperlayout->addWidget(kernelRadioBox);
    upperlayout->addWidget(estimationBox);

    QHBoxLayout *lowerlayout = new QHBoxLayout;
    lowerlayout->addWidget(m_svg);

    QVBoxLayout *outer = new QVBoxLayout;
    outer->addLayout(upperlayout);
    outer->addLayout(lowerlayout);
    window->setLayout(outer);
    window->show();
}
Ejemplo n.º 5
0
PrintDialog::PrintDialog( QWidget *parent, const char *name, int maxPages,
							bool marked )		
	: QDialog( parent, name, TRUE )
{
	setFocusPolicy(QWidget::StrongFocus);
	
	pgMode = All;
	/*
	printerName.sprintf( "" ); // default printer will be chosen.
	spoolerCommand.sprintf( "lpr" );
	printerVariable.sprintf( "PRINTER" );
	*/

	KConfig *config = KApplication::getKApplication()->getConfig();
	/* Read in the default options. */
	config->setGroup( "Print" );
	printerName=config->readEntry ("Name","");
	spoolerCommand=config->readEntry ("Spool","lpr");
	printerVariable=config->readEntry ("Variable","PRINTER");


	pgMax = maxPages;
	pgStart=0; pgEnd=0;
	
	int border = 10;
	
	QBoxLayout *topLayout = new QVBoxLayout( this, border );
	
	cbFile = new QCheckBox( i18n("Print to file"), this );
	cbFile->setFixedHeight( cbFile->sizeHint().height() );
	
	topLayout->addWidget( cbFile );
	
	QGroupBox *group = new QGroupBox( i18n( "Pages" ), this );
	topLayout->addWidget( group, 10 );
	
	QGridLayout *grid = new QGridLayout( group, 5, 7, 5 );
	
	grid->setRowStretch( 0, 10 );
	grid->setRowStretch( 1, 100 );
	grid->setRowStretch( 2, 0 );
	grid->setRowStretch( 3, 100 );
	grid->setRowStretch( 4, 10 );
	
	grid->setColStretch( 0, 0 );
	grid->setColStretch( 1, 100 );
	grid->setColStretch( 2, 100 );
	grid->setColStretch( 3, 100 );
	grid->setColStretch( 4, 0 );
	grid->setColStretch( 5, 100 );
	grid->setColStretch( 6, 0 );
		
	pgGroup = new QButtonGroup( group );
	pgGroup->hide();
	pgGroup->setExclusive( true );
	connect( pgGroup, SIGNAL( clicked( int ) ), SLOT( slotPageMode( int ) ) );
	
	int widest = 0;
	
	QRadioButton *arb = new QRadioButton( i18n("&All"), group );
	arb->setFixedHeight( arb->sizeHint().height()+6 );
	arb->setChecked( true );
	pgGroup->insert( arb, All );
	
	grid->addWidget( arb, 1, 1 );
	
	if ( arb->sizeHint().width() > widest )
	  widest = arb->sizeHint().width();
	
	QRadioButton *rb = new QRadioButton( i18n("&Current"), group );
	rb->setFixedHeight( rb->sizeHint().height()+6 );
	pgGroup->insert( rb, Current );
	
	grid->addWidget( rb, 1, 2 );
	
	if ( rb->sizeHint().width() > widest ) widest = rb->sizeHint().width();
	
	rb = new QRadioButton( i18n("&Marked"), group );
	rb->setFixedHeight( rb->sizeHint().height()+6 );
	if ( !marked )
	  rb->setEnabled( false );
	else
	  {
	    arb->setChecked ( false );
	    rb->setChecked ( true );
	  }

	pgGroup->insert( rb, Marked );
	
	grid->addWidget( rb, 3, 1 );
	
	if ( rb->sizeHint().width() > widest ) widest = rb->sizeHint().width();
	
	rb = new QRadioButton( i18n("&Range"), group );
	rb->setFixedHeight( rb->sizeHint().height()+6 );
	pgGroup->insert( rb, Range );
	
	grid->addWidget( rb, 3, 2 );
	
	if ( rb->sizeHint().width() > widest ) widest = rb->sizeHint().width();
	
	leStart = new QLineEdit( group );
	leStart->setFixedHeight( rb->sizeHint().height()+6 );
	
	grid->addWidget( leStart, 3, 3 );
	
	lTo = new QLabel( group );
	lTo->setText( i18n("to") );
	lTo->setAlignment( AlignCenter );
	lTo->setMinimumSize( lTo->sizeHint() );
	
	grid->addWidget( lTo, 3, 4 );
	
	leEnd = new QLineEdit( group );
	leEnd->setFixedHeight( rb->sizeHint().height()+6 );
	
	grid->addWidget( leEnd, 3, 5 );
	
	group->setMinimumSize( QSize( 4*widest+25, 4*(rb->sizeHint().height()+6) ) );
	
	cbOrder = new QCheckBox( i18n("Print document in re&verse order"), this );
	cbOrder->setFixedHeight( cbOrder->sizeHint().height() );
	
	topLayout->addWidget( cbOrder );
	
	
	QFrame* tmpQFrame;
	tmpQFrame = new QFrame( this );
	tmpQFrame->setFrameStyle( QFrame::HLine | QFrame::Sunken );
	tmpQFrame->setMinimumHeight( tmpQFrame->sizeHint().height() );
	
	topLayout->addWidget( tmpQFrame );
	
	// CREATE BUTTONS
	
	KButtonBox *bbox = new KButtonBox( this );
	
	QPushButton* setup = bbox->addButton( i18n("&Setup ...") );
	connect( setup, SIGNAL(clicked()), SLOT( setup()) );
	
	
	bbox->addStretch( 10 );

	QPushButton* ok = bbox->addButton( i18n("&OK") );
	connect( ok, SIGNAL(clicked()), SLOT( checkRange() ) );

	QPushButton* cancel = bbox->addButton( i18n("&Cancel") );
	connect( cancel, SIGNAL(clicked()), SLOT(reject()) );

	bbox->layout();
	topLayout->addWidget( bbox );
	
	topLayout->activate();
	
	if ( marked )
	  slotPageMode( Marked );
	else
	  slotPageMode( All );

	resize( 250, 0 );
	
}