Polygon::Polygon(Point center, int n, myFloat radius, myFloat alpha){ for (int i = 0; i < n; ++i) { Vector dir(((myFloat)i) * 2 * M_PI / n + alpha); pnts.push_back(center + radius * dir); } updateCenter(); }
void MainWindow::updateArea() { m_north = ui->maxLatField->text(); m_south = ui->minLatField->text(); m_east = ui->maxLonField->text(); m_west = ui->minLonField->text(); if (!m_west.isEmpty()) { QList<QPointF> coord; coord.append(QPointF(m_west.toFloat(), m_north.toFloat())); coord.append(QPointF(m_east.toFloat(), m_south.toFloat())); mc->setViewAndZoomIn(coord); QList<Point*> points; points.append(new Point(m_west.toFloat(), m_south.toFloat(), "1")); points.append(new Point(m_west.toFloat(), m_north.toFloat(), "1")); points.append(new Point(m_east.toFloat(), m_north.toFloat(), "1")); points.append(new Point(m_east.toFloat(), m_south.toFloat(), "1")); points.append(new Point(m_west.toFloat(), m_south.toFloat(), "1")); QPen* linepen = new QPen(Qt::red); linepen->setWidth(2); LineString* ls = new LineString(points, "Area Boundary", linepen); mainlayer->clearGeometries(); mainlayer->addGeometry(ls); } settings.setValue("boundaries/north", m_north); settings.setValue("boundaries/south", m_south); settings.setValue("boundaries/east", m_east); settings.setValue("boundaries/west", m_west); updateElevationRange(); updateCenter(); }
//-------------------------------------------------------------- void ofxMtlMapping2DVertex::init(float _x, float _y, int _index) { index = _index; setPosition(_x, _y); //Center updateCenter(); }
//-------------------------------------------------------------- void ofxMtlMapping2DVertex::onDragOutside(int x, int y, int button) { if(activeVertex == this) { this->x = x - width/2; this->y = y - height/2; updateCenter(); } }
Z3DCameraParameter::Z3DCameraParameter(const QString &name, const Z3DCamera &value, QObject *parent) : ZSingleValueParameter<Z3DCamera>(name, value, parent) , m_projectionType("Projection Type") , m_eye("Eye Position", value.getEye(), glm::vec3(-std::numeric_limits<float>::max()), glm::vec3(std::numeric_limits<float>::max())) , m_center("Center Position", value.getCenter(), glm::vec3(-std::numeric_limits<float>::max()), glm::vec3(std::numeric_limits<float>::max())) , m_upVector("Up Vector", value.getUpVector(), glm::vec3(-1.f), glm::vec3(1.f)) , m_eyeSeparationAngle("Eye Separation Angle", value.getEyeSeparationAngle(), 1.f, 80.f) , m_fieldOfView("Field of View", value.getFieldOfView(), 10.f, 170.f) , m_nearDist("Near Distance", value.getNearDist(), 1e-10, std::numeric_limits<float>::max()) , m_farDist("Far Distance", value.getFarDist(), 1e-10, std::numeric_limits<float>::max()) , m_receiveWidgetSignal(true) { m_projectionType.addOptions("Perspective", "Orthographic"); if (value.isPerspectiveProjection()) m_projectionType.select("Perspective"); else m_projectionType.select("Orthographic"); connect(&m_projectionType, SIGNAL(valueChanged()), this, SLOT(updateProjectionType())); m_eye.setSingleStep(1e-10); m_eye.setDecimal(10); //m_eye.setWidgetOrientation(Qt::Horizontal); m_eye.setStyle("SPINBOX"); connect(&m_eye, SIGNAL(valueChanged()), this, SLOT(updateEye())); m_center.setSingleStep(1e-10); m_center.setDecimal(10); //m_center.setWidgetOrientation(Qt::Horizontal); m_center.setStyle("SPINBOX"); connect(&m_center, SIGNAL(valueChanged()), this, SLOT(updateCenter())); m_upVector.setSingleStep(1e-10); m_upVector.setDecimal(10); m_upVector.setStyle("SPINBOX"); connect(&m_upVector, SIGNAL(valueChanged()), this, SLOT(updateUpVector())); m_eyeSeparationAngle.setSingleStep(.1); m_eyeSeparationAngle.setDecimal(1); connect(&m_eyeSeparationAngle, SIGNAL(valueChanged()), this, SLOT(updateEyeSeparationAngle())); m_fieldOfView.setSingleStep(.1); m_fieldOfView.setDecimal(1); connect(&m_fieldOfView, SIGNAL(valueChanged()), this, SLOT(updateFieldOfView())); m_nearDist.setSingleStep(1e-10); m_nearDist.setDecimal(10); m_nearDist.setStyle("SPINBOX"); m_nearDist.setRange(1e-10, value.getFarDist()); connect(&m_nearDist, SIGNAL(valueChanged()), this, SLOT(updateNearDist())); m_farDist.setSingleStep(1e-10); m_farDist.setDecimal(10); m_farDist.setStyle("SPINBOX"); m_farDist.setRange(value.getNearDist(), std::numeric_limits<float>::max()); connect(&m_farDist, SIGNAL(valueChanged()), this, SLOT(updateFarDist())); }
/*! Intialise the polygon using the collection of image points. This method compute come internal variables such as center, area, ... \warning the corners must be ordered (either clockwise or counter clockwise). \param corners : The corners of the polyon. */ void vpPolygon::init(const std::vector<vpImagePoint>& corners) { _corners = corners; updateBoundingBox(); updateArea(); updateCenter(); }
// Used to merge two clusters from same time point. void merge(const std::shared_ptr<BarcodeCluster>& c) { _size += c->size(); AddFrequency(c->bpFrequency()); updateCenter(); _raw_barcodes.insert(_raw_barcodes.end(), c->barcodes().begin(), c->barcodes().end()); auto iter = _size_at_time.begin(); for (const auto& s : c->columns()) { *iter += s; ++iter; } }
//-------------------------------------------------------------- ofxMtlMapping2DVertex::ofxMtlMapping2DVertex() { disableAllEvents(); enableMouseEvents(); enabled = false; bIsOnAnEdge = true; edgeIndex = -1; //Vertex setSize(30, 30); toBeRemoved = false; isDefiningTectureCoord = false; updateCenter(); }
void Camera::update(const ego_mesh_t *mesh) { // Update the _turnTime counter. if (CameraTurnMode::None != _turnMode) { _turnTime = 255; } else if (_turnTime > 0) { _turnTime--; } // Camera controls. for (PLA_REF ipla = 0; ipla < MAX_PLAYER; ++ipla) { // Don't do invalid players. if (INVALID_PLA(ipla)) { continue; } player_t *ppla = PlaStack.get_ptr(ipla); // Handle camera control from this player. readInput(ppla->pdevice); } // Update the special camera effects like grog. updateEffects(); // Update the average position of the tracked characters. updateTrack(mesh); // Move the camera center, if need be. updateCenter(); // Make the zadd and zoom work together. updateZoom(); // Update the position of the camera. updatePosition(); // Set the view matrix. makeMatrix(); }
void QuadrantLayout::resized() { updateCenter(); if (quadrants[Q1]) { quadrants[Q1]->setBounds (q1area); } if (quadrants[Q2]) { quadrants[Q2]->setBounds (q2area); } if (quadrants[Q3]) { quadrants[Q3]->setBounds (q3area); } if (quadrants[Q4]) { quadrants[Q4]->setBounds (q4area); } }
bool SGTransformManip::build() { SGIntersectResult& result = generalResult[0]; if (result.resultType != SGComponentType::kNone) { intersector.intersectPoint = result.intersectPoint; } m_selVertices = SGSelection::getIndices( SGSelection::sels.getSelVtxIndicesMap() ); if (!m_selVertices.length()) return false; SGMesh* pMesh = SGMesh::pMesh; MBoundingBox bb; for (unsigned int i = 0; i < m_selVertices.length(); i++) { MPoint& targetPoint = pMesh->points[m_selVertices[i]]; pMesh->isCenter(m_selVertices[i], SGComponentType::kVertex); if( !pMesh->isCenter(m_selVertices[i], SGComponentType::kVertex ) && SGToolCondition::option.symInfo.compairIsMirror( intersector.intersectPoint, targetPoint ) ) continue; bb.expand(targetPoint); } MPoint bbCenter = bb.center(); if (SGSpace::space == MSpace::kObject) { bbCenter *= pMesh->dagPath.inclusiveMatrix(); } MMatrix mtx; mtx(3, 0) = bbCenter.x; mtx(3, 1) = bbCenter.y; mtx(3, 2) = bbCenter.z; intersector.build( mtx ); intersectType = SGTransformManipIntersector::kCenter; updateCenter(); return true; }
void PathGroup::rotate(float degrees) { updateCenter(); rotate(degrees, int(centerLocation.getX()), int(centerLocation.getY())); }
void PathGroup::flip(bool hf, bool vf) { updateCenter(); flip(hf, vf, int(centerLocation.getX()), int(centerLocation.getY())); }
int main(void) { consoleDemoInit(); //videoSetMode(MODE_FB0); videoSetMode( MODE_5_2D ); vramSetBankA(VRAM_A_MAIN_BG); vramSetBankB(VRAM_B_MAIN_BG); // vramSetBankC(VRAM_C_MAIN_BG); // vramSetBankD(VRAM_D_MAIN_BG_0x06040000); int bg = bgInit(3, BgType_Bmp8, BgSize_B8_512x512, 0,0); //vramSetBankA(VRAM_A_LCD); lcdMainOnBottom(); // lcdMainOnTop(); printf("Video modes configured\n"); printf("BG ID %d\n", bg); if (fatInitDefault()) printf("FAT initialized\n"); else printf("FAT initialization failed\n"); AppState state; uiOpenNotebook(state); // Keyboard *kbd = keyboardDemoInit(); Segment * currentSegment = NULL; touchPosition touch; while (1) { scanKeys(); if(keysHeld() & KEY_TOUCH) { // write the touchscreen coordinates in the touch variable touchRead(&touch); Point screenPoint = Point(touch.px, touch.py); Point imagePoint = state.convertScreenToImage(screenPoint); if (currentSegment == NULL) { state.currentPage->segments.push_back(Segment()); currentSegment = &(state.currentPage->segments[state.currentPage->segments.size()-1]); currentSegment->points.push_back(imagePoint); continue; } Point lastImagePoint = currentSegment->points[currentSegment->points.size()-1]; currentSegment->points.push_back(imagePoint); Point bufferPoint = state.convertScreenToBuffer(screenPoint); Point lastBufferPoint = state.convertImageToBuffer(lastImagePoint); drawLine(lastBufferPoint.x, lastBufferPoint.y, bufferPoint.x, bufferPoint.y, RGB15(31,0,0) | BIT(15)); } else { currentSegment = NULL; } if (keysDown() & KEY_X) { int page = state.lastPage+1; while (state.notebook.pages.size() < page+1) { state.notebook.pages.push_back(Page()); printf("New Page created\n"); } state.currentPage = &(state.notebook.pages[page]); currentSegment = NULL; printf("Display page %d\n", page); fillDisplay(RGB15(0,0,0) | BIT(15), page, state); drawPage(state.currentPage, RGB15(31,0,0) | BIT(15), state); } if (keysDown() & KEY_Y) { int page = 0; if (state.lastPage > 0) { page = state.lastPage-1; } state.currentPage = &(state.notebook.pages[page]); currentSegment = NULL; printf("Display page %d\n", page); fillDisplay(RGB15(0,0,0) | BIT(15), page, state); drawPage(state.currentPage, RGB15(31,0,0) | BIT(15), state); } if (keysDown() & KEY_A) { int page = 0; std::string fileName = state.notebookName + "/notes.txt"; state.notebook = loadFile(fileName.c_str()); state.currentPage = &(state.notebook.pages[page]); currentSegment = NULL; printf("Display page %d\n", page); fillDisplay(RGB15(0,0,0) | BIT(15), page, state); drawPage(state.currentPage, RGB15(31,0,0) | BIT(15), state); } if (keysDown() & KEY_B) { std::string fileName = state.notebookName + "/notes.txt"; saveFile(fileName.c_str(), state.notebook); } if (keysDown() & KEY_LEFT) { state.scroll_x-=50; updateCenter(state); } if (keysDown() & KEY_RIGHT) { state.scroll_x+=50; updateCenter(state); } if (keysDown() & KEY_UP) { state.scroll_y-=50; updateCenter(state); } if (keysDown() & KEY_DOWN) { state.scroll_y+=50; updateCenter(state); } if (keysDown() & KEY_START) { uiOpenNotebook(state); } swiWaitForVBlank(); } }
//-------------------------------------------------------------- void ofxMtlMapping2DVertex::snapIt(float _x, float _y) { setPosition(_x, _y); updateCenter(); }
Polygon::Polygon(vector<Point> vector) { pnts.assign(vector.begin(), vector.end()); updateCenter(); }