void ArrowLine::drawShape(QPainter &p) { p.setPen(darkGray); QCanvasLine::drawShape(p); double angle = computeAngle(startPoint().x(), startPoint().y(), endPoint().x(), endPoint().y()); QPointArray pts(3); QWMatrix m; int x, y; m.rotate(angle); m.map(-5, -2, &x, &y); pts.setPoint(0, x, y); m.map(-5, 2, &x, &y); pts.setPoint(1, x, y); m.map(0, 0, &x, &y); pts.setPoint(2, x, y); pts.translate(endPoint().x(), endPoint().y()); p.setBrush(QColor(darkGray)); p.drawPolygon(pts); }
CXTPChartDeviceCommand* CXTPChartRadarAxisXView::CreateTickMarksDeviceCommand(CXTPChartDeviceContext* pDC) { UNREFERENCED_PARAMETER(pDC); CXTPChartDeviceCommand* pCommands = new CXTPChartHitTestElementCommand(m_pAxis, m_rcBounds); CXTPChartAxisTickMarks* pTickMarks = m_pAxis->GetTickMarks(); if (!pTickMarks->IsVisible()) return pCommands; CXTPChartColor clrAxis = m_pAxis->GetActualColor(); int nLength = pTickMarks->GetLength(); int nThickness = pTickMarks->GetThickness(); BOOL bMinorVisible = pTickMarks->IsMinorVisible(); BOOL bCross = pTickMarks->IsCrossAxis(); int nAxisThickness = m_pAxis->GetThickness() - 1; int nExtraLength = bCross ? nLength + nAxisThickness : 0; for (int i = 0; i < m_arrTicks.GetSize(); i++) { double lineAngle = ValueToAngle(m_arrTicks[i].m_dValue); double cs = cos(lineAngle); double sn = sin(lineAngle); CXTPChartPointF startPoint(m_ptCenter.X + (m_nRadius - nExtraLength) * cs, m_ptCenter.Y - (m_nRadius - nExtraLength) * sn); CXTPChartPointF finishPoint(m_ptCenter.X + (m_nRadius + nAxisThickness + nLength) * cs, m_ptCenter.Y - (m_nRadius + nAxisThickness + nLength) * sn); pCommands->AddChildCommand(new CXTPChartSolidLineDeviceCommand(startPoint, finishPoint, clrAxis, nThickness)); } if (bMinorVisible && !IsPolygonDiagramStyle()) { nLength = pTickMarks->GetMinorLength(); int nExtraLength = bCross ? nLength + nAxisThickness : 0; int nMinorThickness = pTickMarks->GetMinorThickness(); for (int i = 0; i < m_arrMinorTicks.GetSize(); i++) { double lineAngle = ValueToAngle(m_arrMinorTicks[i]); double cs = cos(lineAngle); double sn = sin(lineAngle); CXTPChartPointF startPoint(m_ptCenter.X + (m_nRadius - nExtraLength) * cs, m_ptCenter.Y - (m_nRadius - nExtraLength) * sn); CXTPChartPointF finishPoint(m_ptCenter.X + (m_nRadius + nAxisThickness + nLength) * cs, m_ptCenter.Y - (m_nRadius + nAxisThickness + nLength) * sn); pCommands->AddChildCommand(new CXTPChartSolidLineDeviceCommand(startPoint, finishPoint, clrAxis, nMinorThickness)); } } return pCommands; }
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { #if OS(WINDOWS) // This glyph buffer holds our glyphs + advances + font data for each glyph. GlyphBuffer glyphBuffer; float startX = point.x(); UniscribeController controller(this, run); controller.advance(from); float beforeWidth = controller.runWidthSoFar(); controller.advance(to, &glyphBuffer); // We couldn't generate any glyphs for the run. Give up. if (glyphBuffer.isEmpty()) return; float afterWidth = controller.runWidthSoFar(); if (run.rtl()) { controller.advance(run.length()); startX += controller.runWidthSoFar() - afterWidth; } else startX += beforeWidth; // Draw the glyph buffer now at the starting point returned in startX. FloatPoint startPoint(startX, point.y()); drawGlyphBuffer(context, glyphBuffer, run, startPoint); #else notImplemented(); #endif }
void KviCanvasLine::draw(QPainter &p) { if(isEnabled()) { p.setPen(pen()); p.drawLine(startPoint(),endPoint()); } if(isSelected()) { p.setRasterOp(NotROP); p.setPen(QPen(DotLine)); p.drawLine(startPoint(),endPoint()); p.setRasterOp(CopyROP); } }
bool Viewport::getSample(vec2 &p, Ray &r) { _i += 1.0/_incPP; if (_i >= _pixelsWide) { _i = _incPP/2; _j += 1.0/_incPP; } if (_j >= _pixelsHigh) { resetSampler(); return false; } p = vec2(_i,_j); // friendly progress counter int soFar = int( 100*((floor(_i)+1)*(floor(_j)+1) / (double) (_pixelsWide * _pixelsHigh)) ); if (soFar >= _percentage+10) { _percentage = soFar; cout << soFar << "% Done." << endl; } double u = _i / (double) _pixelsWide; double v = _j / (double) _pixelsHigh; vec4 startPoint(((1-u)*((1-v)*_LL[0] + v*_UL[0]) + u*((1-v)*_LR[0] + v*_UR[0])), ((1-u)*((1-v)*_LL[1] + v*_UL[1]) + u*((1-v)*_LR[1] + v*_UR[1])), ((1-u)*((1-v)*_LL[2] + v*_UL[2]) + u*((1-v)*_LR[2] + v*_UR[2])),1); _lens.getRays(startPoint, r); return true; }
void LayoutSVGResourceLinearGradient::buildGradient(GradientData* gradientData) const { const LinearGradientAttributes& attributes = this->attributes(); gradientData->gradient = Gradient::create(startPoint(attributes), endPoint(attributes)); gradientData->gradient->setSpreadMethod(platformSpreadMethodFromSVGType(attributes.spreadMethod())); addStops(gradientData, attributes.stops()); }
void KipiImageItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& sortMappedindex) const { if (sortMappedindex.column() != KipiImageItem::ColumnThumbnail) { QItemDelegate::paint(painter, option, sortMappedindex); return; } const QModelIndex& sourceModelIndex = d->imageList->getSortProxyModel()->mapToSource(sortMappedindex); if (option.state & QStyle::State_Selected) { painter->fillRect(option.rect, option.palette.highlight()); } // TODO: clipping, selected state, disabled state, etc. QPixmap itemPixmap = d->imageList->getModel()->getPixmapForIndex(sourceModelIndex, d->thumbnailSize); if (itemPixmap.isNull()) { // TODO: paint some default logo // TODO: cache this logo itemPixmap = SmallIcon("image-x-generic", d->thumbnailSize, KIconLoader::DisabledState); } const QSize availableSize = option.rect.size(); const QSize pixmapSize = itemPixmap.size().boundedTo(availableSize); QPoint startPoint((availableSize.width() - pixmapSize.width()) / 2, (availableSize.height() - pixmapSize.height()) / 2); startPoint += option.rect.topLeft(); painter->drawPixmap(QRect(startPoint, pixmapSize), itemPixmap, QRect(QPoint(0, 0), pixmapSize)); }
void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoint& point) const { FontCachePurgePreventer purgePreventer; GlyphData markGlyphData; if (!getEmphasisMarkGlyphData(mark, markGlyphData)) return; const SimpleFontData* markFontData = markGlyphData.fontData; ASSERT(markFontData); if (!markFontData) return; Glyph markGlyph = markGlyphData.glyph; Glyph spaceGlyph = markFontData->spaceGlyph(); float middleOfLastGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, 0); FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph(markFontData, markGlyph), point.y()); GlyphBuffer markBuffer; for (int i = 0; i + 1 < glyphBuffer.size(); ++i) { float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1); float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph; markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFontData, advance); middleOfLastGlyph = middleOfNextGlyph; } markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spaceGlyph, markFontData, 0); drawGlyphBuffer(context, run, markBuffer, startPoint); }
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { #if PLATFORM(CHROMIUM) if (preferHarfBuzz(this)) { GlyphBuffer glyphBuffer; HarfBuzzShaper shaper(this, run); shaper.setDrawRange(from, to); if (shaper.shape(&glyphBuffer)) { drawGlyphBuffer(context, run, glyphBuffer, point); return; } } #endif // This glyph buffer holds our glyphs + advances + font data for each glyph. GlyphBuffer glyphBuffer; float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer); // We couldn't generate any glyphs for the run. Give up. if (glyphBuffer.isEmpty()) return; // Draw the glyph buffer now at the starting point returned in startX. FloatPoint startPoint(startX, point.y()); drawGlyphBuffer(context, run, glyphBuffer, startPoint); }
////////////////// PathInfo ////////////////// PathInfo::PathInfo(const Unit* owner, const float destX, const float destY, const float destZ, bool useStraightPath) : m_polyLength(0), m_type(PATHFIND_BLANK), m_useStraightPath(useStraightPath), m_sourceUnit(owner), m_navMesh(NULL), m_navMeshQuery(NULL) { PathNode endPoint(destX, destY, destZ); setEndPosition(endPoint); float x,y,z; m_sourceUnit->GetPosition(x, y, z); PathNode startPoint(x, y, z); setStartPosition(startPoint); DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathInfo::PathInfo for %u \n", m_sourceUnit->GetGUID()); uint32 mapId = m_sourceUnit->GetMapId(); if (MMAP::MMapFactory::IsPathfindingEnabled(mapId)) { MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager(); m_navMesh = mmap->GetNavMesh(mapId); m_navMeshQuery = mmap->GetNavMeshQuery(mapId, m_sourceUnit->GetInstanceId()); } createFilter(); if (m_navMesh && m_navMeshQuery && !m_sourceUnit->hasUnitState(UNIT_STAT_IGNORE_PATHFINDING)) { BuildPolyPath(startPoint, endPoint); } else { BuildShortcut(); m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); } }
void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { // This glyph buffer holds our glyphs+advances+font data for each glyph. GlyphBuffer glyphBuffer; float startX = point.x(); WidthIterator it(this, run); it.advance(from); float beforeWidth = it.m_runWidthSoFar; it.advance(to, &glyphBuffer); // We couldn't generate any glyphs for the run. Give up. if (glyphBuffer.isEmpty()) return; float afterWidth = it.m_runWidthSoFar; if (run.rtl()) { float finalRoundingWidth = it.m_finalRoundingWidth; it.advance(run.length()); startX += finalRoundingWidth + it.m_runWidthSoFar - afterWidth; } else startX += beforeWidth; // Swap the order of the glyphs if right-to-left. if (run.rtl()) for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end) glyphBuffer.swap(i, end); // Calculate the starting point of the glyphs to be displayed by adding // all the advances up to the first glyph. FloatPoint startPoint(startX, point.y()); drawGlyphBuffer(context, glyphBuffer, run, startPoint); }
int RDLogLine::segueLength(RDLogLine::TransType next_trans) { switch(type()) { case RDLogLine::Cart: switch(next_trans) { case RDLogLine::Stop: case RDLogLine::Play: return log_effective_length; case RDLogLine::Segue: if(segueStartPoint(RDLogLine::AutoPointer)<0) { return log_effective_length; } return segueStartPoint(RDLogLine::AutoPointer)- startPoint(RDLogLine::AutoPointer); default: break; } break; case RDLogLine::Macro: return log_effective_length; case RDLogLine::Marker: return 0; default: break; } return 0; }
void Font::drawGlyphBuffer(GraphicsContext* context, const GlyphBuffer& glyphBuffer, const FloatPoint& point) const { // Draw each contiguous run of glyphs that use the same font data. const SimpleFontData* fontData = glyphBuffer.fontDataAt(0); FloatSize offset = glyphBuffer.offsetAt(0); FloatPoint startPoint(point); float nextX = startPoint.x(); int lastFrom = 0; int nextGlyph = 0; while (nextGlyph < glyphBuffer.size()) { const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph); FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph); if (nextFontData != fontData || nextOffset != offset) { drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); lastFrom = nextGlyph; fontData = nextFontData; offset = nextOffset; startPoint.setX(nextX); } nextX += glyphBuffer.advanceAt(nextGlyph); nextGlyph++; } drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); }
void Initial::setCoordString() { int ylen = numberOfCoords(); string *coordList = new string[ylen]; int i = startPoint(); int j = 0; string str = ""; /*List of strings. Each string is a coordinate *pair.*/ while(j<ylen) { while(i<buffer.length() && buffer[i]!=')') str+=buffer[i++]; //Grabs ) if(i<buffer.length()) str+=buffer[i++]; //Skips comma inbetween ) ( i++; coordList[j++] = str; str = ""; } setCoord(coordList,ylen); }
//Run inference with Lazy Flipper initialized to setting in initlab void runLazyFlipper(GraphicalModelType* gm,std::string ofname, std::string initlab, size_t subGraphsize) { //Initial Labelling std::vector<LabelType> startPoint(gm->numberOfVariables()); std::ifstream input; input.open(initlab.c_str()); int label; for(size_t i=0;i<gm->numberOfVariables();i++) { input>>label; startPoint[i] = LabelType(label); #ifdef DEBUG std::cout<<"L"<<i<<":"<<label<<" "; #endif } //Run Inference size_t maxSubgraphsize; if(subGraphsize<=0) maxSubgraphsize = gm->numberOfVariables()/2; else maxSubgraphsize = subGraphsize; LazyFlipper::Parameter para(maxSubgraphsize); LazyFlipper lf(*gm,para); lf.setStartingPoint(startPoint.begin()); std::cout<<"Running Inference"<<std::endl; lf.infer(); std::cout << "MAP Result: " << lf.value() << " Bound: "<<lf.bound()<<std::endl; std::vector<LabelType> result; lf.arg(result); //Write Result writeResult(result,ofname); }
//Run inference with Lazy Flipper initialized to setting in initlab void runICM(GraphicalModelType* gm,std::string ofname, std::string initlab) { //Initial Labelling std::vector<LabelType> startPoint(gm->numberOfVariables()); std::ifstream input; input.open(initlab.c_str()); int label; for(size_t i=0;i<gm->numberOfVariables();i++) { input>>label; startPoint[i] = LabelType(label); #ifdef DEBUG std::cout<<"L"<<i<<":"<<label<<" "; #endif } //Run Inference ICM::Parameter para(startPoint); ICM icm(*gm,para); std::cout<<"Running Inference"<<std::endl; icm.infer(); std::cout << "MAP Result: " << icm.value() << " Bound: "<<icm.bound()<<std::endl; std::vector<LabelType> result; icm.arg(result); //Write Result writeResult(result,ofname); }
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { // This glyph buffer holds our glyphs + advances + font data for each glyph. GlyphBuffer glyphBuffer; float startX = point.x(); CoreTextController controller(this, run); controller.advance(from); float beforeWidth = controller.runWidthSoFar(); controller.advance(to, &glyphBuffer); // We couldn't generate any glyphs for the run. Give up. if (glyphBuffer.isEmpty()) return; float afterWidth = controller.runWidthSoFar(); if (run.rtl()) { startX += controller.totalWidth() + controller.finalRoundingWidth() - afterWidth; for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end) glyphBuffer.swap(i, end); } else startX += beforeWidth; // Draw the glyph buffer now at the starting point returned in startX. FloatPoint startPoint(startX, point.y()); drawGlyphBuffer(context, glyphBuffer, run, startPoint); }
////////////////// PathInfo ////////////////// PathInfo::PathInfo(const Unit* owner, const float destX, const float destY, const float destZ, bool useStraightPath) : m_pathPolyRefs(NULL), m_polyLength(0), m_type(PATHFIND_BLANK), m_useStraightPath(useStraightPath), m_sourceUnit(owner), m_navMesh(NULL), m_navMeshQuery(NULL) { PathNode endPoint(destX, destY, destZ); setEndPosition(endPoint); float x,y,z; m_sourceUnit->GetPosition(x, y, z); PathNode startPoint(x, y, m_sourceUnit->GetMap()->GetHeight(x,y,z,100.0f)); setStartPosition(startPoint); PATH_DEBUG("++ PathInfo::PathInfo for %u \n", m_sourceUnit->GetGUID()); uint32 mapId = m_sourceUnit->GetMapId(); MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager(); m_navMesh = mmap->GetNavMesh(mapId); m_navMeshQuery = mmap->GetNavMeshQuery(mapId); if (m_navMesh && m_navMeshQuery) { BuildPolyPath(startPoint, endPoint); } else { BuildShortcut(); m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); } }
void QgsLineStringV2::close() { if ( numPoints() < 1 || isClosed() ) { return; } addVertex( startPoint() ); }
void QgsCompoundCurve::close() { if ( numPoints() < 1 || isClosed() ) { return; } addVertex( startPoint() ); }
AdvisorReligionWindow::AdvisorReligionWindow( CityPtr city, Widget* parent, int id ) : Widget( parent, id, Rect( 0, 0, 1, 1 ) ), _d( new Impl ) { setGeometry( Rect( Point( (parent->getWidth() - 640 )/2, parent->getHeight() / 2 - 242 ), Size( 640, 280 ) ) ); Label* title = new Label( this, Rect( 60, 10, 60 + 210, 10 + 40) ); title->setText( _("##Religion advisor##") ); title->setFont( Font::create( FONT_3 ) ); title->setTextAlignment( alignUpperLeft, alignCenter ); _d->background.reset( Picture::create( getSize() ) ); //main _d->_d->background PictureDecorator::draw( *_d->background, Rect( Point( 0, 0 ), getSize() ), PictureDecorator::whiteFrame ); //buttons _d->_d->background PictureDecorator::draw( *_d->background, Rect( 35, 62, getWidth() - 35, 62 + 130 ), PictureDecorator::blackFrame ); Picture& icon = Picture::load( ResourceGroup::panelBackground, 264 ); _d->background->draw( icon, Point( 11, 11 ) ); Font font = Font::create( FONT_1 ); font.draw( *_d->background, _("##Temples##"), 268, 32, false ); font.draw( *_d->background, _("##small##"), 240, 47, false ); font.draw( *_d->background, _("##large##"), 297, 47, false ); font.draw( *_d->background, _("##Fest.##"), 370, 47, false ); font.draw( *_d->background, _("##Mood##"), 450, 47, false ); Point startPoint( 42, 65 ); Size labelSize( 550, 20 ); Impl::InfrastructureInfo info = _d->getInfo( city, building::templeCeres, building::B_BIG_TEMPLE_CERES ); _d->lbCeresInfo = new ReligionInfoLabel( this, Rect( startPoint, labelSize ), DivinePantheon::ceres(), info.smallTemplCount, info.bigTempleCount ); info = _d->getInfo( city, building::B_TEMPLE_NEPTUNE, building::B_BIG_TEMPLE_NEPTUNE ); _d->lbNeptuneInfo = new ReligionInfoLabel( this, Rect( startPoint + Point( 0, 20), labelSize), DivinePantheon::neptune(), info.smallTemplCount, info.bigTempleCount ); info = _d->getInfo( city, building::B_TEMPLE_MERCURE, building::B_BIG_TEMPLE_MERCURE ); _d->lbMercuryInfo = new ReligionInfoLabel( this, Rect( startPoint + Point( 0, 40), labelSize), DivinePantheon::mercury(), info.smallTemplCount, info.bigTempleCount ); info = _d->getInfo( city, building::B_TEMPLE_MARS, building::B_BIG_TEMPLE_MARS ); _d->lbMarsInfo = new ReligionInfoLabel( this, Rect( startPoint + Point( 0, 60), labelSize), DivinePantheon::mars(), info.smallTemplCount, info.bigTempleCount ); info = _d->getInfo( city, building::B_TEMPLE_VENUS, building::B_BIG_TEMPLE_VENUS ); _d->lbVenusInfo = new ReligionInfoLabel( this, Rect( startPoint + Point( 0, 80), labelSize), DivinePantheon::venus(), info.smallTemplCount, info.bigTempleCount ); info = _d->getInfo( city, building::B_TEMPLE_ORACLE, building::B_TEMPLE_ORACLE ); _d->lbOracleInfo = new ReligionInfoLabel( this, Rect( startPoint + Point( 0, 100), labelSize), RomeDivinityPtr(), info.smallTemplCount, 0 ); _d->btnHelp = new TexturedButton( this, Point( 12, getHeight() - 39), Size( 24 ), -1, ResourceMenu::helpInfBtnPicId ); }
void MetropolisHastings::Initialize() { Algorithm::Initialize(); if (fBetas.empty()) fBetas = { 1.0 }; // const size_t nChainConfigs = fChains.size(); const size_t nBetas = fBetas.size(); // global start point in parameter space Sample startPoint( fParameterConfig.GetStartValues(false) ); Evaluate( startPoint ); startPoint.SetAccepted( true ); // if not set by the user, instantiate default proposal function if (!fProposalFunction) { LOG(Info, "Using default proposal function 'ProposalGaussian'."); fProposalFunction = make_shared<ProposalNormal>(); } // initialize chain configurations for (auto& chainConfig : fChainConfigs) { chainConfig.reset( new ChainConfig(nBetas, fParameterConfig, fProposalFunction.get()) ); // for each PT (beta) chain, setup an individual parameter configuration const double initialErrorScaling = fParameterConfig.GetErrorScaling(); for (size_t iBeta = 0; iBeta < nBetas; iBeta++) { // scale parameter configurations if (iBeta > 0) chainConfig->fDynamicParamConfigs[iBeta].SetErrorScaling( initialErrorScaling / sqrt(fBetas[iBeta]) ); // update proposal functions with parameter configuration chainConfig->fProposalFunctions[iBeta]->UpdateParameterConfig( chainConfig->fDynamicParamConfigs[iBeta] ); } // setup start points for (auto& chain : chainConfig->fPtChains) { // if required, randomize the starting vector for each chain if (fRandomizeStartPoint) { startPoint.Values() = GetParameterConfig().GetStartValues(true); Evaluate( startPoint ); } chain.reserve( GetTotalLength()+1 ); chain.push_back( startPoint ); } } }
bool QgsCurve::isClosed() const { if ( numPoints() == 0 ) return false; //don't consider M-coordinates when testing closedness QgsPointV2 start = startPoint(); QgsPointV2 end = endPoint(); return ( qgsDoubleNear( start.x(), end.x(), 1E-8 ) && qgsDoubleNear( start.y(), end.y(), 1E-8 ) && qgsDoubleNear( start.z(), end.z(), 1E-8 ) ); }
/** * Paints the specified arrow * @return the end point */ void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { // if (myStartItem->collidesWithItem(myEndItem)) return; QPen myPen = pen(); myPen.setColor(myColor); qreal arrowSize = 10; painter->setPen(myPen); painter->setBrush(myColor); setLine(QLineF(startPoint(), endPoint())); line1 = QLineF(startPoint(), midPoint()); line2 = QLineF(midPoint(), endPoint()); double angle = acos(line1.dx() / line1.length()); if (line1.dy() >= 0) angle = (Pi * 2) - angle; QPointF arrowP1 = line1.p1() + QPointF(sin(angle + Pi / 3) * arrowSize, cos(angle + Pi / 3) * arrowSize); QPointF arrowP2 = line1.p1() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize, cos(angle + Pi - Pi / 3) * arrowSize); //arrow corner cornerLine1= QLineF(endPoint(),endPoint()+QPointF(0,10)); cornerLine2= QLineF(endPoint(),endPoint()-QPointF(10,0)); arrowHead.clear(); arrowHead << line1.p1() << arrowP1 << arrowP2; painter->setRenderHint(QPainter::Antialiasing); painter->drawLine(line1); painter->drawLine(line2); painter->drawLine(cornerLine1); painter->drawLine(cornerLine2); painter->drawPolygon(arrowHead); }
void Font::drawSimpleText(GraphicsContext* context, const TextRunPaintInfo& runInfo, const FloatPoint& point) const { // This glyph buffer holds our glyphs+advances+font data for each glyph. GlyphBuffer glyphBuffer; float startX = point.x() + getGlyphsAndAdvancesForSimpleText(runInfo.run, runInfo.from, runInfo.to, glyphBuffer); if (glyphBuffer.isEmpty()) return; FloatPoint startPoint(startX, point.y()); drawGlyphBuffer(context, runInfo, glyphBuffer, startPoint); }
QgsAbstractGeometry *QgsCurve::boundary() const { if ( isEmpty() ) return nullptr; if ( isClosed() ) return nullptr; QgsMultiPoint *multiPoint = new QgsMultiPoint(); multiPoint->addGeometry( new QgsPoint( startPoint() ) ); multiPoint->addGeometry( new QgsPoint( endPoint() ) ); return multiPoint; }
/** * Writes game over on the gametable */ void GameTable::showGameOverScreen() { std::vector<GameTableLetterCube*> gameOver; std::string gameOverMsg("gameover"); std::string pressMsg("press"); std::string enterMsg("enter"); // create game over msg for(unsigned int i=0; i<gameOverMsg.size(); i++){ Point startPoint(i*this->cubeUnit+this->cubePadding+this->startX, this->height, 0.0f+this->cubePadding); Dimension dimension(this->cubeUnit-2*this->cubePadding, 0.3f-2*this->cubePadding, this->cubeUnit-2*this->cubePadding); GameTableLetterCube* letterCube = new GameTableLetterCube(startPoint, dimension, gameOverMsg.at(i), this->cubeUnit); gameOver.push_back(letterCube); } // create game over msg for(unsigned int i=0; i<pressMsg.size(); i++){ Point startPoint(i*this->cubeUnit+this->cubePadding+this->startX, this->height, 0.0f+this->cubePadding); Dimension dimension(this->cubeUnit-2*this->cubePadding, 0.3f-2*this->cubePadding, this->cubeUnit-2*this->cubePadding); GameTableLetterCube* letterCube = new GameTableLetterCube(startPoint, dimension, pressMsg.at(i), this->cubeUnit); letterCube->incrementRow(); gameOver.push_back(letterCube); } // create game over msg for(unsigned int i=0; i<enterMsg.size(); i++){ Point startPoint(i*this->cubeUnit+this->cubePadding+this->startX, this->height, 0.0f+this->cubePadding); Dimension dimension(this->cubeUnit-2*this->cubePadding, 0.3f-2*this->cubePadding, this->cubeUnit-2*this->cubePadding); GameTableLetterCube* letterCube = new GameTableLetterCube(startPoint, dimension, enterMsg.at(i), this->cubeUnit); letterCube->incrementRow(); letterCube->incrementRow(); gameOver.push_back(letterCube); } this->letterCubes.clear(); this->letterCubes = gameOver; }
void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, FloatPoint& point) const { #if !ENABLE(SVG_FONTS) UNUSED_PARAM(run); #endif // Draw each contiguous run of glyphs that use the same font data. const SimpleFontData* fontData = glyphBuffer.fontDataAt(0); FloatSize offset = glyphBuffer.offsetAt(0); FloatPoint startPoint(point.x(), point.y() - glyphBuffer.initialAdvance().height()); float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width(); float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height(); int lastFrom = 0; int nextGlyph = 1; #if ENABLE(SVG_FONTS) TextRun::RenderingContext* renderingContext = run.renderingContext(); #endif while (nextGlyph < glyphBuffer.size()) { const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph); FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph); if (nextFontData != fontData || nextOffset != offset) { #if ENABLE(SVG_FONTS) if (renderingContext && fontData->isSVGFont()) renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); else #endif drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); lastFrom = nextGlyph; fontData = nextFontData; offset = nextOffset; startPoint.setX(nextX); startPoint.setY(nextY); } nextX += glyphBuffer.advanceAt(nextGlyph).width(); nextY += glyphBuffer.advanceAt(nextGlyph).height(); nextGlyph++; } #if ENABLE(SVG_FONTS) if (renderingContext && fontData->isSVGFont()) renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); else { #endif drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); point.setX(nextX); #if ENABLE(SVG_FONTS) } #endif }
/** * Return whether on seq. line. * Takes into account destruction box if shown. * * @param p The point to investigate. * @return Non-zero if point is on this sequence line. */ int SeqLineWidget::onWidget(const QPoint & p) { int nOnWidget = 0; QPoint sp = startPoint(); QPoint ep = endPoint(); //see if on widget ( for message creation ) if( sp.x() - m_nMouseDownEpsilonX < p.x() && ep.x() + m_nMouseDownEpsilonX > p.x() && sp.y() < p.y() && ep.y() + 3 > p.y() ) { nOnWidget = 1; } return nOnWidget; }
void ReportPrintSetting::drawPosition(int type, QString content, QPainter &painter, int drawType,QString img, int fontSize, const QString family, bool bold) { ReportFormDefinition report; // QString file("../tcdstation/reportForm.xml"); QString file("reportForm.xml"); report.ReadReportContent(file); QRectF rectF; report.GetPosition(type,rectF); QFont font; font.setPointSize(fontSize); font.setBold(bold); font.setFamily(family); painter.setFont(font); if(drawType == SPLITTER) { QPoint startPoint(rectF.x(),rectF.y()); QPoint endPoint(rectF.x()+rectF.width(),rectF.y()+rectF.height()); painter.drawLine(startPoint,endPoint); } else if(drawType == TEXT) { painter.drawText(rectF,Qt::TextWordWrap,content); } else if(drawType == IMAGE) { //QImage image(img); QPixmap pixmap; pixmap.load(img); //painter.drawImage(rectF,image); painter.drawPixmap(rectF.x(),rectF.y(),rectF.width(),rectF.height(),pixmap); } else if(drawType == WIDGET) { QPixmap grabImage; QRect rect; rect.setSize(QSize(rectF.width(),rectF.height())); m_tableView->resize(rect.size()); grabImage = m_tableView->grab(QRect(0,0,m_tableView->width(),m_tableView->height())); grabImage.scaled(rect.size(),Qt::KeepAspectRatio); painter.drawPixmap(rectF.x(),rectF.y(),grabImage); } }