Esempio n. 1
0
void MultiLayer::mousePressEvent(QMouseEvent *e) {
  int margin = 5;
  QPoint pos = canvas->mapFromParent(e->pos());
  // iterate backwards, so layers on top are preferred for selection
  QList<QWidget *>::iterator i = graphsList.end();
  while (i != graphsList.begin()) {
    --i;
    QRect igeo = (*i)->frameGeometry();
    igeo.addCoords(-margin, -margin, margin, margin);
    if (igeo.contains(pos)) {
      if (e->modifiers() & Qt::ShiftModifier) {
        if (d_layers_selector)
          d_layers_selector->add(*i);
        else {
          d_layers_selector = new SelectionMoveResizer(*i);
          connect(d_layers_selector, SIGNAL(targetsChanged()), this,
                  SIGNAL(modifiedPlot()));
        }
      } else {
        setActiveGraph((Graph *)(*i));
        active_graph->raise();
        if (!d_layers_selector) {
          d_layers_selector = new SelectionMoveResizer(*i);
          connect(d_layers_selector, SIGNAL(targetsChanged()), this,
                  SIGNAL(modifiedPlot()));
        }
      }
      return;
    }
  }
  if (d_layers_selector) delete d_layers_selector;
}
void MultiLayer::keyPressEvent(QKeyEvent * e)
{
if (e->key() == Qt::Key_F12)	
	{
	int index=graphsList->findRef ((QWidget *)active_graph);
	Graph *g=(Graph *)graphsList->at(index+1);
	if (g)
		setActiveGraph(g);
	}
	
if (e->key() == Qt::Key_F10)	
	{
	int index=graphsList->findRef ((QWidget *)active_graph);
	Graph *g=(Graph *)graphsList->at(index-1);
	if (g)
		setActiveGraph(g);
	}
	
if (e->key() == Qt::Key_F11)
	emit showWindowContextMenu();
}
Esempio n. 3
0
void MultiLayer::keyPressEvent(QKeyEvent *e) {
  if (e->key() == Qt::Key_F12) {
    if (d_layers_selector) delete d_layers_selector;
    int index = graphsList.indexOf((QWidget *)active_graph) + 1;
    if (index >= graphsList.size()) index = 0;
    Graph *g = (Graph *)graphsList.at(index);
    if (g) setActiveGraph(g);
    return;
  }

  if (e->key() == Qt::Key_F10) {
    if (d_layers_selector) delete d_layers_selector;
    int index = graphsList.indexOf((QWidget *)active_graph) - 1;
    if (index < 0) index = graphsList.size() - 1;
    Graph *g = (Graph *)graphsList.at(index);
    if (g) setActiveGraph(g);
    return;
  }

  if (e->key() == Qt::Key_F11) {
    emit showWindowContextMenu();
    return;
  }
}
Esempio n. 4
0
static THD_FUNCTION(ThreadGFXEvent, arg)
{
	(void)arg;

	chRegSetThreadName("GFXEvent");

	GEvent* pe;
	static RTCDateTime timespec;
	struct tm timeinfo;
	struct tm tim;
	struct tm *canary;
	static time_t unix_time;
	while (true) {
		pe = geventEventWait(&gl, TIME_INFINITE);
		switch (pe->type) {
			case GEVENT_GWIN_BUTTON:
				if (((GEventGWinButton*)pe)->gwin == ghBtnSettings) {
					createSettingsFrame();
					gwinShow(ghFrame1);
					updateGraph = false;
					updateSettingTime = true;
				} else if (((GEventGWinButton*)pe)->gwin == ghBtnSave) {
					timeinfo.tm_hour = atoi(gwinListGetSelectedText(ghListHour));
					timeinfo.tm_min = atoi(gwinListGetSelectedText(ghListMin));
					timeinfo.tm_sec = 0;
					timeinfo.tm_mday = atoi(gwinListGetSelectedText(ghListDay));
					timeinfo.tm_mon = gwinListGetSelected(ghListMonth);
					timeinfo.tm_year = atoi(gwinListGetSelectedText(ghListYear))-1900;
					unix_time = mktime(&timeinfo);
					canary = localtime_r(&unix_time, &tim);
					osalDbgCheck(&tim == canary);
					rtcConvertStructTmToDateTime(&tim, 0, &timespec);
					rtcSetTime(RTC_DRIVER, &timespec);
				} else if (((GEventGWinButton*)pe)->gwin == ghBtnTime) {
					updateGraph = false;
					gwinShow(ghListFreq);
				}
				break;

			case GEVENT_GWIN_CHECKBOX:
				if (((GEventGWinCheckbox*)pe)->gwin == ghCheckBoxHR) {
					if (((GEventGWinCheckbox*)pe)->isChecked)
						use12HR = true;
					else
						use12HR = false;
				}
				break;

			case GEVENT_GWIN_CLOSE:
				updateGraph = true;
				updateSettingTime = false;
				switch (activeGraph) {
					case 0:
						drawGraphLines(ghContainerGraphC);
						break;

					case 1:
						drawGraphLines(ghContainerGraphV);
						break;

					case 2:
						drawGraphLines(ghContainerGraphW);
						break;

					case 3:
						drawGraphLines(ghContainerGraphCV_1);
						drawGraphLines(ghContainerGraphCV_2);
						break;

					default:
						break;
				}
				break;

			case GEVENT_GWIN_RADIO:
				activeGraph = atoi(gwinGetText(((GEventGWinRadio *)pe)->gwin));
				setActiveGraph(activeGraph);
				break;

			case GEVENT_GWIN_LIST:
				if (((GEventGWinList*)pe)->gwin == ghListFreq)  {
					char str[5];
					uint8_t val = atoi(gwinListGetSelectedText(ghListFreq));
					GRAPH_Refresh = ((1.0/val)*1000);
					snprintf(str, 5, "%d%s", val, "Hz");
					gwinSetText(ghBtnTime, str, true);
					chThdSleepMilliseconds(10);
					gwinHide(ghListFreq);
					updateGraph = true;

					switch (activeGraph) {
					case 0:
						drawGraphLines(ghContainerGraphC);
						break;

					case 1:
						drawGraphLines(ghContainerGraphV);
						break;

					case 2:palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 5);
						drawGraphLines(ghContainerGraphW);
						break;

					case 3:
						drawGraphLines(ghContainerGraphCV_1);
						drawGraphLines(ghContainerGraphCV_2);
						break;

					default:
						break;
					}

				}

				break;
			default:
				break;
		}

		chThdSleepMilliseconds(500);
	}
}