Example #1
0
ToolBoxWidget::ToolBoxWidget(QWidget *parent) :
    QDockWidget(parent),
    ui(new Ui::ToolBoxWidget)
{
    ui->setupUi(this);

    emptyPage = new QWidget; //index 0
    this-ui->stackedWidget->addWidget(emptyPage);
    createBlockW = new CreateBlockWidget; //index 1
    this->ui->stackedWidget->addWidget(createBlockW);
    moveVerticesW = new MoveVerticesWidget; //index 2
    this->ui->stackedWidget->addWidget(moveVerticesW);
    setBCsW = new SetBCsWidget; //index 3
    this->ui->stackedWidget->addWidget(setBCsW);
    edgePropsW = new EdgePropsWidget; //index 4
    this->ui->stackedWidget->addWidget(edgePropsW);
    this->ui->stackedWidget->setCurrentIndex(1);

    connect(createBlockW,SIGNAL(cancel()),this,SLOT(slotCancel()));
    connect(setBCsW,SIGNAL(done()),this,SLOT(slotCancel()));
    connect(moveVerticesW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(moveVerticesW,SIGNAL(moveDone()),this,SLOT(slotCancel()));
    connect(createBlockW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(setBCsW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(edgePropsW,SIGNAL(cancel()),this,SLOT(slotCancel()));
    connect(edgePropsW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));

}
Example #2
0
ItemContainer::ItemContainer(QPixmap &graph,State s,QWidget *parent)
    :width(300),height(300),state(s),level(state.N),
    pieceWidth(width/level),pieceHeight(height/level),
    picture(graph),paintoption(paintAll),QWidget(parent)
{
    resize(width,height);
    trimPicture();//trim the picture and save it to myPicture
    createPieces();//setup pieces
    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(updateArea()));
    connect(this,SIGNAL(moveDone()),this,SLOT(processNextMove()));//actually It could be done with invoking.
    setFocusPolicy(Qt::StrongFocus);
}
Example #3
0
ToolBoxWidget::ToolBoxWidget(QWidget *parent) :
    QDockWidget(parent),
    ui(new Ui::ToolBoxWidget)
{
    ui->setupUi(this);

    emptyPage = new QWidget; //index 0
    this-ui->stackedWidget->addWidget(emptyPage);
    createBlockW = new CreateBlockWidget; //index 1
    this->ui->stackedWidget->addWidget(createBlockW);
    moveVerticesW = new MoveVerticesWidget; //index 2
    this->ui->stackedWidget->addWidget(moveVerticesW);
    setBCsW = new SetBCsWidget; //index 3
    this->ui->stackedWidget->addWidget(setBCsW);
    edgePropsW = new EdgePropsWidget; //index 4
    this->ui->stackedWidget->addWidget(edgePropsW);
    edgeSetTypeW = new EdgeSetTypeWidget; //index 5;
    this->ui->stackedWidget->addWidget(edgeSetTypeW);
    rotateVerticesW = new RotateVerticesWidget; //index 6
    this->ui->stackedWidget->addWidget(rotateVerticesW);

    connect(createBlockW,SIGNAL(cancel()),this,SLOT(slotCancel()));
    connect(setBCsW,SIGNAL(done()),this,SLOT(slotCancel()));
    connect(moveVerticesW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(moveVerticesW,SIGNAL(moveDone()),this,SLOT(slotCancel()));
    connect(rotateVerticesW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(rotateVerticesW,SIGNAL(rotateDone()),this,SLOT(slotCancel()));
    connect(createBlockW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(setBCsW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(edgePropsW,SIGNAL(cancel()),this,SLOT(slotCancel()));
    connect(edgePropsW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(edgePropsW,SIGNAL(openSetTypeDialog(vtkIdType)),this,SLOT(slotOpenSetEdgeTypeDialog(vtkIdType)));

    connect(edgeSetTypeW,SIGNAL(setStatusText(QString)),this,SLOT(slotSetStatusText(QString)));
    connect(edgeSetTypeW,SIGNAL(apply()),this,SLOT(slotCloseSetEdgeTypeDialog()));


    this->ui->stackedWidget->setCurrentIndex(1);
}
Example #4
0
void ItemContainer::updateArea()
{
	const int totalnum = 20;
    static int count = totalnum;
	
    int dx = pieceWidth/totalnum;
    int dy = pieceHeight/totalnum;
    if(count == 0)
        return;
    switch(towards){
	case State::L:
        newX-=dx;
        repaint(updateRect);
        break;
    case State::R:
        newX+=dx;
        repaint(updateRect);
        break;
    case State::U:
        newY-=dy;
        repaint(updateRect);
        break;
    case State::D:
        newY+=dy;
        repaint(updateRect);
        break;
    }
    //repaint(updateRect);
    count--;
    if(count==0){
        count = totalnum;
        timer->stop();
		paintoption = paintAll;
		repaint();
        emit moveDone();
    }
}
Example #5
0
//This fuction process the message from list
void ItemContainer::moveToward(State::Way to)
{
    UINT8 opt = state.wayToGo();//the able way to move from the current state
    blankPos = state.id%10-1;//get the blank piece pos;
    int blankX = blankPos%level*pieceWidth;//get blank piece's x position
    int blankY = blankPos/level*pieceHeight;
    objPos = 0;
    switch(to){
    case State::L:
		if((opt&State::L)==0){
			moveMessageList.pop_front();
			return;
		}
        paintoption = pieceSlide;
        state.moveLeft();
        objPos = blankPos+1;
        currentPiece = &arrange[objPos];
        towards = State::L;
        newX = blankX+pieceWidth;
        newY = blankY;
        updateRect = QRect(blankX,blankY,pieceWidth*2,pieceHeight);
        timer->start(10);
        arrange.swap(blankPos,objPos);
        //paintoption = paintAll;
        break;
    case State::R:
		if((opt&State::R)==0){
			moveMessageList.pop_front();
			return;
		}
        paintoption = pieceSlide;
        state.moveRight();
        objPos = blankPos-1;
        currentPiece = &arrange[objPos];
        towards = State::R;
        newX = blankX-pieceWidth;
        newY = blankY;
        updateRect = QRect(newX,newY,pieceWidth*2,pieceHeight);
        timer->start(10);
        arrange.swap(blankPos,objPos);
        //paintoption = paintAll;
        break;
    case State::U:
		if((opt&State::U)==0){
			moveMessageList.pop_front();
			return;
		}
        paintoption = pieceSlide;
        state.moveUp();
        objPos = blankPos+level;
        currentPiece = &arrange[objPos];
        towards = State::U;
        newX = blankX;
        newY = blankY+pieceHeight;
        updateRect = QRect(blankX,blankY,pieceWidth,pieceHeight*2);
        timer->start(10);
        arrange.swap(blankPos,objPos);
        //paintoption = paintAll;
        break;
    case State::D:
		if((opt&State::D)==0){
			moveMessageList.pop_front();
			return;
		}
        paintoption = pieceSlide;
        state.moveDown();
        objPos = blankPos-level;
        currentPiece = &arrange[objPos];
        towards = State::D;
        newX = blankX;
        newY = blankY-pieceHeight;
        updateRect = QRect(newX,newY,pieceWidth,pieceHeight*2);
        timer->start(10);
        arrange.swap(blankPos,objPos);
        //paintoption = paintAll;
        break;
	case State::Z:
		//when we receive this state, it means the puzzle has accomplish
		emit moveDone();
		break;
    }

}