[QGIS-trac] Re: [Quantum GIS] #2868: Label alignment in composer

Quantum GIS qgis at qgis.org
Mon Jul 12 04:48:14 EDT 2010


#2868: Label alignment in composer
--------------------------------+-------------------------------------------
   Reporter:  medspx            |              Owner:  nobody       
       Type:  enhancement       |             Status:  new          
   Priority:  minor: annoyance  |          Milestone:  Version 1.6.0
  Component:  Printing          |            Version:               
   Keywords:                    |   Platform_version:               
   Platform:  All               |           Must_fix:  No           
Status_info:  0                 |  
--------------------------------+-------------------------------------------
Changes (by medspx):

  * component:  Build/Install => Printing


Comment:

 I tried to code this enhancement. The attachement is a png file which
 shows what could be a centered (horizontally) label in the composer.

 After looking into the code, the source files that need to be modified are
 in src/core/composer:

    * qgscomposerlabel.cpp (alignment attributes)
    * qgscomposeritem.cpp (effective printing)

 For the moment here is how I implement it:

   * the QPainter->drawText (QT native) already deals with vertical and
 horizontal alignment.
   * all we have to do is to pass the good args
   * I have add a halign and a valign attributes in QgsComposerLabel class
 in order to deals with horizontal and vertical alignements
   * those attributes are "text" formatted as I think that it is important
 to specify rather "center", "left or "right" (human readable in the qpt
 file) instead of the OR value from the mix of QT::AlignHCenter,
 QT::AlignLeft or QT::AlignRight values. This is only my point of view and
 it can be changed to the constant values OR number (easier to implement in
 the code cause you don't have to convert Strings to QT::Alignxxxx values).
   * I have add a new QgsComposerItem::drawText function which uses
 alignements args

 My next operation is a GUI implementation of this...

 I will post a patch as soon as possible !

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/2868#comment:1>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list