コード例 #1
0
ファイル: main_snake.c プロジェクト: spoto/ProgrammazioneC
int main(void) {
  struct snake *sn = construct_snake();
  char *s;

  printf("%s\n", s = toString(sn));
  free(s);

  goLeft(sn);
  goLeft(sn);
  goLeft(sn);
  goUp(sn);
  goUp(sn);

  printf("%s\n", s = toString(sn));
  free(s);

  goRight(sn);
  goRight(sn);
  goDown(sn);

  printf("%s\n", s = toString(sn));
  free(s);

  printf("ultima mossa eseguita: %d\n", goDown(sn));

  destruct_snake(sn);

  return 0;
}
コード例 #2
0
ファイル: rightpanel.cpp プロジェクト: emware/qtcat-emware
void RightPanel::init()
{
    // Set up GUI elements
    catalogTable = new CatalogTable(dm, this);
    showDescription = new QTextEdit;

    QVBoxLayout *layout = new QVBoxLayout;
    layout->setMargin(0);
    layout->setSpacing(0);
    this->setLayout(layout);

    vertSplit = new QSplitter(Qt::Vertical);
    vertSplit->addWidget(catalogTable);
    vertSplit->addWidget(showDescription);
    vertSplit->setStretchFactor(0, 5);
    vertSplit->setStretchFactor(1, 1);
    layout->addWidget(vertSplit);

    connect(catalogTable, SIGNAL(goUp()), this, SIGNAL(goUp()));
    connect(catalogTable, SIGNAL(goDown(int)), this, SIGNAL(goDown(int)));
    connect(catalogTable, SIGNAL(newItemSelected(int)), this, SLOT(newItemSelectedSlot(int)));
    connect(catalogTable, SIGNAL(newItemSelected(QString)), this, SLOT(newItemSelectedSlot(QString)));
    connect(catalogTable, SIGNAL(canceledDrag()), this, SIGNAL(canceledDrag()));

}
コード例 #3
0
ファイル: gameframe.cpp プロジェクト: gotonis/danmake
int Field::CheckJewel(Point ind, bool donotscore)
{
	int s1=goLeft(ind);
	s1+=goRight(ind)-1;

	int s2=goUp(ind);
	s2+=goDown(ind)-1;

	int bs=0;


	if (s2>2 && s1>2)
	{
		bs=s1+s2-1;
		if (donotscore)
			return bs;

		At(ind)->LockUnlock();
		goLeft(ind,true); 
		goRight(ind,true); 
		goUp(ind,true);
		At(ind)->LockUnlock();
		goDown(ind,true);
		return bs;
	}

	if (s1>s2 && s1>2)
	{
		bs=s1-2;
		if (donotscore) 
			return s1;

		At(ind)->LockUnlock();
		goLeft(ind,true); 
		At(ind)->LockUnlock();
		goRight(ind,true);
		return bs;
	}

	if (s2>s1 && s2>2)
	{
		bs=s2-2;
		if (donotscore) 
			return s2;
		At(ind)->LockUnlock();
		goUp(ind,true); 
		At(ind)->LockUnlock();
		goDown(ind,true);
		return bs;
	}
	return bs;
}
コード例 #4
0
void RemoteBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
	switch (cmd) {
	case kChooseCmd: {
		// If nothing is selected in the list widget, choose the current dir.
		// Else, choose the dir that is selected.
		int selection = _fileList->getSelected();
		if (selection >= 0)
			_choice = _nodeContent[selection];
		else
			_choice = _node;
		setResult(1);
		close();
		break;
	}
	case kGoUpCmd:
		goUp();
		break;
	case kListItemActivatedCmd:
	case kListItemDoubleClickedCmd:
		if (_nodeContent[data].isDirectory()) {
			_rememberedNodeContents[_node.path()] = _nodeContent;
			listDirectory(_nodeContent[data]);
		}
		break;
	case kListSelectionChangedCmd:
		// We do not allow selecting directories,
		// thus we will invalidate the selection
		// when the user selects a directory over here.
		if (data != (uint32)-1 && !_nodeContent[data].isDirectory())
			_fileList->setSelected(-1);
		break;
	default:
		Dialog::handleCommand(sender, cmd, data);
	}
}
コード例 #5
0
ファイル: SolutionTree.cpp プロジェクト: krzysztoftc/PEA_LAB1
SolutionNode* SolutionTree::goUp(SolutionNode *node) {
//	std::cout << "GoUp node = " << node << std::endl;
	SolutionNode *parent = node->parent;

	if (parent) {
//		std::cout << "Wchodze w prawego syna!" << std::endl;
		if (parent->matrix.getSize() > 3) {
			parent->rightSon = new SolutionNode;
			SolutionNode *son = parent->rightSon;
			son->visited = true;
			son->parent = parent;
			son->leftSon = 0;
			son->rightSon = 0;
			son->matrix = parent->matrix;
			son->trace = parent->trace;
			son->lowBound += son->matrix.reduction();

			std::pair<int, int> best = son->matrix.maxMin();
//			std::cout << "best (" << best.first << " , " << best.second << ")"
//					<< std::endl;
			std::pair<int, int> vert = son->matrix.getVert(best);

			son->matrix.blockEdge(vert);
			std::cout << "Matrix po blokowaniu" << std::endl;
			std::cout << son->matrix.toString() << std::endl;

			if (son->lowBound < uBound) {
				goUp(goDeeper(son));
			}
		}
	}

	return 0;
}
コード例 #6
0
ファイル: PopUp.hpp プロジェクト: HSOFEUP/dune
    //! Start maneuver function
    //! @param[in] maneuver rows maneuver message
    void
    start(const IMC::PopUp* maneuver)
    {
        m_maneuver = *maneuver;

        m_dur_timer.setTop(m_maneuver.duration);

        // Waiting or station keeping will be the same
        if (mustKeep() || mustWait())
            m_maneuver.flags |= IMC::PopUp::FLG_WAIT_AT_SURFACE | IMC::PopUp::FLG_STATION_KEEP;

        if (useCurr())
        {
            goUp();
            m_pstate = ST_GO_UP;
        }
        else
        {
            m_task->setControl(IMC::CL_PATH);

            IMC::DesiredPath path;
            path.end_lat = m_maneuver.lat;
            path.end_lon = m_maneuver.lon;
            path.end_z = m_maneuver.z;
            path.end_z_units = m_maneuver.z_units;
            path.speed = m_maneuver.speed;
            path.speed_units = m_maneuver.speed_units;

            m_task->dispatch(path);

            m_pstate = ST_GO_TO;
        }
    }
コード例 #7
0
ファイル: Cubester.cpp プロジェクト: chjk122/finalGame
int CubesterBTP::getAction(Ogre::Vector3 playerPos)
{
    int caseNum = (actionIndex/pathLength) % 2;
    if(caseNum == 0 ) // 0 to pathLength go right
        return goUp();
    else
        reload();
}
コード例 #8
0
ファイル: Cubester.cpp プロジェクト: chjk122/finalGame
int AbstractCubester::move(int dir)
{
    if(dir == 0 ) // 0 to pathLength go right
        return goUp();
    else if(dir == 1)
        return goRight();
    else if(dir == 2)
        return goDown();
    else if(dir == 3)
        return goLeft();
}
コード例 #9
0
ファイル: Mouse.cpp プロジェクト: Jraymond/Project7
void Mouse::move()
{
	if (icon == 0)
		goRight();
	else if (icon == 1)
		goLeft();
	else if (icon == 2)
		goUp();
	else
		goDown();
}
コード例 #10
0
ファイル: Cubester.cpp プロジェクト: chjk122/finalGame
int CubesterCCBLSquare::getAction(Ogre::Vector3 playerPos)
{
    int caseNum = (actionIndex/pathLength) % 4;
    if(caseNum == 0 ) // 0 to pathLength go right
        return goRight();
    else if(caseNum == 1)
        return goUp();
    else if(caseNum == 2)
        return goLeft();
    else if(caseNum == 3)
        return goDown();
}
コード例 #11
0
ファイル: task.c プロジェクト: kpoxapy/C_university
void checkRelation(Task * task)
{
	if (task->cur->rel == NULL)
	{
		task->cur = NULL;
		return;
	}

	switch (task->cur->rel->relType)
	{
		case TREL_SCRIPT:
			task->cur = task->cur->rel->next;
			goDown(task);
			break;
		case TREL_OR:
			debug("IN OR Getted %d\n", task->curRet);
			if (task->curRet != 0)
			{
				task->cur = task->cur->rel->next;
				goDown(task);
			}
			else
				goUp(task);
			break;
		case TREL_AND:
			debug("IN AND Getted %d\n", task->curRet);
			if (task->curRet == 0)
			{
				task->cur = task->cur->rel->next;
				goDown(task);
			}
			else
				goUp(task);
			break;
		case TREL_END:
			goUp(task);
			break;
	}
}
コード例 #12
0
ファイル: Npc.cpp プロジェクト: CarlosPerezPuertas/Action-RPG
void Npc::updateCurrent(CommandQueue &command_queue, const sf::Time dt)
{
	if (isActive())
	{
		updateAnimation(dt);
		action_queue.update(dt);

		if (getCurrentDirection() == Direction::Left) goLeft(dt);
		else if (getCurrentDirection() == Direction::Right) goRight(dt);
		else if (getCurrentDirection() == Direction::Up) goUp(dt);
		else if (getCurrentDirection() == Direction::Down) goDown(dt);
	}
}
コード例 #13
0
ファイル: gameframe.cpp プロジェクト: gotonis/danmake
int Field::goUp(Point ind, bool scoreit)
{	

	Point next_ind = ind;
	next_ind.y-=1;
	int sum=1;

	if (At(next_ind) && At(next_ind)->IsID(At(ind))) sum+=goUp(next_ind,scoreit);
	if (scoreit) 
	{
		StartAnimation(ind);
	}
	return sum; 
}
コード例 #14
0
void Enemy::patrol()
{

	std::discrete_distribution<int> dir_distribution({ 60, 10, 10, 10, 10 });
	std::uniform_int_distribution<int> distance_distribution(50, 100);
	std::uniform_real_distribution<float> wait_time_distribution(1.f, 3.f);
	Direction dir = static_cast<Direction>(dir_distribution(mt));
	int distance = distance_distribution(mt);
	stop_time = sf::seconds(wait_time_distribution(mt));
	

	//Action selection
	Action patrol;
	patrol.thread_id = 1;
	patrol.action = get_action([this, dir, distance](sf::Time dt)
	{
		if (dir == Direction::Left) { moveLeft(distance); }
		else if (dir == Direction::Right) { moveRight(distance); }
		else if (dir == Direction::Up) { moveUp(distance); }
		else if (dir == Direction::Down) { moveDown(distance); }
		//else if (dir == Direction::None) { std::cout << "Stop time" << stop_time.asSeconds() << std::endl; wait(stop_time); }
		

		return false;
	});
	//When we have 2 actions we stop action addition
	unsigned int max_actions = 2;
	if (action_tree.threadSize(patrol.thread_id) < max_actions)
	{
		pushAction(patrol);
	}


	//Action updating, each frame
	Action patrol_update;
	patrol_update.thread_id = 0;
	patrol_update.action = get_action([this](sf::Time dt)
	{
		if (getCurrentDirection() == Direction::Left) { goLeft(dt); }
		else if (getCurrentDirection() == Direction::Right) { goRight(dt); }
		else if (getCurrentDirection() == Direction::Up) { goUp(dt); }
		else if (getCurrentDirection() == Direction::Down) { goDown(dt); }

		return false;
	});
	pushAction(patrol_update);

	
}
コード例 #15
0
void MainMenuController::handleEvents(sf::Event &event) {
    IController::handleEvents(event);
    if (event.type == sf::Event::KeyPressed) {
        ///EVENT FOR BUTTONS :
        if (event.key.code == sf::Keyboard::Return) {
            fireButton();
        }
        else if (event.key.code == sf::Keyboard::Up) {
            goUp();
        }
        else if (event.key.code == sf::Keyboard::Down) {
            goDown();
        }
    }
}
コード例 #16
0
FilesystemWidget::FilesystemWidget(QWidget *parent)
{
    setParent(parent);

    // Create the toolbar
    QToolBar *fsToolbar = new QToolBar();
    fsToolbar->setMovable(false);

    goUpAction = new QAction(IconFactory::fromTheme("go-up"), tr("Go up"), this);
    connect(goUpAction, SIGNAL(triggered()), this, SLOT(goUp()));
    fsToolbar->addAction(goUpAction);

    goHomeAction = new QAction(IconFactory::fromTheme("go-home"), tr("Go to the home folder"), this);
    connect(goHomeAction, SIGNAL(triggered()), this, SLOT(goHome()));
    fsToolbar->addAction(goHomeAction);

    // TODO: use placeholderText in Qt 4.7.
    filterEdit = new QLineEdit();
    QLabel* filterLabel = new QLabel(tr("Filter:"));
    filterLabel->setContentsMargins(5, 0, 5, 0);
    fsToolbar->addSeparator();
    fsToolbar->addWidget(filterLabel);
    fsToolbar->addWidget(filterEdit);
    connect(filterEdit, SIGNAL(textChanged(QString)), this, SLOT(setNameFilter(QString)));

    // Create the filesystem view
    fsWidgetModel = new QFileSystemModel();
    fsWidgetModel->setNameFilterDisables(false);
    fsWidgetModel->setFilter(QDir::AllDirs|QDir::Files|QDir::NoDotAndDotDot);
    fsListView = new QListView();
    fsListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    fsListView->setDragEnabled(true);
    fsListView->setModel(fsWidgetModel);

    // We shall use this to filter available file extensions from Phonon
    //fsWidgetModel->setFilter(getPhononExtensions());

    connect(fsWidgetModel, SIGNAL(rootPathChanged(QString)), this, SLOT(pathChanged()));
    connect(fsListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(doubleClickAt(QModelIndex)));

    // Create a new horizontal box
    QVBoxLayout *vlayout = new QVBoxLayout();
    vlayout->addWidget(fsToolbar);
    vlayout->addWidget(fsListView);
    goHome();

    this->setLayout(vlayout);
}
コード例 #17
0
void BHTreeCZBuilder::countPartsRecursor()
{
   for (size_t i = 0; i < 8; i++)
   {
      if (static_cast<gcllPtrT>(curPtr)->child[i] != NULL)
      {
         if (static_cast<gcllPtrT>(curPtr)->child[i]->isParticle)
            countParts++;
         else
         {
            goChild(i);
            countPartsRecursor();
            goUp();
         }
      }
   }
}
コード例 #18
0
ファイル: triaaction.cpp プロジェクト: NuriaProject/Tria
void PreprocessorHooks::FileChanged (clang::SourceLocation loc, clang::PPCallbacks::FileChangeReason reason,
                                     clang::SrcMgr::CharacteristicKind fileType, clang::FileID prevFID) {
	qint64 now = nowUsec ();
	
	if (reason == EnterFile) { // Stop parents' time
		TimingNode *p = this->m_current->parent;
		if (p) {
			p->time += now - p->startTime;
		}
		
	} else if (reason == ExitFile) { // Leaving
		goUp (false);
	}
	
	// 
	this->m_current->startTime = now;
	
}
コード例 #19
0
ファイル: sketch.c プロジェクト: Fendrirj/ECE497
/*
 * This controls where the cursor moves to next.
 * Press w to go up
 * Press a to go left
 * Press s to go down
 * Press d to go right
 */
void control(unsigned char c, point * p, int (*board)[width]){
	if(c == 'w'){
		goUp(p, board);
	}
	if(c == 'a'){
		goLeft(p, board);	
	}
	if(c == 's'){
		goDown(p,board);		
	}

	if(c == 'd'){
		goRight(p,board);		
	}
	//9 corresponds to Tab
	if(c == 9){
		clearGrid(board, p);
	}
}
コード例 #20
0
int main()
{
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD pos;
    pos.X = 0;
    pos.Y = 0;
    SetConsoleCursorPosition(hConsole, pos);
    while(pos.X < cols){
        goDown(&pos, hConsole);
        if(pos.X == cols - 1) break;
        pos.X++;
        SetConsoleCursorPosition(hConsole, pos);

        goUp(&pos, hConsole);
        pos.X++;
        SetConsoleCursorPosition(hConsole, pos);
    }
    return EXIT_SUCCESS;
}
コード例 #21
0
ファイル: Unit.cpp プロジェクト: FishFilletsNG/ffng-android
/**
 * Test keys and try move, use borrowed controls.
 * @return a symbol when unit has moved or SYM_NONE
 */
char
Unit::driveBorrowed(const InputProvider *input, const KeyControl &buttons)
{
    if (canDrive()) {
        if (input->isPressed(buttons.getLeft())) {
            return goLeft();
        }
        if (input->isPressed(buttons.getRight())) {
            return goRight();
        }
        if (input->isPressed(buttons.getUp())) {
            return goUp();
        }
        if (input->isPressed(buttons.getDown())) {
            return goDown();
        }
    }
    return ControlSym::SYM_NONE;
}
コード例 #22
0
ファイル: Unit.cpp プロジェクト: FishFilletsNG/ffng-android
/**
 * Make move.
 * @return move symbol or SYM_NONE for bad move
 */
char
Unit::driveOrder(char move)
{
    if (canDrive()) {
        if (m_symbols.getLeft() == move) {
            return goLeft();
        }
        if (m_symbols.getRight() == move) {
            return goRight();
        }
        if (m_symbols.getUp() == move) {
            return goUp();
        }
        if (m_symbols.getDown() == move) {
            return goDown();
        }
    }
    return ControlSym::SYM_NONE;
}
コード例 #23
0
ファイル: SolutionTree.cpp プロジェクト: krzysztoftc/PEA_LAB1
Solution SolutionTree::findSolution() {
	Solution solution;
	SolutionNode *n = goDeeper(0);
//	std::cout << "findSolution *n: " << n << std::endl;
	goUp(n);

	solution.trace = bestSolution->trace;
	solution.cost = 0;

	/*std::list<int>::iterator it = solution.trace.begin();
	 while (++it != solution.trace.end()) {
	 solution.cost += bestSolution->matrix.getCost(
	 std::pair<int, int>(*(--it), *(++it)));
	 }
	 solution.cost += bestSolution->matrix.getCost(
	 std::pair<int, int>(bestSolution->trace.back(),
	 bestSolution->trace.front()));
	 */
	return solution;
}
コード例 #24
0
ファイル: PopUp.hpp プロジェクト: HSOFEUP/dune
    //! On PathControlState message
    //! @param[in] pcs pointer to PathControlState message
    void
    onPathControlState(const IMC::PathControlState* pcs)
    {
        switch (m_pstate)
        {
        case ST_GO_TO:
            if (pcs->flags & IMC::PathControlState::FL_NEAR)
            {
                goUp();
                m_pstate = ST_GO_UP;
            }
            break;
        case ST_GO_UP:
            m_elevate->updatePathControl(pcs);

            // reached surface?
            if (m_elevate->isDone())
            {
                m_task->setControl(IMC::CL_NONE);
                m_pstate = ST_NEAR_SURFACE;
            }

            break;
        case ST_GO_DOWN:
            m_elevate->updatePathControl(pcs);

            // all done?
            if (m_elevate->isDone())
                m_pstate = ST_DONE;

            break;
        case ST_SKEEP:
            m_skeep->updatePathControl(pcs);
            break;
        case ST_DONE:
            m_task->signalCompletion();
            break;
        default:
            break;
        }
    }
コード例 #25
0
void BHTreeCZBuilder::sumCostRecursor()
{
   if (not curPtr->atBottom)
   {
      static_cast<czllPtrT>(curPtr)->relCost = 0.;
      static_cast<czllPtrT>(curPtr)->noParts = 0;

      for (size_t i = 0; i < 8; i++)
      {
         if (static_cast<gcllPtrT>(curPtr)->child[i] != NULL)
         {
            goChild(i);
            sumCostRecursor();
            static_cast<czllPtrT>(curPtr->parent)->relCost +=
               static_cast<czllPtrT>(curPtr)->relCost;
            static_cast<czllPtrT>(curPtr->parent)->noParts +=
               static_cast<czllPtrT>(curPtr)->noParts;
            goUp();
         }
      }
   }
}
コード例 #26
0
ファイル: triaaction.cpp プロジェクト: NuriaProject/Tria
void PreprocessorHooks::FileSkipped (const clang::FileEntry &, const clang::Token &,
                                     clang::SrcMgr::CharacteristicKind) {
	goUp (true);
}
コード例 #27
0
//==============================================================================
void FileBrowserComponent::buttonClicked (Button*)
{
    goUp();
}
コード例 #28
0
ファイル: MediaBrowser.cpp プロジェクト: dtbinh/dviz
void MediaBrowser::setupUI()
{
	QVBoxLayout *vbox0 = new QVBoxLayout(this);
	m_splitter = new QSplitter(this);
	m_splitter->setOrientation(Qt::Vertical);
	vbox0->addWidget(m_splitter);

	QWidget *browser = new QWidget(m_splitter);
	QVBoxLayout *vbox = new QVBoxLayout(browser);
	SET_MARGIN(vbox,0);

	// Setup filter box at the top of the widget
	m_searchBase = new QWidget(browser);

	QHBoxLayout *hbox = new QHBoxLayout(m_searchBase);
	SET_MARGIN(hbox,0);

	m_btnBack = new QPushButton(QIcon(":/data/stock-go-back.png"),"");
	m_btnBack->setEnabled(false);
	connect(m_btnBack, SIGNAL(clicked()), this, SLOT(goBack()));

	m_btnForward = new QPushButton(QIcon(":/data/stock-go-forward.png"),"");
	m_btnForward->setEnabled(false);
	connect(m_btnForward, SIGNAL(clicked()), this, SLOT(goForward()));

	m_btnUp = new QPushButton(QIcon(":/data/stock-go-up.png"),"");
	m_btnUp->setEnabled(false);
	connect(m_btnUp, SIGNAL(clicked()), this, SLOT(goUp()));

	QLabel *label = new QLabel("Fil&ter:");
	m_searchBox = new QLineEdit(m_searchBase);
	label->setBuddy(m_searchBox);

	m_clearSearchBtn = new QPushButton(QIcon(":/data/stock-clear.png"),"");
	m_clearSearchBtn->setVisible(false);

	hbox->addWidget(m_btnBack);
	hbox->addWidget(m_btnForward);
	hbox->addWidget(m_btnUp);
	hbox->addWidget(label);
	hbox->addWidget(m_searchBox);
	hbox->addWidget(m_clearSearchBtn);

	connect(m_searchBox, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged(const QString &)));
	connect(m_searchBox, SIGNAL(returnPressed()), this, SLOT(filterReturnPressed()));
	connect(m_clearSearchBtn, SIGNAL(clicked()), this, SLOT(clearFilter()));
	
	// Now for the list itself
	m_listView = new MediaBrowserQListView(browser);
	m_listView->setAlternatingRowColors(true);
	m_listView->setIconSize(m_iconSize);
	//m_listView->setWrapping(true);
	m_listView->setWordWrap(true);
	//m_listView->setGridSize(MEDIABROWSER_LIST_ICON_SIZE);
	m_listView->setLayoutMode(QListView::Batched);
	//m_listView->setFlow(QListView::LeftToRight);
	m_listView->setResizeMode(QListView::Adjust);
	//m_listView->setSelectionMode(QAbstractItemView::SingleSelection);

	// below doesnt seem to be enough
	//m_listView->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);

	m_fsModel = new DirectoryListModel(browser); //QFileSystemModel(browser);
	m_fsModel->setIconProvider(new MyQFileIconProvider());
	//m_fsModel->setNameFilterDisables(false);

	m_listView->setModel(m_fsModel);

	connect(m_listView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(indexDoubleClicked(const QModelIndex &)));
	connect(m_listView,     SIGNAL(activated(const QModelIndex &)), this, SLOT(indexDoubleClicked(const QModelIndex &)));
	connect(m_listView,       SIGNAL(clicked(const QModelIndex &)), this, SLOT(indexSingleClicked(const QModelIndex &)));

	////////////////////////
	
	// Add action buttons
	m_btnBase = new QWidget(browser);
	QHBoxLayout *hbox3 = new QHBoxLayout(m_btnBase);
	SET_MARGIN(hbox3,0);

	m_btnSetAsBgLive = new QPushButton(QIcon(":/data/stock-apply-ffwd.png"),"");
	m_btnSetAsBgLive->setToolTip("Set selected file as background for the current live slide");
	hbox3->addWidget(m_btnSetAsBgLive);

	m_btnAddToSchedue = new QPushButton(QIcon(":/data/stock-add.png"),"");
	m_btnAddToSchedue->setToolTip("Add selected file to schedule");
	hbox3->addWidget(m_btnAddToSchedue);

	m_btnSetAsBgLater = new QPushButton(QIcon(":/data/stock-apply-next.png"),"");
	m_btnSetAsBgLater->setToolTip("Set selected file as background for the NEXT slide to go live");
	hbox3->addWidget(m_btnSetAsBgLater);

	m_btnSetAsBgCurrent = new QPushButton(QIcon(":/data/stock-apply-pause.png"),"");
	m_btnSetAsBgCurrent->setToolTip("Set selected file as background for the selected slide group");
	hbox3->addWidget(m_btnSetAsBgCurrent);

	connect(m_btnAddToSchedue, SIGNAL(clicked()), this, SLOT(slotAddToSchedule()));
	connect(m_btnSetAsBgCurrent, SIGNAL(clicked()), this, SLOT(slotSetAsBgCurrent()));
	connect(m_btnSetAsBgLater, SIGNAL(clicked()), this, SLOT(slotSetAsBgLater()));
	connect(m_btnSetAsBgLive, SIGNAL(clicked()), this, SLOT(slotSetAsBgLive()));

	// enabled by indexSingleClicked()
	m_btnBase->setEnabled(false);
	
	/////////////////

	// Add the directory box and filter box at bottom
	m_folderBoxBase = new QWidget(browser);
	QHBoxLayout *hbox2 = new QHBoxLayout(m_folderBoxBase);
	SET_MARGIN(hbox2,0);
	
	hbox2->addWidget(new QLabel("Folder:"));
	
	m_dirBox = new QLineEdit(m_folderBoxBase);
	hbox2->addWidget(m_dirBox);
	
	m_filterBox = new QComboBox(m_folderBoxBase);
	hbox2->addWidget(m_filterBox);

	connect(m_dirBox, SIGNAL(returnPressed()), this, SLOT(dirBoxReturnPressed()));
	connect(m_filterBox, SIGNAL(currentIndexChanged(int)), this, SLOT(fileTypeChanged(int)));
	
	//#######################################333
	
	
	m_bookmarkBase = new QWidget(browser);
	
	QHBoxLayout *hbox4 = new QHBoxLayout(m_bookmarkBase);
	SET_MARGIN(hbox4,0);
	
	hbox4->addWidget(new QLabel("Saved:"));
	
	m_bookmarkBox = new QComboBox(m_bookmarkBase);
	hbox4->addWidget(m_bookmarkBox,2);

	m_btnBookmark = new QPushButton(QIcon(":/data/stock-new.png"),"");
	m_btnBookmark->setToolTip("Bookmark current folder");
	hbox4->addWidget(m_btnBookmark);
	
	m_btnDelBookmark = new QPushButton(QIcon(":/data/stock-remove.png"),"");
	m_btnDelBookmark->setToolTip("Delete current bookmark");
	hbox4->addWidget(m_btnDelBookmark);
	
	connect(m_bookmarkBox, SIGNAL(activated(int)), this, SLOT(loadBookmarkIndex(int)));
	connect(m_btnBookmark, SIGNAL(clicked()), this, SLOT(slotBookmarkFolder()));
	connect(m_btnDelBookmark, SIGNAL(clicked()), this, SLOT(slotDelBookmark()));
	
	
	//#######################################333
	


	QFrame * line = new QFrame();
        line->setFrameShape(QFrame::HLine);
        line->setFrameShadow(QFrame::Sunken);
	
	vbox->addWidget(m_searchBase);
	vbox->addWidget(m_folderBoxBase);
	vbox->addWidget(line);
	vbox->addWidget(m_bookmarkBase);
	vbox->addWidget(m_listView);
	vbox->addWidget(m_btnBase);
	
	m_splitter->addWidget(browser);

	m_viewerBase = new QWidget(m_splitter);
	m_viewerLayout = new QVBoxLayout(m_viewerBase);
	m_viewerLayout->setContentsMargins(0,0,0,0);
	
	// Setup the slide group viewer
	m_viewer = new SlideGroupViewer(m_viewerBase);
	m_viewer->setCanZoom(true);
	m_viewer->setSceneContextHint(MyGraphicsScene::Preview);
	m_viewer->setBackground(Qt::black);

	// Create the slide and slide group that we'll reuse to preview the 
	// selected media items
	Slide * slide = new Slide();
	AbstractVisualItem * bg = dynamic_cast<AbstractVisualItem*>(slide->background());
	bg->setFillType(AbstractVisualItem::Solid);
	bg->setFillBrush(Qt::black);

	SlideGroup *group = new SlideGroup();
	group->addSlide(slide);
	
	//qDebug() << "MediaBrowser::setupUI(): Setting slidegroup "<<group<<" on viewer "<<m_viewer; 
	m_viewer->setSlideGroup(group, slide);
	
	m_viewerLayout->addWidget(m_viewer);
	m_splitter->addWidget(m_viewerBase);
	
	loadBookmarks();
}
コード例 #29
0
void BHTreeCZBuilder::refineCZcell(const czllPtrT _czllPtr)
{
   ///
   /// transform all children to empty CZ cells. if a child
   /// is a particle, first link a empty cell in between.
   ///
   curPtr = _czllPtr;

   for (size_t i = 0; i < 8; i++)
   {
      if (static_cast<gcllPtrT>(curPtr)->child[i] == NULL)
      {
         static_cast<gcllPtrT>(curPtr)->child[i] = new czllT;
         goChild(i);
         static_cast<czllPtrT>(curPtr)->clear();
         curPtr->parent = _czllPtr;
         static_cast<gcllPtrT>(curPtr)->inheritCellPos(i);
         goUp();
      }
      else if (static_cast<gcllPtrT>(curPtr)->child[i]->isParticle)
      {
         const pnodPtrT resPartPtr =
            static_cast<pnodPtrT>(static_cast<gcllPtrT>(curPtr)->child[i]);

         static_cast<gcllPtrT>(curPtr)->child[i] = new czllT;

         goChild(i);
         static_cast<czllPtrT>(curPtr)->clear();
         curPtr->parent = _czllPtr;
         static_cast<czllPtrT>(curPtr)->inheritCellPos(i);

         const size_t newOct = getOctant(resPartPtr->pos);
         static_cast<gcllPtrT>(curPtr)->child[newOct] = resPartPtr;
         resPartPtr->depth++;
         resPartPtr->parent = curPtr;
         goUp();
      }
      else
      if (not static_cast<gcllPtrT>(curPtr)->child[i]->isCZ)
      {
         const qcllPtrT oldCell =
            static_cast<qcllPtrT>(static_cast<gcllPtrT>(curPtr)->child[i]);
         static_cast<gcllPtrT>(curPtr)->child[i] = new czllT;
         goChild(i);
         static_cast<czllPtrT>(curPtr)->clear();
         static_cast<czllPtrT>(curPtr)->initFromCell(*oldCell);
         delete oldCell;
         goUp();
      }
   }

   ///
   /// now count the particles of this child
   /// estimate the relative cost of those
   ///
   const fType relCostPerPart = (_czllPtr->relCost / _czllPtr->noParts);
   for (size_t i = 0; i < 8; i++)
   {
      goChild(i);
      countParts = 0;
      countPartsRecursor();
      static_cast<czllPtrT>(curPtr)->relCost = countParts * relCostPerPart;
      static_cast<czllPtrT>(curPtr)->noParts = countParts;

      goUp();
   }

   ///
   /// now also distribute the orphans of the former parent cell to
   /// the new bottom cells
   ///
   nodePtrT curOrph = _czllPtr->orphFrst;
   nodePtrT nxtOrph = NULL;
   curPtr = _czllPtr;

   while (curOrph != NULL)
   {
      // next ptr will be overwritten in adopt(), so we need a temporary
      // storage for the next orphan
      nxtOrph = curOrph->next;

      const size_t newOct = getOctant(static_cast<pnodPtrT>(curOrph)->pos);
      static_cast<czllPtrT>(_czllPtr->child[newOct])->adopt(
         static_cast<pnodPtrT>(curOrph));
      static_cast<czllPtrT>(_czllPtr->child[newOct])->noParts++;
      static_cast<czllPtrT>(_czllPtr->child[newOct])->relCost += relCostPerPart;

      curOrph = nxtOrph;
   }

   static_cast<czllPtrT>(curPtr)->orphFrst = NULL;
   static_cast<czllPtrT>(curPtr)->orphLast = NULL;
}
コード例 #30
0
ファイル: du.c プロジェクト: eskirk/MyDu
/*
   flags:
      -a:      Displays an entry for each file in a file hierarchy
      -dn:     Goes n directories deep during recursion
      -c:      Displays a grand total
      -h:      Displays the output in a human readable way using prefixes like Byte, KB, MB...
      -f<%s>:  Tallies up only files that contain the substring s
      -v:      Displays a visual tree of the current directory
      -un:     Goes up n directories and then does what it needs to do
*/
int main(int argc, char *argv[]) {
   int all = 0, depth = 5, total = 0, human = 0, count = 1, visual = 0, look = 0, none = 0, up = 0, tdepth = 0;
   long tot = 0;
   char *find = malloc(sizeof(char) * MAX_LEN), *temp = malloc(sizeof(char) * 10), *path = malloc(sizeof(char) * MAX_LEN);
   char *rtn = malloc(sizeof(char) * MAX_LEN);
   DIR *directory = opendir(".");
   
   if (argc > 1) {
      do {
         switch(argv[count][1]) {
            case 'a':
               all = 1;
               break;
            case 'd':
               depth = atoi(&argv[count][2]);
               tdepth = depth;
               break;
            case 'h':
               human = 1;
               break;
            case 'f':
               strcpy(find, &argv[count][2]);
               look = 1;
               break;
            case 'c':
               total = 1;
               break;
            case 'v':
               visual = 1;
               break;
            case 'u':
               up = atoi(&argv[count][2]);
               break;
            default:
               none = 1;
               break;
         }
      } while (argv[++count] != NULL);
   }

   if (up) {
      if (up && look) {
         if (up > 2)
            up = 2;
      }
      goUp(up, rtn);
      directory = opendir(".");
   }

   if (none || (!all && !look && !visual)) {
      displayFolders(directory, NULL, &tot, depth, human);
      depth = tdepth;
   }

   if (all) {
      if (look) {
         printf("Look through all files on this user for substring '%s'?\ny/n: ", find);
         scanf("%s", temp);
         if (*temp == 'y' || *temp == 'Y') {
            realpath(".", path);
            chdir(getenv("HOME"));
            if (visual)
               system("tree");
            directory = opendir(".");
            findSub(directory, NULL, find);
            chdir(path);
         }
      }
      else {
         if (visual)
            system("tree");
         if (!human) {
            displayAll(directory, NULL, &tot, 0, depth, human);
            depth = tdepth;
         }

      }
   }

   if (visual && !all && !up) {
      system("tree");
   }

   if (look) {
      if (all) {
         directory = opendir(getenv("HOME"));
      }
      findSub(directory, NULL, find);
   }
   if (up) 
      chdir(rtn);

   if (total && !up) {
      tot = 0;
      directory = opendir(".");
      displayAll(directory, NULL, &tot, 1, depth, human);
      depth = tdepth;
      if (!human)
         printf("%ld\ttotal\n", tot);
      else
         printHuman(NULL, tot, "!");
   }
   else {
      tot = 0;
      directory = opendir(".");
      displayAll(directory, NULL, &tot, 1, depth, human);
   }

   if (up && visual) {
      goUp(up, rtn);
      directory = opendir(".");
      printf("%ld\t%s\n", tot, ".");
      system("tree");
   }
   else if (visual) 
      printf("%ld\t%s\n", tot, ".");

   if (!human && !visual) {
      printf("%ld\t%s\n", tot, ".");
   }

   if (human) {
      if (up) {
         if (up && look) {
            if (up > 2)
               up = 2;
         }
         goUp(up, rtn);
         directory = opendir(".");
         depth = tdepth;
         displayAll(directory, NULL, &tot, 1, depth, human);
      }
      printHuman(NULL, tot, ".");
   }

   return 0;
}