Exemplo n.º 1
0
FlyToEditWidget::FlyToEditWidget( const QModelIndex &index, MarbleWidget* widget, QWidget *parent ) :
    QWidget( parent ),
    m_widget( widget ),
    m_index( index ),
    m_button( new QToolButton )
{
    QHBoxLayout *layout = new QHBoxLayout;
    layout->setSpacing( 5 );

    QLabel* iconLabel = new QLabel;
    iconLabel->setPixmap( QPixmap( ":/marble/flag.png" ) );
    layout->addWidget( iconLabel );

    QLabel *waitLabel = new QLabel;
    waitLabel->setText(tr("Wait duration:"));
    layout->addWidget(waitLabel);

    m_waitSpin = new QDoubleSpinBox;
    layout->addWidget(m_waitSpin);
    m_waitSpin->setValue(flyToElement()->duration());
    m_waitSpin->setSuffix( tr(" s", "seconds") );

    QToolButton* flyToPinCenter = new QToolButton;
    flyToPinCenter->setIcon(QIcon(":/marble/places.png"));
    flyToPinCenter->setToolTip(tr("Current map center"));
    connect(flyToPinCenter, SIGNAL(clicked()), this, SLOT(updateCoordinates()));
    layout->addWidget(flyToPinCenter);

    m_button->setIcon( QIcon( ":/marble/document-save.png" ) );
    connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
    layout->addWidget( m_button );

    setLayout( layout );
}
Exemplo n.º 2
0
void TimedController::handleTimedUpdate()
{
    int timeDiff = m_exTime.msecsTo(QTime::currentTime());
    if (timeDiff<  m_delay) return;
    updateCoordinates();
    m_exTime = QTime::currentTime();
}
Exemplo n.º 3
0
/**
 Author: 	Joel Denke
 Description: 	Runs event
 Params: 	eventData	Event data to parse and run
 */
void runEvent(int type, char * data)
{
	int id, x , y;
	int xb, yb;
	char * msg = malloc(sizeof(char) * MESSAGE_SIZE);
	
	if (data != NULL) {
		id = atoi(strsep(&data, ","));

		switch (type) {
			case 1:
			case 2:
				if (data != NULL) {
					x = atoi(strsep(&data, ","));

					if (data != NULL) {
						y = atoi(strsep(&data, ","));
						updateCoordinates(type, id, x, y);
					}
				}
				break;
			case 3:
				if (data != NULL) {
					msg = strsep(&data, ",");
					messageAction(id, msg);
				}

				break;
		}
	} else {
		printf("Incomplete packet string, discarding event action\n");
	}
}
Exemplo n.º 4
0
void
ConditionalRelation::detachBox(BasicBox * box)
{
    Maquette::getInstance()->detachFromCondition(_id,box);
    updateCoordinates();
    _boxesAttached.removeAll(box);
}
void AccelerometerController::update()
{
    qreal accX = m_accelerometer.reading()->x();
    qreal accY= m_accelerometer.reading()->y();
    m_dx = accX*3;
    m_dy= -accY*3;
    updateCoordinates();

}
Exemplo n.º 6
0
void
ConditionalRelation::updateCoordinates(unsigned int boxId)
{
    /// \todo Maquette::getInstance()->getConditionDate(ID()); then update start/end;    
    if (!Maquette::getInstance()->isZooming() ) {
        updateBoxesCoordinates(boxId);
    }
    updateCoordinates();
}
void RotationController::update()
{
    qreal pitch = m_rotationSensor.reading()->x();
    qreal roll= m_rotationSensor.reading()->y();

    m_dx = - m_factor* roll;
    m_dy =  - m_factor * pitch;

    updateCoordinates();
}
Exemplo n.º 8
0
ConditionalRelation::ConditionalRelation(unsigned int id, QList<BasicBox *> boxesAttached, MaquetteScene *parent)
    : QGraphicsObject(), _id(id), _scene(parent), _boxesAttached(boxesAttached)
{
    init();

    _scene->addItem(this);

    //set conditional relation to each box
    QList<BasicBox *>::iterator     it;
    for(it = _boxesAttached.begin() ; it!=_boxesAttached.end() ; it++)
        (*it)->addConditionalRelation(this);

    updateCoordinates();
}
Exemplo n.º 9
0
    bool slide()
    {
        // MPI_Barrier(topology);
        yoffset--;
        if (yoffset == -dims[1])
            yoffset = 0;

        updateCoordinates();
        if (DIM >= DIM2)
        {
            if (coordinates[1] == dims[1] - 1)
                return true;
        }

        return false;
    }
Exemplo n.º 10
0
ConditionalRelation::ConditionalRelation(QList<BasicBox *> boxesAttached, MaquetteScene *parent)
    : QGraphicsObject(), _scene(parent), _boxesAttached(boxesAttached)
{
    init();

    _id = Maquette::getInstance()->createCondition(boxesAttached);        


    //set conditional relation to each box
    QList<BasicBox *>::iterator     it;
    for(it = _boxesAttached.begin() ; it!=_boxesAttached.end() ; it++)
    {
        (*it)->addConditionalRelation(this);

        //default : auto-trigger = false for all triggerPoints attached
        Maquette::getInstance()->setTriggerPointDefault((*it)->getTriggerPoint(BOX_START)->ID(),false);
    }

    updateCoordinates();
}
Exemplo n.º 11
0
void
Relation::init()
{
  updateCoordinates();
  setFlag(QGraphicsItem::ItemIsMovable, false);
  setFlag(QGraphicsItem::ItemIsSelectable, true);
  setFlag(QGraphicsItem::ItemIsFocusable, true);

  setVisible(true);
  setAcceptsHoverEvents(true);
  setZValue(1);
  _leftHandleSelected = false;
  _rightHandleSelected = false;
  _color = QColor(Qt::blue);
  _lastMaxBound = -1;
  _elasticMode = false;
  _mouseClickPosSave = mapToScene(_start);
  _hover = false;
  updateFlexibility();
}
Exemplo n.º 12
0
void
ConditionalRelation::attachBoxes(QList<BasicBox *> conditionedBox)
{
    QList<BasicBox *>::iterator it;

    for(it=conditionedBox.begin() ; it!=conditionedBox.end() ; it++)
    {
        if(!_boxesAttached.contains(*it))
        {
            _boxesAttached<<(*it);
            Maquette::getInstance()->attachToCondition(_id,*it);

            //set conditional relation to each box
            (*it)->addConditionalRelation(this);

            //default : auto-trigger = false for all triggerPoints attached
            Maquette::getInstance()->setTriggerPointDefault((*it)->getTriggerPoint(BOX_START)->ID(),false);
        }
    }
    updateCoordinates();
}
Exemplo n.º 13
0
    /*! initializes all processes to build a 3D-grid
     *
     * @param nodes number of GPU nodes in each dimension
     * @param periodic specifying whether the grid is periodic (1) or not (0) in each dimension
     *
     * \warning throws invalid argument if cx*cy*cz != totalnodes
     */
    void init(DataSpace<DIM3> numberProcesses, DataSpace<DIM3> periodic) throw (std::invalid_argument)
    {
        this->periodic = periodic;

        //check if parameters are correct
        MPI_CHECK(MPI_Comm_size(MPI_COMM_WORLD, &mpiSize));

        if (numberProcesses.productOfComponents() != mpiSize)
        {
            throw std::invalid_argument("wrong parameters or wrong mpirun-call!");
        }

        //1. create Communicator (computing_comm) of computing nodes (ranks 0...n)
        MPI_Comm computing_comm = MPI_COMM_WORLD;

        yoffset = 0;

        // 2. create topology

        //int dims[3];
        dims[0] = numberProcesses.x();
        dims[1] = numberProcesses.y();
        dims[2] = numberProcesses.z();

        topology = MPI_COMM_NULL;

        int periods[] = {periodic.x(), periodic.y(), periodic.z()};

        /*create new communicator based on cartesian coordinates*/
        MPI_CHECK(MPI_Cart_create(computing_comm, DIM, dims, periods, 0, &topology));

        // 3. update Host rank
        hostRank = UpdateHostRank();

        //4. update Coordinates
        updateCoordinates();


    }
Exemplo n.º 14
0
Data::OsgEdge::OsgEdge( qlonglong id, QString name, Data::Graph* graph, bool isOriented, Data::Type* type, float scaling, osg::ref_ptr<Data::Node> srcNode, osg::ref_ptr<Data::Node> dstNode,osg::ref_ptr<osg::Camera> camera )
	:DbEdge( id, name, graph, isOriented, type, scaling )
{
	this->srcNode = srcNode;
	this->dstNode = dstNode;
	this->camera = camera;

	coordinates = new osg::Vec3Array();
	edgeTexCoords = new osg::Vec2Array();
	rotation = new osg::Vec3Array();
	center = new osg::Vec3Array();

	createLabel( name );
	//updateCoordinates(getSrcNode()->getTargetPosition(), getDstNode()->getTargetPosition());
	updateCoordinates( getSrcNode()->restrictedTargetPosition(), getDstNode()->restrictedTargetPosition() );

	float r = type->getSettings()->value( "color.R" ).toFloat();
	float g = type->getSettings()->value( "color.G" ).toFloat();
	float b = type->getSettings()->value( "color.B" ).toFloat();
	float a = type->getSettings()->value( "color.A" ).toFloat();
	this->edgeColor = osg::Vec4( r, g, b, a );
}
void DesktopSelectionRectangle::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
{
    if(event->buttons().testFlag(Qt::LeftButton))
    {
        if(resizing_)
        {
            QRectF r = rect();
            QPointF eventPos = event->pos();

            r.setBottomRight(eventPos);

            setRect(r);
        }
        else
        {
            QPointF delta = event->pos() - event->lastPos();

            moveBy(delta.x(), delta.y());
        }

        updateCoordinates();
        emit coordinatesChanged(x_, y_, width_, height_);
    }
}
Exemplo n.º 16
0
void XUIObject::onAttributeChanged(const char *attributeName, const char *attributeValue) {
  ASSERT(m_wnd);
  COLORREF color;
  int intval;
      
  switch (xuiObjectAttributes.getId(attributeName)) {
    case XUIOBJECT_ATTRIBUTE_ID:
      m_id = attributeValue;
      break;
    case XUIOBJECT_ATTRIBUTE_X:
      //parseCoordinateAttribute(getAttribute("x"), &m_x_attr, &m_fx_attr, COORDINATE_FROM_X);
      m_x = atoi(attributeValue);
      if (m_wnd->isInited())
        updateCoordinates();
      break;
    case XUIOBJECT_ATTRIBUTE_Y:
      //parseCoordinateAttribute(getAttribute("y"), &m_y_attr, &m_fy_attr, COORDINATE_FROM_Y);
      m_y = atoi(attributeValue);
      if (m_wnd->isInited())
        updateCoordinates();
      break;
    case XUIOBJECT_ATTRIBUTE_W:
      //parseCoordinateAttribute(getAttribute("w"), &m_w_attr, &m_fw_attr, COORDINATE_FROM_0);
      m_w = atoi(attributeValue);
      if (m_wnd->isInited())
        updateCoordinates();
      break;
    case XUIOBJECT_ATTRIBUTE_H:
      //parseCoordinateAttribute(getAttribute("h"), &m_h_attr, &m_fh_attr, COORDINATE_FROM_0);
      m_h = atoi(attributeValue);
      if (m_wnd->isInited())
        updateCoordinates();
      break;
    case XUIOBJECT_ATTRIBUTE_MINW:
      //parseCoordinateAttribute(getAttribute("minw"), &m_minw_attr, &m_fminw_attr, COORDINATE_FROM_0);
      m_minw = atoi(attributeValue);
      if (m_wnd->isInited())
        updateCoordinates();
      break;
    case XUIOBJECT_ATTRIBUTE_MINH:
      //parseCoordinateAttribute(getAttribute("minh"), &m_minh_attr, &m_fminh_attr, COORDINATE_FROM_0);
      m_minh = atoi(attributeValue);
      if (m_wnd->isInited())
        updateCoordinates();
      break;
    case XUIOBJECT_ATTRIBUTE_MAXW:
      //parseCoordinateAttribute(getAttribute("maxw"), &m_maxw_attr, &m_fmaxw_attr, COORDINATE_FROM_0);
      m_maxw = atoi(attributeValue);
      if (m_wnd->isInited())
        updateCoordinates();
      break;
    case XUIOBJECT_ATTRIBUTE_MAXH:
      //parseCoordinateAttribute(getAttribute("maxh"), &m_maxh_attr, &m_fmaxh_attr, COORDINATE_FROM_0);
      m_maxh = atoi(attributeValue);
      if (m_wnd->isInited())
        updateCoordinates();
      break;
    case XUIOBJECT_ATTRIBUTE_HIDDEN:
      intval = parseBoolAttribute(attributeValue);
      if (!m_wnd->isInited()) m_wnd->setStartHidden(intval);
      else m_wnd->setVisible(!intval);
      break;
    case XUIOBJECT_ATTRIBUTE_BGCOLOR:
      parseColorAttribute(attributeValue, &m_bgcolor);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_SHADOWCOLOR:
      parseColorAttribute(attributeValue, &m_shadowcolor);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_HIGHLIGHTCOLOR:
      parseColorAttribute(attributeValue, &m_highlightcolor);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_BGSTYLE:
      m_bgstyle = parseBGStyleAttribute(attributeValue);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_OUTLINECOLOR: 
      parseColorAttribute(attributeValue, &m_outlinecolor);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_OUTLINESIZE: {
      parseCSVIntAttribute(attributeValue, m_outlinesize, 4, -999999);
      if (m_outlinesize[0] == -999999) m_outlinesize[0] = 0;
      for (int i=1;i<4;i++) {
        if (m_outlinesize[i] == -999999) m_outlinesize[i] = m_outlinesize[i-1];
      }
      invalidate();
      break;
    }
    case XUIOBJECT_ATTRIBUTE_DEBUG:
      parseColorAttribute(attributeValue, &m_debugColor);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_IMAGE:
      setBackgroundImage(attributeValue);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_IMAGEALPHA:
      m_imagealpha = atoi(attributeValue);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_DISABLEDIMAGEALPHA:
      m_disabledimagealpha = atoi(attributeValue);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_WANTFOCUS:
      m_wantFocus = parseBoolAttribute(attributeValue);
      break;
    case XUIOBJECT_ATTRIBUTE_MOUSETHROUGH:
      m_mousethrough = parseBoolAttribute(attributeValue, 1);
      break;
    case XUIOBJECT_ATTRIBUTE_DISABLED:
      m_wnd->setEnabled(!parseBoolAttribute(attributeValue));
      break;
    case XUIOBJECT_ATTRIBUTE_FOCUSMARGIN:
      parseCSVIntAttribute(attributeValue, m_focusrectmargin, 4, 0);
      invalidate();
      break;
    case XUIOBJECT_ATTRIBUTE_MARGIN: {
      int v[4];
      parseCSVIntAttribute(attributeValue, v, 4, 0);
      m_wnd->setMargins(v[0], v[1], v[2], v[3]);
      invalidate();
      break;
    }
    case XUIOBJECT_ATTRIBUTE_FLEX: {
      if (STRCASEEQL(attributeValue, "*")) m_flex = -1;
      else m_flex = atoi(attributeValue);
      updateCoordinates();
      break;
    }
  }
}
Exemplo n.º 17
0
void MainWindow::setupUI()
{
    QWidget * widget = new QWidget();
    QFormLayout * formLayout = new QFormLayout();
    widget->setLayout(formLayout);

    setCentralWidget(widget);

    // connect widget signals / slots
    connect(&xSpinBox_, SIGNAL(editingFinished()), this, SLOT(updateCoordinates()));
    connect(&ySpinBox_, SIGNAL(editingFinished()), this, SLOT(updateCoordinates()));
    connect(&widthSpinBox_, SIGNAL(editingFinished()), this, SLOT(updateCoordinates()));
    connect(&heightSpinBox_, SIGNAL(editingFinished()), this, SLOT(updateCoordinates()));
    connect(&retinaBox_, SIGNAL(released()), this, SLOT(updateCoordinates()));

    hostnameLineEdit_.setText( DEFAULT_HOST_ADDRESS );

    char hostname[256] = {0};
    gethostname( hostname, 256 );
    uriLineEdit_.setText( hostname );

    const int screen = -1;
    QRect desktopRect = QApplication::desktop()->screenGeometry( screen );

    xSpinBox_.setRange(0, desktopRect.width());
    ySpinBox_.setRange(0, desktopRect.height());
    widthSpinBox_.setRange(1, desktopRect.width());
    heightSpinBox_.setRange(1, desktopRect.height());

    // default to full screen
    xSpinBox_.setValue(0);
    ySpinBox_.setValue(0);
    widthSpinBox_.setValue( desktopRect.width( ));
    heightSpinBox_.setValue( desktopRect.height( ));

    // call updateCoordinates() to commit coordinates from the UI
    updateCoordinates();

    // frame rate limiting
    frameRateSpinBox_.setRange(1, 60);
    frameRateSpinBox_.setValue(24);

    // add widgets to UI
    formLayout->addRow("Hostname", &hostnameLineEdit_);
    formLayout->addRow("Stream name", &uriLineEdit_);
    formLayout->addRow("X", &xSpinBox_);
    formLayout->addRow("Y", &ySpinBox_);
    formLayout->addRow("Width", &widthSpinBox_);
    formLayout->addRow("Height", &heightSpinBox_);
    formLayout->addRow("Retina Display", &retinaBox_);
    formLayout->addRow("Max frame rate", &frameRateSpinBox_);
    formLayout->addRow("Actual frame rate", &frameRateLabel_);

    // share desktop action
    shareDesktopAction_ = new QAction("Share Desktop", this);
    shareDesktopAction_->setStatusTip("Share desktop");
    shareDesktopAction_->setCheckable(true);
    shareDesktopAction_->setChecked(false);
    connect(shareDesktopAction_, SIGNAL(triggered(bool)), this, SLOT(shareDesktop(bool))); // Only user actions
    connect(this, SIGNAL(streaming(bool)), shareDesktopAction_, SLOT(setChecked(bool)));

    // show desktop selection window action
    showDesktopSelectionWindowAction_ = new QAction("Show Rectangle", this);
    showDesktopSelectionWindowAction_->setStatusTip("Show desktop selection rectangle");
    showDesktopSelectionWindowAction_->setCheckable(true);
    showDesktopSelectionWindowAction_->setChecked(false);
    connect(showDesktopSelectionWindowAction_, SIGNAL(triggered(bool)), this, SLOT(showDesktopSelectionWindow(bool))); // Only user actions

    // create toolbar
    QToolBar * toolbar = addToolBar("toolbar");

    // add buttons to toolbar
    toolbar->addAction(shareDesktopAction_);
    toolbar->addAction(showDesktopSelectionWindowAction_);

    // Update timer
    connect(&shareDesktopUpdateTimer_, SIGNAL(timeout()), this, SLOT(shareDesktopUpdate()));
}
Exemplo n.º 18
0
FlyToEditWidget::FlyToEditWidget( const QModelIndex &index, MarbleWidget* widget, QWidget *parent ) :
    QWidget( parent ),
    m_widget( widget ),
    m_index( index ),
    m_button( new QToolButton )
{
    QHBoxLayout *layout = new QHBoxLayout;
    layout->setSpacing( 5 );

    QLabel* iconLabel = new QLabel;
    iconLabel->setPixmap(QPixmap(QStringLiteral(":/marble/flag.png")));
    layout->addWidget( iconLabel );

    QHBoxLayout *pairLayout = new QHBoxLayout;
    pairLayout->setSpacing( 10 );

    QHBoxLayout *durationLayout = new QHBoxLayout;
    durationLayout->setSpacing( 5 );

    QLabel *durationLabel = new QLabel;
    durationLabel->setText( tr("Duration:") );
    durationLayout->addWidget( durationLabel );

    m_durationSpin = new QDoubleSpinBox;
    durationLayout->addWidget( m_durationSpin );
    m_durationSpin->setValue( flyToElement()->duration() );
    m_durationSpin->setSuffix( tr(" s", "seconds") );

    QHBoxLayout *modeLayout = new QHBoxLayout;
    modeLayout->addSpacing( 5 );

    QLabel *modeLabel = new QLabel;
    modeLabel->setText( tr("Mode:") );
    modeLayout->addWidget( modeLabel );

    m_modeCombo = new QComboBox;
    modeLayout->addWidget( m_modeCombo );
    m_modeCombo->addItem( tr("Smooth") );
    m_modeCombo->addItem( tr("Bounce") );

    if( flyToElement()->flyToMode() == GeoDataFlyTo::Smooth ){
        m_modeCombo->setCurrentIndex( 0 );
    } else if( flyToElement()->flyToMode() == GeoDataFlyTo::Bounce ){
        m_modeCombo->setCurrentIndex( 1 );
    } else {
        m_modeCombo->setCurrentIndex( -1 );
    }

    pairLayout->addLayout( durationLayout );
    pairLayout->addLayout( modeLayout );

    layout->addLayout( pairLayout );

    QToolButton* flyToPinCenter = new QToolButton;
    flyToPinCenter->setIcon(QIcon(QStringLiteral(":/marble/places.png")));
    flyToPinCenter->setToolTip(tr("Current map center"));
    connect(flyToPinCenter, SIGNAL(clicked()), this, SLOT(updateCoordinates()));
    layout->addWidget(flyToPinCenter);

    m_button->setIcon(QIcon(QStringLiteral(":/marble/document-save.png")));
    connect(m_button, SIGNAL(clicked()), this, SLOT(save()));
    layout->addWidget( m_button );

    setLayout( layout );
}
Exemplo n.º 19
0
void FrameWidget::move(const QPoint& pos)
{
	QWidget::move(pos);
	updateCoordinates();
}
Exemplo n.º 20
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    absoluteAfterAxisAdj(false),
    checkLogWrite(false),
    sliderPressed(false),
    sliderTo(0.0),
    sliderZCount(0)
{
    // Setup our application information to be used by QSettings
    QCoreApplication::setOrganizationName(COMPANY_NAME);
    QCoreApplication::setOrganizationDomain(DOMAIN_NAME);
    QCoreApplication::setApplicationName(APPLICATION_NAME);

    // required if passing the object by reference into signals/slots
    qRegisterMetaType<Coord3D>("Coord3D");
    qRegisterMetaType<PosItem>("PosItem");
    qRegisterMetaType<ControlParams>("ControlParams");


    ui->setupUi(this);

    readSettings();

    info("%s has started", GRBL_CONTROLLER_NAME_AND_VERSION);

    // see http://blog.qt.digia.com/2010/06/17/youre-doing-it-wrong/
    // The thread points out that the documentation for QThread is wrong :) and
    // you should NOT subclass from QThread and override run(), rather,
    // attach your QOBJECT to a thread and use events (signals/slots) to communicate.
    gcode.moveToThread(&gcodeThread);
    timer.moveToThread(&timerThread);

    ui->lcdWorkNumberX->setDigitCount(8);
    ui->lcdMachNumberX->setDigitCount(8);
    ui->lcdWorkNumberY->setDigitCount(8);
    ui->lcdMachNumberY->setDigitCount(8);
    ui->lcdWorkNumberZ->setDigitCount(8);
    ui->lcdMachNumberZ->setDigitCount(8);

    //buttons
    connect(ui->btnOpenPort,SIGNAL(clicked()),this,SLOT(openPort()));
    connect(ui->btnGRBL,SIGNAL(clicked()),this,SLOT(setGRBL()));
    connect(ui->DecXBtn,SIGNAL(clicked()),this,SLOT(decX()));
    connect(ui->DecYBtn,SIGNAL(clicked()),this,SLOT(decY()));
    connect(ui->DecZBtn,SIGNAL(clicked()),this,SLOT(decZ()));
    connect(ui->IncXBtn,SIGNAL(clicked()),this,SLOT(incX()));
    connect(ui->IncYBtn,SIGNAL(clicked()),this,SLOT(incY()));
    connect(ui->IncZBtn,SIGNAL(clicked()),this,SLOT(incZ()));
    connect(ui->btnSetHome,SIGNAL(clicked()),this,SLOT(setHome()));
    connect(ui->Command,SIGNAL(editingFinished()),this,SLOT(gotoXYZ()));
    connect(ui->Begin,SIGNAL(clicked()),this,SLOT(begin()));
    connect(ui->openFile,SIGNAL(clicked()),this,SLOT(openFile()));
    connect(ui->Stop,SIGNAL(clicked()),this,SLOT(stop()));
    connect(ui->SpindleOn,SIGNAL(toggled(bool)),this,SLOT(toggleSpindle()));
    connect(ui->chkRestoreAbsolute,SIGNAL(toggled(bool)),this,SLOT(toggleRestoreAbsolute()));
    connect(ui->actionOptions,SIGNAL(triggered()),this,SLOT(getOptions()));
    connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close()));
    connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout()));
    connect(ui->btnResetGrbl,SIGNAL(clicked()),this,SLOT(grblReset()));
    connect(ui->btnUnlockGrbl,SIGNAL(clicked()),this,SLOT(grblUnlock()));
    connect(ui->btnGoHomeSafe,SIGNAL(clicked()),this,SLOT(goHomeSafe()));
    connect(ui->verticalSliderZJog,SIGNAL(valueChanged(int)),this,SLOT(zJogSliderDisplay(int)));
    connect(ui->verticalSliderZJog,SIGNAL(sliderPressed()),this,SLOT(zJogSliderPressed()));
    connect(ui->verticalSliderZJog,SIGNAL(sliderReleased()),this,SLOT(zJogSliderReleased()));

    connect(this, SIGNAL(sendFile(QString)), &gcode, SLOT(sendFile(QString)));
    connect(this, SIGNAL(openPort(QString,QString)), &gcode, SLOT(openPort(QString,QString)));
    connect(this, SIGNAL(closePort(bool)), &gcode, SLOT(closePort(bool)));
    connect(this, SIGNAL(sendGcode(QString)), &gcode, SLOT(sendGcode(QString)));
    connect(this, SIGNAL(gotoXYZ(QString)), &gcode, SLOT(gotoXYZ(QString)));
    connect(this, SIGNAL(axisAdj(char, float, bool, bool, int)), &gcode, SLOT(axisAdj(char, float, bool, bool, int)));
    connect(this, SIGNAL(setResponseWait(ControlParams)), &gcode, SLOT(setResponseWait(ControlParams)));
    connect(this, SIGNAL(shutdown()), &gcodeThread, SLOT(quit()));
    connect(this, SIGNAL(shutdown()), &timerThread, SLOT(quit()));
    connect(this, SIGNAL(setProgress(int)), ui->progressFileSend, SLOT(setValue(int)));
    connect(this, SIGNAL(setRuntime(QString)), ui->outputRuntime, SLOT(setText(QString)));
    connect(this, SIGNAL(sendSetHome()), &gcode, SLOT(grblSetHome()));
    connect(this, SIGNAL(sendGrblReset()), &gcode, SLOT(sendGrblReset()));
    connect(this, SIGNAL(sendGrblUnlock()), &gcode, SLOT(sendGrblUnlock()));
    connect(this, SIGNAL(goToHome()), &gcode, SLOT(goToHome()));
    connect(this, SIGNAL(setItems(QList<PosItem>)), ui->wgtVisualizer, SLOT(setItems(QList<PosItem>)));

    connect(&gcode, SIGNAL(sendMsg(QString)),this,SLOT(receiveMsg(QString)));
    connect(&gcode, SIGNAL(portIsClosed(bool)), this, SLOT(portIsClosed(bool)));
    connect(&gcode, SIGNAL(portIsOpen(bool)), this, SLOT(portIsOpen(bool)));
    connect(&gcode, SIGNAL(addList(QString)),this,SLOT(receiveList(QString)));
    connect(&gcode, SIGNAL(addListFull(QStringList)),this,SLOT(receiveListFull(QStringList)));
    connect(&gcode, SIGNAL(addListOut(QString)),this,SLOT(receiveListOut(QString)));
    connect(&gcode, SIGNAL(stopSending()), this, SLOT(stopSending()));
    connect(&gcode, SIGNAL(setCommandText(QString)), ui->Command, SLOT(setText(QString)));
    connect(&gcode, SIGNAL(setProgress(int)), ui->progressFileSend, SLOT(setValue(int)));
    connect(&gcode, SIGNAL(adjustedAxis()), this, SLOT(adjustedAxis()));
    connect(&gcode, SIGNAL(resetTimer(bool)), &timer, SLOT(resetTimer(bool)));
    connect(&gcode, SIGNAL(enableGrblDialogButton()), this, SLOT(enableGrblDialogButton()));
    connect(&gcode, SIGNAL(updateCoordinates(Coord3D,Coord3D)), this, SLOT(updateCoordinates(Coord3D,Coord3D)));
    connect(&gcode, SIGNAL(setLastState(QString)), ui->outputLastState, SLOT(setText(QString)));
    connect(&gcode, SIGNAL(setUnitsWork(QString)), ui->outputUnitsWork, SLOT(setText(QString)));
    connect(&gcode, SIGNAL(setUnitsMachine(QString)), ui->outputUnitsMachine, SLOT(setText(QString)));
    connect(&gcode, SIGNAL(setLivePoint(double, double, bool)), ui->wgtVisualizer, SLOT(setLivePoint(double, double, bool)));
    connect(&gcode, SIGNAL(setVisCurrLine(int)), ui->wgtVisualizer, SLOT(setVisCurrLine(int)));

    connect(&timer, SIGNAL(setRuntime(QString)), ui->outputRuntime, SLOT(setText(QString)));

    timerThread.start();
    gcodeThread.start();

    ui->comboStep->addItem("0.01");
    ui->comboStep->addItem("0.1");
    ui->comboStep->addItem("1");
    ui->comboStep->addItem("10");
    ui->comboStep->setCurrentIndex(2);

    ui->statusList->setUniformItemSizes(true);
	// Does not work correctly for horizontal scrollbar:
    //MyItemDelegate *scrollDelegate = new MyItemDelegate(ui->statusList);
    //scrollDelegate->setWidth(600);
    //ui->statusList->setItemDelegate(scrollDelegate);

    scrollStatusTimer.start();

    // Cool utility class off Google code that enumerates COM ports in platform-independent manner
    QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();

    int portIndex = -1;
    for (int i = 0; i < ports.size(); i++)
    {
        ui->cmbPort->addItem(ports.at(i).portName.toLocal8Bit().constData());

        if (ports.at(i).portName == lastOpenPort)
            portIndex = i;

        //diag("port name: %s\n", ports.at(i).portName.toLocal8Bit().constData());
        //diag("friendly name: %s\n", ports.at(i).friendName.toLocal8Bit().constData());
        //diag("physical name: %s\n", ports.at(i).physName.toLocal8Bit().constData());
        //diag("enumerator name: %s\n", ports.at(i).enumName.toLocal8Bit().constData());
        //diag("===================================\n\n");
    }

    if (portIndex >= 0)
    {
        // found matching port
        ui->cmbPort->setCurrentIndex(portIndex);
    }
    else if (lastOpenPort.size() > 0)
    {
        // did not find matching port
        // This code block is used to restore a port to view that isn't visible to QextSerialEnumerator
        ui->cmbPort->addItem(lastOpenPort.toLocal8Bit().constData());
        if (ports.size() > 0)
            ui->cmbPort->setCurrentIndex(ports.size());
        else
            ui->cmbPort->setCurrentIndex(0);
    }

    int baudRates[] = { 9600, 19200, 38400, 57600, 115200 };
    int baudRateCount = sizeof baudRates / sizeof baudRates[0];
    int baudRateIndex = 0;
    for (int i = 0; i < baudRateCount; i++)
    {
        QString baudRate = QString::number(baudRates[i]);
        ui->comboBoxBaudRate->addItem(baudRate);
        if (baudRate == lastBaudRate)
        {
            baudRateIndex = i;
        }
    }

    ui->comboBoxBaudRate->setCurrentIndex(baudRateIndex);

    ui->tabAxisVisualizer->setEnabled(false);
    ui->groupBoxSendFile->setEnabled(true);
    ui->groupBoxManualGCode->setEnabled(false);
    ui->Begin->setEnabled(false);
    ui->Stop->setEnabled(false);
    ui->progressFileSend->setEnabled(false);
    ui->outputRuntime->setEnabled(false);
    ui->labelRuntime->setEnabled(false);
    ui->btnGRBL->setEnabled(false);
    ui->btnSetHome->setEnabled(false);
    ui->btnResetGrbl->setEnabled(false);
    ui->btnUnlockGrbl->setEnabled(false);
    ui->btnGoHomeSafe->setEnabled(false);
    styleSheet = ui->btnOpenPort->styleSheet();
    ui->statusList->setEnabled(true);
    ui->openFile->setEnabled(true);

    this->setWindowTitle(GRBL_CONTROLLER_NAME_AND_VERSION);

    QSettings settings;
    QString useAggrPreload = settings.value(SETTINGS_USE_AGGRESSIVE_PRELOAD, "true").value<QString>();
    controlParams.useAggressivePreload = useAggrPreload == "true";

    if (!controlParams.useAggressivePreload && !promptedAggrPreload)
    {
        QMessageBox msgBox;
        msgBox.setText("You appear to have upgraded to the latest version of Grbl Controller. "
                       "Please be aware that as of version 3.4 the default behavior of sending commands "
                       "to Grbl has been changed to send them as fast as possible (Aggressive preload mode).\n\n"
                       "Your settings have been changed to enable this mode. Why? Because it provides the most "
                       "optimal use of Grbl and greatly reduces the time to finish a typical job.\n\n"
                       "What does this mean to you? "
                       "Arc commands will now run smoother and faster than before, which may "
                       "cause your spindle to work slightly harder, so please run some tests first. "
                       "Alternately, go to the Options dialog and manually disable Aggressive Preload");
        msgBox.exec();

        controlParams.useAggressivePreload = true;
        settings.setValue(SETTINGS_USE_AGGRESSIVE_PRELOAD, controlParams.useAggressivePreload);
    }

    promptedAggrPreload = true;

    emit setResponseWait(controlParams);
}