예제 #1
0
void D()
{
	if(M == 0)
	{
		printf("STOP\n");
		return;
	}
		if(M * 20 >= P)
		{
			if(M && angle < 5 && angle > -5)//???????????
			{
				fire(P);
				return;
			}
			else
			{
				backward(X);
				return;
			}
		}
		else G();	
		return;
}
예제 #2
0
int main()
{
  double t1, t2;
  const int dim = 2000;
  Chronometer chrono;

  t1 = chrono.click();
  Vector x(dim);
  Matrix A(dim);
  t2 = chrono.click();
  std::cout << "Time to create matrix: " << t2 - t1 << " sec.\n";

  t1 = chrono.click();
  matrixAssembly(A);
  t2 = chrono.click();
  std::cout << "Time to compute coefficients of the matrix: " << t2 - t1 << " sec.\n";

  t1 = chrono.click();
  assemblyRhs(A, x);
  t2 = chrono.click();
  std::cout << "Time to compute coefficients of the right hand side: " << t2 - t1 << " sec.\n";

  t1 = chrono.click();
  factorize(A);
  t2 = chrono.click();
  std::cout << "Time to factorize the matrix: " << t2 - t1 << " sec.\n";

  t1 = chrono.click();
  forward(A, x);
  backward(A, x);
  t2 = chrono.click();
  std::cout << "Time to solve the linear system: " << t2 - t1 << " sec.\n";

  verifySolution(x);

  return EXIT_SUCCESS;
}
예제 #3
0
void MainWindow::initButtons(){
    QPixmap rotateLeft(":images/rotate_left.png");
    QIcon rotateLeftIcon(rotateLeft);
    this->ui->angZL->setIcon(rotateLeftIcon);

    QPixmap rotateRight(":images/rotate_right.png");
    QIcon rotateRightIcon(rotateRight);
    this->ui->angZR->setIcon(rotateRightIcon);

    QPixmap up(":images/up.png");
    QIcon upIcon(up);
    this->ui->linZU->setIcon(upIcon);

    QPixmap down(":images/down.png");
    QIcon downIcon(down);
    this->ui->linZD->setIcon(downIcon);

    QPixmap toggle(":images/toggle_cam.png");
    QIcon toggleIcon(toggle);
    this->ui->toggleCam->setIcon(toggleIcon);

    QPixmap forward(":images/forward.png");
    QIcon forwardIcon(forward);
    this->ui->linXF->setIcon(forwardIcon);

    QPixmap backward(":images/backward.png");
    QIcon backwardIcon(backward);
    this->ui->linXB->setIcon(backwardIcon);

    QPixmap left(":images/left.png");
    QIcon leftIcon(left);
    this->ui->linYL->setIcon(leftIcon);

    QPixmap right(":images/right.png");
    QIcon rightIcon(right);
    this->ui->linYR->setIcon(rightIcon);
}
예제 #4
0
파일: solution.cpp 프로젝트: pmdiano/shuati
    int candy(vector<int>& ratings) {
        if (ratings.empty()) {
            return 0;
        }
        vector<int> forward(ratings.size(), 1);
        vector<int> backward(ratings.size(), 1);

        for (int i = 1; i < ratings.size(); i++) {
            if (ratings[i] > ratings[i-1]) {
                forward[i] = forward[i-1] + 1;
            }
        }
        for (int i = ratings.size()-2; i >= 0; i--) {
            if (ratings[i] > ratings[i+1]) {
                backward[i] = backward[i+1] + 1;
            }
        }

        int candy = 0;
        for (int i = 0; i < ratings.size(); i++) {
            candy += max(forward[i], backward[i]);
        }
        return candy;
    }
예제 #5
0
void terminalCheck1()
{
	if (ct != ot)
	{
		if (dir == 1 || dir == 3)
		{
			if (ct == 3 || ct == 0)
				turnRight();
			else turnLeft();
			front();
		}
		if (((ct == 0 || ct == 1) && dir == 2) || ((ct == 2 || ct == 3) && dir == 0))
			backward();
		ot = ct;
	}
	if (((ct == 0 || ct == 1) && dir == 0) || ((ct == 2 || ct == 3) && dir == 2))
		turnRight();
	else turnLeft();
	//..printf("Enter term[%d][%d]\n", ct, 0);
	//..scanf("%d", &term[ct][0]);
	term[ct][0]=scan();
	if (term[ct][0] == -1 || term[ct][0] == color[ct])
		total--;
}
예제 #6
0
/* used primarily for taking contents of macro file */
void move_tank(char direc[], int time)
{
	if (!strcmp(direc, "ff")) {
		forward(time);
	}

	else if (!strcmp(direc, "bb")) {
		backward(time);
	}

	else if (!strcmp(direc, "fr")) {
		foright(time);
	}

	else if (!strcmp(direc, "fl")) {
		foleft(time);
	}

	else if (!strcmp(direc, "br")) {
		baright(time);
	}

	else if (!strcmp(direc, "bl")) {
		baleft(time);
	}

	else if (!strcmp(direc, "ss")) {
		stop(time);
	}
	
	else {
		printf("ERROR: cannot move tank in that direction\n");
		safe_exit(1);
	}

} /* end move_tank function */ 
예제 #7
0
  void FFT::convolve(VolumeList &vols, Volume &mask) {
    if (vols.size() > 0 && 
	vols[0].width == mask.width &&
	vols[0].height == mask.height &&
	vols[0].depth == mask.depth) {
      forward(vols);
      forward(mask);
      vols *= mask;
      size_t i = 0;
      for (size_t x = 0; x < vols[0].width; ++x) {
	for (size_t y = 0; y < vols[0].height; ++y) {
	  for (size_t z = 0; z < vols[0].complex_depth; ++z) {
	    if ((x+y+z) % 2) {
	      for (size_t j = 0; j < vols.size(); ++j) {
		vols[j].complex_data[i] *= -1.0;
	      }
	    }
	    ++i;
	  }
	}
      }
      backward(vols);
    }
  }
예제 #8
0
/// PUBLIC
HelpBrowser::HelpBrowser(QString strPath,
                         QString strFileName,
                         QWidget *parent):
    QWidget(parent)
{
    pButtonBack    = new QPushButton("<<");
    pButtonHome    = new QPushButton("Home");
    pButtonForward = new QPushButton(">>");
    textBrowser = new QTextBrowser();

    connect(pButtonBack, SIGNAL(clicked()),
            textBrowser, SLOT(backward()));
    connect(pButtonHome, SIGNAL(clicked()),
            textBrowser, SLOT(home()));
    connect(pButtonForward, SIGNAL(clicked()),
            textBrowser, SLOT(forward()));
    connect(textBrowser, SIGNAL(backwardAvailable(bool)),
            pButtonBack, SLOT(setEnabled(bool)));
    connect(textBrowser, SIGNAL(forwardAvailable(bool)),
            pButtonForward, SLOT(setEnabled(bool)));

    textBrowser->setSource(QUrl::fromLocalFile(QString(strPath + strFileName)));

    hBoxLayoutCommandButton = new QHBoxLayout;

    hBoxLayoutCommandButton->addWidget(pButtonBack);
    hBoxLayoutCommandButton->addWidget(pButtonHome);
    hBoxLayoutCommandButton->addWidget(pButtonForward);

    vBoxLayoutMain = new QVBoxLayout;

    vBoxLayoutMain->addLayout(hBoxLayoutCommandButton);
    vBoxLayoutMain->addWidget(textBrowser);

    setLayout(vBoxLayoutMain);
}
예제 #9
0
/* More robust, but expensive, bbox transform
 * in the face of proj4 out of bounds conditions.
 * Can result in 20 -> 10 r/s performance hit.
 * Alternative is to provide proper clipping box
 * in the target srs by setting map 'maximum-extent'
 */
bool proj_transform::backward(box2d<double>& env, int points) const
{
    if (is_source_equal_dest_)
        return true;

    std::vector<coord<double,2> > coords;
    envelope_points(coords, env, points);

    double z;
    for (std::vector<coord<double,2> >::iterator it = coords.begin(); it!=coords.end(); ++it) {
        z = 0;
        if (!backward(it->x, it->y, z)) {
            return false;
        }
    }

    box2d<double> result = calculate_bbox(coords);

    env.re_center(result.center().x, result.center().y);
    env.height(result.height());
    env.width(result.width());

    return true;
}
예제 #10
0
void A()
{
		scanf("%d%d", &N, &NP);
		if(M == 0)
		{
			front(X);
			return;
		}
		if((N*NP > M*MP*3))
		{
			if(M && angle <= 10 && angle >= -10)//???????????
			{
				fire(P);
				return;
			}
			else
			{
				front(X);
				return;
			}
		}
		else
		{
			if(M && angle <= 5 && angle >= -5)//???????????
			{
				fire(P);
				return;
			}
			else
			{
				backward(X);
				return;
			}
		}
		//return 0;
}
예제 #11
0
// real backward
int check_rb(int n, int mode, int veclen, int sizeOfVect) {
  int i,j;

  DFT *p = DFT_init(mode, n, DFT_FLAG_REAL);
  REAL *sx = SIMDBase_alignedMalloc(sizeOfVect*n);

  //

  double complex fs[veclen][n], ts[veclen][n];

  for(j=0;j<veclen;j++) {
    for(i=0;i<n/2;i++) {
      if (i == 0) {
	fs[j][0  ] = (random() / (double)RAND_MAX);
	fs[j][n/2] = (random() / (double)RAND_MAX);
      } else {
	fs[j][i  ] = (random() / (double)RAND_MAX) + (random() / (double)RAND_MAX) * _Complex_I;
	fs[j][n-i] = conj(fs[j][i]);
      }
    }
  }

  for(j=0;j<veclen;j++) {
    for(i=0;i<n/2;i++) {
      if (i == 0) {
	sx[(2*0+0) * veclen + j] = creal(fs[j][0  ]);
	sx[(2*0+1) * veclen + j] = creal(fs[j][n/2]);
      } else {
	sx[(2*i+0) * veclen + j] = creal(fs[j][i]);
	sx[(2*i+1) * veclen + j] = cimag(fs[j][i]);
      }
    }
  }

  //

  for(j=0;j<veclen;j++) {
    backward(fs[j], ts[j], n);
  }

  DFT_execute(p, mode, sx, 1);

  //

  int success = 1;

  for(j=0;j<veclen;j++) {
    for(i=0;i<n;i++) {
      if (fabs(cimag(ts[j][i])) > THRES) {
	success = 0;
      }

      if ((fabs(sx[i * veclen + j]*2 - creal(ts[j][i])) > THRES)) {
	success = 0;
      }
    }
  }

  //

  SIMDBase_alignedFree(sx);
  DFT_dispose(p, mode);

  //

  return success;
}
예제 #12
0
/*
 * Main command processor.
 * Accept and execute commands until a quit command, then return.
 */
void
commands(void)
{
	int c, action;

	last_mca = 0;
	nscroll = (sc_height + 1) / 2;

	for (;;) {
		mca = 0;
		number = 0;

		/*
		 * See if any signals need processing.
		 */
		if (sigs) {
			psignals();
			if (quitting)
				quit();
		}
		/*
		 * Display prompt and accept a character.
		 */
		CMD_RESET;
		if (!prompt()) {
			next_file(1);
			continue;
		}
		noprefix();
		c = getcc();

again:		if (sigs)
			continue;

		/*
		 * If we are in a multicharacter command, call mca_char.
		 * Otherwise we call cmd_decode to determine the
		 * action to be performed.
		 */
		if (mca)
			switch (mca_char(c)) {
			case MCA_MORE:
				/*
				 * Need another character.
				 */
				c = getcc();
				goto again;
			case MCA_DONE:
				/*
				 * Command has been handled by mca_char.
				 * Start clean with a prompt.
				 */
				continue;
			case NO_MCA:
				/*
				 * Not a multi-char command
				 * (at least, not anymore).
				 */
				break;
			}

		/* decode the command character and decide what to do. */
		switch (action = cmd_decode(c)) {
		case A_DIGIT:		/* first digit of a number */
			start_mca(A_DIGIT, ":");
			goto again;
		case A_F_SCREEN:	/* forward one screen */
			CMD_EXEC;
			if (number <= 0 && (number = sc_window) <= 0)
				number = sc_height - 1;
			forward(number, 1);
			break;
		case A_B_SCREEN:	/* backward one screen */
			CMD_EXEC;
			if (number <= 0 && (number = sc_window) <= 0)
				number = sc_height - 1;
			backward(number, 1);
			break;
		case A_F_LINE:		/* forward N (default 1) line */
			CMD_EXEC;
			forward(number <= 0 ? 1 : number, 0);
			break;
		case A_B_LINE:		/* backward N (default 1) line */
			CMD_EXEC;
			backward(number <= 0 ? 1 : number, 0);
			break;
		case A_F_SCROLL:	/* forward N lines */
			CMD_EXEC;
			if (number > 0)
				nscroll = number;
			forward(nscroll, 0);
			break;
		case A_B_SCROLL:	/* backward N lines */
			CMD_EXEC;
			if (number > 0)
				nscroll = number;
			backward(nscroll, 0);
			break;
		case A_FREPAINT:	/* flush buffers and repaint */
			if (!ispipe) {
				ch_init(0, 0);
				clr_linenum();
			}
			/* FALLTHROUGH */
		case A_REPAINT:		/* repaint the screen */
			CMD_EXEC;
			repaint();
			break;
		case A_GOLINE:		/* go to line N, default 1 */
			CMD_EXEC;
			if (number <= 0)
				number = 1;
			jump_back(number);
			break;
		case A_PERCENT:		/* go to percent of file */
			CMD_EXEC;
			if (number < 0)
				number = 0;
			else if (number > 100)
				number = 100;
			jump_percent(number);
			break;
		case A_GOEND:		/* go to line N, default end */
			CMD_EXEC;
			if (number <= 0)
				jump_forw();
			else
				jump_back(number);
			break;
		case A_STAT:		/* print file name, etc. */
			longprompt = 1;
			continue;
		case A_QUIT:		/* exit */
			quit();
		case A_F_SEARCH:	/* search for a pattern */
		case A_B_SEARCH:
			if (number <= 0)
				number = 1;
			start_mca(action, (action==A_F_SEARCH) ? "/" : "?");
			last_mca = mca;
			wsearch = 1;
			c = getcc();
			if (c == '!') {
				/*
				 * Invert the sense of the search; set wsearch
				 * to 0 and get a new character for the start
				 * of the pattern.
				 */
				start_mca(action, 
				    (action == A_F_SEARCH) ? "!/" : "!?");
				wsearch = 0;
				c = getcc();
			}
			goto again;
		case A_AGAIN_SEARCH:		/* repeat previous search */
			if (number <= 0)
				number = 1;
			if (wsearch)
				start_mca(last_mca, 
				    (last_mca == A_F_SEARCH) ? "/" : "?");
			else
				start_mca(last_mca, 
				    (last_mca == A_F_SEARCH) ? "!/" : "!?");
			CMD_EXEC;
			(void)search(mca == A_F_SEARCH, (char *)NULL,
			    number, wsearch);
			break;
		case A_HELP:			/* help */
			lower_left();
			clear_eol();
			fputs("help", stdout);
			CMD_EXEC;
			help();
			break;
		case A_TAGFILE:			/* tag a new file */
			CMD_RESET;
			start_mca(A_TAGFILE, "Tag: ");
			c = getcc();
			goto again;
		case A_FILE_LIST:		/* show list of file names */
			CMD_EXEC;
			showlist();
			repaint();
			break;
		case A_EXAMINE:			/* edit a new file */
			CMD_RESET;
			start_mca(A_EXAMINE, "Examine: ");
			c = getcc();
			goto again;
		case A_VISUAL:			/* invoke the editor */
			if (ispipe) {
				error("Cannot edit standard input");
				break;
			}
			CMD_EXEC;
			editfile();
			ch_init(0, 0);
			clr_linenum();
			break;
		case A_NEXT_FILE:		/* examine next file */
			if (number <= 0)
				number = 1;
			next_file(number);
			break;
		case A_PREV_FILE:		/* examine previous file */
			if (number <= 0)
				number = 1;
			prev_file(number);
			break;
		case A_SETMARK:			/* set a mark */
			lower_left();
			clear_eol();
			start_mca(A_SETMARK, "mark: ");
			c = getcc();
			if (c == erase_char || c == kill_char)
				break;
			setmark(c);
			break;
		case A_GOMARK:			/* go to mark */
			lower_left();
			clear_eol();
			start_mca(A_GOMARK, "goto mark: ");
			c = getcc();
			if (c == erase_char || c == kill_char)
				break;
			gomark(c);
			break;
		case A_PREFIX:
			/*
			 * The command is incomplete (more chars are needed).
			 * Display the current char so the user knows what's
			 * going on and get another character.
			 */
			if (mca != A_PREFIX)
				start_mca(A_PREFIX, "");
			if (CONTROL_CHAR(c)) {
				putchar('^');
				c = CARAT_CHAR(c);
			}
			putchar(c);
			c = getcc();
			goto again;
		default:
			putchar('\7');
			break;
		}
	}
}
예제 #13
0
void makeLine(int count){
	int i;
	for (i=0; i<count;i++)
		makePattern();
	backward(count*5);
}
예제 #14
0
task main()
{

  initializeRobot();

  waitForStart();

  while(true)
  {
    switch(sm)
		{

		case DELAY_1:

		count++;

		if (count>=300)
		{
		sm=FORWARD_2;
		}

		break;

		case DELAY_2:

		count++;

		if (count>=300)
		{
		sm=POSITION_2_PH_2;
		}

		break;

		case DELAY_3:

		count++;

		if (count>=300)
		{
		sm=POSITION_3_PH_2;
		}

		break;

		case FORWARD:
		servo[score]=230;
		writeDebugStreamLine("%d",SensorValue[IR]);
		if (forward(50,4000)==true)
		{
		wait1Msec(1000);
		sm=IR;
		}

		break;

		case IR:

		writeDebugStreamLine("%d",SensorValue[IR]);

		if (SensorValue[IR]==3)
		{
		sm=POSITION_1;
		}

		if (SensorValue[IR]==5||SensorValue[IR]==4)
		{
		sm=POSITION_2;
		}

		if (SensorValue[IR]==7||SensorValue[IR]==6)
		{
		sm=POSITION_3;
		}

		break;

		case POSITION_1:

		if(forward(25,250)==true)
		{
		sm=POSITION_1_PH_1;
		}

		break;

			case POSITION_1_PH_1:

		if(Turnright(25,65)==true)
		{
		sm=DELAY_1;
		}

		break;

		case POSITION_2:

	if (backward(25,500)==true)
	{
	sm=POSITION_2_PH_1;
	}

		break;

		case POSITION_3:

	if (backward(25,500)==true)
	{
	sm=POSITION_3_PH_1;
	}


		break;

		case FORWARD_2:

		if(forward(25,3000)==true)
		{
		sm=STOP;

		}

		break;

		case STOP:

		motor[rtWheelMotor]=0;
		motor[ltWheelMotor]=0;

		break;

		case POSITION_2_PH_1:

		if(Turnright(25,80)==true)
		{
			sm=DELAY_2;
		}

		break;


		case POSITION_2_PH_2:

		if(forward(25,1000)==true)
		{
			sm=POSITION_2_PH_3;
		}

		break;

		case POSITION_2_PH_3:

		if(Turnleft(25,55)==true)
		{
			sm=POSITION_2_PH_4;
		}

		break;

		case POSITION_2_PH_4:

		if(forward(25,4000)==true)
		{
			sm=STOP;
		}

		break;


		case POSITION_3_PH_1:

		if(Turnright(25,70)==true)
		{
			sm=DELAY_3;
		}

		break;

		case POSITION_3_PH_2:

		if(forward(25,2850)==true)
		{
			sm=POSITION_3_PH_3;
		}

		break;

		case POSITION_3_PH_3:


		if(Turnleft(25,80)==true)
		{
			sm=POSITION_3_PH_4;
		}

		break;

		case POSITION_3_PH_4:

		if(forward(50,4000)==true)
		{
			sm=STOP;
		}

		break;

		}
	wait1Msec(50);
	}
}
예제 #15
0
void
play(void)
{
	MWEvent		event;
	MW244BPacket	incoming;

	event.eventDetail = &incoming;

	while (TRUE) {
		NextEvent(&event, M->theSocket());
		if (!M->peeking())
			switch(event.eventType) {
			case EVENT_A:
				aboutFace();
				break;

			case EVENT_S:
				leftTurn();
				break;

			case EVENT_D:
				forward();
				break;

			case EVENT_F:
				rightTurn();
				break;

			case EVENT_BAR:
				backward();
				break;

			case EVENT_LEFT_D:
				peekLeft();
				break;

			case EVENT_MIDDLE_D:
				shoot();
				break;

			case EVENT_RIGHT_D:
				peekRight();
				break;

			case EVENT_NETWORK:
				processPacket(&event);
				break;

			case EVENT_INT:
				quit(0);
				break;

			}
		else
			switch (event.eventType) {
			case EVENT_RIGHT_U:
			case EVENT_LEFT_U:
				peekStop();
				break;

			case EVENT_NETWORK:
				processPacket(&event);
				break;
			}

		ratStates();		/* clean house */

		manageMissiles();

		DoViewUpdate();

		mws_update(M->state);

		/* Any info to send over network? */

	}
}
예제 #16
0
void NeighbourGenerator::makeNeighbour(){
	vector<Node*> bottleneck;
	Graph g(m_solution,m_SettingTable);
	g.setLongestPath();
	int L=g.getMakespan();
	for(int i=0;i<g.size();i++){
		if(g[i]->m_R+g[i]->m_Q-g[i]->m_Jobpair->time==L){
			bottleneck.push_back(g[i]);
		}
	}

	m_CriticalPathList=pair<vector<Node*>,int>(vector<Node*>(),-1);
	vector<Node*> criticalPath;
	findCriticalPath(g[0],g[g.size()-1],bottleneck,criticalPath,0);

	criticalPath.clear();
	criticalPath=m_CriticalPathList.first;
	for(int j=0;j<criticalPath.size()-1;j++){
		for(int k=j+1;k<criticalPath.size()-1;k++){
			if(criticalPath[j]->m_Jobpair->machine!=
				criticalPath[k]->m_Jobpair->machine)
				continue;
			JobPair *I=criticalPath[j]->m_Jobpair;
			JobPair *J=criticalPath[k]->m_Jobpair;
			JobPair *alphaI=findJobFromSetting(I,PREV);
			JobPair *gammaI=findJobFromSetting(I,NEXT);
			JobPair *alphaJ=findJobFromSetting(J,PREV);
			JobPair *gammaJ=findJobFromSetting(J,NEXT);

			for(int l=0;l<criticalPath.size();l++){
				// gammaJがCriticalPathに含まれていればforwardchangeする
				if(gammaJ!=NULL && gammaI!=NULL && gammaJ->index==criticalPath[l]->m_Jobpair->index &&
					g.getNodeByIndex(J->index)->m_Q-J->time>=g.getNodeByIndex(gammaI->index)->m_Q-gammaI->time){
					vector<vector<JobPair> > forwardSolution;
					forwardSolution=changeForward(m_solution,criticalPath[j]->m_Jobpair,criticalPath[k]->m_Jobpair);
					m_NeighbourList.push_back(forwardSolution);
					Graph forward(forwardSolution,m_SettingTable);
					forward.setLongestPath();
					if(g.getMakespan()>forward.getMakespan()){
					}else{
						if(forward.getNodeByIndex(J->index)->m_R-J->time<=g.getNodeByIndex(J->index)->m_R-J->time-I->time){
						}
						if(forward.getNodeByIndex(J->index)->m_Q<=g.getNodeByIndex(J->index)->m_Q+I->time){
						}
					}
				}
				
				// alphaIがCriticalPathに含まれていればbackwardchangeする
				if(alphaI!=NULL && alphaJ!=NULL && alphaI->index==criticalPath[l]->m_Jobpair->index &&
					g.getNodeByIndex(I->index)->m_R>=g.getNodeByIndex(alphaJ->index)->m_R){
					vector<vector<JobPair> > backwardSolution;
					backwardSolution=changeBackward(m_solution,criticalPath[j]->m_Jobpair,criticalPath[k]->m_Jobpair);
					m_NeighbourList.push_back(backwardSolution);

					Graph backward(backwardSolution,m_SettingTable);
					backward.setLongestPath();
					if(g.getMakespan()>backward.getMakespan()){
					}else{
						if(backward.getNodeByIndex(I->index)->m_Q<=g.getNodeByIndex(I->index)->m_Q-J->time){
						}
						if(backward.getNodeByIndex(I->index)->m_R-I->time<=g.getNodeByIndex(I->index)->m_R-I->time+J->time){
						}
					}
				}
			}
		}
	}
}
예제 #17
0
DocumentBrowser::DocumentBrowser(LiteApi::IApplication *app, QObject *parent) :
    LiteApi::IDocumentBrowser(parent),
    m_liteApp(app),
    m_extension(new Extension)
{
    m_widget = new QWidget;

    m_htmlWidget = app->htmlWidgetManager()->createByName(this,"QTextBrowser");

    m_toolBar = new QToolBar;
    m_toolBar->setIconSize(LiteApi::getToolBarIconSize());

    m_backwardAct = new QAction(QIcon("icon:images/backward.png"),tr("Back"),this);
    m_forwardAct = new QAction(QIcon("icon:images/forward.png"),tr("Forward"),this);
    m_reloadUrlAct = new QAction(QIcon("icon:images/reload.png"),tr("Reload"),this);
    m_toolBar->addAction(m_backwardAct);
    m_toolBar->addAction(m_forwardAct);

    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Document");

    m_increaseFontSize = new QAction(tr("Increase Font Size"),this);
    actionContext->regAction(m_increaseFontSize,"IncreaseFontSize","Ctrl++;Ctrl+=");

    m_decreaseFontSize = new QAction(tr("Decrease Font Size"),this);
    actionContext->regAction(m_decreaseFontSize,"DecreaseFontSize","Ctrl+-");

    m_resetFontSize = new QAction(tr("Reset Font Size"),this);
    actionContext->regAction(m_resetFontSize,"ResizeFontSize","Ctrl+0");

    m_urlComboBox = new QComboBox;
    m_urlComboBox->setEditable(true);
    m_urlComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);

    m_toolBar->addSeparator();
    m_toolBar->addWidget(m_urlComboBox);
    m_toolBar->addAction(m_reloadUrlAct);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);

    mainLayout->addWidget(m_toolBar);
    mainLayout->addWidget(m_htmlWidget->widget());
    m_widget->setLayout(mainLayout);

    m_widget->addAction(m_increaseFontSize);
    m_widget->addAction(m_decreaseFontSize);
    m_widget->addAction(m_resetFontSize);

    connect(m_increaseFontSize,SIGNAL(triggered()),this,SLOT(increaseFontSize()));
    connect(m_decreaseFontSize,SIGNAL(triggered()),this,SLOT(decreaseFontSize()));
    connect(m_resetFontSize,SIGNAL(triggered()),this,SLOT(resetFontSize()));
    connect(m_htmlWidget,SIGNAL(linkHovered(QUrl)),this,SIGNAL(linkHovered(QUrl)));
    connect(m_htmlWidget,SIGNAL(linkClicked(QUrl)),this,SLOT(linkClicked(QUrl)));
    connect(m_htmlWidget,SIGNAL(loadFinished(bool)),this,SIGNAL(documentLoaded()));
    connect(m_backwardAct,SIGNAL(triggered()),this,SLOT(backward()));
    connect(m_forwardAct,SIGNAL(triggered()),this,SLOT(forward()));
    connect(m_reloadUrlAct,SIGNAL(triggered()),this,SLOT(reloadUrl()));
    connect(m_urlComboBox,SIGNAL(activated(QString)),this,SLOT(activatedUrl(QString)));
    connect(this,SIGNAL(backwardAvailable(bool)),m_backwardAct,SLOT(setEnabled(bool)));
    connect(this,SIGNAL(forwardAvailable(bool)),m_forwardAct,SLOT(setEnabled(bool)));

    m_extension->addObject("LiteApi.IDocumentBrowser",this);
    m_extension->addObject("LiteApi.IHtmlWidget",m_htmlWidget);
    m_extension->addObject("LiteApi.QTextBrowser",m_htmlWidget->widget());
    m_htmlWidget->installEventFilter(m_liteApp->editorManager());

    requestFontZoom(0);

    QPalette p = m_htmlWidget->widget()->palette();
    p.setBrush(QPalette::Highlight,Qt::yellow);
    p.setColor(QPalette::HighlightedText,Qt::black);
    m_htmlWidget->widget()->setPalette(p);

    emit backwardAvailable(false);
    emit forwardAvailable(false);
}
예제 #18
0
void QHTMLView::init()
{
  QString qs;
  QString qs2;
  mpTextBrowser = new QTextBrowser(this);
  mpTextBrowser->setTextFormat(Qt::RichText);
  setCentralWidget(mpTextBrowser);
  qs = xmlConfig->stringValue("HELP_INDEX");
  qs2 = xmlConfig->stringValue("HELP_LAST_PAGE");
  QFile qf1(qs);
  if(qf1.exists()) mpTextBrowser->setSource(qs);
  if(qs != qs2 )
  {
    QFile qf2(qs2);
    if(qf2.exists()) mpTextBrowser->setSource(qs2);
  }
  QPopupMenu* file = new QPopupMenu( this );
  file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O );
  file->insertSeparator();
  file->insertItem( tr("&Quit"), this, SLOT( close() ), ALT | Key_Q );

  QPopupMenu* go = new QPopupMenu( this );

  mIdBackward = go->insertItem(tr("&Backward"),mpTextBrowser,
                   SLOT( backward() ),ALT | Key_Left );
  mIdForward = go->insertItem(tr("&Forward"),mpTextBrowser,
                   SLOT( forward() ),ALT | Key_Right );
  go->insertItem(tr("&Home"),mpTextBrowser, SLOT( home() ) );

  QPopupMenu* help = new QPopupMenu( this );
  help->insertItem(tr("&About ..."),this,SLOT(about()));

#ifdef KDEAPP
  KMenuBar* mb = new KMenuBar(this);
#else
  QMenuBar* mb = new QMenuBar(this);
#endif
  mb->insertItem(tr("&File"),file);
  mb->insertItem(tr("&Go"),go);
  mb->insertSeparator();
  mb->insertItem(tr("&Help"),help );

  mb->setItemEnabled( mIdForward, false);
  mb->setItemEnabled( mIdBackward, false);

  connect(mpTextBrowser, SIGNAL( backwardAvailable( bool ) ),
    	    this, SLOT( setBackwardAvailable( bool ) ) );
  connect(mpTextBrowser, SIGNAL( forwardAvailable( bool ) ),
	        this, SLOT( setForwardAvailable( bool ) ) );
  connect(mpTextBrowser,SIGNAL(textChanged() ),this,
          SLOT( slotTextChanged() ) );

  QToolBar* toolbar = new QToolBar( this );
  addToolBar( toolbar);
  QToolButton* tb1;

	mPixForward = QPixmap((const char **)forward_xpm);
	mPixBackward = QPixmap((const char **)backward_xpm);
	mPixHome = QPixmap((const char **)home_xpm);

  tb1 = new QToolButton(mPixBackward, tr("Backward"), "", mpTextBrowser,
                        SLOT(backward()), toolbar );
  connect(mpTextBrowser, SIGNAL( backwardAvailable(bool) ),tb1,
          SLOT( setEnabled(bool) ) );
  tb1->setEnabled( false );

  tb1 = new QToolButton(mPixForward, tr("Forward"), "",mpTextBrowser,
                        SLOT(forward()), toolbar );
  connect(mpTextBrowser,SIGNAL(forwardAvailable(bool) ),tb1,
          SLOT( setEnabled(bool) ) );
  tb1->setEnabled( false );

  tb1 = new QToolButton(mPixHome, tr("Home"), "",this,
                        SLOT(home()), toolbar );
  QWidget* dummy = new QWidget(toolbar);
  toolbar->setStretchableWidget(dummy);
  setRightJustification(true);
}
예제 #19
0
int main()
{
	// INITIALIZE
	
	int x, y, color=0, pink=1;  // set up for color channel 0 (green)
	int xvalue, yvalue;
	int greencentered = 0;
	int loop = 0;
	int centerx=77; // calibrate these number and enter manually
	int centery=63;
	int margin=8;
	int deltax = 0;
	int deltay = 0;
	int stepsizex;
	int stepsizey;
	int currpos;
	int s_time;
	
	light_start(L_SENSOR);				// light start
	shut_down_in(119);
	camera_open(LOW_RES);
	enable_servos();						// enable servos
	set_servo_position(S_CATCHER,S_DOWN);
	msleep(500);
	set_servo_position(S_GATE,S_OPEN);
	msleep(500);
	
	// TRIBBLE PILE 1
	
	//set_servo_position(S_GATE,S_OPEN);		// open gate
	msleep(5000);
	set_servo_position(S_CATCHER,CATCHER_UP);
	right(28,ks/2);									// right
	f_until_black(TOPHAT_RIGHT/*,TOPHAT_LEFT*/);	// forward until right sensor sees black]
	forward(2);
	//printf("see black! time to close the gate\n");
	set_servo_position(S_GATE,S_GAP);				// close gate
	//f_until_white(TOPHAT_RIGHT);
	set_servo_position(CATCHERARM, CATCHER_UP);
	
	// camera sort

	s_time = curr_time();
	while((curr_time()-s_time) < 14)
	{
		while (greencentered == 0)
		{
			camera_update(); // process the most recent image
			camera_update(); // process the most recent image
			camera_update(); // process the most recent image
			camera_update(); // process the most recent image
			camera_update(); // process the most recent image
			loop = loop + 1;
			printf("Update camera, loop %d\n", loop);
			//msleep(10);
			if (get_object_count(color) > 0)
			{
				xvalue = get_object_center(color,0).x;
				yvalue = get_object_center(color,0).y;
				deltax = abs(xvalue-centerx);
				deltay = abs(yvalue-centery);
				stepsizex = (deltax>10) ? 50: 20;
				stepsizey = (deltay>10) ? 50: 20;
				printf("x is %d, y is %d\n", xvalue, yvalue);
				greencentered = ((xvalue >= centerx-margin) & (xvalue <= centerx+margin)) && ((yvalue >= centery-margin) & (yvalue <= centery+margin));
				if(greencentered == 1)//get x, y for the biggest blob the channel sees		
				{	
					printf("Biggest blob at (%d,%d)\n",xvalue,yvalue);
					msleep(300);
					set_servo_position(CATCHERARM, CATCHER_MIDWAY);
					msleep(300);
					set_servo_position(CATCHERARM, CATCHER_DOWN);
					//slow_servo(CATCHERARM,20,40,CATCHER_UP,CATCHER_DOWN);
					msleep(300);
					currpos=get_servo_position(CATCHERARM);
					printf("%d\n",currpos);
					/*if(CATCHER_MIDWAY>=currpos>CATCHER_DOWN)
					{	
					currpos=get_servo_position(CATCHERARM);
					set_servo_position(CATCHERARM, currpos-INCREMENT);
					msleep(SLEEP_INCREMENT);
					currpos=get_servo_position(CATCHERARM);
					}
					if(currpos<CATCHER_MIDWAY)
					{	
					currpos=get_servo_position(CATCHERARM);
					set_servo_position(CATCHERARM, currpos+INCREMENT);
					msleep(SLEEP_INCREMENT);
					currpos=get_servo_position(CATCHERARM);
					}*/
					set_servo_position(CATCHERARM,CATCHER_UP);
					msleep(500);
				}
				else
				{
					if(xvalue <= centerx+margin) //moves right if senses value greater than 80
					{
						motor(MOT_RIGHT,70);
						motor(MOT_LEFT,-70);
						msleep(stepsizex);
						motor(MOT_RIGHT,0);
						motor(MOT_LEFT,0);
						//msleep(10);
						printf("blob is too right\n");
					}	
					if(xvalue >= centerx-margin) // moves left if senses value less than 70
					{
						motor(MOT_LEFT,70);
						motor(MOT_RIGHT,-70);
						msleep(stepsizex);	
						motor(MOT_LEFT,0);
						motor(MOT_RIGHT,0);
						//msleep(10);
						printf("blob is too left\n");
					}
					
					if ((xvalue > 67 /*centerx-margin*/) && (xvalue < 87 /*centerx+margin*/))
					{
						if(yvalue > centery+margin) //moves forward if senses value greater than 43
						{
							motor(MOT_LEFT,-50);
							motor(MOT_RIGHT,-50);
							msleep(stepsizey);
							motor(MOT_LEFT,0);
							motor(MOT_RIGHT,0);
							//msleep(10);
							printf("blob is too close\n");
						}
						
						if(yvalue < centery-margin) // moves backwar if senses value less than 38
						{
							motor(MOT_LEFT,50);
							motor(MOT_RIGHT,50);
							msleep(stepsizey);
							motor(MOT_LEFT,0);
							motor(MOT_RIGHT,0);
							//msleep(10);
							printf("blob is too far\n");
						}
					}
				}
			}
		}
	}
	set_servo_position(S_GATE,S_CLOSE);	
	while (analog10(2)<BLACK_SEN_THRESH)
	{
		motor(MOT_LEFT,-100);
	}
	
	// SCORE PILE 1
	
	left(5,0);
	//backward(50);
	touch_back(TOUCH_SEN);
	forward(10);
	backward(10);
	forward(20);
	right(55,0);
	forward(35);
	backward(4);
	right(45,0);
	while (analog10(3)<BLACK_SEN_THRESH)
	{
		motor(MOT_LEFT, 100);
		motor(MOT_RIGHT, 100);
	}
	msleep(10);
	backward(24);
	left(42,0);
	backward(10); 
	left(50,0);
	//backward(35);
	touch_back(TOUCH_SEN);
	forward(120.00);
	
	// TRIBBLE PILE 2
	
	set_servo_position(S_GATE,S_OPEN);
	forward(40.00);
	set_servo_position(S_GATE,S_GAP);
	
	// camera sort
	
	s_time = curr_time();
	while((curr_time()-s_time) < 14) //timer
	{
		while (greencentered == 0)
		{
			camera_update(); // process the most recent image
			camera_update(); // process the most recent image
			camera_update(); // process the most recent image
			camera_update(); // process the most recent image
			camera_update(); // process the most recent image
			loop = loop + 1;
			printf("Update camera, loop %d\n", loop);
			//msleep(10);
			if (get_object_count(color) > 0)
			{
				xvalue = get_object_center(color,0).x;
				yvalue = get_object_center(color,0).y;
				deltax = abs(xvalue-centerx);
				deltay = abs(yvalue-centery);
				stepsizex = (deltax>10) ? 50: 20;
				stepsizey = (deltay>10) ? 50: 20;
				printf("x is %d, y is %d\n", xvalue, yvalue);
				greencentered = ((xvalue >= centerx-margin) & (xvalue <= centerx+margin)) && ((yvalue >= centery-margin) & (yvalue <= centery+margin));
				if(greencentered == 1)//get x, y for the biggest blob the channel sees		
				{	
					printf("Biggest blob at (%d,%d)\n",xvalue,yvalue);
					msleep(300);
					set_servo_position(CATCHERARM, CATCHER_MIDWAY);
					msleep(300);
					set_servo_position(CATCHERARM, CATCHER_DOWN);
					//slow_servo(CATCHERARM,20,40,CATCHER_UP,CATCHER_DOWN);
					msleep(300);
					currpos=get_servo_position(CATCHERARM);
					printf("%d\n",currpos);
					/*if(CATCHER_MIDWAY>=currpos>CATCHER_DOWN)
					{	
					currpos=get_servo_position(CATCHERARM);
					set_servo_position(CATCHERARM, currpos-INCREMENT);
					msleep(SLEEP_INCREMENT);
					currpos=get_servo_position(CATCHERARM);
					}
					if(currpos<CATCHER_MIDWAY)
					{	
					currpos=get_servo_position(CATCHERARM);
					set_servo_position(CATCHERARM, currpos+INCREMENT);
					msleep(SLEEP_INCREMENT);
					currpos=get_servo_position(CATCHERARM);
					}*/
					set_servo_position(CATCHERARM,CATCHER_UP);
					msleep(500);
				}
				else
				{
					if(xvalue <= centerx+margin) //moves right if senses value greater than 80
					{
						motor(MOT_RIGHT,70);
						motor(MOT_LEFT,-70);
						msleep(stepsizex);
						motor(MOT_RIGHT,0);
						motor(MOT_LEFT,0);
						//msleep(10);
						printf("blob is too right\n");
					}	
					if(xvalue >= centerx-margin) // moves left if senses value less than 70
					{
						motor(MOT_LEFT,70);
						motor(MOT_RIGHT,-70);
						msleep(stepsizex);	
						motor(MOT_LEFT,0);
						motor(MOT_RIGHT,0);
						//msleep(10);
						printf("blob is too left\n");
					}
					
					if ((xvalue > 67 /*centerx-margin*/) && (xvalue < 87 /*centerx+margin*/))
					{
						if(yvalue > centery+margin) //moves forward if senses value greater than 43
						{
							motor(MOT_LEFT,-50);
							motor(MOT_RIGHT,-50);
							msleep(stepsizey);
							motor(MOT_LEFT,0);
							motor(MOT_RIGHT,0);
							//msleep(10);
							printf("blob is too close\n");
						}
						
						if(yvalue < centery-margin) // moves backwar if senses value less than 38
						{
							motor(MOT_LEFT,50);
							motor(MOT_RIGHT,50);
							msleep(stepsizey);
							motor(MOT_LEFT,0);
							motor(MOT_RIGHT,0);
							//msleep(10);
							printf("blob is too far\n");
						}
					}
				}
			}
		}
	}
	set_servo_position(S_GATE,S_CLOSE);
	
	// SCORE PILE 2
	
	right(55,0);
	forward(28);
	backward(12);
	right(55,0);
	touch_back(TOUCH_SEN);
	forward(200);
	right(50,0);
	touch_back(TOUCH_SEN);
	forward(15);
	left(50,0);
	while (analog10(3)<BLACK_SEN_THRESH)
	{
		motor(MOT_LEFT, 100);
		motor(MOT_RIGHT, 100);
	}
	backward(4);
	right(50,0);
	msleep(10);
	forward(24);
	right(42,0);
	touch_back(TOUCH_SEN);
	backward(4);
	
	// END
	ao();
	disable_servos();
	printf("done!");
}
예제 #20
0
FLHelpWindow::FLHelpWindow(const QString &home_,
                           const QString &_path,
                           QWidget *parent,
                           const char *name) :
  QMainWindow(parent, name, WDestructiveClose),
  pathCombo(0), selectedURL()
{
  readHistory();
  readBookmarks();

  browser = new QTextBrowser(this);

  browser->mimeSourceFactory() ->setFilePath(_path);
  browser->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged()));

  setCentralWidget(browser);

  if (!home_.isEmpty())
    browser->setSource(home_);

  connect(browser, SIGNAL(highlighted(const QString &)), statusBar(),
          SLOT(message(const QString &)));

  resize(640, 700);

  QPopupMenu *file = new QPopupMenu(this);

  file->insertItem(tr("&Imprimir"), this, SLOT(print()), CTRL + Key_I);
  file->insertSeparator();
  file->insertItem(tr("&Cerrar"), this, SLOT(close()), Key_Escape);

  // The same three icons are used twice each.
  QIconSet icon_back(QPixmap::fromMimeSource("previous.png"));
  QIconSet icon_forward(QPixmap::fromMimeSource("next.png"));
  QIconSet icon_home(QPixmap::fromMimeSource("home.png"));

  QPopupMenu *go = new QPopupMenu(this);

  backwardId =
    go->insertItem(icon_back, tr("&Atrás"), browser, SLOT(backward()),
                   CTRL + Key_Left);
  forwardId =
    go->insertItem(icon_forward, tr("&Adelante"), browser,
                   SLOT(forward()), CTRL + Key_Right);
  go->insertItem(icon_home, tr("&Inicio"), browser, SLOT(home()));

  QPopupMenu *help = new QPopupMenu(this);

  help->insertItem(tr("&Acerca ..."), this, SLOT(about()));
  help->insertItem(tr("Acerca de &Qt ..."), this, SLOT(aboutQt()));

  hist = new QPopupMenu(this);
  QStringList::Iterator it = history.begin();
  for (; it != history.end(); ++it)
    mHistory[ hist->insertItem(*it)] = *it;
  connect(hist, SIGNAL(activated(int)), this, SLOT(histChosen(int)));

  bookm = new QPopupMenu(this);
  bookm->insertItem(tr("Agregar Favorito"), this, SLOT(addBookmark()));
  bookm->insertSeparator();

  QStringList::Iterator it2 = bookmarks.begin();
  for (; it2 != bookmarks.end(); ++it2)
    mBookmarks[ bookm->insertItem(*it2)] = *it2;
  connect(bookm, SIGNAL(activated(int)), this, SLOT(bookmChosen(int)));

  menuBar() ->insertItem(tr("&Archivo"), file);
  menuBar() ->insertItem(tr("&Ir"), go);
  menuBar() ->insertItem(tr("Historial"), hist);
  menuBar() ->insertItem(tr("Favoritos"), bookm);
  menuBar() ->insertSeparator();
  menuBar() ->insertItem(tr("&Ayuda"), help);

  menuBar() ->setItemEnabled(forwardId, FALSE);
  menuBar() ->setItemEnabled(backwardId, FALSE);
  connect(browser, SIGNAL(backwardAvailable(bool)), this,
          SLOT(setBackwardAvailable(bool)));
  connect(browser, SIGNAL(forwardAvailable(bool)), this,
          SLOT(setForwardAvailable(bool)));


  QToolBar *toolbar = new QToolBar(this);

  addToolBar(toolbar, "Toolbar");
  QToolButton *button;

  button =
    new QToolButton(icon_back, tr("Atrás"), "", browser, SLOT(backward()),
                    toolbar);
  connect(browser, SIGNAL(backwardAvailable(bool)), button,
          SLOT(setEnabled(bool)));
  button->setEnabled(FALSE);
  button =
    new QToolButton(icon_forward, tr("Adelante"), "", browser,
                    SLOT(forward()), toolbar);
  connect(browser, SIGNAL(forwardAvailable(bool)), button,
          SLOT(setEnabled(bool)));
  button->setEnabled(FALSE);
  button =
    new QToolButton(icon_home, tr("Inicio"), "", browser, SLOT(home()),
                    toolbar);

  toolbar->addSeparator();

  pathCombo = new QComboBox(TRUE, toolbar);
  connect(pathCombo, SIGNAL(activated(const QString &)), this,
          SLOT(pathSelected(const QString &)));
  toolbar->setStretchableWidget(pathCombo);
  setRightJustification(TRUE);
  setDockEnabled(DockLeft, FALSE);
  setDockEnabled(DockRight, FALSE);

  pathCombo->insertItem(home_);
  browser->setFocus();
}
CKJVBrowser::CKJVBrowser(CVerseListModel *pModel, CBibleDatabasePtr pBibleDatabase, QWidget *parent) :
	QWidget(parent),
	m_pBibleDatabase(pBibleDatabase),
	m_ndxCurrent(0),
	m_SearchResultsHighlighter(pModel, false),
	m_ExcludedSearchResultsHighlighter(pModel, true),
	m_bShowExcludedSearchResults(CPersistentSettings::instance()->showExcludedSearchResultsInBrowser()),
	m_bDoingUpdate(false),
#ifndef PLASTIQUE_STATIC
	m_pPlastiqueStyle(NULL),
#endif
	m_bDoingPassageReference(false),
	m_pScriptureBrowser(NULL)
{
	assert(!m_pBibleDatabase.isNull());
	assert(!g_pUserNotesDatabase.isNull());

	ui.setupUi(this);

#ifndef PLASTIQUE_STATIC
	m_pPlastiqueStyle = new QProxyStyle(QStyleFactory::create("plastique"));
#endif

	initialize();

	assert(m_pScriptureBrowser != NULL);

	ui.lblBibleDatabaseName->setText(m_pBibleDatabase->description());

	setNavigationActivationDelay(CPersistentSettings::instance()->navigationActivationDelay());
	setPassageReferenceActivationDelay(CPersistentSettings::instance()->passageReferenceActivationDelay());
	setBrowserNavigationPaneMode(CPersistentSettings::instance()->browserNavigationPaneMode());

	connect(CPersistentSettings::instance(), SIGNAL(changedNavigationActivationDelay(int)), this, SLOT(setNavigationActivationDelay(int)));
	connect(CPersistentSettings::instance(), SIGNAL(changedPassageReferenceActivationDelay(int)), this, SLOT(setPassageReferenceActivationDelay(int)));
	connect(CPersistentSettings::instance(), SIGNAL(changedChapterScrollbarMode(CHAPTER_SCROLLBAR_MODE_ENUM)), this, SLOT(en_changedChapterScrollbarMode()));
	connect(CPersistentSettings::instance(), SIGNAL(changedBrowserNavigationPaneMode(BROWSER_NAVIGATION_PANE_MODE_ENUM)), this, SLOT(setBrowserNavigationPaneMode(BROWSER_NAVIGATION_PANE_MODE_ENUM)));

// Data Connections:
	connect(pModel, SIGNAL(verseListAboutToChange()), this, SLOT(en_SearchResultsVerseListAboutToChange()));
	connect(pModel, SIGNAL(verseListChanged()), this, SLOT(en_SearchResultsVerseListChanged()));

// UI Connections:
	connect(m_pScriptureBrowser, SIGNAL(gotoIndex(const TPhraseTag &)), &m_dlyGotoIndex, SLOT(trigger(const TPhraseTag &)));
	connect(&m_dlyGotoIndex, SIGNAL(triggered(const TPhraseTag &)), this, SLOT(gotoIndex(const TPhraseTag &)));
	connect(this, SIGNAL(en_gotoIndex(const TPhraseTag &)), m_pScriptureBrowser, SLOT(en_gotoIndex(const TPhraseTag &)));
	connect(m_pScriptureBrowser, SIGNAL(sourceChanged(const QUrl &)), this, SLOT(en_sourceChanged(const QUrl &)));
	connect(m_pScriptureBrowser, SIGNAL(cursorPositionChanged()), this, SLOT(en_selectionChanged()));

	connect(ui.btnHideNavigation, SIGNAL(clicked()), this, SLOT(en_clickedHideNavigationPane()));

	connect(ui.comboBk, SIGNAL(currentIndexChanged(int)), this, SLOT(delayBkComboIndexChanged(int)));
	connect(ui.comboBkChp, SIGNAL(currentIndexChanged(int)), this, SLOT(delayBkChpComboIndexChanged(int)));
	connect(ui.comboTstBk, SIGNAL(currentIndexChanged(int)), this, SLOT(delayTstBkComboIndexChanged(int)));
	connect(ui.comboTstChp, SIGNAL(currentIndexChanged(int)), this, SLOT(delayTstChpComboIndexChanged(int)));
	connect(ui.comboBibleBk, SIGNAL(currentIndexChanged(int)), this, SLOT(delayBibleBkComboIndexChanged(int)));
	connect(ui.comboBibleChp, SIGNAL(currentIndexChanged(int)), this, SLOT(delayBibleChpComboIndexChanged(int)));

	connect(ui.widgetPassageReference, SIGNAL(passageReferenceChanged(const TPhraseTag &)), this, SLOT(delayPassageReference(const TPhraseTag &)));
	connect(ui.widgetPassageReference, SIGNAL(enterPressed()), this, SLOT(PassageReferenceEnterPressed()));

	connect(&m_dlyBkCombo, SIGNAL(triggered(int)), this, SLOT(BkComboIndexChanged(int)));
	connect(&m_dlyBkChpCombo, SIGNAL(triggered(int)), this, SLOT(BkChpComboIndexChanged(int)));
	connect(&m_dlyTstBkCombo, SIGNAL(triggered(int)), this, SLOT(TstBkComboIndexChanged(int)));
	connect(&m_dlyTstChpCombo, SIGNAL(triggered(int)), this, SLOT(TstChpComboIndexChanged(int)));
	connect(&m_dlyBibleBkCombo, SIGNAL(triggered(int)), this, SLOT(BibleBkComboIndexChanged(int)));
	connect(&m_dlyBibleChpCombo, SIGNAL(triggered(int)), this, SLOT(BibleChpComboIndexChanged(int)));

	connect(&m_dlyPassageReference, SIGNAL(triggered(const TPhraseTag &)), this, SLOT(PassageReferenceChanged(const TPhraseTag &)));

	connect(m_pScriptureBrowser, SIGNAL(activatedScriptureText()), this, SLOT(en_activatedScriptureText()));
	connect(ui.widgetPassageReference, SIGNAL(activatedPassageReference()), this, SLOT(en_activatedPassageReference()));

	// Set Outgoing Pass-Through Signals:
	connect(m_pScriptureBrowser, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool)));
	connect(m_pScriptureBrowser, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool)));
	connect(m_pScriptureBrowser, SIGNAL(historyChanged()), this, SIGNAL(historyChanged()));

	// Set Incoming Pass-Through Signals:
	connect(this, SIGNAL(backward()), m_pScriptureBrowser, SLOT(backward()));
	connect(this, SIGNAL(forward()), m_pScriptureBrowser, SLOT(forward()));
	connect(this, SIGNAL(home()), m_pScriptureBrowser, SLOT(home()));
	connect(this, SIGNAL(reload()), m_pScriptureBrowser, SLOT(reload()));
	connect(this, SIGNAL(rerender()), m_pScriptureBrowser, SLOT(rerender()));

	// Highlighting colors changing:
	connect(CPersistentSettings::instance(), SIGNAL(changedColorSearchResults(const QColor &)), this, SLOT(en_SearchResultsColorChanged(const QColor &)));
	connect(CPersistentSettings::instance(), SIGNAL(changedColorWordsOfJesus(const QColor &)), this, SLOT(en_WordsOfJesusColorChanged(const QColor &)));
	connect(CPersistentSettings::instance(), SIGNAL(changedShowExcludedSearchResultsInBrowser(bool)), this, SLOT(en_ShowExcludedSearchResultsChanged(bool)));

	connect(g_pUserNotesDatabase.data(), SIGNAL(highlighterTagsAboutToChange(CBibleDatabasePtr, const QString &)), this, SLOT(en_highlighterTagsAboutToChange(CBibleDatabasePtr, const QString &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(highlighterTagsChanged(CBibleDatabasePtr, const QString &)), this, SLOT(en_highlighterTagsChanged(CBibleDatabasePtr, const QString &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(aboutToChangeHighlighters()), this, SLOT(en_highlightersAboutToChange()));
	connect(g_pUserNotesDatabase.data(), SIGNAL(changedHighlighters()), this, SLOT(en_highlightersChanged()));

	// User Notes changing:
	connect(g_pUserNotesDatabase.data(), SIGNAL(addedUserNote(const CRelIndex &)), this, SLOT(en_userNoteEvent(const CRelIndex &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(changedUserNote(const CRelIndex &)), this, SLOT(en_userNoteEvent(const CRelIndex &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(removedUserNote(const CRelIndex &)), this, SLOT(en_userNoteEvent(const CRelIndex &)));

	// Cross Refs changing:
	connect(g_pUserNotesDatabase.data(), SIGNAL(addedCrossRef(const CRelIndex &, const CRelIndex &)), this, SLOT(en_crossRefsEvent(const CRelIndex &, const CRelIndex &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(removedCrossRef(const CRelIndex &, const CRelIndex &)), this, SLOT(en_crossRefsEvent(const CRelIndex &, const CRelIndex &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(changedAllCrossRefs()), this, SLOT(en_allCrossRefsChanged()));
}
예제 #22
0
void HelpBrowser::setupLocalUI()
{
	setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png"));
	//Add Menus
	fileMenu=menuBar()->addMenu("");
	editMenu=menuBar()->addMenu("");
	bookMenu=menuBar()->addMenu("");
	histMenu=new QMenu(this);

	//Add Menu items
	filePrint=fileMenu->addAction(IconManager::instance()->loadIcon("16/document-print.png"), "", this, SLOT(print()), Qt::CTRL+Qt::Key_P);
	fileMenu->addSeparator();
	fileExit=fileMenu->addAction(IconManager::instance()->loadIcon("exit.png"), "", this, SLOT(close()), Qt::CTRL+Qt::Key_W);
	editFind=editMenu->addAction(IconManager::instance()->loadIcon("find.png"), "", this, SLOT(find()), Qt::CTRL+Qt::Key_F);
	editFindNext=editMenu->addAction( "", this, SLOT(findNext()), Qt::Key_F3);
	editFindPrev=editMenu->addAction( "", this, SLOT(findPrevious()), Qt::SHIFT+Qt::Key_F3);
	bookAdd=bookMenu->addAction( "", this, SLOT(bookmarkButton_clicked()), Qt::CTRL+Qt::Key_D);
	bookDel=bookMenu->addAction( "", this, SLOT(deleteBookmarkButton_clicked()));
	bookDelAll=bookMenu->addAction( "", this, SLOT(deleteAllBookmarkButton_clicked()));

	//Add Toolbar items
	goHome=toolBar->addAction(IconManager::instance()->loadIcon("16/go-home.png"), "", textBrowser, SLOT(home()));
	goBack=toolBar->addAction(IconManager::instance()->loadIcon("16/go-previous.png"), "", textBrowser, SLOT(backward()));
	goFwd=toolBar->addAction(IconManager::instance()->loadIcon("16/go-next.png"), "", textBrowser, SLOT(forward()));
	goBack->setMenu(histMenu);
	
	helpNav->listView->header()->hide();
	helpNav->searchingView->header()->hide();
	helpNav->bookmarksView->header()->hide();

//	splitter->setStretchFactor(splitter->indexOf(tabWidget), 0);
//	splitter->setStretchFactor(splitter->indexOf(textBrowser), 1);
	// reset previous size
	prefs = PrefsManager::instance()->prefsFile->getPluginContext("helpbrowser");
	int xsize = prefs->getUInt("xsize", 640);
	int ysize = prefs->getUInt("ysize", 480);
	resize(QSize(xsize, ysize).expandedTo(minimumSizeHint()) );

	//basic ui
	connect(histMenu, SIGNAL(triggered(QAction*)), this, SLOT(histChosen(QAction*)));
	// searching
	connect(helpNav->searchingEdit, SIGNAL(returnPressed()), this, SLOT(searchingButton_clicked()));
	connect(helpNav->searchingButton, SIGNAL(clicked()), this, SLOT(searchingButton_clicked()));
	connect(helpNav->searchingView, SIGNAL(itemClicked( QTreeWidgetItem *, int)), this, SLOT(itemSearchSelected(QTreeWidgetItem *, int)));
	// bookmarks
	connect(helpNav->bookmarkButton, SIGNAL(clicked()), this, SLOT(bookmarkButton_clicked()));
	connect(helpNav->deleteBookmarkButton, SIGNAL(clicked()), this, SLOT(deleteBookmarkButton_clicked()));
	connect(helpNav->deleteAllBookmarkButton, SIGNAL(clicked()), this, SLOT(deleteAllBookmarkButton_clicked()));
	connect(helpNav->bookmarksView, SIGNAL(itemClicked( QTreeWidgetItem *, int)), this, SLOT(itemBookmarkSelected(QTreeWidgetItem *, int)));
	// links hoover
//	connect(textBrowser, SIGNAL(overLink(const QString &)), this, SLOT(showLinkContents(const QString &)));

	// status bar
//	connect(textBrowser,SIGNAL(statusBarMessage(QString)), this->statusBar(), SLOT(showMessage(QString)));
	
	languageChange();
}
예제 #23
0
HelpWindow::HelpWindow( const QString& home_, const QString& _path,
			QWidget* parent, const char *name )
    : QMainWindow( parent, name, WDestructiveClose ),
      pathCombo( 0 ), selectedURL()
{
    readHistory();
    readBookmarks();

    browser = new QTextBrowser( this );
    browser->mimeSourceFactory()->setFilePath( _path );
    browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
    connect( browser, SIGNAL( textChanged() ),
	     this, SLOT( textChanged() ) );

    setCentralWidget( browser );

    if ( !home_.isEmpty() )
	browser->setSource( home_ );

    connect( browser, SIGNAL( highlighted( const QString&) ),
	     statusBar(), SLOT( message( const QString&)) );

    resize( 640,700 );

    QPopupMenu* file = new QPopupMenu( this );
    file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N );
    file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O );
    file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P );

    // The same three icons are used twice each.
    QIconSet icon_back( QPixmap("textdrawing/previous.png") );
    QIconSet icon_forward( QPixmap("textdrawing/next.png") );
    QIconSet icon_home( QPixmap("textdrawing/home.png") );

    QPopupMenu* go = new QPopupMenu( this );
    backwardId = go->insertItem( icon_back,
				 tr("&Backward"), browser, SLOT( backward() ),
				 ALT | Key_Left );
    forwardId = go->insertItem( icon_forward,
				tr("&Forward"), browser, SLOT( forward() ),
				ALT | Key_Right );
    go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) );

    hist = new QPopupMenu( this );
    QStringList::Iterator it = history.begin();
    for ( ; it != history.end(); ++it )
	mHistory[ hist->insertItem( *it ) ] = *it;
    connect( hist, SIGNAL( activated( int ) ),
	     this, SLOT( histChosen( int ) ) );

    bookm = new QPopupMenu( this );
    bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
    bookm->insertSeparator();

    QStringList::Iterator it2 = bookmarks.begin();
    for ( ; it2 != bookmarks.end(); ++it2 )
	mBookmarks[ bookm->insertItem( *it2 ) ] = *it2;
    connect( bookm, SIGNAL( activated( int ) ),
	     this, SLOT( bookmChosen( int ) ) );

    menuBar()->insertItem( tr("&File"), file );
    menuBar()->insertItem( tr("&Go"), go );
    menuBar()->insertItem( tr( "History" ), hist );
    menuBar()->insertItem( tr( "Bookmarks" ), bookm );

    menuBar()->setItemEnabled( forwardId, FALSE);
    menuBar()->setItemEnabled( backwardId, FALSE);
    connect( browser, SIGNAL( backwardAvailable( bool ) ),
	     this, SLOT( setBackwardAvailable( bool ) ) );
    connect( browser, SIGNAL( forwardAvailable( bool ) ),
	     this, SLOT( setForwardAvailable( bool ) ) );


    QToolBar* toolbar = new QToolBar( this );
    addToolBar( toolbar, "Toolbar");
    QToolButton* button;

    button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar );
    connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
    button->setEnabled( FALSE );
    button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar );
    connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
    button->setEnabled( FALSE );
    button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar );

    toolbar->addSeparator();

    pathCombo = new QComboBox( TRUE, toolbar );
    connect( pathCombo, SIGNAL( activated( const QString & ) ),
	     this, SLOT( pathSelected( const QString & ) ) );
    toolbar->setStretchableWidget( pathCombo );
    setRightJustification( TRUE );
    setDockEnabled( DockLeft, FALSE );
    setDockEnabled( DockRight, FALSE );

    pathCombo->insertItem( home_ );

    browser->setFocus();
}
void LineFollower::turnLeft()
{
  int turnCounter=0;
  _motor2.setSpeed(200);
  _motor1.setSpeed(200);
  int i=1;
  int flag=0;
  
  while(digitalRead(sensorFL)==LOW)
    {
      _motor2.run(BACKWARD);
    }
  pause();
  _motor1.run(FORWARD);
  while(i==1)
  {
  if(digitalRead(sensorFR)==LOW && flag==0)
    flag=1;
  if(digitalRead(sensorFR)==HIGH && flag==1)
  {
    turnCounter++;
    Serial.println(turnCounter);
  }
  if(digitalRead(sensorFR)==LOW && flag==2)
  {
    pause();
    break;
  }
    
  if(turnCounter==50)
    flag=2;  
  }
  
  i=1;
  int MIDflag=0;
  int MIDcounter=0;
  
  while(i==1)
  {
    
  //Rover Reacts Based on the Reading of Each Sensor
  //These Conditions Were Placed Like Below Based On Their Priority
  
  if(digitalRead(sensorBL)==HIGH && digitalRead(sensorBR)==HIGH && digitalRead(sensorFR)==HIGH && digitalRead(sensorFL)==HIGH)
    forward();
  else if(digitalRead(sensorBL)==LOW && digitalRead(sensorBR)==LOW)  
    forward();
  else if(digitalRead(sensorFR)==LOW && digitalRead(sensorFL)==LOW)
  {
    backward();
    pause();
    //Count The Number of Grids & Print on Serial Monitor
    gridCounter++; 
    Serial.print("GRID#: ");
    Serial.println(gridCounter);
    break;
  }
  else if(digitalRead(sensorFR)==LOW && digitalRead(sensorBR)==LOW)
  {
   _motor1.run(RELEASE);      // turn it on go right
   _motor2.run(FORWARD);
  }
  else if(digitalRead(sensorFL)==LOW && digitalRead(sensorBL)==LOW)
  {
   _motor1.run(FORWARD);      // turn it on go left
   _motor2.run(RELEASE);
  }
  else if(digitalRead(sensorBL)==LOW)
    right();
  else if(digitalRead(sensorBR)==LOW)
    left();
  else if(digitalRead(sensorFR)==LOW)
    right();
  else if(digitalRead(sensorFL)==LOW)
    left();
  
  if(digitalRead(sensorBL)==HIGH && digitalRead(sensorBR)==HIGH)
    forward();
  if(digitalRead(sensorFL)==HIGH && digitalRead(sensorFR)==HIGH)
    forward();
  }
  delay(500);
}
예제 #25
0
 inline double apply  (IteratorIn in, IteratorOut out) const {
     if(I) return backward(in,out);
     else  return forward (in,out);
 }
void LineFollower::turnAround()
{
  int turning=1;
  _motor1.setSpeed(200);
  _motor2.setSpeed(200);
  int i=1;
  int flag=0;
  while(i==1)
  {
    left();
    if(digitalRead(sensorBR)==HIGH && flag==0)
      flag=1;
    if(digitalRead(sensorBR)==LOW && flag==1)
      flag=2;
    if(digitalRead(sensorBL)==LOW && flag==2)
      flag=3;
    if(((digitalRead(sensorBR)==HIGH && digitalRead(sensorBL)==HIGH) || (digitalRead(sensorFR)==HIGH && digitalRead(sensorFL)==HIGH))  && flag==3)
    {
      pause();
      turning=0;
      break;
     }
  }
  
  delay(300);
  int MIDflag=0;
  int MIDcounter=0;
  
  
  while(turning==0)
  {  
  //Rover Reacts Based on the Reading of Each Sensor
  //These Conditions Were Placed Like Below Based On Their Priority
  
  if(digitalRead(sensorBL)==HIGH && digitalRead(sensorBR)==HIGH && digitalRead(sensorFR)==HIGH && digitalRead(sensorFL)==HIGH)
    backward();
  else if(digitalRead(sensorBL)==LOW && digitalRead(sensorBR)==LOW)  
    backward();
  else if(digitalRead(sensorFR)==LOW && digitalRead(sensorFL)==LOW && MIDflag==0)
    backward();
  else if(digitalRead(sensorFR)==LOW && digitalRead(sensorBR)==LOW)
  {
   _motor1.run(RELEASE);      // turn it on go right
   _motor2.run(BACKWARD);
  }
  else if(digitalRead(sensorFL)==LOW && digitalRead(sensorBL)==LOW)
  {
   _motor1.run(BACKWARD);      // turn it on go left
   _motor2.run(RELEASE);
  }
  else if(digitalRead(sensorBL)==LOW)
    right();
  else if(digitalRead(sensorBR)==LOW)
    left();
  else if(digitalRead(sensorFR)==LOW)
    right();
  else if(digitalRead(sensorFL)==LOW)
    left();
  
  if(digitalRead(sensorBL)==HIGH && digitalRead(sensorBR)==HIGH)
    backward();
  if(digitalRead(sensorFL)==HIGH && digitalRead(sensorFR)==HIGH)
     backward();
  if(digitalRead(sensorBR)==LOW && digitalRead(sensorBL)==LOW && MIDflag==0)
  {
    backward();
    MIDflag=1;
  }
  if((digitalRead(sensorFR)==HIGH || digitalRead(sensorFL)==HIGH) && MIDflag==2)
    MIDcounter++;
  
  if(digitalRead(sensorFR)==LOW && digitalRead(sensorFL)==LOW && MIDflag==1)
  {
    backward();
    MIDcounter++;
  }
  if(MIDcounter==20 && MIDflag==1)
  {
    MIDflag=2;
    MIDcounter=0;
  }
  
  if(MIDcounter==150 && MIDflag==2)
  {
   forward();
   pause();
   MIDflag=3;
   MIDcounter=0;
   break;
  }
  
  }
  
  while(MIDflag==3)
  {
   if(digitalRead(sensorBL)==HIGH && digitalRead(sensorBR)==HIGH && digitalRead(sensorFR)==HIGH && digitalRead(sensorFL)==HIGH)
    forward();
  else if(digitalRead(sensorBL)==LOW && digitalRead(sensorBR)==LOW)  
    forward();
  else if(digitalRead(sensorFR)==LOW && digitalRead(sensorFL)==LOW)
    MIDcounter++;
  else if(digitalRead(sensorFR)==LOW && digitalRead(sensorBR)==LOW)
  {
   _motor1.run(RELEASE);      // turn it on go right
   _motor2.run(FORWARD);
  }
  else if(digitalRead(sensorFL)==LOW && digitalRead(sensorBL)==LOW)
  {
   _motor1.run(FORWARD);      // turn it on go left
   _motor2.run(RELEASE);
  }
  else if(digitalRead(sensorBL)==LOW)
    right();
  else if(digitalRead(sensorBR)==LOW)
    left();
  else if(digitalRead(sensorFR)==LOW)
    right();
  else if(digitalRead(sensorFL)==LOW)
    left();
  
  if(digitalRead(sensorBL)==HIGH && digitalRead(sensorBR)==HIGH)
    forward();
  //if(digitalRead(sensorFL)==HIGH && digitalRead(sensorFR)==HIGH)
  //  forward();
  if(MIDcounter==10)
  {
    backward();
    pause();
    //Count The Number of Grids & Print on Serial Monitor
    gridCounter++; 
    Serial.print("GRID#: ");
    Serial.println(gridCounter);
    break;
  }
  }
}
예제 #27
0
GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
{
    TRACE_OBJ

    // TODO: Put resource path in misc class
    QString resourcePath = QLatin1String(":/trolltech/assistant/images/");
#ifdef Q_OS_MAC
    resourcePath.append(QLatin1String("mac"));
#else
    resourcePath.append(QLatin1String("win"));
#endif
    CentralWidget *centralWidget = CentralWidget::instance();

    m_backAction = new QAction(tr("&Back"), parent);
    m_backAction->setEnabled(false);
    m_backAction->setShortcuts(QKeySequence::Back);
    m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png")));
    connect(m_backAction, SIGNAL(triggered()), centralWidget, SLOT(backward()));
    m_actionList << m_backAction;

    m_nextAction = new QAction(tr("&Forward"), parent);
    m_nextAction->setPriority(QAction::LowPriority);
    m_nextAction->setEnabled(false);
    m_nextAction->setShortcuts(QKeySequence::Forward);
    m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png")));
    connect(m_nextAction, SIGNAL(triggered()), centralWidget, SLOT(forward()));
    m_actionList << m_nextAction;

    setupNavigationMenus(m_backAction, m_nextAction, centralWidget);

    m_homeAction = new QAction(tr("&Home"), parent);
    m_homeAction->setShortcut(tr("ALT+Home"));
    m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png")));
    connect(m_homeAction, SIGNAL(triggered()), centralWidget, SLOT(home()));
    m_actionList << m_homeAction;

    QAction *separator = new QAction(parent);
    separator->setSeparator(true);
    m_actionList << separator;

    m_zoomInAction = new QAction(tr("Zoom &in"), parent);
    m_zoomInAction->setPriority(QAction::LowPriority);
    m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png")));
    m_zoomInAction->setShortcut(QKeySequence::ZoomIn);
    connect(m_zoomInAction, SIGNAL(triggered()), centralWidget, SLOT(zoomIn()));
    m_actionList << m_zoomInAction;

    m_zoomOutAction = new QAction(tr("Zoom &out"), parent);
    m_zoomOutAction->setPriority(QAction::LowPriority);
    m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png")));
    m_zoomOutAction->setShortcut(QKeySequence::ZoomOut);
    connect(m_zoomOutAction, SIGNAL(triggered()), centralWidget, SLOT(zoomOut()));
    m_actionList << m_zoomOutAction;

    separator = new QAction(parent);
    separator->setSeparator(true);
    m_actionList << separator;

    m_copyAction = new QAction(tr("&Copy selected Text"), parent);
    m_copyAction->setPriority(QAction::LowPriority);
    m_copyAction->setIconText("&Copy");
    m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png")));
    m_copyAction->setShortcuts(QKeySequence::Copy);
    m_copyAction->setEnabled(false);
    connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copy()));
    m_actionList << m_copyAction;

    m_printAction = new QAction(tr("&Print..."), parent);
    m_printAction->setPriority(QAction::LowPriority);
    m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png")));
    m_printAction->setShortcut(QKeySequence::Print);
    connect(m_printAction, SIGNAL(triggered()), centralWidget, SLOT(print()));
    m_actionList << m_printAction;

    m_findAction = new QAction(tr("&Find in Text..."), parent);
    m_findAction->setIconText(tr("&Find"));
    m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png")));
    m_findAction->setShortcuts(QKeySequence::Find);
    connect(m_findAction, SIGNAL(triggered()), centralWidget, SLOT(showTextSearch()));
    m_actionList << m_findAction;

#ifdef Q_WS_X11
    m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon()));
    m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon()));
    m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon()));
    m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out" , m_zoomOutAction->icon()));
    m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon()));
    m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon()));
    m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon()));
    m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon()));
#endif
}
예제 #28
0
int main() {
     
     
     printf("Online%\n\r");
     
     wait_ms(500);
     
     /*inturupts*/
     w1_cha.fall(&count_w1_a);
     w1_chb.fall(&count_w1_b);
     
     w2_cha.fall(&count_w2_a);
     w2_chb.fall(&count_w2_b);
    
     
    c_forward(); //sets the robot to go forward
  
     
    while(1) {
        
        s1_check = s1;
        s2_check = s2;
        s3_check = s3;
        //s4_check = s4;

         if(s1_check != 1)
         {
          printf("S1 Hit \n\r");
        
         }
         
         if(s2_check != 1)
         {
          printf("S2 Hit \n\r");
        
         }
         
         if(s3_check != 1)
         {
          printf("S3 Hit \n\r");
        
         }
         
        // if(s4_check != 1)
         //{
          //printf("S4 Hit \n\r");
        
         //}
        
         if (w1_count_a != w1_dif_a){
        
         w1_dif_a = w1_count_a;
        printf("w1 count a = %d\n\r", w1_dif_a);
        }

        if (w1_count_b != w1_dif_b){
         w1_dif_b = w1_count_b;
        printf("w1 count b = %d\n\r", w1_dif_b);
        }
        
        if (w2_count_a != w2_dif_a){
        
         w2_dif_a = w2_count_a;
        printf("w2 count a = %d\n\r", w2_dif_a);
        }

        if (w2_count_b != w2_dif_b){
         w2_dif_b = w2_count_b;
        printf("w2 count b = %d\n\r", w2_dif_b);
        }
        
        
        
        /*goes backwards if it hits a detects a wall*/
        if (s1 != 1 && s2 !=1)
        {
            backward();//to correct when aligning
            c_backward();
            
        }
        
        
        /*goes forwards when detecting the wall*/
        if (s3 != 1){ 
          c_forward();
           
            }
        
        /*tries to aligin with the wall*/
        if (s1 != 1 && s2 != 0)
        {
            while(s1 != 1 && s2 != 0){
            c_right();    
            }
            backward();
            //dir = 0;
            //c_backward();
            
        }
        
        /*tries to aligin with the wall*/
         if (s1 != 0 && s2 != 1)
        {
             while(s1 != 0 && s2 != 1){
            c_left();    
            }
            backward();
            //dir = 0;
            //c_backward();
        }
        
        /*if all sensors triggured tries to turn to escape*/
        if (s1 != 1 && s2 != 1 && s3 != 1)
        {
           turnl(); 
        }
        
        /*if no senors triggred tries to contiue on*/
       if (s1 != 0 && s2 != 0 && s3 != 0)
        {
           if (dir == 0){
               c_backward();
               }
            else{
                c_forward();
                }
        }
        
        
    }
}
예제 #29
0
void backwards(char **argv, int left, int right){
	int i = left;
	for(i;i<=right;i++){
		backward(argv[i],strlen(argv[i]));		
	}
}
예제 #30
0
 cube_p<real> backward( cube_p<complex>&& in )
 {
     cube_p<real> ret = get_cube<real>(sz);
     backward( *in, *ret );
     return ret;
 }