void Canvas::addRubber() { if (!d->wrapItem) { d->wrapItem = new ClickDragReleaseItem(d->canvasItem); } d->wrapItem->setFocus(); setFocus(); connect(d->wrapItem, SIGNAL(started(QPointF)), this, SLOT(slotAddItemStarted(QPointF))); connect(d->wrapItem, SIGNAL(moving(QRectF)), this, SLOT(slotAddItemMoving(QRectF))); connect(d->wrapItem, SIGNAL(finished(QRectF)), this, SLOT(slotAddItemFinished(QRectF))); connect(d->wrapItem, SIGNAL(cancelled()), this, SLOT(cancelAddItem())); }
int main (int argc, char **argv) { if (argc == 2) { fp = fopen (argv[1], "r"); init_pathblock (); } alexsdl_init (WIDTH, HEIGHT, SDL_HWSURFACE | SDL_DOUBLEBUF); run_inits (); while (1) { process_input (); SDL_FillRect (screen, NULL, 0x000000); selecting (); moving (); draw (); SDL_Flip (screen); } return (0); }
void Player::handPosZDistance() { float distance_z = LEAPHANDS.GetHandCenterPos().z - before_hand_pos.z; // 手のz軸に対しての移動量が満たなかった場合はじく if (distance_z < dash_range) return; ci::Vec3f hand_distance = before_hand_pos - LEAPHANDS.GetHandCenterPos(); float distance = std::sqrtf((hand_distance.x * hand_distance.x) + (hand_distance.y * hand_distance.y) + (hand_distance.z * hand_distance.z)); if (distance < dash_range * 2.0f) return; if (!isAttacking()) return; ci::Vec2f dash_move = before_hand_pos.xy() - LEAPHANDS.GetHandCenterPos().xy(); (dash_move).normalize(); moving(transform.position.xy() + dash_move * 10000.0f); }
void move_dir(player_circle& play_circ, const float delta_dist) { sf::Vector2f move{0.0f, 0.0f}; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) { move.y -= delta_dist; } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) { move.y += delta_dist; } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) { move.x += delta_dist; } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) { move.x -= delta_dist; } moving(play_circ, move); }
void sched (Info * info) { //mylogfd (SCHFD, "%d\n", info->state); // if (!info->video_info->is_valid) return; // mylogfd(SCHFD, "%d %d\n", IsEdgeValid(info), getEdgeX(info)); // mylogfd(SCHFD, "IsDoorSeen %d IsDoorAllSeen %d IsDoorLeft %d IsDoorRight %d IsDoorMiddle %d DoorMidX %d DoorMidY %d\n", // IsDoorSeen(info), IsDoorAllSeen(info), IsDoorLeft(info), IsDoorRight(info), IsDoorMiddle(info), getDoorMidx(info), getDoorMidy(info)); /*static int wait_edge = -1; if (wait_edge >= 0) { wait_edge ++; if (wait_edge >= 5) { mylogfd(SCHFD, "Touch edges->Stop\n"); do_stop(info); wait_edge = -1; } return; }*/ // mylogfd(SCHFD, "IsDoorSeen:%d IsEdgeValid:%d IsOutSide:%d edgeX %d\n", IsDoorAllSeen(info), IsEdgeValid(info), IsOutSide(info), getEdgeX(info)); estimate_seen_state(info); // mylogfd(SCHFD, "IsRobotSeen %d RobotX %d RobotY %d\n", IsRobotSeen(info), getRobotX(info), getRobotY(info)); if (info->last_cmd == CMD_FORWARD && info->state != SHOOTING && IsOutSide(info)) { mylogfd(SCHFD, "Outside\n"); info->last_cmd = CMD_STOP; do_stop(info); info->state = OUTSIDE; return; } /* if (info->last_cmd == CMD_FORWARD && IsOutSide(info) && IsEdgeValid(info)) { if (getEdgeX(info) < 50 && getEdgeX(info) >= 0) { mylogfd(SCHFD, "Touch edges %d\n", getEdgeX(info)); do_stop(info); info->state = DONE; //wait_edge = 0; return; } }*/ /* if (info->last_cmd == CMD_FORWARD && IsRobotSeen(info)) { if (IsRobotAcc(info)) { if (getRobotY(info) < 30) { do_stop(info); info->state = SEARCH_BALL; } else if (getRobotY(info) < 60) { info->destP.x = 0; info->destP.y = getRobotY(info) + 50; info->obstacle[0].x = getRobotY(info); info->obstacle[0].y = - getRobotX(info); do_obstacle(info); info->state = OBSTACLE; } } }*/ //mylogfd(-1, "s"); switch (info->state) { case START: //chang in state machine -- redwalker start(info); case FIND_PLACE: // find_place(info); break; case SEARCH_BALL: search_ball(info); break; case SEARCHING_BALL: searching_ball(info); break; case SEARCHING_ADJUST: searching_adjust(info); break; case FORWARDING_BALL: forwarding_ball(info); break; case CATCHING_BALL: catching_ball(info); break; case BALL_CATCHED: ball_catched(info); break; case SHOOT: shoot(info); break; case SHOOTING: shooting(info); break; case MOVING: moving(info); break; case CHANGE_PLACE: change_place(info); break; case FINDING_DIR: finding_dir(info); break; case CHANGING_PLACE: changing_place(info); break; case OBSTACLE: obstacle(info); break; case PROTECT_DOOR: protect_door(info); break; case OUTSIDE: if (!IsOutSide(info)) { mylogfd(SCHFD, "Inside restart to search_ball\n"); info->state = SEARCH_BALL; } break; case FACE_DOOR: face_door(info); break; case DONE: break; case GAME: //game(info); break; case SHOOTED: shooted(info); default : break; } }
// slot je zavolany (zvatsa rucne) ked ma aktualny hrac tahat // jeho ulohou je tah vykonat a o tahu signalizovat signalom moving(int, int) void Player::processMove(int arrX, int arrY) { // obycajny hrac proste hodi krizik na miesto emit moving(arrX, arrY, this); }
void tetDecompositionEngineMesh::move() { scalar deltaZ = engineDB_.pistonDisplacement().value(); Info<< "deltaZ = " << deltaZ << endl; // Position of the top of the static mesh layers above the piston scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value(); pointField newPoints = points(); tetPolyMesh tetMesh(*this); // Select the set of boundary condition types. For symmetry planes // and wedge boundaries, the slip condition should be used; // otherwise, use the fixedValue wordList boundaryTypes ( boundary().size(), fixedValueTetPolyPatchScalarField::typeName ); forAll (boundary(), patchI) { if ( isType<symmetryFvPatch>(boundary()[patchI]) || isType<wedgeFvPatch>(boundary()[patchI]) || isType<emptyFvPatch>(boundary()[patchI]) ) { boundaryTypes[patchI] = slipTetPolyPatchScalarField::typeName; } } tetPointScalarField motionUz ( IOobject ( "motionUz", engineDB_.timeName(), engineDB_, IOobject::NO_READ, IOobject::NO_WRITE ), tetMesh, dimensionedScalar("0", dimLength, 0), boundaryTypes ); motionUz.boundaryField()[pistonIndex_] == deltaZ; { scalarField linerPoints = motionUz.boundaryField()[linerIndex_].patch() .localPoints().component(vector::Z); motionUz.boundaryField()[linerIndex_] == deltaZ*pos(deckHeight_.value() - linerPoints) *(deckHeight_.value() - linerPoints) /(deckHeight_.value() - pistonPlusLayers); } elementScalarField diffusion ( IOobject ( "motionDiffusion", engineDB_.timeName(), engineDB_, IOobject::NO_READ, IOobject::NO_WRITE ), tetMesh, dimensionedScalar("d", dimless, 1.0) ); const fvPatchList& patches = boundary(); forAll (patches, patchI) { const unallocLabelList& fc = patches[patchI].faceCells(); forAll (fc, fcI) { diffusion[fc[fcI]] = 2; } } solve(tetFem::laplacian(diffusion, motionUz)); newPoints.replace ( vector::Z, newPoints.component(vector::Z) + scalarField::subField ( motionUz.internalField(), newPoints.size() ) ); if (engineDB_.foundObject<surfaceScalarField>("phi")) { surfaceScalarField& phi = const_cast<surfaceScalarField&> (engineDB_.lookupObject<surfaceScalarField>("phi")); const volScalarField& rho = engineDB_.lookupObject<volScalarField>("rho"); const volVectorField& U = engineDB_.lookupObject<volVectorField>("U"); bool absolutePhi = false; if (moving()) { phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U); absolutePhi = true; } movePoints(newPoints); if (absolutePhi) { phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U); } } pistonPosition_.value() += deltaZ; scalar pistonSpeed = deltaZ/engineDB_.deltaT().value(); Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl << "Piston speed = " << pistonSpeed << " m/s" << endl; }
UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) : QObject(parent) , mTransparentDrawingView(0) , mTransparentDrawingScene(0) , mDesktopPalette(NULL) , mDesktopPenPalette(NULL) , mDesktopMarkerPalette(NULL) , mDesktopEraserPalette(NULL) , mWindowPositionInitialized(0) , mIsFullyTransparent(false) , mDesktopToolsPalettePositioned(false) , mPendingPenButtonPressed(false) , mPendingMarkerButtonPressed(false) , mPendingEraserButtonPressed(false) , mbArrowClicked(false) , mBoardStylusTool(UBDrawingController::drawingController()->stylusTool()) , mDesktopStylusTool(UBDrawingController::drawingController()->stylusTool()) { mTransparentDrawingView = new UBBoardView(UBApplication::boardController, 0); // deleted in UBDesktopAnnotationController::destructor mTransparentDrawingView->setAttribute(Qt::WA_TranslucentBackground, true); // !!!! Should be included into Windows after QT recompilation #ifdef Q_WS_MAC mTransparentDrawingView->setAttribute(Qt::WA_MacNoShadow, true); #endif mTransparentDrawingView->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Window); mTransparentDrawingView->setCacheMode(QGraphicsView::CacheNone); mTransparentDrawingView->resize(UBApplication::desktop()->width(), UBApplication::desktop()->height()); mTransparentDrawingView->setMouseTracking(true); mTransparentDrawingView->setAcceptDrops(true); QString backgroundStyle = "QWidget {background-color: rgba(127, 127, 127, 0)}"; mTransparentDrawingView->setStyleSheet(backgroundStyle); mTransparentDrawingScene = new UBGraphicsScene(0); mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingScene->setDrawingMode(true); mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView); if (UBPlatformUtils::hasVirtualKeyboard()) { connect( UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); #ifdef Q_WS_X11 connect(UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask())); connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(refreshMask())); connect(mDesktopPalette,SIGNAL(refreshMask()), this, SLOT(refreshMask())); #endif } connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(customCapture())); connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(windowCapture())); connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(screenCapture())); connect(mDesktopPalette, SIGNAL(maximized()), this, SLOT(onDesktopPaletteMaximized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize())); connect(mTransparentDrawingView, SIGNAL(resized(QResizeEvent*)), this, SLOT(onTransparentWidgetResized())); connect(UBDrawingController::drawingController(), SIGNAL(stylusToolChanged(int)) , this, SLOT(stylusToolChanged(int))); // Add the desktop associated palettes mDesktopPenPalette = new UBDesktopPenPalette(mTransparentDrawingView); connect(mDesktopPalette, SIGNAL(maximized()), mDesktopPenPalette, SLOT(onParentMaximized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), mDesktopPenPalette, SLOT(onParentMinimized())); mDesktopMarkerPalette = new UBDesktopMarkerPalette(mTransparentDrawingView); mDesktopEraserPalette = new UBDesktopEraserPalette(mTransparentDrawingView); mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopPenPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopMarkerPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopEraserPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); // Hack : the size of the property palettes is computed the first time the palette is visible // In order to prevent palette overlap on if the desktop palette is on the right of the // screen, a setVisible(true) followed by a setVisible(false) is done. mDesktopPenPalette->setVisible(true); mDesktopMarkerPalette->setVisible(true); mDesktopEraserPalette->setVisible(true); mDesktopPenPalette->setVisible(false); mDesktopMarkerPalette->setVisible(false); mDesktopEraserPalette->setVisible(false); connect(UBApplication::mainWindow->actionEraseDesktopAnnotations, SIGNAL(triggered()), this, SLOT(eraseDesktopAnnotations())); connect(&mHoldTimerPen, SIGNAL(timeout()), this, SLOT(penActionReleased())); connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased())); connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased())); #ifdef Q_WS_X11 connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask())); // connect(mRightPalette, SIGNAL(resized()), this, SLOT(refreshMask())); connect(UBApplication::boardController->paletteManager()->rightPalette(), SIGNAL(resized()), this, SLOT(refreshMask())); #endif onDesktopPaletteMaximized(); }
Foam::fvMesh::fvMesh(const IOobject& io) : polyMesh(io), surfaceInterpolation(*this), fvSchemes(static_cast<const objectRegistry&>(*this)), fvSolution(static_cast<const objectRegistry&>(*this)), data(static_cast<const objectRegistry&>(*this)), boundary_(*this, boundaryMesh()), lduPtr_(NULL), curTimeIndex_(time().timeIndex()), VPtr_(NULL), V0Ptr_(NULL), V00Ptr_(NULL), SfPtr_(NULL), magSfPtr_(NULL), CPtr_(NULL), CfPtr_(NULL), phiPtr_(NULL) { if (debug) { Info<< "Constructing fvMesh from IOobject" << endl; } // Check the existance of the cell volumes and read if present // and set the storage of V00 if (isFile(time().timePath()/"V0")) { V0Ptr_ = new DimensionedField<scalar, volMesh> ( IOobject ( "V0", time().timeName(), *this, IOobject::MUST_READ, IOobject::NO_WRITE, false ), *this ); V00(); } // Check the existance of the mesh fluxes, read if present and set the // mesh to be moving if (isFile(time().timePath()/"meshPhi")) { phiPtr_ = new surfaceScalarField ( IOobject ( "meshPhi", time().timeName(), *this, IOobject::MUST_READ, IOobject::NO_WRITE, false ), *this ); // The mesh is now considered moving so the old-time cell volumes // will be required for the time derivatives so if they haven't been // read initialise to the current cell volumes if (!V0Ptr_) { V0Ptr_ = new DimensionedField<scalar, volMesh> ( IOobject ( "V0", time().timeName(), *this, IOobject::NO_READ, IOobject::NO_WRITE, false ), V() ); } moving(true); } }
void GcWindow::mouseMoveEvent(QMouseEvent *e) { if (!resizable()) return; if (dragState == None) { // set the cursor shape setCursorShape(spotHotSpot(e)); return; } // work out the relative move x and y int relx = mapFromGlobal(QCursor::pos()).x() - mX; int rely = mapFromGlobal(QCursor::pos()).y() - mY; switch (dragState) { default: case Move : //move(oX + relx, oY + rely); #if QT_VERSION < 0x040700 setCursor(Qt::ClosedHandCursor); #else setCursor(Qt::DragMoveCursor); #endif emit moving(this); break; case TLCorner : { int newWidth = oWidth - relx; int newHeight = oHeight - rely; // need to move and resize if (newWidth > 30 && newHeight > 30) { move(oX + relx, oY + rely); setNewSize(newWidth, newHeight); emit resizing(this); } } break; case TRCorner : { int newWidth = oWidth + relx; int newHeight = oHeight - rely; // need to move and resize if changes on y plane if (newWidth > 30 && newHeight > 30) { move(oX, oY + rely); setNewSize(newWidth, newHeight); emit resizing(this); } } break; case BLCorner : { int newWidth = oWidth - relx; int newHeight = oHeight + rely; // need to move and resize if (newWidth > 30 && newHeight > 30) { move(oX + relx, oY); setNewSize(newWidth, newHeight); emit resizing(this); } } break; case BRCorner : { int newWidth = oWidth + relx; int newHeight = oHeight + rely; // need to move and resize if (newWidth > 30 && newHeight > 30) { setNewSize(newWidth, newHeight); emit resizing(this); } } break; case Top : { int newHeight = oHeight - rely; // need to move and resize if (newHeight > 30) { move (oX, oY + rely); setNewSize(oWidth, newHeight); emit resizing(this); } } break; case Bottom : { int newHeight = oHeight + rely; // need to move and resize if (newHeight > 30) { setNewSize(oWidth, newHeight); emit resizing(this); } } break; case Left : { int newWidth = oWidth - relx; // need to move and resize if (newWidth > 30) { move (oX + relx, oY); setNewSize(newWidth, oHeight); emit resizing(this); } } break; case Right : { int newWidth = oWidth + relx; // need to move and resize if (newWidth > 30) { setNewSize(newWidth, oHeight); emit resizing(this); } } break; } oX = pos().x(); oY = pos().y(); //repaint(); //QApplication::processEvents(); // flicker... }
int main (int argc, char **argv) { int i; double now; feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW); init_sdl_gl_flags (WIDTH, HEIGHT, 0); srandom (time (NULL)); init_gl (&argc, argv); glEnable (GL_LIGHTING); glEnable (GL_DEPTH_TEST); glEnable (GL_AUTO_NORMAL); glEnable (GL_NORMALIZE); glClearDepth (1); glViewport (0, 0, WIDTH, HEIGHT); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective (60, (GLfloat) WIDTH/(GLfloat) HEIGHT, .1, 1000); glClearColor (0, 0, 0, 0); glMatrixMode (GL_MODELVIEW); SDL_ShowCursor (1); makeImages (); glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glGenTextures (1, texName); makeTexture (texName[0], groundtexture.texturesize, (GLubyte ***) groundtexture.tex); glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glBlendFunc (GL_SRC_ALPHA, GL_ONE); gndcounter = 1; read_terrain (); player.p.x = 0; player.p.y = 0; player.p.z = ground_height (&player.p); player.loc = detect_plane (&player.p); player.movtype = GROUNDED; player.speed = 100; player.mass = 1; vset (&player.vel, 0, 0, 0); player.turnspeed = DTOR (180); player.theta = DTOR (0); player.camdist = 15; player.lasttime = get_secs (); player.moving = NO; playercamera.phi = DTOR (0); playercamera.theta_difference = 0; while (1) { process_input (); if (mousebutton[1] == 0 && mousebutton[2] == 0 && mousebutton[3] == 0) { SDL_ShowCursor (1); } else { SDL_ShowCursor (0); } movement (); if (paused == NO) { for (i = 0; i < 1; i++) { moving (); now = get_secs (); player.lasttime = now; } } process_mouse (); draw (); now = get_secs (); player.lasttime = now; SDL_Delay (10); } return (0); }
void Volleyball::checkActions() { moving(); moveBall(); setPupils(); }
void zombie::move() { last_pos = pos; if(chasing) { chase(); } else { int new_pos_x[4],new_pos_y[4]; if(pos.x!=0) { new_pos_x[0]=pos.x-1; new_pos_y[0]=pos.y; } else { new_pos_x[0]=-1; new_pos_y[0]=-1; } if(pos.x!=X-1) { new_pos_x[2]=pos.x+1; new_pos_y[2]=pos.y; } else { new_pos_x[2]=-1; new_pos_y[2]=-1; } if(pos.y!=0) { new_pos_x[3]=pos.x; new_pos_y[3]=pos.y-1; } else { new_pos_x[3]=-1; new_pos_y[3]=-1; } if(pos.y!=X-1) { new_pos_x[1]=pos.x; new_pos_y[1]=pos.y+1; } else { new_pos_x[1]=-1; new_pos_y[1]=-1; } int decision = decide( (new_pos_x[0]!=-1 && new_pos_y[0]!=-1)?1.0:0 ,(new_pos_x[1]!=-1 && new_pos_y[1]!=-1)?1.0:0,(new_pos_x[2]!=-1 && new_pos_y[2]!=-1)?1.0:0,(new_pos_x[3]!=-1 && new_pos_y[3]!=-1)?1.0:0); switch(decision) { case 0:moving(*it_zombie,grid[pos.x-1][pos.y]); break; case 1:moving(*it_zombie,grid[pos.x][pos.y-1]); break; case 2:moving(*it_zombie,grid[pos.x+1][pos.y]); break; case 3:moving(*it_zombie,grid[pos.x][pos.y+1]); break; } } }
void acting(ground& earth, square& another) { moving(earth, another); shooting(another); }
/*! \class RWidgetResizer Create a new RReportWidget resize manager. A resize manager show 8 circle on widget that user can drag them to resize the widget */ QReportWidgetResizer::QReportWidgetResizer(QGraphicsScene *parent) : QObject(), parentScene(parent), //_parent( 0 ), m_scale(1) { resizerTL = new QReportResizeHandle(0, 0, CIRCLER); resizerT = new QReportResizeHandle(0, 0, CIRCLER); resizerTR = new QReportResizeHandle(0, 0, CIRCLER); resizerL = new QReportResizeHandle(0, 0, CIRCLER); resizerR = new QReportResizeHandle(0, 0, CIRCLER); resizerBL = new QReportResizeHandle(0, 0, CIRCLER); resizerB = new QReportResizeHandle(0, 0, CIRCLER); resizerBR = new QReportResizeHandle(0, 0, CIRCLER); /*parent->addItem( resizerTL ); parent->addItem( resizerT ); parent->addItem( resizerTR ); parent->addItem( resizerL ); parent->addItem( resizerR ); parent->addItem( resizerBL ); parent->addItem( resizerB ); parent->addItem( resizerBR );*/ handles.append(resizerTL); handles.append(resizerT); handles.append(resizerTR); handles.append(resizerL); handles.append(resizerR); handles.append(resizerBL); handles.append(resizerB); handles.append(resizerBR); resizerTL->setPen(QPen(Qt::black)); setVisible(false); resizerTL->setCursor(Qt::SizeFDiagCursor); resizerT->setCursor(Qt::SizeVerCursor); resizerTR->setCursor(Qt::SizeBDiagCursor); resizerL->setCursor(Qt::SizeHorCursor); resizerR->setCursor(Qt::SizeHorCursor); resizerBL->setCursor(Qt::SizeBDiagCursor); resizerB->setCursor(Qt::SizeVerCursor); resizerBR->setCursor(Qt::SizeFDiagCursor); resizerT->setResizeDirection(::Top); resizerL->setResizeDirection(::Left); resizerR->setResizeDirection(::Right); resizerB->setResizeDirection(::Bottom); resizerTR->setResizeDirection(::Top | ::Right); resizerTL->setResizeDirection(::Top | ::Left); resizerBR->setResizeDirection(::Bottom | ::Right); resizerBL->setResizeDirection(::Bottom | ::Left); for (int i = 0; i < handles.count(); i++) { /*QRadialGradient gradient( CIRCLER, CIRCLER, 270); gradient.setColorAt(0, QColor::fromRgb(128, 128, 255) ); gradient.setColorAt(1, QColor::fromRgb(255, 255, 255) ); handles.at( i )->setBrush( QBrush(gradient) );*/ handles.at(i)->setBrush(QBrush(Qt::white)); parent->addItem(handles.at(i)); connect(handles.at(i), SIGNAL(moving(QPointF)), this, SLOT(handleMoving(QPointF))); connect(handles.at(i), SIGNAL(moved()), this, SIGNAL(resized())); }//for }
QVariant SizeAnchor::itemChange (GraphicsItemChange change, const QVariant &value) { if (change==ItemPositionHasChanged) emit moving(); return QGraphicsItem::itemChange(change, value); }
void fvMotionSolverEngineMesh::move() { scalar deltaZ = engineDB_.pistonDisplacement().value(); Info<< "deltaZ = " << deltaZ << endl; // Position of the top of the static mesh layers above the piston scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value(); motionSolver_.cellMotionU().boundaryField()[pistonIndex_] == deltaZ; { scalarField linerPoints = motionSolver_.cellMotionU() .boundaryField()[linerIndex_].patch().Cf().component(vector::Z); motionSolver_.cellMotionU().boundaryField()[linerIndex_] == deltaZ*pos(deckHeight_.value() - linerPoints) *(deckHeight_.value() - linerPoints) /(deckHeight_.value() - pistonPlusLayers); } motionSolver_.solve(); if (engineDB_.foundObject<surfaceScalarField>("phi")) { surfaceScalarField& phi = const_cast<surfaceScalarField&> (engineDB_.lookupObject<surfaceScalarField>("phi")); const volScalarField& rho = engineDB_.lookupObject<volScalarField>("rho"); const volVectorField& U = engineDB_.lookupObject<volVectorField>("U"); bool absolutePhi = false; if (moving()) { phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U); absolutePhi = true; } movePoints(motionSolver_.curPoints()); if (absolutePhi) { phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U); } } else { movePoints(motionSolver_.curPoints()); } pistonPosition_.value() += deltaZ; scalar pistonSpeed = deltaZ/engineDB_.deltaT().value(); Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl << "Piston speed = " << pistonSpeed << " m/s" << endl; }
/******************************************************************************** Hero Update ********************************************************************************/ void CPlayerInfo::HeroUpdate(float timeDiff, CAIManager* ai_manager, GameObjectFactory* go_manager, CMap* map, Sound UpdateSound) { if(currentState != DYING) { // Update Hero's info switch(currentState) { case CPlayerInfo::KNOCKED_BACKING: { moving(timeDiff, map); } break; case CPlayerInfo::ATTACKING: { Attacking(timeDiff, ai_manager, go_manager, UpdateSound); } break; default: { Vector3 HeroPrevPos = theHeroPosition; moving(timeDiff, map); if(currentState == MOVING) { moveAnimation(timeDiff, HeroPrevPos); } } break; } if(currentState == NIL) { if(theHeroCurrentPosNode->posType != 0 && theHeroCurrentPosNode->posType < CPosNode::TOTAL_ACTIVE_GO) { if(CheckCollisionCurrent()) { CollisionResponseCurrent(); } } } // Flicker hero when got damaged if(justGotDamged) { if(timeElasped < 1.f) { timeElasped += timeDiff; if(unrenderOrRenderTimeLeft < 0.02f) { unrenderOrRenderTimeLeft += timeDiff; } else { unrenderOrRenderTimeLeft = 0.f; if(RenderHero) { RenderHero = false; } else { RenderHero = true; } } } else { timeElasped = 0.f; unrenderOrRenderTimeLeft = 0.f; justGotDamged = false; RenderHero = true; } } } else { // Death animation if(timeElasped < 2.f) { if(theHeroCurrentPosNode->posType == CPosNode::HOLE) { holeDropScale -= timeDiff; if(holeDropScale < 0.1) holeDropScale = 0.1; } timeElasped += timeDiff; heroAnimationCounter += 20 * timeDiff; if(heroAnimationCounter > 5.0f) heroAnimationCounter = 5.0f; } } }
bool Foam::rawTopoChangerFvMesh::update() { // Do mesh changes (use inflation - put new points in topoChangeMap) Info<< "rawTopoChangerFvMesh : Checking for topology changes..." << endl; // Mesh not moved/changed yet moving(false); topoChanging(false); // Do any topology changes. Sets topoChanging (through polyTopoChange) autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(true); bool hasChanged = topoChangeMap.valid(); if (hasChanged) { Info<< "rawTopoChangerFvMesh : Done topology changes..." << endl; // Temporary: fix fields on patch faces created out of nothing // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Two situations: // - internal faces inflated out of nothing // - patch faces created out of previously internal faces // Is face mapped in any way? PackedBoolList mappedFace(nFaces()); const label nOldInternal = topoChangeMap().oldPatchStarts()[0]; const labelList& faceMap = topoChangeMap().faceMap(); for (label facei = 0; facei < nInternalFaces(); facei++) { if (faceMap[facei] >= 0) { mappedFace[facei] = 1; } } for (label facei = nInternalFaces(); facei < nFaces(); facei++) { if (faceMap[facei] >= 0 && faceMap[facei] >= nOldInternal) { mappedFace[facei] = 1; } } const List<objectMap>& fromFaces = topoChangeMap().facesFromFacesMap(); forAll(fromFaces, i) { mappedFace[fromFaces[i].index()] = 1; } const List<objectMap>& fromEdges = topoChangeMap().facesFromEdgesMap(); forAll(fromEdges, i) { mappedFace[fromEdges[i].index()] = 1; } const List<objectMap>& fromPts = topoChangeMap().facesFromPointsMap(); forAll(fromPts, i) { mappedFace[fromPts[i].index()] = 1; } // Set unmapped faces to zero Info<< "rawTopoChangerFvMesh : zeroing unmapped boundary values." << endl; zeroUnmappedValues<scalar, fvPatchField, volMesh>(mappedFace); zeroUnmappedValues<vector, fvPatchField, volMesh>(mappedFace); zeroUnmappedValues<sphericalTensor, fvPatchField, volMesh>(mappedFace); zeroUnmappedValues<symmTensor, fvPatchField, volMesh>(mappedFace); zeroUnmappedValues<tensor, fvPatchField, volMesh>(mappedFace); // Special handling for phi: set unmapped faces to recreated phi Info<< "rawTopoChangerFvMesh :" << " recreating phi for unmapped boundary values." << endl; const volVectorField& U = lookupObject<volVectorField>("U"); surfaceScalarField& phi = const_cast<surfaceScalarField&> ( lookupObject<surfaceScalarField>("phi") ); setUnmappedValues ( phi, mappedFace, (linearInterpolate(U) & Sf())() ); if (topoChangeMap().hasMotionPoints()) { pointField newPoints = topoChangeMap().preMotionPoints(); // Give the meshModifiers opportunity to modify points Info<< "rawTopoChangerFvMesh :" << " calling modifyMotionPoints." << endl; topoChanger_.modifyMotionPoints(newPoints); // Actually move points Info<< "rawTopoChangerFvMesh :" << " calling movePoints." << endl; movePoints(newPoints); } } else { //Pout<< "rawTopoChangerFvMesh :" // << " no topology changes..." << endl; } return hasChanged;
bool drop_action () const { return moving() || m_paste; }
void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if (None == mCurrentTool) return; QLineF move = QLineF(mStartingPoint, event->scenePos()); qreal moveX = move.length() * cos((move.angle() - mAngle) * PI / 180); qreal moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180); qreal width = delegated()->boundingRect().width() * mTotalScaleX; qreal height = delegated()->boundingRect().height() * mTotalScaleY; if (mOperationMode == Scaling) { if(!rotating()) { mTranslateX = moveX; // Perform the resize if (resizingBottomRight()) { // ----------------------------------------------------- // ! We want to keep the aspect ratio with this resize ! // ----------------------------------------------------- qreal scaleX; qreal scaleY; if(!mMirrorX) { scaleX = (width + moveX) / width; } else { scaleX = (width - moveX) / width; } if(!mMirrorY) { scaleY = (height + moveY) / height; } else { scaleY = (height - moveY) / height; } qreal scaleFactor = (scaleX + scaleY) / 2; // Do not allow resizing of image size under frame size if (canResizeBottomRight(width, height, scaleFactor)) { if (mRespectRatio) { mScaleX = scaleFactor; mScaleY = scaleFactor; } else { mScaleX = scaleX; mScaleY = scaleY; } } } else if (resizingLeft() || resizingRight()) { if(width != 0) { qreal scaleX = 0.0; if(resizingLeft()) { scaleX = (width - moveX) / width; } else if(resizingRight()) { scaleX = (width + moveX) / width; } if(mDelegate->isFlippable() && qAbs(scaleX) != 0) { if((qAbs(width * scaleX)) < 2*mFrameWidth) { bool negative = (scaleX < 0)?true:false; if(negative) { if(mMirrorX) scaleX = 2*mFrameWidth/width; else scaleX = -2*mFrameWidth/width; } else { scaleX = -1; mFlippedX = !mFlippedX; } } mScaleX = scaleX; } else if (scaleX > 1 || (width * scaleX) > 2 * mFrameWidth) { mScaleX = scaleX; if(resizingLeft()) { mTranslateX = moveX; } } } } else if(resizingTop() || resizingBottom()) { if(height != 0) { qreal scaleY = 0.0; if(resizingTop()) { scaleY = (height - moveY) / height; } else if(resizingBottom()) { scaleY = (height + moveY) / height; } if(mDelegate->isFlippable() && qAbs(scaleY) != 0) { if((qAbs(height * scaleY)) < 2*mFrameWidth) { bool negative = (scaleY < 0)?true:false; if(negative) { if(mMirrorY) scaleY = 2*mFrameWidth/width; else scaleY = -2*mFrameWidth/width; } else { scaleY = -1; mFlippedY = !mFlippedY; } } mScaleY = scaleY; } else if (scaleY > 1 || (height * scaleY) > 2 * mFrameWidth) { mScaleY = scaleY; if(resizingTop()) { mTranslateY = moveY; } } } } } } if (rotating()) { mTranslateX = 0; mTranslateY = 0; QLineF startLine(sceneBoundingRect().center(), event->lastScenePos()); QLineF currentLine(sceneBoundingRect().center(), event->scenePos()); mAngle += startLine.angleTo(currentLine); if ((int)mAngle % 45 >= 45 - mAngleTolerance || (int)mAngle % 45 <= mAngleTolerance) { mAngle = qRound(mAngle / 45) * 45; mAngleOffset += startLine.angleTo(currentLine); if ((int)mAngleOffset % 360 > mAngleTolerance && (int)mAngleOffset % 360 < 360 - mAngleTolerance) { mAngle += mAngleOffset; mAngleOffset = 0; } } else if ((int)mAngle % 30 >= 30 - mAngleTolerance || (int)mAngle % 30 <= mAngleTolerance) { mAngle = qRound(mAngle / 30) * 30; mAngleOffset += startLine.angleTo(currentLine); if ((int)mAngleOffset % 360 > mAngleTolerance && (int)mAngleOffset % 360 < 360 - mAngleTolerance) { mAngle += mAngleOffset; mAngleOffset = 0; } } setCursorFromAngle(QString::number((int)mAngle % 360)); } else if (moving()) { mTranslateX = move.dx(); mTranslateY = move.dy(); moveLinkedItems(move); } if (mOperationMode == Scaling || moving() || rotating()) { QTransform tr = buildTransform(); if (resizingRight() || resizingBottom() || resizingBottomRight()) { QPointF ref; // we just detects coordinates of corner before and after scaling and then moves object at diff between them. if (resizingBottomRight() && (mMirrorX || mMirrorY)) { if (mFlippedX && !mMirrorX && mFlippedY)// && !mMirrorY) { mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomLeft()).x() - tr.map(delegated()->boundingRect().bottomLeft()).x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomLeft()).y() - tr.map(delegated()->boundingRect().bottomLeft()).y(); } else if ((mFlippedX || mMirrorX) && (mFlippedY || mMirrorY)) { mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y(); } else if (mFlippedX || mMirrorX) { mTranslateX += mInitialTransform.map(delegated()->boundingRect().topRight()).x() - tr.map(delegated()->boundingRect().topRight()).x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().topRight()).y() - tr.map(delegated()->boundingRect().topRight()).y(); } else if (mFlippedY || mMirrorY) { mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomLeft()).x() - tr.map(delegated()->boundingRect().bottomLeft()).x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomLeft()).y() - tr.map(delegated()->boundingRect().bottomLeft()).y(); } else { mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y(); } } else { mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().topLeft()).y() - tr.map(delegated()->boundingRect().topLeft()).y(); } } else if (resizingTop() || resizingLeft()) { QPointF bottomRight = tr.map(delegated()->boundingRect().bottomRight()); QPointF fixedPoint = mInitialTransform.map(delegated()->boundingRect().bottomRight()); mTranslateX += fixedPoint.x() - bottomRight.x(); mTranslateY += fixedPoint.y() - bottomRight.y(); } delegated()->setTransform(buildTransform()); } else // resizing/resizing horizontally { if (resizingBottomRight()) { static QSizeF incV = QSizeF(); static QSizeF incH = QSizeF(); if (mMirrorX && mMirrorY) mCurrentTool = ResizeTop; else mCurrentTool = ResizeBottom; incV = resizeDelegate(moveX, moveY); mOriginalSize += incV; if (mMirrorX && mMirrorY) mCurrentTool = ResizeLeft; else mCurrentTool = ResizeRight; move = QLineF(event->lastScenePos(), event->scenePos()); moveX = move.length() * cos((move.angle() - mAngle) * PI / 180); moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180); mFixedPoint = getFixedPointFromPos(); incH = resizeDelegate(moveX, moveY); mOriginalSize -= incV; mOriginalSize += incH; mCurrentTool = ResizeBottomRight; } else resizeDelegate(moveX, moveY); } event->accept(); }
void Composition::update(){ if(track == 1){ stationary(false); if(status == 1){ g.update(); } else if (status == 2){ g.update(); for(int i=0; i<vines.size(); i++){ vines[i].update(); } } else if (status == 3){ g.update(); for(int i=0; i<vines.size(); i++){ vines[i].update(); } } else if (status == 4){ if(g.fadeNow) {stationary(true);} if(g.resetLights){ pointLight.setSpotlight(1200.0, 200.0); pointLight2.setSpotlight(1200.0, 200.0); } g.update(); for(int i=0; i<vines.size(); i++){ vines[i].update(); vines[i].wither(); } } } else if (track == 2){ moving(); ofPushMatrix(); if(status == 1){ line1.update(attack01*2, started); line2.update(attack02, started); } else if (status == 2){ for(int i=0; i<darts.size(); i++){ darts[i].state = 0; darts[i].pos = darts[i].pos * 0.995 + line1.pos * 0.005; darts[i].update(); } } else if (status == 3){ for(int i=0; i<darts.size(); i++){ darts[i].state = 1; darts[i].pos = darts[i].pos * 0.9 + ofVec3f(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()), ofRandom(ofGetWidth()))*0.1; darts[i].update(); } } else if (status == 4){ stationary(false); g.update(); // line1.updatePiece(); // line2.updatePiece(); } else if (status == 5){ stationary(false); g.update(); for(int i=0; i<vines.size(); i++){ vines[i].update(); } } else if (status == 6){ stationary(false); g.update(); for(int i=0; i<vines.size(); i++){ vines[i].update(); vines[i].wither(); } for(int i=0; i<darts.size(); i++){ darts[i].state = 0; darts[i].pos = darts[i].pos * 0.995 + ofVec3f(ofGetWidth()/2,ofGetHeight(),0) * 0.005; darts[i].update(); } } else if (status == 7){ stationary(false); g.update(); } else if (status == 8){ stationary(true); g.update(); } else if (status == 9){ stationary(false); g.update(); } ofPopMatrix(); } else if (track == 3){ if (status == 1){ } else if (status == 2){ } else if (status == 3){ } else if (status == 4){ } } else if (track == 4){ if (status == 1){ } else if (status == 2){ } else if (status == 3){ } } }