void ImageWidget::tallyMark(QMouseEvent *event)
{
    QPoint p;
    int pos[3];
    if (event->button()== Qt::LeftButton) {
        if (event->type() == event->MouseButtonPress) {
            p = event->pos();
            pos[0] = p.x();
            pos[1] = 480 - p.y();
            pos[2] = 0;
            if (event->modifiers() & Qt::ShiftModifier){
                printf("Detected a shift-L-button mouse press event at: %d %d\n",p.x(),p.y());
            } else {
                printf("Detected a L-button mouse press event at: %d %d\n",p.x(),p.y());
                AddNumber(pos);
            }
        }
        if (event->type() == event->MouseButtonRelease) {
            if(event->modifiers() & Qt::ShiftModifier){
                p = event->pos();
                printf("Detected a shift-L-button mouse release event at: %d %d\n",p.x(),p.y());
            }
        }
    }
    fflush(stdout);
}
Exemple #2
0
int IsPandigital(int number) {
   int multiplyer = 1, concatNumber[9], ndx, temp, tempSize;
   int numberSize = GetSize(number), sizeSum=0, concatNdx=0;
   int digitCheck[9];
   for(ndx=0;ndx<9;ndx++) {
      concatNumber[ndx] = 0;
      digitCheck[ndx] = 0;
   }
   while(sizeSum<10) { 
      temp = number*multiplyer;
      tempSize = GetSize(temp);
      sizeSum += tempSize;
      concatNdx = AddNumber(temp, tempSize, concatNdx, concatNumber);
      multiplyer++;
   }
   for(ndx=0;ndx<9;ndx++) {
      digitCheck[(concatNumber[ndx]-1)]++;
   }  
   for(ndx=0;ndx<9;ndx++) {
      if(digitCheck[ndx] != 1)
         return 0;
   } 

   return GetNumber(concatNumber);
}
Exemple #3
0
void LoadPuzzle() {
	int a, b;
	char temp[20];
	for (a = 0; a < 16; a++) {
		scanf("%s", temp);
		for (b = 0; b < 16; b++) {
			char c = temp[b];
			if (c >= 'A' && c <= 'P') {
				AddNumber((c - 'A'), a, b);
			}
		}
	}
}
void PointSelectionStyle2D::OnLeftButtonDown() 
{
  //std::cout << "Picking pixel: " << this->Interactor->GetEventPosition()[0] << " " << this->Interactor->GetEventPosition()[1] << std::endl;
  this->Interactor->GetPicker()->Pick(this->Interactor->GetEventPosition()[0], 
		      this->Interactor->GetEventPosition()[1], 
		      0,  // always zero.
                      this->CurrentRenderer);

  double picked[3];
  this->Interactor->GetPicker()->GetPickPosition(picked);
  //std::cout << "Picked point with coordinate: " << picked[0] << " " << picked[1] << " " << picked[2] << std::endl;

  AddNumber(picked);
 
  // Forward events
  vtkInteractorStyleImage::OnLeftButtonDown();
}
void LoadPuzzle() {
	int a, b;
	char temp;
	//FILE * a_file = fopen(FileName, "r");

	/*if (a_file == NULL) {
		printf("File load fail!\n");
		return;
	}*/

	//fscanf(a_file, "%d", &testCase);
	for (a = 0; a < 9; a++) {
		for (b = 0; b < 9; b++) {
			if (!scanf("%c\n", &temp)) {
				printf("File loading error!\n");
				return;
			}
			if (temp >= '1'&&temp <= '9')
				AddNumber((temp - '0') - 1, a, b);
		}
	}
}
Exemple #6
0
static int ReadCommands(CurPos &cp, const char *Name) {
    STARTFUNC("ReadCommands");
    LOG << "Name = " << (Name != NULL ? Name : "(null)") << ENDLINE;

    unsigned char obj;
    unsigned short len;
    long Cmd = NewCommand(Name);
    long cmdno;

    if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1);
    if (GetNum(cp, cmdno) == 0) ENDFUNCRC(-1);
    if (cmdno != (Cmd | CMD_EXT)) {
        fprintf(stderr, "Bad Command map %s -> %ld != %ld\n", Name, Cmd, cmdno);
        ENDFUNCRC(-1);
    }

    while ((obj = GetObj(cp, len)) != 0xFF) {
        switch (obj) {
        case CF_COMMAND:
            {
                //              char *s;
                long cnt;
                long ign;
                long cmd;

                //                if ((s = GetCharStr(cp, len)) == 0) return -1;
                if (GetNum(cp, cmd) == 0) ENDFUNCRC(-1);
                if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1);
                if (GetNum(cp, cnt) == 0) ENDFUNCRC(-1);
                if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1);
                if (GetNum(cp, ign) == 0) ENDFUNCRC(-1);

                //                if (cmd != CmdNum(s)) {
                //                    fprintf(stderr, "Bad Command Id: %s -> %d\n", s, cmd);
                //                    return -1;
                //                }

                if (AddCommand(Cmd, cmd, cnt, ign) == 0) {
                    if (Name == 0 || strcmp(Name, "xx") != 0) {
                        fprintf(stderr, "Bad Command Id: %ld\n", cmd);
                        ENDFUNCRC(-1);
                    }
                }
            }
            break;
        case CF_STRING:
            {
                const char *s = GetCharStr(cp, len);

                if (s == 0) ENDFUNCRC(-1);
                if (AddString(Cmd, s) == 0) ENDFUNCRC(-1);
            }
            break;
        case CF_INT:
            {
                long num;

                if (GetNum(cp, num) == 0) ENDFUNCRC(-1);
                if (AddNumber(Cmd, num) == 0) ENDFUNCRC(-1);
            }
            break;
        case CF_VARIABLE:
            {
                long num;

                if (GetNum(cp, num) == 0) ENDFUNCRC(-1);
                if (AddVariable(Cmd, num) == 0) ENDFUNCRC(-1);
            }
            break;
        case CF_CONCAT:
            if (AddConcat(Cmd) == 0) ENDFUNCRC(-1);
            break;
        case CF_END:
            ENDFUNCRC(Cmd);
        default:
            ENDFUNCRC(-1);
        }
    }
    ENDFUNCRC(-1);
}