本文整理汇总了C++中centerOn函数的典型用法代码示例。如果您正苦于以下问题:C++ centerOn函数的具体用法?C++ centerOn怎么用?C++ centerOn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了centerOn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: connect
void SearchWidget::setMarbleWidget( MarbleWidget* widget )
{
if ( d->m_widget ) {
return;
}
d->m_widget = widget;
d->m_searchField->setCompletionModel( widget->model()->placemarkModel() );
connect( d->m_searchField, SIGNAL(centerOn(GeoDataCoordinates)),
widget, SLOT(centerOn(GeoDataCoordinates)) );
d->m_runnerManager = new MarbleRunnerManager( widget->model()->pluginManager(), this );
d->m_runnerManager->setModel( widget->model() );
connect( d->m_runnerManager, SIGNAL(searchResultChanged(QVector<GeoDataPlacemark*>)),
this, SLOT(setSearchResult(QVector<GeoDataPlacemark*>)) );
connect( d->m_runnerManager, SIGNAL(searchFinished(QString)),
d->m_searchField, SLOT(disableSearchAnimation()));
GeoDataTreeModel* treeModel = d->m_widget->model()->treeModel();
treeModel->addDocument( d->m_document );
d->m_branchfilter.setSourceModel( treeModel );
d->m_branchfilter.setBranchIndex( treeModel, treeModel->index( d->m_document ) );
d->m_searchResultView->setRootIndex(
d->m_sortproxy.mapFromSource(
d->m_branchfilter.mapFromSource( treeModel->index( d->m_document ) ) ) );
}
开发者ID:oberluz,项目名称:marble,代码行数:29,代码来源:SearchWidget.cpp
示例2: viewport
void PathView::zoom(int z, const QPoint &pos)
{
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
return;
QPoint offset = pos - viewport()->rect().center();
QPointF spos = mapToScene(pos);
qreal os = mapScale(_zoom);
_zoom = z;
rescale(_zoom);
QRectF sr = contentsSceneRect();
_scene->setSceneRect(sr);
if (sr.width() < viewport()->size().width()
&& sr.height() < viewport()->size().height())
centerOn(sr.center());
else
centerOn((spos * (os/mapScale(_zoom))) - offset);
_mapScale->setZoom(_zoom);
resetCachedContent();
}
开发者ID:tumic0,项目名称:GPXSee,代码行数:26,代码来源:pathview.cpp
示例3: centerOn
void AutoNavigation::Private::moveOnBorderToCenter( const GeoDataCoordinates &position, qreal )
{
qreal x = 0.0;
qreal y = 0.0;
//recenter if initially the gps location is not visible on the screen
if(!( m_viewport->screenCoordinates( position, x, y ) ) ) {
centerOn( position );
}
qreal centerLon = m_viewport->centerLongitude();
qreal centerLat = m_viewport->centerLatitude();
qreal centerX = 0.0;
qreal centerY = 0.0;
m_viewport->screenCoordinates( centerLon, centerLat, centerX, centerY );
const qreal borderRatio = 0.25;
//defining the default border distance from map center
int shiftX = qRound( centerX * borderRatio );
int shiftY = qRound( centerY * borderRatio );
QRect recenterBorderBound;
recenterBorderBound.setCoords( centerX-shiftX, centerY-shiftY, centerX+shiftX, centerY+shiftY );
if( !recenterBorderBound.contains( x,y ) ) {
centerOn( position );
}
}
开发者ID:KDE,项目名称:marble,代码行数:28,代码来源:AutoNavigation.cpp
示例4: QRect
void MapView::centerMapOnPath(QGraphicsPathItem *path)
{
if (path == 0) {qDebug("cMoP: path is null!"); return; }
QRect view = QRect(0,0,width(),height());
QPoint center = view.center();
QRect nextView = view;
nextView.setSize(view.size()/2);
nextView.moveCenter(center);
QRectF pathBoundingRect = path->boundingRect();
//if the item has no path data, abort
if(pathBoundingRect.width() == 0.0)
{
qDebug("This item has no valid path");
return;
}
centerOn(path);
if (mapToScene(view).boundingRect().contains(pathBoundingRect))
{
centerOn(path);
while (mapToScene(nextView).boundingRect().contains(pathBoundingRect)) {zoom(1);}
} else {
while (!mapToScene(view).boundingRect().contains(pathBoundingRect)) {zoom(-1);}
}
}
开发者ID:mueslo,项目名称:TEA,代码行数:28,代码来源:mapview.cpp
示例5: connect
void SerialTrack::append(PlaybackItem* item)
{
connect( item, SIGNAL( progressChanged( double ) ), this, SLOT( changeProgress( double ) ) );
connect( item, SIGNAL( centerOn( GeoDataCoordinates ) ), this, SIGNAL( centerOn( GeoDataCoordinates ) ) );
connect( item, SIGNAL( finished() ), this, SLOT( handleFinishedItem() ) ) ;
connect( item, SIGNAL( paused() ), this, SLOT( pause() ) ) ;
m_items.append( item );
if( m_items.size() == 1 ) {
PlaybackFlyToItem *flyTo = dynamic_cast<PlaybackFlyToItem*>( item );
if( flyTo != 0 ) {
flyTo->setFirst( true )
; }
}
}
开发者ID:calincru,项目名称:marble,代码行数:14,代码来源:SerialTrack.cpp
示例6: pow
void GraphicsView::wheelEvent(QWheelEvent *event)
{
if(event->modifiers().testFlag(Qt::ControlModifier))
{
const int numSteps = event->delta() / 15 / 8;
if (numSteps == 0)
{
event->ignore();
return;
}
const qreal factor = pow(ZOOM_FACTOR, numSteps);
if((zoomCount > ZOOM_LIMIT && factor > 1) || (zoomCount == 0 && factor < 1))
return;
if(factor > 1)
zoomCount += 1;
else
zoomCount -= 1;
scale(factor, factor);
centerOn(mapToScene(event->pos()));
}
else
QGraphicsView::wheelEvent(event);
}
开发者ID:cfillion,项目名称:cfiSlides,代码行数:26,代码来源:graphicsview.cpp
示例7: rect
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();
}
}
开发者ID:Lisy09Personal,项目名称:opentoonz,代码行数:28,代码来源:schematicviewer.cpp
示例8: centerOn
void SchematicSceneViewer::centerOnCurrent()
{
SchematicScene *schematicScene = dynamic_cast<SchematicScene *>(scene());
QGraphicsItem *node = schematicScene->getCurrentNode();
if (node)
centerOn(node);
}
开发者ID:Lisy09Personal,项目名称:opentoonz,代码行数:7,代码来源:schematicviewer.cpp
示例9: matrix
void SchematicSceneViewer::zoomQt(bool zoomin, bool resetZoom)
{
#if QT_VERSION >= 0x050000
double scale2 = matrix().determinant();
#else
double scale2 = matrix().det();
#endif
// if the zoom scale is changed over 100% in FxSchematic, call updateScene
bool beforeIsLarge = (scale2 >= 1.0);
if (resetZoom || ((scale2 < 100000 || !zoomin) && (scale2 > 0.001 * 0.05 || zoomin))) {
double oldZoomScale = sqrt(scale2);
double zoomScale = resetZoom ? 1 : ImageUtils::getQuantizedZoomFactor(oldZoomScale, zoomin);
QMatrix scale = QMatrix().scale(zoomScale / oldZoomScale, zoomScale / oldZoomScale);
//See QGraphicsView::mapToScene()'s doc for details
QRect rect(0, 0, width(), height());
QRectF sceneCenterRect(mapToScene(QRect(rect.center(), QSize(2, 2))).boundingRect());
setMatrix(scale, true);
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();
}
}
}
开发者ID:Lisy09Personal,项目名称:opentoonz,代码行数:34,代码来源:schematicviewer.cpp
示例10: setScale
//!
//! Resets the network graphics view's matrix.
//!
void BaseGraphicsView::homeView ()
{
setScale(1);
QRectF boundingRect = scene()->itemsBoundingRect();
centerOn(boundingRect.left() + boundingRect.width() / 2, boundingRect.top() + boundingRect.height() / 2);
}
开发者ID:banduladh,项目名称:levelfour,代码行数:10,代码来源:BaseGraphicsView.cpp
示例11: centerOn
void
Panned::slotSetPannedRect(QRectF pr)
{
centerOn(pr.center());
// setSceneRect(pr);
// m_pannedRect = pr;
}
开发者ID:UIKit0,项目名称:rosegarden,代码行数:7,代码来源:Panned.cpp
示例12: centerOn
void SmViewPanel::mouseMoveEvent(QMouseEvent *event)
{
if (is_left_mouse_pressed_ && (sm_gadget_==smgis::ZoomIn ||sm_gadget_==smgis::ZoomOut))
{
is_mouse_dragged_=true;
mouse_current_point_= event->pos();
mouse_max_dragged_point_.setX((mouse_max_dragged_point_.x() > mouse_current_point_.x())?
mouse_max_dragged_point_.x():mouse_current_point_.x());
mouse_max_dragged_point_.setY((mouse_max_dragged_point_.y() > mouse_current_point_.y())?
mouse_max_dragged_point_.y():mouse_current_point_.y());
this->viewport()->update();
}
if(sm_gadget_==smgis::Pan)
{
mouse_current_point_=event->pos();
QPoint delta_x=mouse_current_point_-mouse_press_point_;
view_center_point_=view_center_point_-delta_x;
centerOn(mapToScene( view_center_point_) );
mouse_press_point_=mouse_current_point_;
view_center_point_=this->viewport()->rect().center();
}
QGraphicsView::mouseMoveEvent(event);
}
开发者ID:maroofi,项目名称:smgis,代码行数:25,代码来源:sm_view_panel.cpp
示例13: zoom_extent
void SmViewPanel::mouseReleaseEvent ( QMouseEvent * event )
{
is_left_mouse_pressed_=false;
if ((sm_gadget_==smgis::ZoomIn ||sm_gadget_==smgis::ZoomOut) && is_mouse_dragged_)
{
mouse_current_point_=event->pos();
QRect zoom_extent(mouse_press_point_,mouse_current_point_);
QPointF first_point=mapToScene(zoom_extent.center());
double scale_rate=(zoom_extent.width()>zoom_extent.height())?zoom_extent.width():
zoom_extent.height();
double darsad=viewport()->width()>viewport()->height()?viewport()->height():
viewport()->width();
if (sm_gadget_==smgis::ZoomIn)
scale(qAbs(darsad/scale_rate),qAbs(darsad/scale_rate));
if(sm_gadget_==smgis::ZoomOut)
scale(qAbs(scale_rate/darsad),qAbs(scale_rate/darsad));
// QPointF second_point=mapToScene(zoom_extent.center());
// std::cout<<first_point.x()<<","<<first_point.y()
// <<"-------"<<second_point.x()<<","<<second_point.y()<<std::endl;
centerOn(first_point);
is_mouse_dragged_=false;
}
else if (sm_gadget_==smgis::FullExtent)
{
sm_gadget_=smgis::Cursor;
return;
}
else if (sm_gadget_==smgis::Cursor)
{
QPointF cl=mapToScene(event->pos());
temp_item_=(SmGeoItem*)scene_handle_->itemAt(cl);
if (temp_item_)
{
this->viewport()->update();
}
return;
}
else if (sm_gadget_==smgis::Pan)
{
this->setCursor(Qt::OpenHandCursor);
mouse_press_point_=QPoint();
}
else if (sm_gadget_==smgis::Identify)
{
QPointF cl=mapToScene(event->pos());
temp_item_=(SmGeoItem*)scene_handle_->itemAt(cl);
if (temp_item_)
{
identify_table_->execute(temp_item_->get_item_id_());
this->viewport()->update();
}
}
QGraphicsView::mouseReleaseEvent(event);
}
开发者ID:maroofi,项目名称:smgis,代码行数:60,代码来源:sm_view_panel.cpp
示例14: qDebug
void GraphView::moveTo(const QModelIndex &index)
{
QTableView *view = qobject_cast<QTableView *>(QObject::sender());
GraphTableProxyModel *tableProxy = static_cast<GraphTableProxyModel *>(view->model());
if (tableProxy == NULL)
{
qDebug() << "[GraphView]: can't cast sender of signal";
return;
}
QVariant var = tableProxy->data(QModelIndex(), objectIdListRole);
mapIntToInt idMap = qvariant_cast<mapIntToInt>(var);
foreach(int id, idMap)
{
qDebug() << "[GraphView]: (table, model):(" << id << "," << idMap[id] << ")";
}
int modelRow = idMap.value(index.row(), -1);
ObjectVisual *obj = scene()->getObjectById(modelRow);
if (obj != NULL)
{
qDebug() << "[GraphView]: moving to #" << modelRow <<
"(tabled as#" << index.row() << ")=" << obj;
centerOn(obj);
}
}
开发者ID:OSLL,项目名称:sca,代码行数:25,代码来源:GraphView.cpp
示例15: m_scene
Palapeli::PieceHolder::PieceHolder(QWidget* parent, const QSizeF& pieceArea,
const QString& title)
: m_scene(scene())
{
qDebug() << "CONSTRUCTING Palapeli::PieceHolder" << title;
setParent(parent);
setWindowFlags(Qt::Window | Qt::Tool | Qt::WindowTitleHint);
// Allow space for (2 * 2) pieces in minimum view initially.
m_scene->setPieceAreaSize(pieceArea);
m_scene->initializeGrid(QPointF(0.0, 0.0));
m_scene->setMinGrid(minGrid);
// Add margin for constraint_handles+spacer and setSceneRect().
QRectF rect = m_scene->piecesBoundingRect();
qreal handleWidth = qMin(rect.width(), rect.height())/25.0;
m_scene->addMargin(handleWidth, 0.5*handleWidth);
setWindowTitle(title);
qreal s = calculateCloseUpScale();
QRectF r = m_scene->sceneRect();
setMinimumSize(s*r.width()+1.0, s*r.height()+1.0);
resize(minimumSize());
qDebug() << "Close-up scale" << s << "pieceArea" << pieceArea
<< "size" << size();
QTransform t;
t.scale(s, s);
setTransform(t);
centerOn(r.center());
setSelected(true);
show();
}
开发者ID:KDE,项目名称:palapeli,代码行数:29,代码来源:pieceholder.cpp
示例16: QGraphicsView
QtTextureViewer::QtTextureViewer(QWidget* parent)
: QGraphicsView(parent)
{
m_scene = new QGraphicsScene();
m_scene->setSceneRect(0, 0, 2048, 2048);
setScene(m_scene);
centerOn(1024, 1024);
m_pixmapItem = new QGraphicsPixmapItem();
m_scene->addItem(m_pixmapItem);
setBackground();
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setRenderHint(QPainter::Antialiasing, false);
setTransformationAnchor(AnchorUnderMouse);
setDragMode(ScrollHandDrag);
viewport()->setCursor(Qt::ArrowCursor);
// Turn this off to make background grid pixmap sharp
setRenderHint(QPainter::SmoothPixmapTransform, false);
// Zoom in out to the current cursor location
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
}
开发者ID:creepydragon,项目名称:r2,代码行数:26,代码来源:QtTextureViewer.cpp
示例17: reset
void qfi_VSI::init()
{
m_scaleX = (float)width() / (float)m_originalWidth;
m_scaleY = (float)height() / (float)m_originalHeight;
reset();
m_itemFace = new QGraphicsSvgItem( ":/qfi/"+m_theme+"/vsi/vsi_face.svg" );
m_itemFace->setCacheMode( QGraphicsItem::NoCache );
m_itemFace->setZValue( m_faceZ );
m_itemFace->setTransform( QTransform::fromScale( m_scaleX, m_scaleY ), true );
m_scene->addItem( m_itemFace );
m_itemHand = new QGraphicsSvgItem( ":/qfi/"+m_theme+"/vsi/vsi_hand.svg" );
m_itemHand->setCacheMode( QGraphicsItem::NoCache );
m_itemHand->setZValue( m_handZ );
m_itemHand->setTransform( QTransform::fromScale( m_scaleX, m_scaleY ), true );
m_itemHand->setTransformOriginPoint( m_originalVsiCtr );
m_scene->addItem( m_itemHand );
m_itemCase = new QGraphicsSvgItem( ":/qfi/"+m_theme+"/vsi/vsi_case.svg" );
m_itemCase->setCacheMode( QGraphicsItem::NoCache );
m_itemCase->setZValue( m_caseZ );
m_itemCase->setTransform( QTransform::fromScale( m_scaleX, m_scaleY ), true );
m_scene->addItem( m_itemCase );
centerOn( width() / 2.0f , height() / 2.0f );
updateView();
}
开发者ID:mrdeveloperdude,项目名称:OctoMY,代码行数:30,代码来源:qfi_VSI.cpp
示例18: addWaypoints
QList<PathItem *> PathView::loadData(const Data &data)
{
QList<PathItem *> paths;
int zoom = _zoom;
for (int i = 0; i < data.tracks().count(); i++)
paths.append(addTrack(*(data.tracks().at(i))));
for (int i = 0; i < data.routes().count(); i++)
paths.append(addRoute(*(data.routes().at(i))));
addWaypoints(data.waypoints());
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
return paths;
if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
|| (_waypoints.size() && _zoom < zoom))
rescale(_zoom);
else
updatePOIVisibility();
QRectF sr = contentsSceneRect();
_scene->setSceneRect(sr);
centerOn(sr.center());
_mapScale->setZoom(_zoom, -(sr.center().ry() * mapScale(_zoom)));
if (_mapScale->scene() != _scene)
_scene->addItem(_mapScale);
return paths;
}
开发者ID:tumic0,项目名称:GPXSee,代码行数:31,代码来源:pathview.cpp
示例19: setEnabled
void PianoView::setStaff(Staff* s, Pos* l)
{
staff = s;
_locator = l;
setEnabled(staff != nullptr);
if (!staff) {
scene()->blockSignals(true); // block changeSelection()
scene()->clear();
scene()->blockSignals(false);
return;
}
pos.setContext(staff->score()->tempomap(), staff->score()->sigmap());
Measure* lm = staff->score()->lastMeasure();
ticks = lm->tick() + lm->ticks();
scene()->setSceneRect(0.0, 0.0, double(ticks + 960), keyHeight * 75);
updateNotes();
//
// move to something interesting
//
QList<QGraphicsItem*> items = scene()->selectedItems();
QRectF boundingRect;
foreach (QGraphicsItem* item, items) {
if (item->type() == PianoItemType)
boundingRect |= item->mapToScene(item->boundingRect()).boundingRect();
}
centerOn(boundingRect.center());
horizontalScrollBar()->setValue(0);
}
开发者ID:trig-ger,项目名称:MuseScore,代码行数:31,代码来源:pianoview.cpp
示例20: centerOn
void PagesView::handleSmoothScroll (int frame)
{
const int endFrame = ScrollTimeline_->endFrame ();
auto interp = [frame, endFrame] (const QPair<qreal, qreal>& pair)
{ return pair.first + (pair.second - pair.first) * frame / endFrame; };
centerOn (interp (XPath_), interp (YPath_));
}
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:7,代码来源:pagesview.cpp
注:本文中的centerOn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论