void CQLayoutView::slotResetZoom() { setTransformationAnchor(QGraphicsView::AnchorUnderMouse); resetMatrix(); ensureVisible(scene()->itemsBoundingRect()); update(); }
View::View( QWidget* parent ) : QGraphicsView( parent ) { resetMatrix(); setTransformationAnchor( NoAnchor ); setResizeAnchor( NoAnchor ); }
void MapView::wheelEvent(QWheelEvent* event) { // Get the number of steps of the wheel int numDegrees = event->delta() / 8; int numSteps = numDegrees / 15; // Do nothing if the user is trying to zoom past the limits if((m_currentZoom <= m_minZoom && numSteps <= 0) || (m_currentZoom >= m_maxZoom && numSteps >= 0)) { return; } m_currentZoom += 0.25 * numSteps; if(m_currentZoom <= m_minZoom) { m_currentZoom = m_minZoom; } if(m_currentZoom >= m_maxZoom) { m_currentZoom = m_maxZoom; } // Reset the zoom, so we can specify an absolute scale factor instead of relative to the current scale resetMatrix(); scale(m_currentZoom, m_currentZoom); event->accept(); }
void SchematicSceneViewer::normalizeScene() { #if QT_VERSION >= 0x050000 bool beforeIsLarge = (matrix().determinant() >= 1.0); #else bool beforeIsLarge = (matrix().det() >= 1.0); #endif //See QGraphicsView::mapToScene()'s doc for details QRect rect(0, 0, width(), height()); QRectF sceneCenterRect(mapToScene(QRect(rect.center(), QSize(2, 2))).boundingRect()); resetMatrix(); #if defined(MACOSX) scale(1.32, 1.32); #endif centerOn(sceneCenterRect.center()); #if QT_VERSION >= 0x050000 bool afterIsLarge = (matrix().determinant() >= 1.0); #else bool afterIsLarge = (matrix().det() >= 1.0); #endif if (beforeIsLarge != afterIsLarge) { FxSchematicScene *fxScene = qobject_cast<FxSchematicScene *>(scene()); if (fxScene) fxScene->updateScene(); } }
void F4Res::construct(int lev, int degree) { decltype(timer()) timeA, timeB; resetMatrix(lev, degree); timeA = timer(); makeMatrix(); timeB = timer(); mFrame.timeMakeMatrix += seconds(timeB - timeA); if (M2_gbTrace >= 2) mHashTable.dump(); if (M2_gbTrace >= 2) std::cout << " make matrix time: " << seconds(timeB - timeA) << " sec" << std::endl; #if 0 std::cout << "-- rows --" << std::endl; debugOutputReducers(); std::cout << "-- columns --" << std::endl; debugOutputColumns(); std :: cout << "-- reducer matrix --" << std::endl; if (true or lev <= 2) debugOutputMatrix(mReducers); else debugOutputMatrixSparse(mReducers); std :: cout << "-- reducer matrix --" << std::endl; debugOutputMatrix(mReducers); debugOutputMatrixSparse(mReducers); std :: cout << "-- spair matrix --" << std::endl; debugOutputMatrix(mSPairs); debugOutputMatrixSparse(mSPairs); #endif if (M2_gbTrace >= 2) std::cout << " (degree,level)=(" << (mThisDegree - mThisLevel) << "," << mThisLevel << ") #spairs=" << mSPairs.size() << " reducer= " << mReducers.size() << " x " << mReducers.size() << std::endl; if (M2_gbTrace >= 2) std::cout << " gauss reduce matrix" << std::endl; timeA = timer(); gaussReduce(); timeB = timer(); mFrame.timeGaussMatrix += seconds(timeB - timeA); if (M2_gbTrace >= 2) std::cout << " time: " << seconds(timeB - timeA) << " sec" << std::endl; // mFrame.show(-1); timeA = timer(); clearMatrix(); timeB = timer(); mFrame.timeClearMatrix += seconds(timeB - timeA); }
//Constructor void imageproc::setup(){ myfont.loadFont("visitor1.ttf", 7,false,false,false); camWidth = 320; camHeight = 240; imgWidth = 320; imgHeight = 240; #ifdef _USE_LIVE_VIDEO vidGrabber.setVerbose(true); vidGrabber.initGrabber(camWidth, camHeight); #else vidPlayer.loadMovie("output.mov"); //("convertido.mov"); //("output.mov"); // vidPlayer.play(); #endif sourceImg.allocate(imgWidth,imgHeight); grayImg.allocate(imgWidth,imgHeight); grayImgBg.allocate(imgWidth,imgHeight); grayImgDiff.allocate(imgWidth,imgHeight); grayImgW.allocate(imgWidth,imgHeight); grayImgT.allocate(imgWidth,imgHeight); //320, 240 //matrix tileWidth = (int)(grayImg.width / columnas); tileHeight = (int)(grayImg.height / filas); //cout << tileWidth << " " << tileHeight << endl; //box para el warping boxInputMatrix.setup( 360, 20, imgWidth, imgHeight); //bg remove bLearnBg = false; //lastTimeMeasure = ofGetElapsedTimef(); //lastTimeMeasureFade = ofGetElapsedTimef(); blobMin = 1; blobMax = 22; maxPuntos = 10; minPuntos= 1; threshold = 202 ; thresholdDiff = 102; darken_value=100; resetMatrix(); //cout << "hola2" << endl; }
void SchematicSceneViewer::showEvent(QShowEvent *se) { QGraphicsView::showEvent(se); if (m_firstShowing) { m_firstShowing = false; QRectF rect = scene()->itemsBoundingRect(); resetMatrix(); centerOn(rect.center()); } }
// ---------------------------------------------------- DataMatrix::DataMatrix(){ srand(time(NULL)); ai_count = 0; resetMatrix(); s = 0; lvl = 1; } // end ctor
void WelcomeItem::zoom(int step) { QPointF center = this->boundingRect().center(); resetMatrix(); QTransform mat = this->transform(); mat.translate(center.x(), center.y()); mat.scale(1 + step / 350.0, 1 + step / 350.00); mat.translate(-(center.x()), -center.y()); this->setTransform(mat); }
void SchematicSceneViewer::normalizeScene() { // See QGraphicsView::mapToScene()'s doc for details QRect rect(0, 0, width(), height()); QRectF sceneCenterRect( mapToScene(QRect(rect.center(), QSize(2, 2))).boundingRect()); resetMatrix(); #if defined(MACOSX) scale(1.32, 1.32); #endif centerOn(sceneCenterRect.center()); }
void nRenderer::begin(bool clear) { computeVisibility(); enableAttributes(); if(clear) { clearBuffers(); } glRasterPos2i(0, 0); glViewport(0, 0, viewport.x, viewport.y); resetMatrix(); }
void MapView::resizeEvent(QResizeEvent *event) { QGraphicsView::resizeEvent(event); calculateZoom(); if(m_currentZoom < m_minZoom) { m_currentZoom = m_minZoom; } resetMatrix(); scale(m_currentZoom, m_currentZoom); }
void AbstractDesktopWidget::setRect(const QRectF &rect) { d->mBoundingRect = rect; prepareGeometryChange(); QPointF center = boundingRect().center(); QTransform mat = QTransform(); mat.translate(center.x(), center.y()); mat.translate(-center.x(), -center.y()); setTransform(mat); resetMatrix(); update(); }
void DesktopWidget::configState(DesktopWidget::State s) { resetMatrix(); prepareGeometryChange(); if (s == DOCK) { setRect(0, 0, d->dock.width(), d->dock.height()); } else { setRect(0, 0, d->panel.width(), d->panel.height()); } d->s = s; if (d->proxyWidget) { d->proxyWidget->hide(); } }
NOINLINER void showWord(unsigned char word, float x, float y, float size, float alpha) { if (word == EMPTY) return; resetMatrix(); glTranslatef(x, y, 0); size *= 1.01f - 0.01f * alpha * alpha; glScalef(size, size, 1.f); glColor4f(1.f, 1.f, 1.f, p0d90 * alpha); glBindTexture(GL_TEXTURE_2D, wordTextures[word]); glDrawArrays(GL_QUADS, 0, 4); }
/** * Constructor * * @param cx X axis of the center of the sensor * @param cy Y axis of the center of the sensor * @param angle inclination of the sensor * * @param rows number of rows of sensors in the sensors matrix * @param cols number of columns of sensors in the sensors matrix * * @param marginUp the upper marigin before you encounter the first sensor of the matrix * @param marginDown the lower marigin before you encounter the first sensor of the matrix * @param marginLeft the left marigin before you encounter the first sensor of the matrix * @param marginRight the right marigin before you encounter the first sensor of the matrix * * @param paddingX the X padding betweeen the sensors * @param paddingY the Y padding betweeen the sensors */ GroundSensor::GroundSensor( smReal cx, smReal cy, smReal angle, int rows, int cols, smReal marginUp, smReal marginDown, smReal marginLeft, smReal marginRight, smReal paddingX, smReal paddingY ) : type("standard"), maxVal(255), minVal(0), cx(cx),cy(cy),angle(angle), rows(rows),cols(cols), marginDown( marginDown ),marginUp ( marginUp ), marginLeft( marginLeft ),marginRight( marginRight ), paddingX( paddingX ),paddingY( paddingY ) { this->dimX = cols*paddingX + marginLeft + marginRight; this->dimY = rows*paddingY + marginUp + marginDown; this->upperX = (cx-dimX/2); this->upperY = (cy-dimY/2); this->matrix = new smReal[cols*rows]; resetMatrix(); }
void AbstractDesktopWidget::setRotation(float angle) { d->mAngle = angle; setCacheMode(ItemCoordinateCache); QPointF center = boundingRect().center(); QTransform mat = QTransform(); mat.translate(center.x(), center.y()); mat.rotate(d->mAngle, Qt::YAxis); mat.translate(-center.x(), -center.y()); setTransform(mat); if (d->mAngle >= 180) { if (state() == ROTATED) { setState(VIEW); } else { setState(ROTATED); } resetMatrix(); //setCacheMode(DeviceCoordinateCache); d->mAngle = 0; } }
//-------------------------------------------------------------- void imageproc::keyPressed (int key){ switch (key){ case ' ': bLearnBg = true; #ifdef _USE_LIVE_VIDEO #else resetMatrix(); vidPlayer.setPosition(0); #endif break; case 'u': threshold++; if (threshold > 255) threshold = 255; break; case 'i': threshold--; if (threshold < 0) threshold = 0; break; case 'o': thresholdDiff++; if (threshold > 255) threshold = 255; break; case 'p': thresholdDiff--; if (threshold < 0) threshold = 0; break; } }
void DesktopWidget::spin() { d->angle += 18; setCacheMode(ItemCoordinateCache); QPointF center = boundingRect().center(); QTransform mat = QTransform(); mat.translate(center.x() , center.y()); mat.rotate(d->angle, Qt::YAxis); mat.translate(- center.x() , - center.y()); setTransform(mat); if (d->angle >= 180) { if (state() == BACKSIDE) { setState(NORMALSIDE); } else { setState(BACKSIDE); } d->spintimer->stop(); resetMatrix(); setCacheMode(DeviceCoordinateCache); d->angle = 0; } }
ExampleView::ExampleView(QWidget* parent) : QFrame(parent) { _score = 0; setAcceptDrops(true); setFocusPolicy(Qt::StrongFocus); resetMatrix(); _fgPixmap = nullptr; if (preferences.getBool(PREF_UI_CANVAS_FG_USECOLOR)) _fgColor = preferences.getColor(PREF_UI_CANVAS_FG_COLOR); else { _fgPixmap = new QPixmap(preferences.getString(PREF_UI_CANVAS_FG_WALLPAPER)); if (_fgPixmap == 0 || _fgPixmap->isNull()) qDebug("no valid pixmap %s", qPrintable(preferences.getString(PREF_UI_CANVAS_FG_WALLPAPER))); } // setup drag canvas state sm = new QStateMachine(this); QState* stateActive = new QState; QState* s1 = new QState(stateActive); s1->setObjectName("example-normal"); s1->assignProperty(this, "cursor", QCursor(Qt::ArrowCursor)); QState* s = new QState(stateActive); s->setObjectName("example-drag"); s->assignProperty(this, "cursor", QCursor(Qt::SizeAllCursor)); QEventTransition* cl = new QEventTransition(this, QEvent::MouseButtonRelease); cl->setTargetState(s1); s->addTransition(cl); s1->addTransition(new DragTransitionExampleView(this)); sm->addState(stateActive); stateActive->setInitialState(s1); sm->setInitialState(stateActive); sm->start(); }
int main(int argc, char **argv) { if(argc != 2) { printf("Correct usage: ./wavePropagationSimulator bm\nWhere bm = a (for not generating a new benchmark) or b (generates benchmark)"); exit(4); } int intNTotalNodes = N_HNODES*N_VNODES; // Initiate the CSR Matrix which stands as the coefficients matrix to the linear system CSR_Matrix CSRM_UKP1; CSRM_UKP1 = initCSRMatrix(intNTotalNodes); loadUKP1CSR(CSRM_UKP1,0,waveSpeed); if(argv[1][0] == 'b') { // Generating the Grid. This function uses the constants set in constants.h to do it generateGridToFile("mesh.m"); // These functions generate series of wavefields, they should be uncommented on further tests //generateWaveBenchmark("wave1.m",wave1); generateWaveBenchmarkTimeVariant("wave2","wave2",wave2); } // Trying to establish time variance for u // // Now u must be a vector of extended 2d-vectors, since every "row" in u corresponds to a time step // An extended vector is a matrix shaped to store every node with a special mapping scheme, in which // they're stored line by line. // Initiating uVectorTimeVariant structMatrix *uVectorTimeVariant[2]; for(int i=0; i < 2; i++) { uVectorTimeVariant[i] = (structMatrix*) calloc(N_TIME_STEPS,sizeof(structMatrix)); for(int j = 0; j < N_TIME_STEPS; j++) uVectorTimeVariant[i][j] = initMatrix(intNTotalNodes,1); } // u_0 is a prescript value, since we know how the wave behaves when it starts propagating // Its initial values shall be stored in the testbench folder, for whatever wave used // In this initial test, we will use the "wave2", for its the one that already has time variance loadExtVectorOnInitialTime(uVectorTimeVariant,"../testbench/wave2/wave2_0.m"); //printMatrix(uVectorTimeVariant[0][0]); //printMatrix(uVectorTimeVariant[0][1]); // Calculating u_1 // u_1 is calculated via Taylor series, using both u_0, v_0 (u_0 derivative on time) - both of these are known // in advance - and the space derivatives on X and Y axis (this is easily extensible to a 3rd dimension), which // corresponds to the laplacian of u_0 and are calculated via Finite Differences. Once again, we use "wave2" as //a case test. // The Taylor series expression to u_1 is: // u_1 = u_0 + delta_time * v_0 + (delta_time^2/2) * (d^2 u/dx^2 + d^2 u/dy^2) * (waveSpeed(t=0)^2 * delta_time^2) / 2 // u_0 is already done in uVectorTimeVariant[0] // v_0 is easily calculated: structMatrix *v_0_m,v_0[2],laplacian[2]; v_0_m = loadExtVectorTimeDerivative(wave2TimeDerivative); laplacian[0] = initMatrix(intNTotalNodes,1); laplacian[1] = initMatrix(intNTotalNodes,1); float *boundaryVector; boundaryVector = calloc((2*(N_HNODES + N_VNODES -2)),sizeof(float)); for(int i=0; i < 2; i++) { //matrixSumDestined(uVectorTimeVariant[i][1],uVectorTimeVariant[i][0]); v_0[i] = matrixToExtVector(v_0_m[i]); destroyMatrix(v_0_m[i]); matrixTimesScalar(v_0[i],DELTA_TIME); laplacianViaFD(laplacian[i],uVectorTimeVariant[i][0]); correctLaplacian(laplacian[i],0); // Now summing up the factors matrixSumDestined(uVectorTimeVariant[i][1],uVectorTimeVariant[i][0]); matrixSumDestined(uVectorTimeVariant[i][1],v_0[i]); matrixSumDestined(uVectorTimeVariant[i][1],laplacian[i]); // at the end, apply the boundary conditions on u_1 generateBoundaryVectorFromFunction(boundaryVector,DELTA_TIME,i,wave2Returnable); applyBoundaryConditions(uVectorTimeVariant[i][1],boundaryVector); } //todo assemble the linear system //int k=1; structMatrix vectorB,UKL1; structMatrix tmp_Multiplier; UKL1 = initMatrix(intNTotalNodes,intNTotalNodes); tmp_Multiplier = initMatrix(intNTotalNodes,1); //tmp_Multiplier[Y_AXIS] = initMatrix(intNTotalNodes,1); vectorB = initMatrix(intNTotalNodes,1); exportWaveFieldToFile(extVectorToMatrix(uVectorTimeVariant[X_AXIS][0]),extVectorToMatrix(uVectorTimeVariant[Y_AXIS][0]),0,"wave2","wave2"); exportWaveFieldToFile(extVectorToMatrix(uVectorTimeVariant[X_AXIS][1]),extVectorToMatrix(uVectorTimeVariant[Y_AXIS][1]),1,"wave2","wave2"); for(int k=1; k < N_TIME_STEPS-1; k++) { loadUKL1(UKL1,(k-1)*DELTA_TIME,waveSpeed); for(int axis = 0; axis < 2; axis++) { //if(axis==1) printMatrix(UKL1); printf("Axis: %d %d\n",axis,Y_AXIS); copyMatrix(vectorB,uVectorTimeVariant[axis][k]); applyWaveSpeedTimeStepIntoMatrix(vectorB,DELTA_TIME,waveSpeed); matrixMultiplicationDestined(tmp_Multiplier,UKL1,uVectorTimeVariant[axis][k-1]); matrixSumDestined(vectorB,tmp_Multiplier); generateBoundaryVectorFromFunction(boundaryVector,(k+1)*DELTA_TIME,axis,wave2Returnable); applyBoundaryConditions(vectorB,boundaryVector); // todo SOR method in CSR matrix CSR_SOR(uVectorTimeVariant[axis][k+1],CSRM_UKP1,vectorB,1); resetMatrix(tmp_Multiplier); } //printMatrix(extVectorToMatrix(uVectorTimeVariant[Y_AXIS][k+1])); exportWaveFieldToFile(extVectorToMatrix(uVectorTimeVariant[X_AXIS][k+1]),extVectorToMatrix(uVectorTimeVariant[Y_AXIS][k+1]),k+1,"wave2","wave2"); } //printMatrix(extVectorToMatrix(tmp_Multiplier)); printf("\n"); //printCSRMatrix(CSRM_UKP1); //printMatrix(vectorB); /* // Initiating mesh structMatrix mesh_hmatrix,mesh_vmatrix; structMatrix tmp[2]; tmp[X_AXIS] = extVectorToMatrix(uVectorTimeVariant[X_AXIS][1]); tmp[Y_AXIS] = extVectorToMatrix(uVectorTimeVariant[Y_AXIS][1]); mesh_hmatrix = initMatrix(N_HNODES,N_VNODES); mesh_vmatrix = initMatrix(N_HNODES,N_VNODES); loadMesh(mesh_hmatrix,mesh_vmatrix); //for(int i=0; i< N_TIME_STEPS; i++) { printMatrixToFile(tmp[X_AXIS],"matrix.m","u"); printMatrixToFile(tmp[Y_AXIS],"matrix.m","v"); printMatrixToFile(mesh_hmatrix,"matrix.m","x"); printMatrixToFile(mesh_vmatrix,"matrix.m","y"); // At the end, print the "quiver" function FILE *destinyFile = fopen("matrix.m","a"); fprintf(destinyFile,"quiver(x,y,u,v)\n"); fclose(destinyFile); // } */ // Memory Freeing destroyCSRMatrix(CSRM_UKP1); destroyMatrix(vectorB); destroyMatrix(UKL1); destroyMatrix(tmp_Multiplier); for (int i=0; i < 2; i++) { destroyMatrix(laplacian[i]); destroyMatrix(v_0[i]); for(int j = 0; j < N_TIME_STEPS; j++) destroyMatrix(uVectorTimeVariant[i][j]); free(uVectorTimeVariant[i]); } free(v_0_m); free(boundaryVector); }
void MapView::resetZoom() { m_currentZoom = 1.0f; resetMatrix(); }
ELMatrix4x4::ELMatrix4x4() { resetMatrix(); }
void View::fit() { resetMatrix(); fitInView( sceneRect(), Qt::KeepAspectRatio ); }
void nbody(double** s, double** v, double* m, int n, int iter, int timestep) { int myrank, nprocs; int i,j,k, size, l, p; double* distance; double* currentplanets; double** acceleration; double r, G,f; MPI_Status status; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); size = n / nprocs; distance = (double *)malloc(sizeof(double) * 3); acceleration = (double **)malloc(sizeof(double *) * size); // array med planeter x,y,z,masse currentplanets = (double *)malloc(sizeof(double) * 4 * size); for (i = 0; i < size; i++) { acceleration[i] = (double*)malloc(sizeof(double) * 3); } G = 6.674e-11; for(i = 0; i < iter; i++){ //for loop over iterasjoner resetMatrix(acceleration, size); for (k = 0; k < size; k++) { for(j = 0; j < 4; j++){ currentplanets[j+k*4] = (j == 3) ? m[k] : s[k][j]; } } for(p = 0; p < nprocs ; p++){ for(j = 0; j < size;j++){ //for loop for en spesefikk planet for(k = 0; k< size;k++){ //alle planeter for en spesifikk for(l = 0; l < 3;l++){ distance[l] = s[j][l] - currentplanets[k*4 +l]; } r = norm(distance); if(r==0) continue; f = (G * m[j] * currentplanets[k*4+3] ) / (r*r); for(l = 0; l < 3;l++){ distance[l] = ((distance[l] * f )/ r) / m[j]; acceleration[j][l] = acceleration[j][l] - distance[l]; } } } if (p == (nprocs-1)) continue; if(myrank % 2 == 0){ //MPI Send first, then recieve MPI_Send(¤tplanets[0], size*4, MPI_DOUBLE, (myrank+1)%nprocs, 0, MPI_COMM_WORLD); MPI_Recv(¤tplanets[0], size*4, MPI_DOUBLE, (myrank-1)%nprocs, 0, MPI_COMM_WORLD, &status); }else{ double* tmp; tmp = (double *)malloc(sizeof(double)*size*4); //MPI Recieve first, then send MPI_Recv(&tmp[0], size*4, MPI_DOUBLE, (myrank -1)%nprocs, 0, MPI_COMM_WORLD, &status); MPI_Send(¤tplanets[0], size*4, MPI_DOUBLE, (myrank +1)%nprocs, 0, MPI_COMM_WORLD); for (j = 0; j < size*4; j++) { currentplanets[j] = tmp[j]; } free(tmp); } } for(j=0; j < size;j++){ for(k=0;k<3;k++){ v[j][k] = v[j][k] + timestep * acceleration[j][k]; s[j][k] = s[j][k] + timestep * v[j][k]; } } } free(distance); free(currentplanets); free(acceleration); printInOrder(myrank, nprocs, size, s, v, m); }