示例#1
0
//
// Note: Called from both Apply and OK on New Chart dialog
// Must only called when the changes are definately going to
// be applied, so all input validation must be done by now.
//
Chart *PmChart::acceptNewChart()
{
    bool yAutoScale;
    double yMin, yMax;
    QString scheme;
    int sequence;

    Chart *cp = new Chart(activeTab(), activeTab()->splitter());
    activeGroup->addGadget(cp);
    activeTab()->addGadget(cp);

    QString newTitle = my.newchart->title().trimmed();
    if (newTitle.isEmpty() == false)
	cp->changeTitle(newTitle, true);
    cp->setLegendVisible(my.newchart->legend());
    cp->setAntiAliasing(my.newchart->antiAliasing());
    cp->setRateConvert(my.newchart->rateConvert());
    my.newchart->updateChartPlots(cp);
    my.newchart->scale(&yAutoScale, &yMin, &yMax);
    cp->setScale(yAutoScale, yMin, yMax);
    my.newchart->scheme(&scheme, &sequence);
    cp->setScheme(scheme, sequence);

    activeGroup->setupWorldView();
    activeTab()->showGadgets();

    enableUi();
    return cp;
}
示例#2
0
void PmChart::fileSaveView()
{
    // If we have one host only, we default to "host dynamic" views.
    // Otherwise (multiple hosts), default to explicit host names.
    int i, ngadgets = activeTab()->gadgetCount();
    bool hostDynamic = true;
    for (i = 0; i < ngadgets; i++) {
	Gadget *gadget = activeTab()->gadget(i);
	if (gadget->hosts().size() > 1)
	    hostDynamic = false;
    }

    setupDialogs();
    my.saveview->reset(hostDynamic);
    my.saveview->show();
}
示例#3
0
void PmChart::optionsHideTimeControl()
{
    if (activeTab()->isArchiveSource())
	pmtime->hideArchiveTimeControl();
    else
	pmtime->hideLiveTimeControl();
}
示例#4
0
void PmChart::optionsShowTimeControl()
{
    if (activeTab()->isArchiveSource())
	pmtime->showArchiveTimeControl();
    else
	pmtime->showLiveTimeControl();
}
示例#5
0
void TabWidget::removeTab(int index) {
    assert(mContent->childCount() < index);
    mHeader->removeTab(index);
    mContent->removeChild(index);
    if (activeTab() == index)
        setActiveTab(index == (index - 1) ? index - 1 : 0);
}
示例#6
0
void PmChart::updateFont(const QString &family, const QString &style, int size)
{
    int i, ngadgets = activeTab()->gadgetCount();

    globalFont->setFamily(family);
    globalFont->setPointSize(size);
    globalFont->setStyle(QFont::StyleNormal);
    if (style.contains("Italic"))
	globalFont->setItalic(true);
    if (globalSettings.fontStyle.contains("Bold"))
	globalFont->setBold(true);

    for (i = 0; i < ngadgets; i++)
	activeTab()->gadget(i)->resetFont();
    my.statusBar->resetFont();
}
示例#7
0
void PmChart::acceptEditSamples()
{
    activeGroup->setSampleHistory(my.samples->samples());
    activeGroup->setVisibleHistory(my.samples->visible());
    activeGroup->setupWorldView();
    activeTab()->showGadgets();
}
示例#8
0
void PmChart::editChart()
{
    Chart *cp = (Chart *)activeTab()->currentGadget();

    setupDialogs();
    my.newchart->reset(cp);
    my.newchart->show();
}
示例#9
0
void PmChart::enableUi(void)
{
    bool haveTabs = (chartTabWidget->size() > 1);
    bool haveCharts = (activeTab()->gadgetCount() > 0);
    bool haveLoggers = (activeTab()->isRecording());
    bool haveLiveHosts = (!activeTab()->isArchiveSource() && !Lflag);

    closeTabAction->setEnabled(haveTabs);
    fileSaveViewAction->setEnabled(haveCharts);
    fileExportAction->setEnabled(haveCharts);
    filePrintAction->setEnabled(haveCharts);
    editChartAction->setEnabled(haveCharts);
    closeChartAction->setEnabled(haveCharts);
    recordStartAction->setEnabled(haveCharts && haveLiveHosts && !haveLoggers);
    recordQueryAction->setEnabled(haveLoggers);
    recordStopAction->setEnabled(haveLoggers);
    recordDetachAction->setEnabled(haveLoggers);

    zoomInAction->setEnabled(activeGroup->visibleHistory() > minimumPoints());
    zoomOutAction->setEnabled(activeGroup->visibleHistory() < maximumPoints());
}
示例#10
0
void PmChart::zoomOut()
{
    int visible = activeGroup->visibleHistory();
    int samples = activeGroup->sampleHistory();
    int increase = qMax(qMin((int)((double)samples / 10), visible/2), 1);

    console->post("zoomOut: vis=%d s=%d dec=%d\n", visible, samples, increase);

    visible = qMin(visible + increase, samples);
    activeGroup->setVisibleHistory(visible);
    activeGroup->setupWorldView();
    activeTab()->showGadgets();

    zoomInAction->setEnabled(visible > minimumPoints());
    zoomOutAction->setEnabled(visible < samples);
}
示例#11
0
void TabBar::tabClicked( int _id )
{
	if( m_exclusive == true && activeTab() == -1 )
	{
		setActiveTab( _id );
	}
	else
	{
		bool all_hidden_before = allHidden();
		// disable tabbar-buttons except the one clicked
		hideAll( _id );
		bool now_hidden = allHidden();
		if( all_hidden_before == true && now_hidden == false )
		{
			emit widgetShown();
		}
		else if( all_hidden_before == false && now_hidden == true )
		{
			emit allWidgetsHidden();
		}
	}
}
示例#12
0
void tcOptionsView::UpdateButtonInfo()
{
    std::string activeTab(GetTab());

    if (activeTab == lastTab) return; // no update required
    lastTab = activeTab;

    std::vector<tcOptions::OptionInfo>& optionList = mpOptions->maOptionInfo;

    buttonInfo.clear();

    int ypos = mnYStart;

	for (size_t i=0; i<optionList.size(); i++) 
	{
		int xpos = mnXStart;

        if (optionList[i].group == activeTab.c_str())
        {
            if (optionList[i].associatedFloat == 0)
            {
                for (size_t j=0; j<optionList[i].mzCaption.size(); j++) 
                {
                    tsButtonInfo info;
                    info.optionIdx = i;
                    info.valueIdx = j;
                    info.isSlider = false;

                    wxString& sText = optionList[i].mzCaption[j];
                    wxSize rstring;

                    MeasureText(defaultFont.get(), fontSize, sText.c_str(), rstring);

                    info.textX = xpos;
                    info.textY = ypos;

                    xpos += (int)(rstring.GetWidth()) + 5;

                    info.buttonX = xpos;
                    info.buttonY = ypos-mnButtonHeight/2;

                    buttonInfo.push_back(info);

                    xpos += 3*mnButtonWidth;
                }
            }
            else // slider for float value adjustment
            {
                tsButtonInfo info;
                info.optionIdx = i;
                info.valueIdx = 0;
                info.isSlider = true;

                wxString& sText = optionList[i].mzCaption[0];
                wxSize rstring;

                MeasureText(defaultFont.get(), fontSize, sText.c_str(), rstring);

                info.textX = xpos;
                info.textY = ypos;

                xpos += (int)(rstring.GetWidth()) + 5;

                info.buttonX = xpos;
                info.buttonY = ypos;

                buttonInfo.push_back(info);
            }

            ypos -= 5*(mnButtonHeight >> 1); // 2.5x
        }
	}

}
示例#13
0
void PmChart::painter(QPainter *qp, int pw, int ph, bool transparent, bool currentOnly)
{
    double scale_h = 0;
    double scale_w = 0;
    int i, ngadgets = activeTab()->gadgetCount();
    QSize size;
    QRect rect;	// used for print layout calculations

    qp->setFont(*globalFont);

    console->post("painter() pw=%d ph=%d ngadgets=%d", pw, ph, ngadgets);
    for (i = 0; i < ngadgets; i++) {
	Gadget *gadget = activeTab()->gadget(i);
	if (currentOnly && gadget != activeTab()->currentGadget())
	    continue;
	size = gadget->size();
	console->post("  [%d] w=%d h=%d", i, size.width(), size.height());
	if (size.width() > scale_w) scale_w = size.width();
	scale_h += size.height();
    }
    console->post("  final_w=%d final_h=%d", (int)scale_w, (int)scale_h);
    // timeaxis is _always_ less narrow than the plot(s)
    // datelabel is _never_ wider than the timeaxis
    // so width calculation is done, just need to consider the heights
    size = my.statusBar->timeAxis()->size();
    console->post("  timeaxis w=%d h=%d", size.width(), size.height());
    scale_h += size.height() - TIMEAXISFUDGE;
    size = my.statusBar->dateLabel()->size();
    console->post("  datelabel w=%d h=%d", size.width(), size.height());
    scale_h += size.height();
    console->post("  final_w=%d final_h=%d", (int)scale_w, (int)scale_h);
    if (scale_w/pw > scale_h/ph) {
	// window width drives scaling
	scale_w = pw / scale_w;
	scale_h = scale_w;
    }
    else {
	// window height drives scaling
	scale_h = ph / scale_h;
	scale_w = scale_h;
    }
    console->post("  final chart scale_w=%.2f scale_h=%.2f", scale_w, scale_h);
    rect.setX(0);
    rect.setY(0);
    for (i = 0; i < ngadgets; i++) {
	Gadget *gadget = activeTab()->gadget(i);
	if (currentOnly && gadget != activeTab()->currentGadget())
	    continue;
	size = gadget->size();
	rect.setWidth((int)(size.width()*scale_w+0.5));
	rect.setHeight((int)(size.height()*scale_h+0.5));
	console->post("  [%d] @ (%d,%d) w=%d h=%d", i, rect.x(), rect.y(), rect.width(), rect.height());
	gadget->print(qp, rect, transparent);
	rect.setY(rect.y()+rect.height());
    }

    // time axis
    rect.setY(rect.y() - TIMEAXISFUDGE);
    size = my.statusBar->timeAxis()->size();
    rect.setX(pw-(int)(size.width()*scale_w+0.5));
    rect.setWidth((int)(size.width()*scale_w+0.5));
    rect.setHeight((int)(size.height()*scale_h+0.5));
    console->post("  timeaxis @ (%d,%d) w=%d h=%d", rect.x(), rect.y(), rect.width(), rect.height());
    my.statusBar->timeAxis()->print(qp, rect, transparent);
    rect.setY(rect.y()+rect.height());

    // date label below time axis
    size = my.statusBar->dateLabel()->size();
    rect.setX(pw-(int)(size.width()*scale_w+0.5));
    rect.setWidth((int)(size.width()*scale_w+0.5));
    rect.setHeight((int)(size.height()*scale_h+0.5));
    console->post("  datelabel @ (%d,%d) w=%d h=%d", rect.x(), rect.y(), rect.width(), rect.height());
    qp->drawText(rect, Qt::AlignRight, my.statusBar->dateText());
}
示例#14
0
void PmChart::recordQuery()
{
    activeTab()->queryRecording();
}
示例#15
0
void PmChart::recordDetach()
{
    activeTab()->detachLoggers();
}
示例#16
0
void PmChart::recordStop()
{
    activeTab()->stopRecording();
}
示例#17
0
void PmChart::recordStart()
{
    if (activeTab()->startRecording())
	setRecordState(true);
}
示例#18
0
bool PmChart::isArchiveTab()
{
    return activeTab()->isArchiveSource();
}
示例#19
0
bool PmChart::isTabRecording()
{
    return activeTab()->isRecording();
}
示例#20
0
void PmChart::closeChart()
{
    activeTab()->deleteCurrent();
    enableUi();
}