Example #1
0
void QgsMapSettings::readXml( QDomNode &node )
{
  // set destination CRS
  QgsCoordinateReferenceSystem srs;
  QDomNode srsNode = node.namedItem( QStringLiteral( "destinationsrs" ) );
  if ( !srsNode.isNull() )
  {
    srs.readXml( srsNode );
  }
  setDestinationCrs( srs );

  // set extent
  QDomNode extentNode = node.namedItem( QStringLiteral( "extent" ) );
  QgsRectangle aoi = QgsXmlUtils::readRectangle( extentNode.toElement() );
  setExtent( aoi );

  // set rotation
  QDomNode rotationNode = node.namedItem( QStringLiteral( "rotation" ) );
  QString rotationVal = rotationNode.toElement().text();
  if ( ! rotationVal.isEmpty() )
  {
    double rot = rotationVal.toDouble();
    setRotation( rot );
  }

  //render map tile
  QDomElement renderMapTileElem = node.firstChildElement( QStringLiteral( "rendermaptile" ) );
  if ( !renderMapTileElem.isNull() )
  {
    setFlag( QgsMapSettings::RenderMapTile, renderMapTileElem.text() == QLatin1String( "1" ) );
  }
}
Example #2
0
void QgsMapCanvas::zoomByFactor( double scaleFactor, const QgsPoint* center )
{
  QgsRectangle r = mapSettings().extent();
  r.scale( scaleFactor, center );
  setExtent( r );
  refresh();
}
Example #3
0
void QgsMapCanvasTracer::configure()
{
  setCrsTransformEnabled( mCanvas->mapSettings().hasCrsTransformEnabled() );
  setDestinationCrs( mCanvas->mapSettings().destinationCrs() );
  setExtent( mCanvas->extent() );

  QList<QgsVectorLayer*> layers;
  QStringList visibleLayerIds = mCanvas->mapSettings().layers();

  switch ( mCanvas->snappingUtils()->snapToMapMode() )
  {
    default:
    case QgsSnappingUtils::SnapCurrentLayer:
    {
      QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( mCanvas->currentLayer() );
      if ( vl && visibleLayerIds.contains( vl->id() ) )
        layers << vl;
    }
    break;
    case QgsSnappingUtils::SnapAllLayers:
      Q_FOREACH ( const QString& layerId, visibleLayerIds )
      {
        QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
        if ( vl )
          layers << vl;
      }
      break;
    case QgsSnappingUtils::SnapAdvanced:
      Q_FOREACH ( const QgsSnappingUtils::LayerConfig& cfg, mCanvas->snappingUtils()->layers() )
      {
        if ( visibleLayerIds.contains( cfg.layer->id() ) )
          layers << cfg.layer;
      }
      break;
  }
Example #4
0
void Point::putCoords(const qreal x, const qreal y)
{
    m_x = x;
    m_y = y;
    const QRectF extent(x, y, 0.0001, 0.0001); // minimum rect?
    setExtent(extent);
}
Example #5
0
GuiTabBookCtrl::GuiTabBookCtrl()
{
   VECTOR_SET_ASSOCIATION( mPages );
   
   mTabHeight = 24;
   mTabPosition = AlignTop;
   mActivePage = NULL;
   mHoverTab = NULL;
   mHasTexture = false;
   mBitmapBounds = NULL;
   setExtent( 400, 300 );
   mPageRect = RectI(0,0,0,0);
   mTabRect = RectI(0,0,0,0);
   mFrontTabPadding = 0;

   mPages.reserve(12);
   mTabMargin = 7;
   mMinTabWidth = 64;
   mIsContainer = true;
   mSelectedPageNum = -1;
   mDefaultPageNum = -1;

   mAllowReorder = false;
   mDraggingTab  = false;
   mDraggingTabRect = false;
   mIsFirstWake = true;
}
Example #6
0
void QgsMapCanvasTracer::configure()
{
  setDestinationCrs( mCanvas->mapSettings().destinationCrs() );
  setExtent( mCanvas->extent() );

  QList<QgsVectorLayer *> layers;
  QList<QgsMapLayer *> visibleLayers = mCanvas->mapSettings().layers();

  switch ( mCanvas->snappingUtils()->config().mode() )
  {
    default:
    case QgsSnappingConfig::ActiveLayer:
    {
      QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
      if ( vl && visibleLayers.contains( vl ) )
        layers << vl;
    }
    break;
    case QgsSnappingConfig::AllLayers:
      Q_FOREACH ( QgsMapLayer *layer, visibleLayers )
      {
        QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
        if ( vl )
          layers << vl;
      }
      break;
    case QgsSnappingConfig::AdvancedConfiguration:
      Q_FOREACH ( const QgsSnappingUtils::LayerConfig &cfg, mCanvas->snappingUtils()->layers() )
      {
        if ( visibleLayers.contains( cfg.layer ) )
          layers << cfg.layer;
      }
      break;
  }
Example #7
0
/*!
 * \brief CoOrdinateSystem::CoOrdinateSystem
 * \param coOrdinateSystem
 */
CoOrdinateSystem::CoOrdinateSystem(const CoOrdinateSystem &coOrdinateSystem)
{
  setExtent(coOrdinateSystem.getExtent());
  setPreserveAspectRatio(coOrdinateSystem.getPreserveAspectRatio());
  setInitialScale(coOrdinateSystem.getInitialScale());
  setGrid(coOrdinateSystem.getGrid());
}
Example #8
0
QScope::QScope(QWidget *parent, QGraph *ctrlr):
  QGraph(parent, ctrlr), qpa(0) {
  setCenter(0); setExtent(300);
  setGuideSpacing(125);
  nspikes = 0;
  //dbx("QScope constructor");
}
Example #9
0
void GuiTextListCtrl::setSize(Point2I newSize)
{
   mSize = newSize;

   if ( bool( mFont ) )
   {
      if ( mSize.x == 1 && mFitParentWidth )
      {
         GuiScrollCtrl* parent = dynamic_cast<GuiScrollCtrl *>(getParent());
         if ( parent )
            mCellSize.x = parent->getContentExtent().x;
      }
      else
      {
         // Find the maximum width cell:
         S32 maxWidth = 1;
         for ( U32 i = 0; i < mList.size(); i++ )
         {
            U32 rWidth = getRowWidth( &mList[i] );
            if ( rWidth > maxWidth )
               maxWidth = rWidth;
         }

         mCellSize.x = maxWidth + 8;
      }

      mCellSize.y = mFont->getHeight() + 2;
   }

   Point2I newExtent( newSize.x * mCellSize.x + mHeaderDim.x, newSize.y * mCellSize.y + mHeaderDim.y );
   setExtent( newExtent );
}
GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
{
    mBitmapMode = BitmapStretched;
    mAutoFitExtents = false;
    mUseModifiers = false;
    mUseStates = true;
    setExtent( 140, 30 );
}
Example #11
0
GuiTabPageCtrl::GuiTabPageCtrl(void)
{
   setExtent(Point2I(100, 200));
   mFitBook = false;
   dStrcpy(mText,(UTF8*)"TabPage");
   mActive = true;
   mIsContainer = true;
}
Example #12
0
//--------------------------------------------------------------------------
GuiSeparatorCtrl::GuiSeparatorCtrl() : GuiControl()
{
   mInvisible = false;
   mTextLeftMargin = 0;
   mMargin = 2;
   setExtent( 12, 35 );
   mSeparatorType = GuiSeparatorCtrl::separatorTypeVertical;
}
Example #13
0
GuiGradientSwatchCtrl::GuiGradientSwatchCtrl()
{
	setPosition(0, 0);
	setExtent(14, 14);
	mMouseDownPosition = Point2I(0, 0);
	mSwatchColor = ColorI( 1, 1, 1, 1 );
	mColorFunction = StringTable->insert("getColorF");
	setDataField( StringTable->insert("Profile"), NULL, "GuiInspectorSwatchButtonProfile" );
}
Example #14
0
/*!
 * \brief CoOrdinateSystem::CoOrdinateSystem
 */
CoOrdinateSystem::CoOrdinateSystem()
{
  QList<QPointF> extents;
  extents << QPointF(-100, -100) << QPointF(100, 100);
  setExtent(extents);
  setPreserveAspectRatio(true);
  setInitialScale(0.1);
  setGrid(QPointF(2, 2));
}
void ImageCanvas::CenterOnWorldPosition(const double & ux, const double & uy, const double & scale) {
    if (!image_layer->isValid()) return;
    double w = scale*this->width()/2*image_layer->rasterUnitsPerPixelX();
    double h = scale*this->height()/2*image_layer->rasterUnitsPerPixelY();
    QgsPoint min(ux-w, uy-h);
    QgsPoint max(ux+w, uy+h);
    QgsRectangle view(min, max);
    setExtent(view);
    refresh();
}
Barrier::Barrier(Point st, Point e, F32 width)
{
    mObjectTypeMask = BarrierType | CommandMapVisType;
    start = st;
    end = e;
    Rect r(start, end);
    mWidth = width;
    r.expand(Point(width, width));
    setExtent(r);
    mLastBarrierChangeIndex = 0;
}
Example #17
0
GuiSwatchButtonCtrl::GuiSwatchButtonCtrl()
   : mSwatchColor(1, 1, 1, 1), mUseSRGB(false)
{
   mButtonText = StringTable->insert( "" );   
   setExtent(140, 30);
   
   static StringTableEntry sProfile = StringTable->insert( "profile" );
   setDataField( sProfile, NULL, "GuiInspectorSwatchButtonProfile" );

   mGridBitmap = "tools/gui/images/transp_grid";
}
Example #18
0
//-------------------------------------
void GuiBitmapCtrl::inspectPostApply()
{
   // if the extent is set to (0,0) in the gui editor and appy hit, this control will
   // set it's extent to be exactly the size of the bitmap (if present)
   Parent::inspectPostApply();

   if (!mWrap && (getExtent().x == 0) && (getExtent().y == 0) && mTextureObject)
   {
      setExtent( mTextureObject->getWidth(), mTextureObject->getHeight());
   }
}
Example #19
0
void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn )
{
  double scaleFactor = ( zoomIn ? 1 / mWheelZoomFactor : mWheelZoomFactor );

  // transform the mouse pos to map coordinates
  QgsPoint center  = getCoordinateTransform()->toMapPoint( x, y );
  QgsRectangle r = mapSettings().visibleExtent();
  r.scale( scaleFactor, &center );
  setExtent( r );
  refresh();
}
Example #20
0
void QgsMapCanvas::setCenter( const QgsPoint& center )
{
  QgsRectangle r = mapSettings().extent();
  double x = center.x();
  double y = center.y();
  setExtent(
    QgsRectangle(
      x - r.width() / 2.0, y - r.height() / 2.0,
      x + r.width() / 2.0, y + r.height() / 2.0
    )
  );
} // setCenter
Example #21
0
void QgsFlatTerrainGenerator::readXml( const QDomElement &elem )
{
  QDomElement elemExtent = elem.firstChildElement( "extent" );
  double xmin = elemExtent.attribute( "xmin" ).toDouble();
  double xmax = elemExtent.attribute( "xmax" ).toDouble();
  double ymin = elemExtent.attribute( "ymin" ).toDouble();
  double ymax = elemExtent.attribute( "ymax" ).toDouble();

  setExtent( QgsRectangle( xmin, ymin, xmax, ymax ) );

  // crs is not read/written - it should be the same as destination crs of the map
}
Example #22
0
void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
{
   mTextureObject = handle;

   mBitmapName = String("texhandle");

   // Resize the control to fit the bitmap
   if (resize) 
   {
      setExtent(mTextureObject->getWidth(), mTextureObject->getHeight());
      updateSizing();
   }
}
Example #23
0
void QgsMapCanvas::zoomToFullExtent()
{
  QgsRectangle extent = fullExtent();
  // If the full extent is an empty set, don't do the zoom
  if ( !extent.isEmpty() )
  {
    // Add a 5% margin around the full extent
    extent.scale( 1.05 );
    setExtent( extent );
  }
  refresh();

} // zoomToFullExtent
Example #24
0
void GuiTheoraCtrl::setFile( const String& filename )
{
	mDone = false;
   mFilename = filename;
   mTheoraTexture.setFile( filename );
   
   if( mMatchVideoSize && mTheoraTexture.isReady() )
      setExtent( Point2I( mTheoraTexture.getWidth(), mTheoraTexture.getHeight() ) );

   OggTheoraDecoder* decoder = mTheoraTexture._getTheora();
   if( decoder != NULL )
      decoder->setTranscoder( mTranscoder );
}
Example #25
0
//--------------------------------------------------------------------------
GuiColorPickerCtrl::GuiColorPickerCtrl()
{
   setExtent(140, 30);
   mDisplayMode = pPallet;
   mBaseColor = ColorF(1.,.0,1.);
   mPickColor = ColorF(.0,.0,.0);
   mSelectorPos = Point2I(0,0);
   mMouseDown = mMouseOver = false;
   mActive = true;
   mPositionChanged = false;
   mSelectorGap = 1;
   mActionOnMove = false;
	mShowReticle = true;
}
Example #26
0
GuiGradientCtrl::GuiGradientCtrl()
{
   setExtent(140, 30);
   mDisplayMode = pHorizColorRange;
	mSaveDisplayMode = pHorizColorRange;
   mBaseColor = ColorF(1.,.0,1.);
   mPickColor = ColorF(.0,.0,.0);
   mMouseDown = mMouseOver = false;
   mActive = true;
   mPositionChanged = false;
   mActionOnMove = false;
	mShowReticle = true;
	colorWhiteBlend = ColorF(1.,1.,1.,.75);
	mSwatchFactor = 7;
}
Example #27
0
Camera::Camera(void)
//
// instantiates a camera where `extent` is the length of the longest
// edge of the bounding box of the entire model, including the
// surroundings
//
{
    roll  = 0.0;
    pitch = 0.0;
    yaw   = 0.0;
    // 'near' and 'far' components are set in setExtent()
    towards = Vector3(0.0, 0.0, 1.0); // OpenGL default
    defaultViewingVolume.left  = defaultViewingVolume.bottom = -1.0;
    defaultViewingVolume.right = defaultViewingVolume.top    =  1.0;
    setExtent(2.0); // should be revised once model is defined
    currentViewingVolume = defaultViewingVolume;
}
GuiSplitContainer::GuiSplitContainer()
 : mFixedPanel( None ),
   mFixedPanelSize( 100 ),
   mOrientation( Vertical ),
   mSplitterSize( 2 ),
   mSplitPoint( 0, 0 ),
   mSplitRect( 0, 0, mSplitterSize, mSplitterSize ),
   mDragging( false )
{
   setMinExtent( Point2I(64,64) );
   setExtent(200,200);
   setDocking( Docking::dockNone );

   mSplitPoint.set( 300, 100 );

   // We only support client docked items in a split container
   mValidDockingMask = Docking::dockClient;
}
void GuiConsoleTextCtrl::calcResize()
{
   if ( mResult.isEmpty() )
      return;

   // The width is the longest line.
   U32 ctrlWidth = 0;
   for ( U32 i = 0; i < mLineLen.size(); i++ )
   {
      U32 width = mFont->getStrNWidth( mResult.c_str() + mStartLineOffset[i], mLineLen[i] );

      if ( width > ctrlWidth )
         ctrlWidth = width;
   }

   // The height is the number of lines times the height of the font.
   U32 ctrlHeight = mLineLen.size() * mFont->getHeight();   

   setExtent( Point2I( ctrlWidth, ctrlHeight ) + mProfile->mTextOffset * 2 );
}
Example #30
0
void GuiTheoraCtrl::inspectPostApply()
{
   if( !mTheoraTexture.getFilename().equal( mFilename, String::NoCase ) )
   {
      stop();
      setFile( mFilename );
      
      if( mPlayOnWake && !mTheoraTexture.isPlaying() )
         play();
   }
   
   if( mMatchVideoSize && mTheoraTexture.isReady() )
      setExtent( Point2I( mTheoraTexture.getWidth(), mTheoraTexture.getHeight() ) );

   OggTheoraDecoder* decoder = mTheoraTexture._getTheora();
   if( decoder != NULL )
      decoder->setTranscoder( mTranscoder );
      
   Parent::inspectPostApply();
}