Exemplo n.º 1
0
QPointF HistogramViewPrivate::pix2coord(QPointF pt)
{

	float W=q->width();
	float H=q->height();

	if (m_num_bins<=1) {
		return QPointF(0,0);
	}
	if ((!W)||(!H)) return QPointF(0,0);
    if (W<=m_margin_left+m_margin_right+5) return QPointF(0,0);
    if (H<=m_margin_top+m_margin_bottom+5) return QPointF(0,0);

	float spacing=m_bin_centers[1]-m_bin_centers[0];
	float xmin=m_bin_centers[0]-spacing/2;
	float xmax=m_bin_centers[m_num_bins-1]+spacing/2;
	float ymin=0;
	float ymax=m_max_bin_count;

    float xfrac=(pt.x()-m_margin_left)/(W-m_margin_left-m_margin_right);
    float yfrac=1-(pt.y()-m_margin_top)/(H-m_margin_top-m_margin_bottom);

    float x0=xmin+xfrac*(xmax-xmin);
    float y0=ymin+yfrac*(ymax-ymin);

    return QPointF(x0,y0);
}
Exemplo n.º 2
0
  /**
   * @brief elementName returns the title of the element.
   * @param elementType the type of the element can be NODE or EDGE
   * @param elementId the id of the element
   * @return
   */
  QString elementName(ElementType elementType, unsigned int elementId) const override {
    if (hView->getDataLocation() == EDGE) {
      elementId = hView->getMappedId(elementId);
      return QString("Edge") + " #" + QString::number(elementId);
    }

    return MouseShowElementInfo::elementName(elementType, elementId);
  }
Exemplo n.º 3
0
    /**
     * @brief buildModel create and returns the model to visualize edit elements parameters.
     * @param elementType the type of the element can be NODE or EDGE
     * @param elementId elementId the id of the element
     * @param parent the parent for the model creation.
     * @return
     */
    virtual QAbstractItemModel* buildModel(ElementType elementType, unsigned int elementId, QObject *parent) const {
        if (hView->getDataLocation() == EDGE) {
            elementId = hView->getMappedId(elementId);
            return new GraphEdgeElementModel(hView->graph(), elementId, parent);
        }

        return MouseShowElementInfos::buildModel(elementType, elementId, parent);
    }
Exemplo n.º 4
0
void HistogramController::didBecomeFirstResponder() {
  MultipleDataViewController::didBecomeFirstResponder();

  uint32_t storeChecksum = m_store->storeChecksum();
  if (*m_storeVersion != storeChecksum) {
    *m_storeVersion = storeChecksum;
    initBarParameters();
    initRangeParameters();
  }
  uint32_t barChecksum = m_store->barChecksum();
  if (*m_barVersion != barChecksum) {
    *m_barVersion = barChecksum;
    initRangeParameters();
  }
  uint32_t rangeChecksum = m_store->rangeChecksum();
  if (*m_rangeVersion != rangeChecksum) {
    *m_rangeVersion = rangeChecksum;
    initBarSelection();
    reloadBannerView();
  }
  HistogramView * selectedHistogramView = static_cast<HistogramView *>(m_view.dataViewAtIndex(selectedSeriesIndex()));
  selectedHistogramView->setHighlight(m_store->startOfBarAtIndex(selectedSeriesIndex(), *m_selectedBarIndex), m_store->endOfBarAtIndex(selectedSeriesIndex(), *m_selectedBarIndex));
}
Exemplo n.º 5
0
void MainWindow::setupView()
{
    QSplitter *splitter = new QSplitter;
    splitter->setOrientation(Qt::Vertical);
    QTableView *table = new QTableView;
    HistogramView *histogram = new HistogramView(splitter);
    
    table->setModel(model);
    histogram->setModel(model);

    QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
    table->setSelectionModel(selectionModel);
    histogram->setSelectionModel(selectionModel);

    connect(selectionModel,SIGNAL(selectionChanged(const QItemSelection, const QItemSelection)),
    		histogram,SLOT(selectionChanged(const QItemSelection, const QItemSelection)));
    connect(selectionModel,SIGNAL(selectionChanged(const QItemSelection, const QItemSelection)),
    		table,SLOT(selectionChanged(const QItemSelection, const QItemSelection)));
    
    splitter->addWidget(table);
    splitter->addWidget(histogram);
    
    setCentralWidget(splitter);
}
AdjustLevelsPopup::AdjustLevelsPopup()
	: DVGui::Dialog(TApp::instance()->getMainWindow(), true, false, "AdjustLevels"), m_thresholdD(0.005) //0.5% of the image size
{
	int i, j;

	setWindowTitle(tr("Adjust Levels"));
	setLabelWidth(0);
	setModal(false);

	setTopMargin(0);
	setTopSpacing(0);

	beginVLayout();

	QSplitter *splitter = new QSplitter(Qt::Vertical);
	splitter->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
	addWidget(splitter);

	endVLayout();

	//------------------------- Top Layout --------------------------

	QScrollArea *scrollArea = new QScrollArea(splitter);
	scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	scrollArea->setWidgetResizable(true);
	scrollArea->setMinimumWidth(450);
	splitter->addWidget(scrollArea);
	splitter->setStretchFactor(0, 1);

	QFrame *topWidget = new QFrame(scrollArea);
	scrollArea->setWidget(topWidget);

	QVBoxLayout *topVLayout = new QVBoxLayout(topWidget); //Needed to justify at top
	topWidget->setLayout(topVLayout);

	QHBoxLayout *topLayout = new QHBoxLayout(topWidget);
	topVLayout->addLayout(topLayout);
	topVLayout->addStretch(1);

	//------------------------- Histogram ---------------------------

	m_histogram = new Histogram(topWidget);
	topLayout->addWidget(m_histogram);

	//------------------------- Mark Bars ---------------------------

	MarksBar *histogramMarksBar, *colorBarMarksBar;
	QVBoxLayout *histogramViewLayout;

	for (i = 0; i < 5; ++i) {
		HistogramView *view = m_histogram->getHistograms()->getHistogramView(i);
		histogramViewLayout = static_cast<QVBoxLayout *>(view->layout());

		//Don't draw channel numbers
		view->channelBar()->setDrawNumbers(false);

		for (j = 0; j < 2; ++j) {
			EditableMarksBar *editableMarksBar = m_marksBar[j + (i << 1)] = new EditableMarksBar;
			MarksBar *marksBar = editableMarksBar->marksBar();

			//Set margins up to cover the histogram
			editableMarksBar->layout()->setContentsMargins(6, 0, 5, 0);
			connect(editableMarksBar, SIGNAL(paramsChanged()), this, SLOT(onParamsChanged()));

			histogramViewLayout->insertWidget(1 + (j << 1), editableMarksBar);
		}
	}

	//------------------------- View Widget -------------------------

	//NOTE: It's IMPORTANT that parent widget is supplied. It's somewhat
	//used by QSplitter to decide the initial widget sizes...

	m_viewer = new Swatch(splitter);
	m_viewer->setMinimumHeight(150);
	m_viewer->setFocusPolicy(Qt::WheelFocus);
	splitter->addWidget(m_viewer);

	//--------------------------- Buttons ---------------------------

	QVBoxLayout *buttonsLayout = new QVBoxLayout(topWidget);
	topLayout->addLayout(buttonsLayout);

	buttonsLayout->addSpacing(50);

	QPushButton *clampRange = new QPushButton(tr("Clamp"), topWidget);
	clampRange->setMinimumSize(65, 25);
	buttonsLayout->addWidget(clampRange);
	connect(clampRange, SIGNAL(clicked(bool)), this, SLOT(clampRange()));

	QPushButton *autoAdjust = new QPushButton(tr("Auto"), topWidget);
	autoAdjust->setMinimumSize(65, 25);
	buttonsLayout->addWidget(autoAdjust);
	connect(autoAdjust, SIGNAL(clicked(bool)), this, SLOT(autoAdjust()));

	QPushButton *resetBtn = new QPushButton(tr("Reset"), topWidget);
	resetBtn->setMinimumSize(65, 25);
	buttonsLayout->addWidget(resetBtn);
	connect(resetBtn, SIGNAL(clicked(bool)), this, SLOT(reset()));

	buttonsLayout->addStretch(1);

	m_okBtn = new QPushButton(tr("Apply"));
	addButtonBarWidget(m_okBtn);

	connect(m_okBtn, SIGNAL(clicked()), this, SLOT(apply()));

	//Finally, acquire current selection
	acquireRaster();

	m_viewer->resize(0, 350);
	resize(600, 700);
}