Ejemplo n.º 1
0
void Keeper()
{
  static int g_loop = 0;
  getMaxball();
  PID();
  if (g_diff > 40 || g_diff < -40) turn(g_pid);
  else
  {
    g_integral == 0;
    if(g_no == 0 && g_ball[0] > 300) 
    {
      moveAngle( 80, 0 , 0);
      kick();
    } 
    else if(g_no == 1 && g_ball[1] > 300) moveAngle( 80 , 0 , 270 );

    else if(g_no == 2 && g_ball[2] > 300) moveAngle( 80 , 0 , 270 );

    else if(g_no == 3 && g_ball[3] > 300) moveAngle( 50 , 0 , 315 );

    else if(g_no == 4 && g_ball[4] > 300) moveAngle( 0 , 0 , 180 );

    else if(g_no == 5 && g_ball[5] > 300) moveAngle( 50 , 0 , 45 );

    else if(g_no == 6 && g_ball[6] > 300) moveAngle( 80 , 0 , 80 );

    else if(g_no == 7 && g_ball[7] > 300) moveAngle( 80 , 0 , 80 );

    else goHome();

  }
  g_loop++;
}
void FileBrowserDialog::createToolBar()
{
    toolbar_ = new QToolBar;
    toolbar_->setObjectName("topBar");
    toolbar_->setIconSize(QSize(kToolBarIconSize, kToolBarIconSize));

    backward_button_ = new QToolButton(this);
    backward_button_->setText(tr("Back"));
    backward_button_->setObjectName("backwardButton");
    backward_button_->setIcon(QIcon(":/images/filebrowser/backward.png"));
    backward_button_->setEnabled(false);
    backward_button_->setShortcut(QKeySequence::Back);
    toolbar_->addWidget(backward_button_);
    connect(backward_button_, SIGNAL(clicked()), this, SLOT(goBackward()));

    forward_button_ = new QToolButton(this);
    forward_button_->setText(tr("Forward"));
    forward_button_->setObjectName("forwardButton");
    forward_button_->setIcon(QIcon(":/images/filebrowser/forward.png"));
    forward_button_->setEnabled(false);
    forward_button_->setShortcut(QKeySequence::Forward);
    toolbar_->addWidget(forward_button_);
    connect(forward_button_, SIGNAL(clicked()), this, SLOT(goForward()));

    gohome_action_ = new QAction(tr("Home"), this);
    gohome_action_->setIcon(QIcon(":images/filebrowser/home.png"));
    connect(gohome_action_, SIGNAL(triggered()), this, SLOT(goHome()));
    toolbar_->addAction(gohome_action_);

    path_navigator_ = new QButtonGroup(this);
    connect(path_navigator_, SIGNAL(buttonClicked(int)),
            this, SLOT(onNavigatorClick(int)));

}
void HelpBrowser::createActions()
{
    QAction * action;
    OverridingAction *ovrAction;

    mActions[GoHome] = action = new QAction(tr("Home"), this);
    connect( action, SIGNAL(triggered()), this, SLOT(goHome()) );

    mActions[ZoomIn] = ovrAction = new OverridingAction(tr("Zoom In"), this);
    connect(ovrAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
    ovrAction->addToWidget(mWebView);

    mActions[ZoomOut] = ovrAction = new OverridingAction(tr("Zoom Out"), this);
    connect(ovrAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
    ovrAction->addToWidget(mWebView);

    mActions[ResetZoom] = ovrAction = new OverridingAction(tr("Reset Zoom"), this);
    connect(ovrAction, SIGNAL(triggered()), this, SLOT(resetZoom()));
    ovrAction->addToWidget(mWebView);

    mActions[Evaluate] = ovrAction = new OverridingAction(tr("Evaluate as Code"), this);
    connect(ovrAction, SIGNAL(triggered()), this, SLOT(evaluateSelection()));
    ovrAction->addToWidget(mWebView);

    // For the sake of display:
    mWebView->pageAction(QWebPage::Copy)->setShortcut( QKeySequence::Copy );
    mWebView->pageAction(QWebPage::Paste)->setShortcut( QKeySequence::Paste );
}
Ejemplo n.º 4
0
CustomFileDialog::CustomFileDialog( QWidget* parent )
: QFileDialog( parent, 0, false )
{
  QToolButton *p = new QToolButton( this );

  p->setPixmap( QPixmap( globalbookmark_xpm ) );
  QToolTip::add( p, tr( "Bookmarks" ) );

  bookmarkMenu = new QPopupMenu( this );
  connect( bookmarkMenu, SIGNAL( activated( int ) ), this, SLOT( bookmarkChosen( int ) ) );
  addId = bookmarkMenu->insertItem( "Add bookmark" );
  clearId = bookmarkMenu->insertItem( QPixmap(folder_trash), "Clear bookmarks" );
  bookmarkMenu->insertSeparator();

  p->setPopup( bookmarkMenu );
  p->setPopupDelay(0);
  addToolButton( p, true );

  QToolButton *b = new QToolButton( this );
  QToolTip::add( b, tr( "Go Home!" ) );

  b->setPixmap( QPixmap( homepage_xpm ) );
  connect( b, SIGNAL( clicked() ), this, SLOT( goHome() ) );

  addToolButton( b );
}
int main(int argc, char **argv) {
	ros::init(argc, argv, "testing_scroll");
	ros::NodeHandle node("~");
	ros::AsyncSpinner spinner(1);
	spinner.start();

	clopema_robot::ClopemaRobotCommander ext("ext");
	ext.setNamedTarget("ext_minus_90");
	ext.move();
	ros::Duration(0.1).sleep();

	clopema_robot::ClopemaRobotCommander crc("arms");

	std::vector<std::string> elinks1;
	std::vector<std::string> elinks2;
	getListOfCollisions(elinks1, elinks2, "t3_desk");

	goHome(true);

	std::vector<geometry_msgs::Pose> wp1, wp2;
	moveit_msgs::RobotTrajectory trajectory;
	
	getListOfPoints1(wp1, wp2);	
	planPoses(trajectory, elinks1, elinks2, wp1, wp2, false, crc);
	wp1.erase(wp1.end());
	wp2.erase(wp2.end());
	if(planPoses(trajectory, elinks1, elinks2, wp1, wp2, true, crc)){
		crc.execute_traj(trajectory.joint_trajectory);
	}

	
	goHome(GO_HOME);


	getListOfPoints2(wp1, wp2);
	planPoses(trajectory, elinks1, elinks2, wp1, wp2, false, crc);
	wp1.erase(wp1.end());
	wp2.erase(wp2.end());
	if(planPoses(trajectory, elinks1, elinks2, wp1, wp2, true, crc)){
		crc.execute_traj(trajectory.joint_trajectory);
	}
	
	std::cout << "\033[1;33mEnd\033[0m" << std::endl; //]]
	ros::spinOnce();
	return 0;
}
/// <summary>
/// Show menu: specify a menu name: d -> default, e -> empty
/// </summary>
void SerialMenu::show(char name)
{
// First three lines are always printed
    printLine(MENU_HORIZONTAL_LINE);
    printLine(MENU_TITLE);
    printLine(MENU_HORIZONTAL_LINE);

    if(name == 'd')                                 // print default menu
    {
        printLine(MENU_OPTION1);
        printLine(MENU_OPTION2);
        printLine(MENU_OPTION3);
        printLine(MENU_OPTION4);
    }
    if(name == 'e')                                 //print empty menu
    {
        printLine(MENU_EMPTY);
        printLine(MENU_EMPTY);
        printLine(MENU_EMPTY);
        printLine(MENU_EMPTY);
    }
    if(name == 's')                                 // print text based on selection
    {

        switch (_incomingByte)
        {
        case ASCII_0:
            printLine(MENU_SELECT_0);
            break;
        case ASCII_1:
            printLine(MENU_SELECT_1);
            break;
        case ASCII_2:
            printLine(MENU_SELECT_2);
            break;
        case ASCII_3:
            printLine(MENU_SELECT_3);
            break;

        default:
            printLine(MENU_EMPTY);
        }
        printLine(MENU_EMPTY);
        printLine(MENU_EMPTY);
        printLine(MENU_EMPTY);

    }
    if(name == 'l')                                 // print text based on readline
    {

        printLine(MENU_MSG_1);
        printLine();
        printLine(MENU_EMPTY);
    }

    printLine(MENU_HORIZONTAL_LINE);                // ending line at the end of the menu
    goHome();
}
Ejemplo n.º 7
0
void DirNavBar::onGoHome()
{
    if (this->homePath.isEmpty()) {
        emit goHome();
    } else {
        this->uiw->comboBox->setEditText(this->homePath);
        emit dirInputConfirmed(this->homePath);
    }
}
Ejemplo n.º 8
0
LookupPanel::LookupPanel() : QDockWidget(tr("Search"))
{
  _wordEdit = new QLineEdit(this);
  connect(_wordEdit, SIGNAL(returnPressed()), this, SLOT(editingFinished()));
  _toolBar = new QToolBar(this);
  _toolBar->setFloatable(false);
  _toolBar->setAllowedAreas(Qt::NoToolBarArea);
  _toolBar->setMovable(false);
  // remove excessive space around small buttons
  _toolBar->setStyleSheet("QToolButton{margin:0}");

  // Go Home button.
  _homeAct = new QAction(QIcon(":/images/go-home.svg"), tr("Title page"), this);
  _toolBar->addAction(_homeAct);
  connect(_homeAct, SIGNAL(triggered()), this, SLOT(goHome()));

  // Previous Entry button. Backspace added as an important
  // shortcut.
  _previousAct = new QAction(QIcon(":/images/go-previous.svg"), tr("Previous"), this);
  QList<QKeySequence> previousActShortcuts;
  previousActShortcuts.append(QKeySequence::Back);
  previousActShortcuts.append(Qt::Key_Backspace);
  _previousAct->setShortcuts(previousActShortcuts);
  connect(_previousAct, SIGNAL(triggered()), this, SLOT(goPrevious()));
  _toolBar->addAction(_previousAct);

  // Next Entry button.
  _nextAct = new QAction(QIcon(":/images/go-next.svg"), tr("Next"), this);
  _nextAct->setShortcut(QKeySequence::Forward);
  connect(_nextAct, SIGNAL(triggered()), this, SLOT(goNext()));
  _toolBar->addAction(_nextAct);

  // Update displayed entry history and register a slot catching its changes.
  historyChanged();
  connect(&_history, SIGNAL(changed()), this, SLOT(historyChanged()));

  // Vertical fixed layout without margins.
  QWidget *layoutWidget = new QWidget(this);
  QVBoxLayout *layout = new QVBoxLayout(layoutWidget);
  layout->setContentsMargins(0, 0, 0, 0);
  layout->setSpacing(0);
  layout->setSizeConstraint(QLayout::SetMaximumSize);
  layout->addWidget(_wordEdit);
  layout->addWidget(_toolBar);
  layoutWidget->setMaximumHeight(_wordEdit->height() + _toolBar->height());
  layoutWidget->setLayout(layout);
  setWidget(layoutWidget);

  // Not movable, no title bar.
  setAllowedAreas(Qt::LeftDockWidgetArea);
  setFeatures(QDockWidget::NoDockWidgetFeatures);
  setContentsMargins(0, 4, 2, 4);
  setTitleBarWidget(new QWidget(this)); // no title bar
}
void imuIdentifierThread::threadRelease()
{
    printMessage(0,"Putting head in home position..\n");
        goHome();

    printMessage(0,"Closing controllers..\n");
        ddH.close();

    printMessage(0,"Closing ports...\n");
        closePort(inIMUPort);
        closePort(outPort);
}
void FileBrowserDialog::createToolBar()
{
    toolbar_ = new QToolBar;

    const int w = ::getDPIScaledSize(kToolBarIconSize);
    toolbar_->setIconSize(QSize(w, w));

    toolbar_->setObjectName("topBar");
    toolbar_->setIconSize(QSize(w, w));

    backward_action_ = new QAction(tr("Back"), this);
    backward_action_->setIcon(getIconSet(":/images/filebrowser/backward.png", kToolBarIconSize, kToolBarIconSize));
    backward_action_->setEnabled(false);
    toolbar_->addAction(backward_action_);
    connect(backward_action_, SIGNAL(triggered()), this, SLOT(goBackward()));

    forward_action_ = new QAction(tr("Forward"), this);
    forward_action_->setIcon(getIconSet(":/images/filebrowser/forward.png", kToolBarIconSize, kToolBarIconSize));
    forward_action_->setEnabled(false);
    connect(forward_action_, SIGNAL(triggered()), this, SLOT(goForward()));
    toolbar_->addAction(forward_action_);

    gohome_action_ = new QAction(tr("Home"), this);
    gohome_action_->setIcon(getIconSet(":images/filebrowser/home.png", kToolBarIconSize, kToolBarIconSize));
    connect(gohome_action_, SIGNAL(triggered()), this, SLOT(goHome()));
    toolbar_->addAction(gohome_action_);

    path_navigator_ = new QButtonGroup(this);
    connect(path_navigator_, SIGNAL(buttonClicked(int)),
            this, SLOT(onNavigatorClick(int)));

    // root is special
    QPushButton *path_navigator_root_ = new QPushButton(repo_.name);
    path_navigator_root_->setFlat(true);
    path_navigator_root_->setCursor(Qt::PointingHandCursor);
    connect(path_navigator_root_, SIGNAL(clicked()),
            this, SLOT(goHome()));
    toolbar_->addWidget(path_navigator_root_);
}
Ejemplo n.º 11
0
// This function execute builtin functions
void do_it(int bi) {
	
	switch(comtab[bi].builtin) {
		case BYE: goodbye = 1;	// Set global goodbye variable to true
			break;

		case CDHOME: 
				goHome();
			break;

		case CD: 	// Go to specified path
				gotoDir(bi);
			break;

		case SETALIAS: // Adding alias to the alias table
				printf("adding alias to table\n");
				createAlias(comtab[curr_cmd].atptr->args[0], comtab[curr_cmd].atptr->args[1]);
				printf("Done adding alias to table\n");
			break;

		case UNALIAS:
				removeAlias(comtab[curr_cmd].atptr->args[0]);
			break;

		case PRINTALIAS:	// Print either a specific alias or all aliases
				if( comtab[curr_cmd].nargs == 0) {
					printf("calling\n");
					listAliases();		// Print all aliases
				}
				else {
					printAnAlias(comtab[curr_cmd].atptr->args[0]);	// Print specific alias
				}		
			break;

		case SETENV: 	// Set environment
				if( putenv( strcat(strcat(comtab[curr_cmd].atptr->args[0],"="),comtab[curr_cmd].atptr->args[1]) ) != 0) {
					printf("%s\n", strerror(errno));
				}
			break;
		case UNSETENV: 	// Removing environment variables
			if( unsetenv(comtab[bi].atptr->args[0]) == -1) {
				printf("%s\n", strerror(errno));
			}
			break;
		case PRINTENV: 	// Print environment variables
			printallEnv();
			break;
	}
}
Ejemplo n.º 12
0
void fillScreen(uint16_t color) 
{
    goHome();
    uint32_t i;

    i = 320;
    i *= 240;


    while (i--) 
    {
        uDelay(0);
        writeData(color); 
    }


}
Ejemplo n.º 13
0
QcHelpBrowser::QcHelpBrowser()
{

    // content display
    helpFileView = new HelpFileView;

    // top controls
    QToolBar *toolbar = new QToolBar;
    QAction *actHome = toolbar->addAction( style()->standardIcon( QStyle::SP_DirHomeIcon ),
                                           "Go To Start Page" );
    toolbar->addAction( helpFileView->pageAction( QWebPage::Back ) );
    toolbar->addAction( helpFileView->pageAction( QWebPage::Forward ) );

    findTool = new SimpleFindTool;
    findTool->setMaximumWidth( 200 );

    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget( toolbar );
    topLayout->addStretch();
    topLayout->addWidget( new QLabel( "Find:" ) );
    topLayout->addWidget( findTool );
    topLayout->setContentsMargins(0,0,0,0);

    // bottom controls
    // QToolBar *bottomToolbar = new QToolBar;

    // main layout
    QVBoxLayout *l = new QVBoxLayout;
    // l->setContentsMargins(10,10,10,0);
    l->addLayout( topLayout );
    l->addWidget( helpFileView );
    // l->addWidget( bottomToolbar );

    setLayout( l );
    setWindowTitle( "SuperCollider Help" );

    QShortcut *copyScut = new QShortcut( QKeySequence::Copy, helpFileView );
    copyScut->setContext( Qt::WidgetWithChildrenShortcut );

    connect( helpFileView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)) );
    connect( copyScut, SIGNAL(activated()),
             helpFileView->pageAction( QWebPage::Copy ), SLOT(trigger()) );
    connect( findTool, SIGNAL(activated(const QString&,bool)),
             helpFileView, SLOT(findText(const QString&,bool)) );
    connect( actHome, SIGNAL(activated()), this, SLOT(goHome()) );
}
Ejemplo n.º 14
0
void Ghost::move()
{
    if(isInsideGhostHouse())
    {
        if(isFree())
        {
            if(!isCaught())
            {
                release();
            }
        }
    }
    else if(isOnTheMove()) localMove();
    else if(isCaught()) goHome();
    else if(areGhostsScared()) escape();
    else if(isScattering()) scatter();
    else chase();
}
Ejemplo n.º 15
0
void HtmlTabPage::setCurUrl(const char* page)
{
	if (!page)
	{
		goHome();
		return;
	}

	if (!m_pWebControl)
	{
		gcString home = m_szHomePage;
		m_szHomePage = page;
		constuctBrowser();
		m_szHomePage = home;
	}
	else
	{
		m_pWebControl->loadUrl(page);
	}
}
Ejemplo n.º 16
0
BlueprintWindow::BlueprintWindow(Game* game, QWidget* parent):
	QWidget(parent),
	mBlueprint(new GameBlueprint(game))
{
	setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

	//TODO: make these icons instead of ugly text buttons!
	mToolbar = new QToolBar(tr("Blueprint actions"), this);
	mToolbar->addAction(tr("Home"), mBlueprint, SLOT(goHome()));
	mToolbar->addSeparator();
	mToolbar->addAction(tr("Zoom In"), this, SLOT(zoomIn()));
	mToolbar->addAction(tr("Zoom Out"), this, SLOT(zoomOut()));

	mToolCombo = new QComboBox(this);
	mToolCombo->insertItem(GameBlueprint::dormantPortal, QIcon(), "Dormant Portal");
	mToolCombo->insertItem(GameBlueprint::portal, QIcon(), "Active Portal");
	mToolCombo->insertItem(GameBlueprint::trap, QIcon(), "Ghost Trap");
	mToolCombo->insertItem(GameBlueprint::nav, QIcon(), "Navigate!");
	mToolCombo->setCurrentIndex(-1);
	mToolbar->addSeparator();
	mToolbar->addWidget(mToolCombo);

	QCheckBox* showNavmesh = new QCheckBox("&Navmesh", this);
	mToolbar->addWidget(showNavmesh);

	mStatusBar = new QStatusBar;
	mZoomLbl = new QLabel();
	mStatusBar->addPermanentWidget(mZoomLbl);
	zoomChanged(mBlueprint->zoom());

	QVBoxLayout* layout = new QVBoxLayout;
	layout->addWidget(mToolbar);
	layout->addWidget(mBlueprint);
	layout->addWidget(mStatusBar);

	setLayout(layout);

	connect(mBlueprint, SIGNAL(zoomChanged(float)), this, SLOT(zoomChanged(float)));
	connect(mToolCombo, SIGNAL(activated(int)), mBlueprint, SLOT(setTool(int)));
	connect(showNavmesh, SIGNAL(stateChanged(int)), mBlueprint, SLOT(setShowNavmesh(int)));
}
Ejemplo n.º 17
0
void Help::setupGoActions()
{
    QPopupMenu* menu = new QPopupMenu( this );
    menuBar()->insertItem( tr( "&Go" ), menu );
    QAction *a;

    a = new QAction( tr( "Home" ), createIconSet( "home.xpm" ), ( "&Home" ), ALT + Key_Home, this );
    a->addTo( menu );
    a->addTo( toolbar );
    connect( a, SIGNAL( activated() ), this, SLOT( goHome() ) );

    a = new QAction( tr( "Qt Reference Documentation" ), createIconSet( "customwidget.xpm" ),
		     ( "&Qt Reference Documentation" ), ALT + SHIFT + Key_Home, this );
    a->addTo( menu );
    a->addTo( toolbar );
    connect( a, SIGNAL( activated() ), this, SLOT( goQt() ) );

    menu->insertSeparator();

    a = new QAction( tr( "Backward" ), createIconSet( "left.xpm" ), ( "&Backward" ), ALT + Key_Left, this );
    a->addTo( menu );
    a->addTo( toolbar );
    connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) );
    connect( browser, SIGNAL( backwardAvailable( bool ) ), a, SLOT( setEnabled( bool ) ) );

    a = new QAction( tr( "Forward" ), createIconSet( "right.xpm" ), tr( "&Forward" ), ALT + Key_Right, this );
    a->addTo( menu );
    a->addTo( toolbar );
    connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) );
    connect( browser, SIGNAL( forwardAvailable( bool ) ), a, SLOT( setEnabled( bool ) ) );

    menu->insertSeparator();

    a = new QAction( tr( "Topics/Index" ), createIconSet( "help.xpm" ), tr( "&Topics/Index..." ), CTRL + Key_T, this );
    a->addTo( menu );
    a->addTo( toolbar );
    connect( a, SIGNAL( activated() ), this, SLOT( goTopics() ) );
}
Ejemplo n.º 18
0
akuDragSourceWidget::akuDragSourceWidget(QWidget *parent) : QWidget(parent)
{
  QVBoxLayout *layout = new QVBoxLayout(this);
  KVBox *vbox = new KVBox(this);
  vbox -> setSpacing(10);
  layout -> addWidget(vbox);
  setLayout(layout);
  KHBox *hbox1 = new KHBox(vbox);
  hbox1 -> setSpacing(10);
  icon = new QLabel(hbox1);
  icon -> setMaximumSize(16,16);
  currentDirectory = new QLabel(hbox1);

  KHBox *hbox2 = new KHBox(vbox);
  hbox2 -> setSpacing(3);
  upDirButton = new QToolButton(hbox2);
  upDirButton -> setIcon(KIcon("go-up"));
  upDirButton -> setAttribute(Qt::WA_AlwaysShowToolTips);
  upDirButton -> setToolTip(i18n("Parent Folder"));
  upDirButton -> setAutoRaise(true);  
  homeButton = new QToolButton(hbox2);
  homeButton -> setIcon(KIcon("go-home"));
  homeButton -> setAttribute(Qt::WA_AlwaysShowToolTips);
  homeButton -> setToolTip(i18n("Home Folder"));
  homeButton -> setAutoRaise(true); 
  hiddenFiles = new QCheckBox(i18n("Show hidden files"), hbox2);
  sourceView = new dragSource(vbox); 

  connect(hiddenFiles, SIGNAL(toggled(bool)), sourceView, SLOT(showHiddenFiles(bool)));
  connect(upDirButton, SIGNAL(clicked()), sourceView, SLOT(dirUp()));
  connect(homeButton, SIGNAL(clicked()), sourceView, SLOT(goHome()));
  connect(sourceView, SIGNAL(currentUrlChanged(KUrl)), this, SLOT(updateCurrentDirInfo(KUrl)));

  KUrl current = sourceView -> rootUrl();
  currentDirectory -> setText(current.fileName());
  QPixmap pixmap = KIcon(KMimeType::iconNameForUrl(current)).pixmap(16,16);
  icon -> setPixmap(pixmap);
}
Ejemplo n.º 19
0
void HtmlTabPage::onButtonClicked(int32& id)
{ 
	switch (id)
	{
	case BUTTON_HOME:
		goHome();
		break;

	case BUTTON_STOP:
		m_pWebControl->stop();
		break;

	case BUTTON_REFRESH:
		m_pWebControl->refresh();
		break;

	case BUTTON_BACK:
		m_pWebControl->back();
		break;

	case BUTTON_FOWARD:
		m_pWebControl->forward();
		break;

	case BUTTON_LAUNCH:
		gcLaunchDefaultBrowser(m_szCurUrl.c_str());
		break;
	};

	if (m_pControlBar)
	{
		const wchar_t* url = m_pControlBar->getCrumbUrl(id);

		if (url)
			m_pWebControl->loadUrl(url);
	}
}
Ejemplo n.º 20
0
void TFTLCD::fillScreen(uint16_t color) {
  goHome();
  uint32_t i;
  
  i = 320;
  i *= 240;
  
  *portOutputRegister(csport) &= ~cspin;
  //digitalWrite(_cs, LOW);
  *portOutputRegister(cdport) |= cdpin;
  //digitalWrite(_cd, HIGH);
  *portOutputRegister(rdport) |= rdpin;
  //digitalWrite(_rd, HIGH);
  *portOutputRegister(wrport) |= wrpin;
  //digitalWrite(_wr, HIGH);

  setWriteDir();
  while (i--) {
    writeData_unsafe(color); 
  }

  *portOutputRegister(csport) |= cspin;
  //digitalWrite(_cs, HIGH);
}
Ejemplo n.º 21
0
NavigationBar::NavigationBar(QupZilla* mainClass)
    : QWidget(mainClass)
    , p_QupZilla(mainClass)
{
    setObjectName("navigationbar");
    m_layout = new QHBoxLayout(this);
    m_layout->setMargin(3);
    m_layout->setSpacing(3);
    setLayout(m_layout);

    m_buttonBack = new ToolButton(this);
    m_buttonBack->setObjectName("navigation-button-back");
    m_buttonBack->setToolTip(tr("Back"));
    m_buttonBack->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonBack->setAutoRaise(true);
    m_buttonBack->setEnabled(false);
    m_buttonBack->setFocusPolicy(Qt::NoFocus);

    m_buttonNext = new ToolButton(this);
    m_buttonNext->setObjectName("navigation-button-next");
    m_buttonNext->setToolTip(tr("Forward"));
    m_buttonNext->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonNext->setAutoRaise(true);
    m_buttonNext->setEnabled(false);
    m_buttonNext->setFocusPolicy(Qt::NoFocus);

    QHBoxLayout* backNextLayout = new QHBoxLayout();
    backNextLayout->setContentsMargins(0, 0, 0, 0);
    backNextLayout->setSpacing(0);
    backNextLayout->addWidget(m_buttonBack);
    backNextLayout->addWidget(m_buttonNext);

    m_reloadStop = new ReloadStopButton(this);

    m_buttonHome = new ToolButton(this);
    m_buttonHome->setObjectName("navigation-button-home");
    m_buttonHome->setToolTip(tr("Home"));
    m_buttonHome->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonHome->setAutoRaise(true);
    m_buttonHome->setFocusPolicy(Qt::NoFocus);

    m_buttonAddTab = new ToolButton(this);
    m_buttonAddTab->setObjectName("navigation-button-addtab");
    m_buttonAddTab->setToolTip(tr("New Tab"));
    m_buttonAddTab->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonAddTab->setAutoRaise(true);
    m_buttonAddTab->setFocusPolicy(Qt::NoFocus);

    m_menuBack = new Menu(this);
    m_buttonBack->setMenu(m_menuBack);
    m_menuForward = new Menu(this);
    m_buttonNext->setMenu(m_menuForward);

#ifndef Q_OS_MAC
    m_supMenu = new ToolButton(this);
    m_supMenu->setObjectName("navigation-button-supermenu");
    m_supMenu->setPopupMode(QToolButton::InstantPopup);
    m_supMenu->setToolTip(tr("Main Menu"));
    m_supMenu->setAutoRaise(true);
    m_supMenu->setFocusPolicy(Qt::NoFocus);
    m_supMenu->setMenu(p_QupZilla->superMenu());
    m_supMenu->setShowMenuInside(true);
#endif

    m_searchLine = new WebSearchBar(p_QupZilla);

    m_navigationSplitter = new QSplitter(this);
    m_navigationSplitter->addWidget(p_QupZilla->tabWidget()->locationBars());
    m_navigationSplitter->addWidget(m_searchLine);

    m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
    m_navigationSplitter->setCollapsible(0, false);

    m_exitFullscreen = new ToolButton();
    m_exitFullscreen->setText(tr("Exit Fullscreen"));
    m_exitFullscreen->setToolTip(tr("Exit Fullscreen"));
    m_exitFullscreen->setAutoRaise(true);
    m_exitFullscreen->setVisible(false);

    m_layout->addLayout(backNextLayout);
    m_layout->addWidget(m_reloadStop);
    m_layout->addWidget(m_buttonHome);
    m_layout->addWidget(m_buttonAddTab);
    m_layout->addWidget(m_navigationSplitter);
#ifndef Q_OS_MAC
    m_layout->addWidget(m_supMenu);
#endif
    m_layout->addWidget(m_exitFullscreen);

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));

    connect(m_menuBack, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryBackMenu()));
    connect(m_menuForward, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryNextMenu()));
    connect(m_buttonBack, SIGNAL(clicked()), this, SLOT(goBack()));
    connect(m_buttonBack, SIGNAL(middleMouseClicked()), this, SLOT(goBackInNewTab()));
    connect(m_buttonBack, SIGNAL(controlClicked()), this, SLOT(goBackInNewTab()));
    connect(m_buttonNext, SIGNAL(clicked()), this, SLOT(goForward()));
    connect(m_buttonNext, SIGNAL(middleMouseClicked()), this, SLOT(goForwardInNewTab()));
    connect(m_buttonNext, SIGNAL(controlClicked()), this, SLOT(goForwardInNewTab()));

    connect(m_reloadStop->buttonStop(), SIGNAL(clicked()), p_QupZilla, SLOT(stop()));
    connect(m_reloadStop->buttonReload(), SIGNAL(clicked()), p_QupZilla, SLOT(reload()));
    connect(m_buttonHome, SIGNAL(clicked()), p_QupZilla, SLOT(goHome()));
    connect(m_buttonHome, SIGNAL(middleMouseClicked()), p_QupZilla, SLOT(goHomeInNewTab()));
    connect(m_buttonHome, SIGNAL(controlClicked()), p_QupZilla, SLOT(goHomeInNewTab()));
    connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab()));
    connect(m_exitFullscreen, SIGNAL(clicked(bool)), p_QupZilla, SLOT(toggleFullScreen(bool)));
}
Ejemplo n.º 22
0
NavigationBar::NavigationBar(BrowserWindow* window)
    : QWidget(window)
    , m_window(window)
{
    setObjectName(QSL("navigationbar"));

    m_layout = new QHBoxLayout(this);
    m_layout->setMargin(style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this));
    m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this));
    setLayout(m_layout);

    m_buttonBack = new ToolButton(this);
    m_buttonBack->setObjectName("navigation-button-back");
    m_buttonBack->setToolTip(tr("Back"));
    m_buttonBack->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonBack->setToolbarButtonLook(true);
    m_buttonBack->setAutoRaise(true);
    m_buttonBack->setEnabled(false);
    m_buttonBack->setFocusPolicy(Qt::NoFocus);

    m_buttonForward = new ToolButton(this);
    m_buttonForward->setObjectName("navigation-button-next");
    m_buttonForward->setToolTip(tr("Forward"));
    m_buttonForward->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonForward->setToolbarButtonLook(true);
    m_buttonForward->setAutoRaise(true);
    m_buttonForward->setEnabled(false);
    m_buttonForward->setFocusPolicy(Qt::NoFocus);

    QHBoxLayout* backNextLayout = new QHBoxLayout();
    backNextLayout->setContentsMargins(0, 0, 0, 0);
    backNextLayout->setSpacing(0);
    backNextLayout->addWidget(m_buttonBack);
    backNextLayout->addWidget(m_buttonForward);

    m_reloadStop = new ReloadStopButton(this);

    m_buttonHome = new ToolButton(this);
    m_buttonHome->setObjectName("navigation-button-home");
    m_buttonHome->setToolTip(tr("Home"));
    m_buttonHome->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonHome->setToolbarButtonLook(true);
    m_buttonHome->setAutoRaise(true);
    m_buttonHome->setFocusPolicy(Qt::NoFocus);

    m_buttonAddTab = new ToolButton(this);
    m_buttonAddTab->setObjectName("navigation-button-addtab");
    m_buttonAddTab->setToolTip(tr("New Tab"));
    m_buttonAddTab->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonAddTab->setToolbarButtonLook(true);
    m_buttonAddTab->setAutoRaise(true);
    m_buttonAddTab->setFocusPolicy(Qt::NoFocus);

    m_menuBack = new Menu(this);
    m_menuBack->setCloseOnMiddleClick(true);
    m_buttonBack->setMenu(m_menuBack);
    connect(m_buttonBack, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowHistoryBackMenu()));

    m_menuForward = new Menu(this);
    m_menuForward->setCloseOnMiddleClick(true);
    m_buttonForward->setMenu(m_menuForward);
    connect(m_buttonForward, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowHistoryNextMenu()));

    m_supMenu = new ToolButton(this);
    m_supMenu->setObjectName("navigation-button-supermenu");
    m_supMenu->setPopupMode(QToolButton::InstantPopup);
    m_supMenu->setToolbarButtonLook(true);
    m_supMenu->setToolTip(tr("Main Menu"));
    m_supMenu->setAutoRaise(true);
    m_supMenu->setFocusPolicy(Qt::NoFocus);
    m_supMenu->setMenu(m_window->superMenu());
    m_supMenu->setShowMenuInside(true);

    m_searchLine = new WebSearchBar(m_window);

    m_navigationSplitter = new QSplitter(this);
    m_navigationSplitter->addWidget(m_window->tabWidget()->locationBars());
    m_navigationSplitter->addWidget(m_searchLine);

    m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
    m_navigationSplitter->setCollapsible(0, false);

    m_exitFullscreen = new ToolButton(this);
    m_exitFullscreen->setObjectName("navigation-button-exitfullscreen");
    m_exitFullscreen->setToolTip(tr("Exit Fullscreen"));
    m_exitFullscreen->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_exitFullscreen->setToolbarButtonLook(true);
    m_exitFullscreen->setFocusPolicy(Qt::NoFocus);
    m_exitFullscreen->setAutoRaise(true);
    m_exitFullscreen->setVisible(false);

    m_layout->addLayout(backNextLayout);
    m_layout->addWidget(m_reloadStop);
    m_layout->addWidget(m_buttonHome);
    m_layout->addWidget(m_buttonAddTab);
    m_layout->addWidget(m_navigationSplitter);
    m_layout->addWidget(m_supMenu);
    m_layout->addWidget(m_exitFullscreen);

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));

    connect(m_buttonBack, SIGNAL(clicked()), this, SLOT(goBack()));
    connect(m_buttonBack, SIGNAL(middleMouseClicked()), this, SLOT(goBackInNewTab()));
    connect(m_buttonBack, SIGNAL(controlClicked()), this, SLOT(goBackInNewTab()));
    connect(m_buttonForward, SIGNAL(clicked()), this, SLOT(goForward()));
    connect(m_buttonForward, SIGNAL(middleMouseClicked()), this, SLOT(goForwardInNewTab()));
    connect(m_buttonForward, SIGNAL(controlClicked()), this, SLOT(goForwardInNewTab()));

    connect(m_reloadStop, SIGNAL(stopClicked()), this, SLOT(stop()));
    connect(m_reloadStop, SIGNAL(reloadClicked()), this, SLOT(reload()));
    connect(m_buttonHome, SIGNAL(clicked()), m_window, SLOT(goHome()));
    connect(m_buttonHome, SIGNAL(middleMouseClicked()), m_window, SLOT(goHomeInNewTab()));
    connect(m_buttonHome, SIGNAL(controlClicked()), m_window, SLOT(goHomeInNewTab()));
    connect(m_buttonAddTab, SIGNAL(clicked()), m_window, SLOT(addTab()));
    connect(m_buttonAddTab, SIGNAL(middleMouseClicked()), m_window->tabWidget(), SLOT(addTabFromClipboard()));
    connect(m_exitFullscreen, SIGNAL(clicked(bool)), m_window, SLOT(toggleFullScreen()));
}
Ejemplo n.º 23
0
    }
	
    p->setPopup( bookmarkMenu );

    addToolButton( p, TRUE );

    connect( dirView, SIGNAL( folderSelected( const QString & ) ),
	     this, SLOT( setDir2( const QString & ) ) );
    connect( this, SIGNAL( dirEntered( const QString & ) ),
	     dirView, SLOT( setDir( const QString & ) ) );

    QToolButton *b = new QToolButton( this );
    QToolTip::add( b, tr( "Go Home!" ) );
    b->setPixmap( QPixmap( home ) );
    connect( b, SIGNAL( clicked() ),
	     this, SLOT( goHome() ) );

    addToolButton( b );

    resize( width() + width() / 3, height() );
}

CustomFileDialog::~CustomFileDialog()
{
    if ( !bookmarkList.isEmpty() ) {
	QFile f( ".bookmarks" );
	if ( f.open( IO_WriteOnly ) ) {
	    QDataStream ds( &f );
	    ds << bookmarkList;
	    f.close();
	}
Ejemplo n.º 24
0
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
void arduinoThread::update(){
    ard.update();
    
    switch (curState) {
        case JOG:
            sleepDoneMotors();
            if (allDone()) curState = IDLE;
            break;
        // arm has raised and is ready to take a photo
        case SHOOT_FACE:
            sleepDoneMotors();
            if (allDone()) curState = IDLE;
            break;
        // photo taken, arm is going to the limit switches: home
        case FACE_PHOTO:
            goHome();
            break;
        case HOMING: 
            break;
        // X, Z, and Y have hit limits
        case HOME:
            // start X, Y, and I
            ard.sendDigital(X_SLEEP_PIN, ARD_HIGH);
            ard.sendDigital(Y_SLEEP_PIN, ARD_HIGH);
            ard.sendDigital(INK_SLEEP_PIN, ARD_HIGH);
            // sleep Z
            ard.sendDigital(Z_SLEEP_PIN, ARD_LOW);
            ofSleepMillis(10);
            journeyOn(true);
            curState = PREPRINT;
            point_count = 1;
            break;
        // this is when arm moves from home to first point
        case PREPRINT:
            if (journeysDone()) {
                curState = PRINTING;
            }
            break;
        // print has started from first point
        case PRINTING:
            if (journeysDone()) {
                journeyOn(false);
            }
            break;
        // print is finished and arm is raising up
        case DONE:
            break;
        case ERROR:
            x_steps = y_steps = z_steps = i_steps = x_inc = y_inc = z_inc = i_inc = 0;
            ard.sendDigital(X_SLEEP_PIN, ARD_LOW);
            ard.sendDigital(Y_SLEEP_PIN, ARD_LOW);
            ard.sendDigital(Z_SLEEP_PIN, ARD_LOW);
            ard.sendDigital(INK_SLEEP_PIN, ARD_LOW);
            break;
        case RESET:
            if (journeysDone()){
                curState = IDLE;
                ard.sendDigital(X_SLEEP_PIN, ARD_LOW);
                ard.sendDigital(Y_SLEEP_PIN, ARD_LOW);
                ard.sendDigital(Z_SLEEP_PIN, ARD_LOW);
                x_inc = y_inc = z_inc = x_steps = y_steps = z_steps = 0;
            }
        default:
            break;
    }
}
int main (int argc, char *argv[])
{
  int key;                                                           /*access key to shared memory and semaphore set */
  char *tinp;                                                                      /* numerical parameters test flag */
  unsigned int k;                                                                                   /* flight number */
  unsigned int p;                                                                        /* passenger identification */
  unsigned int stat;                                                                          /* status of operation */

  /* validation of command line parameters */

  if (argc != 5)
     { freopen ("error_GPA", "a", stderr);
       fprintf (stderr, "Number of parameters is incorrect!\n");
       return EXIT_FAILURE;
     }
     else freopen (argv[4], "w", stderr);
  p = (unsigned int) strtol (argv[1], &tinp, 0);
  if ((*tinp != '\0') || (p >= N))
     { fprintf (stderr, "Passenger process identification is wrong!\n");
       return EXIT_FAILURE;
     }
  strcpy (nFic, argv[2]);
  key = (unsigned int) strtol (argv[3], &tinp, 0);
  if (*tinp != '\0')
     { fprintf (stderr, "Error on the access key communication!\n");
       return EXIT_FAILURE;
     }

  /* connection to the semaphore set and the shared memory region and mapping the shared region onto the
     process address space */

  if ((semgid = semConnect (key)) == -1)
     { perror ("error on connecting to the semaphore set");
       return EXIT_FAILURE;
     }
  if ((shmid = shmemConnect (key)) == -1)
     { perror ("error on connecting to the shared memory region");
       return EXIT_FAILURE;
     }
  if (shmemAttach (shmid, (void **) &sh) == -1)
     { perror ("error on mapping the shared region on the process address space");
       return EXIT_FAILURE;
     }

  /* simulation of the life cycle of the passenger */

  for (k = 0; k < K; k++)
    switch (whatShouldIDo (k, p))                                          /* the passenger decides on her next move */
    { case FDBTC:                                /* she has arrived to her final destination and has bags to collect */
                                /* the passenger goes to the luggage collection point to pick up her bags one by one */
        while ((stat = goCollectABag (k, p)) == NO);
        if (stat == MB)                                                     /* the passenger checks for missing bags */
           reportMissingBags (k, p);          /* the passenger go to the baggage reclaim office to fill the form for
                                                                                                        missing bags */
        goHome (k, p);                                                           /* the passenger leaves the airport */
        break;
      case FDNBTC:                            /* she has arrived to her final destination and has no bags to collect */
        goHome (k, p);                                                           /* the passenger leaves the airport */
        break;
      case INTRAN:                                                                              /* she is in transit */
        takeABus (k, p);                             /* the passenger goes to the arrival transfer terminal to queue
                                                                          for taking a bus to the departure terminal */
        enterTheBus (k, p);                       /* the passenger goes on board of the bus as it starts its journey */
        leaveTheBus (k, p);      /* the passenger comes out of the bus as it reaches the departure transfer terminal */
        prepareNextLeg (k, p);              /* the passenger enters the departure and does the check in for the next
                                                                                                  leg of the journey */
        break;
    }

  /* unmapping the shared region off the process address space */

  if (shmemDettach (sh) == -1)
     { perror ("error on unmapping the shared region off the process address space");
       return EXIT_FAILURE;;
     }

  return EXIT_SUCCESS;
}
Ejemplo n.º 26
0
HelpBrowser::HelpBrowser( QWidget * parent ):
    QWidget(parent)
{
    QRect availableScreenRect = qApp->desktop()->availableGeometry(this);
    mSizeHint = QSize( availableScreenRect.width() * 0.4, availableScreenRect.height() * 0.7 );

    QtCollider::WebPage *webPage = new QtCollider::WebPage(this);
    webPage->setDelegateReload(true);
    webPage->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );

    mWebView = new QWebView;
    mWebView->setPage( webPage );
    mWebView->settings()->setAttribute( QWebSettings::LocalStorageEnabled, true );

    // NOTE: we assume all web page shortcuts have Qt::WidgetShortcut context
    mWebView->setContextMenuPolicy( Qt::ActionsContextMenu );
    mWebView->addAction( webPage->action( QWebPage::Copy ) );
    mWebView->addAction( webPage->action( QWebPage::Paste ) );

    // Set the style's standard palette to avoid system's palette incoherencies
    // get in the way of rendering web pages
    mWebView->setPalette( style()->standardPalette() );

    mWebView->installEventFilter(this);

    mLoadProgressIndicator = new LoadProgressIndicator;
    mLoadProgressIndicator->setIndent(10);

    QToolBar *toolBar = new QToolBar;
    toolBar->setIconSize( QSize(16,16) );
    QAction *action = toolBar->addAction("Home");
    connect( action, SIGNAL(triggered()), this, SLOT(goHome()) );
    toolBar->addAction( mWebView->pageAction(QWebPage::Back) );
    toolBar->addAction( mWebView->pageAction(QWebPage::Forward) );
    toolBar->addAction( mWebView->pageAction(QWebPage::Reload) );
    toolBar->addWidget(mLoadProgressIndicator);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->setContentsMargins(0,0,0,0);
    layout->setSpacing(0);
    layout->addWidget(toolBar);
    layout->addWidget(mWebView);
    setLayout(layout);

    connect( mWebView, SIGNAL(linkClicked(QUrl)), this, SLOT(onLinkClicked(QUrl)) );
    connect( mWebView, SIGNAL(loadStarted()), mLoadProgressIndicator, SLOT(start()) );
    connect( mWebView, SIGNAL(loadFinished(bool)), mLoadProgressIndicator, SLOT(stop()) );

    connect( webPage->action(QWebPage::Reload), SIGNAL(triggered(bool)), this, SLOT(onReload()) );
    connect( webPage, SIGNAL(jsConsoleMsg(QString,int,QString)),
             this, SLOT(onJsConsoleMsg(QString,int,QString)) );

    ScProcess * scProcess = Main::scProcess();
    connect( scProcess, SIGNAL(response(QString,QString)),
             this, SLOT(onScResponse(QString,QString)) );
    connect( scProcess, SIGNAL(finished(int)), mLoadProgressIndicator, SLOT(stop()) );
    // FIXME: should actually respond to class library shutdown, but we don't have that signal
    connect( scProcess, SIGNAL(classLibraryRecompiled()), mLoadProgressIndicator, SLOT(stop()) );

    mEvaluateShortcut = new QShortcut(this);
    mEvaluateShortcut->setContext( Qt::WidgetWithChildrenShortcut );
    connect( mEvaluateShortcut, SIGNAL(activated()), this, SLOT(evaluateSelection()) );

    applySettings( Main::settings() );
}
Ejemplo n.º 27
0
DensityViewerWindow::DensityViewerWindow(QWidget *parent) :
    QMainWindow(parent)
{
    //ui->setupUi(this);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    densityViewer = new DensityViewer;
    mainLayout->addWidget(densityViewer);

    auto controllerBar = new QVBoxLayout;

    auto plusButton = new QPushButton("zoom in");
    connect(plusButton,&QPushButton::clicked,[=](bool){densityViewer->changeZoom(1.2);});
    auto minusButton = new QPushButton("zoom out");
    connect(minusButton,&QPushButton::clicked,[=](bool){densityViewer->changeZoom(1./1.2);});
    auto plusMinus = new QHBoxLayout;

    plusMinus->addWidget(minusButton);
    plusMinus->addWidget(plusButton);

    controllerBar->addLayout(plusMinus);

    colorSaturation = new QDoubleSpinBox;
    colorSaturation->setMaximum(INFINITY);
    colorSaturation->setSingleStep(1);
    colorSaturation->setValue(100);
    colorSaturation->setEnabled(false);

    controllerBar->addWidget(new QLabel("Color saturation"));
    connect(colorSaturation,
            SIGNAL(valueChanged(double)),
            densityViewer,
            SLOT(setColorSaturation(double)));
    controllerBar->addWidget(colorSaturation);

    //http://forum.qt.io/topic/17409/solved-qt-4-7-qcombobox-custom-item-delegate-doesn-t-affect-the-current-item-displayed/3

    colormapComboBox = new QComboBox;
    colormapComboBox->setEnabled(false);
    for (const auto& cmap : Colormap::AvailableColormaps )
        colormapComboBox->addItem(QString::fromStdString(cmap.first));

    connect(colormapComboBox,SIGNAL(activated(QString)),densityViewer,SLOT(setColormap(QString)));

    controllerBar->addWidget(colormapComboBox);

    controllerBar->addWidget(new QLabel("Select section:"));
    sectionComboBox = new QComboBox;

    sectionComboBox->setEnabled(false);

    connect(sectionComboBox,
            static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
            [=](QString sec){densityViewer->setSectionDirection( sec );});

    controllerBar->addWidget(sectionComboBox);

    auto xStretch = new QHBoxLayout;
    xStretch->addWidget(new QLabel("x="));
    sectionIndex = new QDoubleSpinBox;
    sectionIndex->setValue(0);
    sectionIndex->setEnabled(false);

    connect(sectionIndex, SIGNAL(valueChanged(double)),densityViewer, SLOT(setSectionIndex(double)));
    connect(densityViewer, SIGNAL(changedSectionDirection()),this,SLOT(setXLimits()));

    xStretch->addWidget(sectionIndex);
    controllerBar->addLayout(xStretch);

    auto gridOn = new QCheckBox("grid");

    gridOn->setChecked(false);
    connect(gridOn,SIGNAL(clicked(bool)),densityViewer,SLOT(setGrid(bool)));

    controllerBar->addWidget(gridOn);

    auto infoButton = new QPushButton("info");
    connect(infoButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::info);});
    controllerBar->addWidget(infoButton);

    auto panButton = new QPushButton("pan");
    connect(panButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::pan);});
    controllerBar->addWidget(panButton);

    auto zoomButton = new QPushButton("zoom");
    connect(zoomButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::zoom);});
    controllerBar->addWidget(zoomButton);

    auto homeButton = new QPushButton("home");
    connect(homeButton,
            SIGNAL(pressed()),
            densityViewer,
            SLOT(goHome()));
    controllerBar->addWidget(homeButton);

    auto updateButton = new QPushButton("update");
    connect(updateButton,
            SIGNAL(pressed()),
            this,
            SLOT(updateDataset()));
    controllerBar->addWidget(updateButton);

    controllerBar->addStretch();

    coordinateCursor = new QLabel;
    coordinateCursor->setMinimumWidth(150);
    connect(densityViewer,
            &DensityViewer::dataCursorMoved,
            [=](int, int, vector<double>,string text){coordinateCursor->setText(QString::fromStdString(text));});
    controllerBar->addWidget(coordinateCursor);

    mainLayout->addLayout(controllerBar);

    connect(densityViewer,
            SIGNAL(loadedDensityData(DensityData&)),
            this,
            SLOT(updateControls()));

    //Context menu
    auto openDataset = new QAction("&Open dataset", this);
    openDataset->setShortcuts(QKeySequence::Open);
    connect(openDataset, SIGNAL(triggered()), this, SLOT(openFile()));

    QMenu* fileMenu = menuBar()->addMenu("&File");
    fileMenu->addAction(openDataset);

    // Set layout in QWidget
    QWidget *inners = new QWidget();
    inners->setLayout(mainLayout);

    // Set QWidget as the central layout of the main window
    setCentralWidget(inners);
    //mainLayout->setContentsMargins(0, 0, 0, 0);
    mainLayout->setSpacing(0);

    //For debug purposes
    //densityViewer->loadDensityData("/Users/arkadiy/ag/yell/yell playground/delta-pdf.h5");

}
Ejemplo n.º 28
0
Direction _313178576_A::step(Direction prevStep)
{
	// update robot's position according to the last move that the simulator actually made with the robot
	// as the exercise specifies, the simulator may not work always according to the algorithm's suggested move
	house.updateRobot(prevStep);

	// check if the simulator took the algorithm's advice with the last steps
	if (prevStep != lastMove) {
		// reset all! algorithm will recalculate destination
		returning = false;
		recharging = false;
		goingX = false;
		end = false;
		wayHome.clear();
		xPath.clear();
	}
	// update
	if (prevStep != Direction::Stay)
		lastMove = prevStep;

	// first, if started the move from the docking station -> charge battery
	if (house.getRobot() == house.getDocking())
		curBattery += batteryRechargeRate;
	curBattery = MIN(curBattery, batteryCapacity);

	// update area
	SensorInformation si = sensor->sense();
	house.updateRobotArea(si);

	Direction step;

	// cleaned the whole house -> go to the docking station and stay there
	if (end) {
		if (wayHome.empty())
			step = Direction::Stay;
		else {
			step = wayHome.front();
			wayHome.pop_front();
		}
	}
	// on the way home -> get the first move in the 'wayHome' list
	else if (returning) {
		step = wayHome.front();
		wayHome.pop_front();
		if (wayHome.empty()) {
			returning = false;
			recharging = true;
		}
	}
	// in docking station but needs to recharge more battery before leaving -> stay
	else if (recharging && !goClean()) {
		step = Direction::Stay;
	}
	// didn't have to return to the docking station in the last step and is not recharging atm, but now has to return to the docking station
	else if (!returning && !recharging && goHome()) {
		goingX = false;
		step = wayHome.front();
		wayHome.pop_front();
		if (wayHome.empty())
			recharging = true;
		else
			returning = true;
	}
	// on the way to a new cell with 'X'
	else if (goingX) {
		step = xPath.front();
		xPath.pop_front();
		if (xPath.empty())
			goingX = false;
	}
	// - recharged enough and should clean OR
	// - is not recharging atm, should not go back to the docking station, and should pick a new step
	else {
		recharging = false;
		// (recharging == false, returning == false)
		// clean all dirt, then move to a new cell
		if (si.dirtLevel >= 1)
			step = Direction::Stay;
		else {
			// get the closest cell with 'X' and move to it
			Cell cell = house.getRobot();
			Cell east = { cell.row, cell.col + 1 };
			Cell west = { cell.row, cell.col - 1 };
			Cell south = { cell.row + 1, cell.col };
			Cell north = { cell.row - 1, cell.col };
			// first clean immediate dirt around you
			if (house.hasCell(east) && (house.getCell(east) > '0') && (house.getCell(east) <= '9'))
				step = Direction::East;
			else if (house.hasCell(west) && (house.getCell(west) > '0') && (house.getCell(west) <= '9'))
				step = Direction::West;
			else if (house.hasCell(south) && (house.getCell(south) > '0') && (house.getCell(south) <= '9'))
				step = Direction::South;
			else if (house.hasCell(north) && (house.getCell(north) > '0') && (house.getCell(north) <= '9'))
				step = Direction::North;
			// then go to immediate X around you
			else if (house.hasCell(east) && (house.getCell(east) == 'X'))
				step = Direction::East;
			else if (house.hasCell(west) && (house.getCell(west) == 'X'))
				step = Direction::West;
			else if (house.hasCell(south) && (house.getCell(south) == 'X'))
				step = Direction::South;
			else if (house.hasCell(north) && (house.getCell(north) == 'X'))
				step = Direction::North;
			// then search for the closest X / dirt
			else {
				// no immediate 'X' cells around robot
				// run BFS to get 'path' updated to hold shortest path to the closest 'X' or '1'-'9' in the house
				// note that we may find '1'-'9' cells (actually 9 is not possible) in case we had to go back
				// to the docking station while cleaning a cell
				Cell xCell;
				xPath = std::move(house.BFS(house.getRobot(), xCell, 'X'));
				if (xPath.empty()) {
					end = true;
					// no 'X' was found -> cleaned the whole house! go Home!
					// BFS (shortest path to the docking station)
					Cell homeCell;
					wayHome = std::move(house.BFS(house.getRobot(), homeCell, 'D'));
					step = wayHome.front();
					wayHome.pop_front();
				}
				else {
					// check if has enough battery to get to the 'X', if not -> go to the Docking station
					Cell homeCell;
					wayHome = std::move(house.BFS(xCell, homeCell, 'D'));
					int distance = xPath.size() + wayHome.size();
					wayHome.clear();
					int movesToMake = curBattery / batteryConsumptionRate;
					if (moreSteps != -1)
						movesToMake = MIN(movesToMake, moreSteps);
					// not enough to 'X' + home => just go home
					if (distance >= movesToMake - 2) {
						xPath.clear();
						wayHome = std::move(house.BFS(house.getRobot(), homeCell, 'D'));
						// in case already in D and the X is impossible to reach -> stay
						if (wayHome.empty()) {
							end = true;
							step = Direction::Stay;
						}
						else {
							step = wayHome.front();
							wayHome.pop_front();
							returning = true;
							if (wayHome.empty()) {
								returning = false;
								recharging = true;
							}
						}
					}
					else {
						step = xPath.front();
						xPath.pop_front();
						if (!xPath.empty())
							goingX = true;
					}
				}
			}
		}
	}

	// consume battery only if did not start the move from the docking station
	if (house.getRobot() != house.getDocking())
		curBattery -= batteryConsumptionRate;
	
	// do not update spot according to 'step' chosen because simulator may not choose the algorithm's suggested step!
	// updated only at start of this method (sense) -> the simulator passes the actual step that has been made
	lastMove = step;

	if (moreSteps != -1)
		moreSteps--;
	return step;
}
Ejemplo n.º 29
0
void Forward()
{
  static int g_loop = 0;
  int power   = 60;  // power
  int power2  = 60;  // turn power
  getMaxball();
  PID();

  if (g_diff > 45 || g_diff < -45) turn(g_pid); 
  else
  { 
    g_integral = 0;
    if(g_no == 0) 
    {
      if(g_ball[0] > 300)
      {  
        g_dist[0] = getPing(0);
        g_dist[1] = getPing(1);
        g_dist[3] = getPing(3);
        if(g_dist[1] >= 35 && g_dist[2] >= 35)
        { 
          kick();
          moveAngle(power , 0 , 0);
        } 
        else if (g_dist[0] < 12)
        {
          if(g_dist[1] < 40)
          {
            turn(power2);
            delay(125);
          }
          else if (g_dist[3] < 40)
          { 
            turn(-power2);
            delay(125);
          } 
        }

      }
      else moveAngle(power , 0 , 0 );
    } 
    else if(g_no == 1)
    { 
      g_dist[1] = getPing(1);
      if (g_dist[1] < 10) moveAngle (power , 0 , 0);
      else if(g_ball[1] > 300)  moveAngle(power , 0 , 270 );
      else moveAngle(power , 0 , 315);
    } 
    else if(g_no == 2)
    {
      if(g_ball[2] > 300) moveAngle(power , 0 , 180);
      else moveAngle(power , 0 , 270);
    }
    else if(g_no == 3 ) 
    {
      moveAngle(power , 0 , 135 );
    }
    else if(g_no == 4 ) 
    {
      g_dist[1] = getPing(1);
      g_dist[3] = getPing(3);
      if (g_dist[1] > g_dist[3]) moveAngle(power , 0 , 270 );
      else moveAngle(60 , 0 , 90 );
    }
    else if (g_no == 5)
    { 
      if (g_ball[5] > 300) moveAngle(power , 0 , 225 );
      else moveAngle( 78 , 0 , 135);
    }
    else if (g_no == 6)
    {
      moveAngle(power , 0 , 180 );
    }
    else if(g_no == 7) 
    {
      g_dist[3] = getPing(3);
      if (g_dist[3] < 10) moveAngle (power , 0 , 0);
      else if (g_ball[7] > 300) moveAngle(power , 0 , 90 );
      else moveAngle(power , 0 , 45);
    }
    else goHome();
  }
  g_loop++;
}
bool imuIdentifierThread::processWayPoint()
{
    processIMU();
    
    if (wayPoints[currentWaypoint].name == "START     " ||
        wayPoints[currentWaypoint].name == "END       " ||
        wayPoints[currentWaypoint].name == "MIDDLE    " )
    {
        if (posCtrlFlag)
        {
            printMessage(1,"Putting head in home position..\n");
            goHome();
            posCtrlFlag = false;
        }

        if (yarp::os::Time::now() - timeNow > CTRL_PERIOD)
        {
            posCtrlFlag = true;
            return false;
        }
    }
    else
    {
        Vector jls = wayPoints[currentWaypoint].jntlims;
        Vector vls = wayPoints[currentWaypoint].vels;
        bool flag = false;

        iencsH->getEncoders(encsH->data());
        yarp::sig::Vector head = *encsH;

        // ivelH -> velocityMove(vls.data());

        VectorOf<int> jointsToSet;
        jointsToSet.push_back(0);
        jointsToSet.push_back(1);
        jointsToSet.push_back(2);
    
        ivelH -> velocityMove(jointsToSet.size(),
                              jointsToSet.getFirst(),
                              vls.data());

        for (int i = 0; i < 3; i++)
        {
            if      (vls(i) > 0.0)
            {
                if (jls(i) - head(i) > 0.0)
                {
                    flag = true;
                }
            }
            else if (vls(i) < 0.0)
            {
                if (jls(i) - head(i) < 0.0)
                {
                    flag = true;
                }
            }
        }

        return flag;
    }

    return true;
}