kivio

kivio_sml_stencil.cpp

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2003 theKompany.com & Dave Marotti
00004  *                         Peter Simonsson
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  */
00020 #include "kivioglobal.h"
00021 #include "kivio_common.h"
00022 #include "kivio_connector_point.h"
00023 #include "kivio_connector_target.h"
00024 #include "kivio_fill_style.h"
00025 #include "kivio_intra_stencil_data.h"
00026 #include "kivio_line_style.h"
00027 #include "kivio_painter.h"
00028 #include "kivio_screen_painter.h"
00029 #include "kivio_shape.h"
00030 #include "kivio_shape_data.h"
00031 #include "kivio_sml_stencil.h"
00032 #include "kivio_dia_stencil_spawner.h"
00033 #include "kivio_sml_stencil_spawner.h"
00034 #include "kivio_stencil_spawner.h"
00035 #include "kivio_stencil_spawner_info.h"
00036 #include "kivio_stencil_spawner_set.h"
00037 
00038 #include <qdom.h>
00039 #include <qpainter.h>
00040 #include <qbrush.h>
00041 #include <qcolor.h>
00042 #include <qpalette.h>
00043 #include <qrect.h>
00044 #include <qbitmap.h>
00045 #include <kdebug.h>
00046 #include <KoGlobal.h>
00047 #include <math.h>
00048 #include <KoZoomHandler.h>
00049 
00055 KivioSMLStencil::KivioSMLStencil()
00056     : KivioStencil(),
00057       m_pShapeList(NULL),
00058       m_pSubSelection(NULL),
00059       m_pConnectorTargets(NULL)
00060 {
00061     m_pShapeList = new QPtrList<KivioShape>;
00062     m_pShapeList->setAutoDelete(true);
00063 
00064     m_pConnectorTargets = new QPtrList<KivioConnectorTarget>;
00065     m_pConnectorTargets->setAutoDelete(true);
00066 }
00067 
00068 
00074 KivioSMLStencil::~KivioSMLStencil()
00075 {
00076     delete m_pShapeList;
00077     m_pShapeList = 0;
00078     
00079     delete m_pConnectorTargets;
00080     m_pConnectorTargets = 0;
00081     
00082     m_pSubSelection = 0;
00083 }
00084 
00085 
00089 bool KivioSMLStencil::loadXML( const QDomElement &e )
00090 {
00091     QDomNode node;
00092     QDomElement ele;
00093 
00094 
00095     node = e.firstChild();
00096     while( !node.isNull() )
00097     {
00098         QString nodeName = node.nodeName();
00099 
00100         ele = node.toElement();
00101 
00102         if( nodeName == "Position" )
00103         {
00104             m_x = XmlReadFloat( ele, "x", 0.0f );
00105             m_y = XmlReadFloat( ele, "y", 0.0f );
00106         }
00107         else if( nodeName == "Dimension" )
00108         {
00109             m_w = XmlReadFloat( ele, "w", 0.0f );
00110             m_h = XmlReadFloat( ele, "h", 0.0f );
00111         }
00112         else if( nodeName == "KivioShape" )
00113         {
00114             // Locate the shape we are supposed to load into
00115             KivioShape *pShape = locateShape( XmlReadString( ele, "name", "" ) );
00116 
00117             if(pShape) {
00118               pShape->loadXML( ele );
00119             }
00120         }
00121         else if( nodeName == "KivioConnectorTargetList" )
00122         {
00123             loadConnectorTargetListXML( ele );
00124         }
00125 
00126         node = node.nextSibling();
00127     }
00128     return true;
00129 }
00130 
00134 void KivioSMLStencil::loadConnectorTargetListXML( const QDomElement &e )
00135 {
00136   QDomNode node;
00137   QDomElement ele;
00138   QString nodeName;
00139   KivioConnectorTarget *pTarget;
00140 
00141   pTarget = m_pConnectorTargets->first();
00142   node = e.firstChild();
00143   while( !node.isNull() && pTarget)
00144   {
00145     nodeName = node.nodeName();
00146     ele = node.toElement();
00147 
00148     if( nodeName == "KivioConnectorTarget" )
00149     {
00150       pTarget->loadXML( ele );
00151       pTarget->setOffsets((pTarget->x() - x()) / w(), (pTarget->y() - y()) / h());
00152       pTarget = m_pConnectorTargets->next();
00153     }
00154 
00155     node = node.nextSibling();
00156   }
00157   
00158   while(!node.isNull()) {
00159     nodeName = node.nodeName();
00160     ele = node.toElement();
00161 
00162     if( nodeName == "KivioConnectorTarget" )
00163     {
00164       pTarget = new KivioConnectorTarget();
00165       pTarget->loadXML( ele );
00166       pTarget->setOffsets((pTarget->x() - x()) / w(), (pTarget->y() -y()) / h());
00167       m_pConnectorTargets->append(pTarget);
00168     }
00169 
00170     node = node.nextSibling();
00171   }
00172 }
00173 
00174 
00178 KivioShape *KivioSMLStencil::locateShape( const QString &name )
00179 {
00180     KivioShape *pShape;
00181 
00182     if( name.isEmpty() )
00183         return NULL;
00184 
00185     pShape = m_pShapeList->first();
00186     while( pShape )
00187     {
00188         if( pShape->shapeData()->name() == name )
00189         {
00190             return pShape;
00191         }
00192 
00193         pShape = m_pShapeList->next();
00194     }
00195 
00196     return NULL;
00197 }
00198 
00199 
00203 QDomElement KivioSMLStencil::saveXML( QDomDocument &doc )
00204 {
00205     QDomElement e = doc.createElement("KivioSMLStencil");
00206 
00207     XmlWriteString( e, "id", m_pSpawner->info()->id() );
00208     XmlWriteString( e, "setId", m_pSpawner->set()->id() );
00209 
00210 
00211     // The positions
00212     QDomElement posE = doc.createElement("Position");
00213     XmlWriteFloat( posE, "x", m_x );
00214     XmlWriteFloat( posE, "y", m_y );
00215     e.appendChild( posE );
00216 
00217     // The dimensions
00218     QDomElement dimE = doc.createElement("Dimension");
00219     XmlWriteFloat( dimE, "w", m_w );
00220     XmlWriteFloat( dimE, "h", m_h );
00221     e.appendChild( dimE );
00222 
00223     // Save the target list
00224     QDomElement clE = doc.createElement("KivioConnectorTargetList");
00225     QDomElement targetE;
00226     KivioConnectorTarget *pTarget = m_pConnectorTargets->first();
00227     while( pTarget )
00228     {
00229         targetE = pTarget->saveXML( doc );
00230         clE.appendChild( targetE );
00231 
00232         pTarget = m_pConnectorTargets->next();
00233     }
00234     e.appendChild( clE );
00235 
00236     // The shape list
00237     KivioShape *pShape = m_pShapeList->first();
00238     while( pShape )
00239     {
00240         e.appendChild( pShape->saveXML(doc ) );
00241 
00242         pShape = m_pShapeList->next();
00243     }
00244 
00245     return e;
00246 }
00247 
00248 
00255 KivioStencil *KivioSMLStencil::duplicate()
00256 {
00257     KivioSMLStencil *pNewStencil = new KivioSMLStencil();
00258     KivioStencil *pReturn;
00259     KivioShape *pShape, *pNewShape;
00260 
00261     pNewStencil->m_x = m_x;
00262     pNewStencil->m_y = m_y;
00263     pNewStencil->m_w = m_w;
00264     pNewStencil->m_h = m_h;
00265 
00266     pNewStencil->m_rotation = m_rotation;
00267 
00268     pNewStencil->m_pSpawner = m_pSpawner;
00269 
00270 
00271     // Copy the shape list
00272     pShape = m_pShapeList->first();
00273     while( pShape )
00274     {
00275         pNewShape = new KivioShape( *pShape );
00276         pNewStencil->m_pShapeList->append( pNewShape );
00277 
00278         pShape = m_pShapeList->next();
00279     }
00280 
00281     // Copy the Connector Targets
00282     KivioConnectorTarget *pTarget = m_pConnectorTargets->first();
00283 
00284     while( pTarget ) //&& pOriginal )
00285     {
00286         pNewStencil->m_pConnectorTargets->append( pTarget->duplicate() );
00287         pTarget = m_pConnectorTargets->next();
00288     }
00289 
00290     *(pNewStencil->protection()) = *m_pProtection;
00291     *(pNewStencil->canProtect()) = *m_pCanProtect;
00292 
00293 
00294     pReturn = pNewStencil;
00295 
00296     return pReturn;
00297 }
00298 
00299 
00303 void KivioSMLStencil::paintOutline( KivioIntraStencilData *pData )
00304 {
00305     KivioShape *pShape;
00306     KivioShapeData *pShapeData;
00307 
00308     m_zoomHandler = pData->zoomHandler;
00309     pData->painter->saveState();
00310     pData->painter->setTranslation(m_zoomHandler->zoomItX(m_x), m_zoomHandler->zoomItY(m_y));
00311     rotatePainter(pData);  // Rotate the painter if needed
00312 
00313     pShape = m_pShapeList->first();
00314     while( pShape )
00315     {
00316         pShapeData = pShape->shapeData();
00317 
00318         switch( pShapeData->shapeType() )
00319         {
00320             case KivioShapeData::kstArc:
00321                 drawOutlineArc( pShape, pData );
00322                 break;
00323 
00324             case KivioShapeData::kstPie:
00325                 drawOutlinePie( pShape, pData );
00326                 break;
00327 
00328             case KivioShapeData::kstLineArray:
00329                 drawOutlineLineArray( pShape, pData );
00330                 break;
00331 
00332             case KivioShapeData::kstPolyline:
00333                 drawOutlinePolyline( pShape, pData );
00334                 break;
00335 
00336             case KivioShapeData::kstPolygon:
00337                 drawOutlinePolygon( pShape, pData );
00338                 break;
00339 
00340             case KivioShapeData::kstBezier:
00341                 drawOutlineBezier( pShape, pData );
00342                 break;
00343 
00344             case KivioShapeData::kstRectangle:
00345                 drawOutlineRectangle( pShape, pData );
00346                 break;
00347 
00348             case KivioShapeData::kstRoundRectangle:
00349                 drawOutlineRoundRectangle( pShape, pData );
00350                 break;
00351 
00352             case KivioShapeData::kstEllipse:
00353                 drawOutlineEllipse( pShape, pData );
00354                 break;
00355 
00356             case KivioShapeData::kstOpenPath:
00357                 drawOutlineOpenPath( pShape, pData );
00358                 break;
00359 
00360             case KivioShapeData::kstClosedPath:
00361                 drawOutlineClosedPath( pShape, pData );
00362                 break;
00363 
00364             case KivioShapeData::kstTextBox:
00365                 drawOutlineTextBox( pShape, pData );
00366                 break;
00367 
00368 
00369             case KivioShapeData::kstNone:
00370             default:
00371                 kdDebug(43000) << "*** KivioShape::Paint AHHHHH!!! NO SHAPE!" << endl;
00372                 break;
00373         }
00374 
00375         pShape = m_pShapeList->next();
00376     }
00377     pData->painter->restoreState();
00378 
00379     // Now iterate through anything connected to it drawing it as an outline
00380     KivioConnectorTarget *pTarget;
00381 
00382     pTarget = m_pConnectorTargets->first();
00383     while( pTarget )
00384     {
00385         pTarget->paintOutline( pData );
00386 
00387         pTarget = m_pConnectorTargets->next();
00388     }
00389 }
00390 
00391 void KivioSMLStencil::drawOutlineArc( KivioShape *pShape, KivioIntraStencilData *pData )
00392 {
00393     double _a, _l, _x, _y, _w, _h, defWidth, defHeight;
00394     KivioPainter *painter;
00395     KivioShapeData *pShapeData;
00396     KivioPoint *pPosition, *pDimensions;
00397     KivioPoint *pPoint;
00398 
00399     pShapeData = pShape->shapeData();
00400     pPosition = pShapeData->position();
00401     pDimensions = pShapeData->dimensions();
00402 
00403     defWidth = m_pSpawner->defWidth();
00404     defHeight = m_pSpawner->defHeight();
00405 
00406     _x = m_zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
00407     _y = m_zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
00408     _w = m_zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
00409     _h = m_zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
00410 
00411     pPoint = pShapeData->pointList()->first();
00412     _a = m_zoomHandler->zoomItX(pPoint->x());
00413     _l = m_zoomHandler->zoomItY(pPoint->y());
00414 
00415 
00416     painter = pData->painter;
00417     painter->drawArc( _x, _y, _w, _h, _a, _l );
00418 }
00419 
00420 void KivioSMLStencil::drawOutlineBezier( KivioShape *pShape, KivioIntraStencilData *pData )
00421 {
00422   KivioPainter *painter;
00423   KivioShapeData *pShapeData = pShape->shapeData();
00424 
00425   double defWidth = m_pSpawner->defWidth();
00426   double defHeight = m_pSpawner->defHeight();
00427 
00428 
00429   painter = pData->painter;
00430   pShapeData = pShape->shapeData();
00431 
00432   KivioPoint *pPoint, *pPoint2, *pPoint3, *pPoint4;
00433   QPtrList <KivioPoint> *pPointList = pShapeData->pointList();
00434   QPointArray controlPoints( 4 );
00435 
00436 
00437   pPoint = pPointList->first();
00438   pPoint2 = pPointList->next();
00439   pPoint3 = pPointList->next();
00440   pPoint4 = pPointList->next();
00441 
00442 
00443   controlPoints.setPoint( 0, m_zoomHandler->zoomItX((pPoint->x() / defWidth)*m_w),
00444     m_zoomHandler->zoomItY((pPoint->y()/defHeight)*m_h) );
00445   controlPoints.setPoint( 1, m_zoomHandler->zoomItX((pPoint2->x() / defWidth)*m_w),
00446     m_zoomHandler->zoomItY((pPoint2->y()/defHeight)*m_h));
00447   controlPoints.setPoint( 2, m_zoomHandler->zoomItX((pPoint3->x() / defWidth)*m_w),
00448     m_zoomHandler->zoomItY((pPoint3->y()/defHeight)*m_h));
00449   controlPoints.setPoint( 3, m_zoomHandler->zoomItX((pPoint4->x() / defWidth)*m_w),
00450     m_zoomHandler->zoomItY((pPoint4->y()/defHeight)*m_h));
00451 
00452   painter = pData->painter;
00453   painter->drawBezier( controlPoints );
00454 }
00455 
00456 void KivioSMLStencil::drawOutlineOpenPath( KivioShape *pShape, KivioIntraStencilData *pData )
00457 {
00458   KivioPainter *painter;
00459   KivioShapeData *pShapeData = pShape->shapeData();
00460   KivioPoint *pPoint, *pNewPoint;
00461 
00462   double defWidth = m_pSpawner->defWidth();
00463   double defHeight = m_pSpawner->defHeight();
00464 
00465   QPtrList <KivioPoint> *pPointList = pShapeData->pointList();
00466   QPtrList <KivioPoint> *pNewPoints = new QPtrList<KivioPoint>;
00467   pNewPoints->setAutoDelete(true);
00468 
00469   pPoint = pPointList->first();
00470 
00471   while( pPoint )
00472   {
00473     pNewPoint = new KivioPoint( m_zoomHandler->zoomItX((pPoint->x()/defWidth)*m_w),
00474                                 m_zoomHandler->zoomItY((pPoint->y()/defHeight)*m_h),
00475                                 pPoint->pointType() );
00476     pNewPoints->append(pNewPoint);
00477 
00478     pPoint = pPointList->next();
00479   }
00480 
00481   painter = pData->painter;
00482   painter->drawOpenPath( pNewPoints );
00483 
00484   delete pNewPoints;
00485 }
00486 
00487 void KivioSMLStencil::drawOutlineClosedPath( KivioShape *pShape, KivioIntraStencilData *pData )
00488 {
00489   KivioPainter *painter;
00490   KivioShapeData *pShapeData = pShape->shapeData();
00491   KivioPoint *pPoint, *pNewPoint;
00492 
00493   double defWidth = m_pSpawner->defWidth();
00494   double defHeight = m_pSpawner->defHeight();
00495 
00496   QPtrList <KivioPoint> *pPointList = pShapeData->pointList();
00497   QPtrList <KivioPoint> *pNewPoints = new QPtrList<KivioPoint>;
00498   pNewPoints->setAutoDelete(true);
00499 
00500   pPoint = pPointList->first();
00501   while( pPoint )
00502   {
00503     pNewPoint = new KivioPoint( m_zoomHandler->zoomItX((pPoint->x()/defWidth)*m_w),
00504                                 m_zoomHandler->zoomItY((pPoint->y()/defHeight)*m_h),
00505                                 pPoint->pointType() );
00506     pNewPoints->append(pNewPoint);
00507 
00508     pPoint = pPointList->next();
00509   }
00510 
00511   painter = pData->painter;
00512   painter->drawOpenPath( pNewPoints );
00513 
00514   delete pNewPoints;
00515 }
00516 
00517 void KivioSMLStencil::drawOutlineEllipse( KivioShape *pShape, KivioIntraStencilData *pData )
00518 {
00519   double _x, _y, _w, _h, defWidth, defHeight;
00520   KivioPainter *painter;
00521   KivioShapeData *pShapeData;
00522   KivioPoint *pPosition, *pDimensions;
00523 
00524   pShapeData = pShape->shapeData();
00525   pPosition = pShapeData->position();
00526   pDimensions = pShapeData->dimensions();
00527 
00528   defWidth = m_pSpawner->defWidth();
00529   defHeight = m_pSpawner->defHeight();
00530 
00531   _x = m_zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
00532   _y = m_zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
00533   _w = m_zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
00534   _h = m_zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
00535 
00536 
00537   painter = pData->painter;
00538   painter->setFGColor( QColor(0, 0, 0) );
00539   painter->drawEllipse( _x, _y, _w, _h );
00540 }
00541 
00542 void KivioSMLStencil::drawOutlineLineArray( KivioShape *pShape, KivioIntraStencilData *pData )
00543 {
00544   double _x, _y, defWidth, defHeight;
00545   KivioPainter *painter;
00546   KivioShapeData *pShapeData;
00547   QPtrList <KivioPoint> *pList;
00548 
00549   pShapeData = pShape->shapeData();
00550 
00551   defWidth = m_pSpawner->defWidth();
00552   defHeight = m_pSpawner->defHeight();
00553 
00554   pList = pShapeData->pointList();
00555 
00556 
00557   QPointArray arr( pList->count() );
00558 
00559   KivioPoint *pPoint;
00560   int i=0;
00561   pPoint = pList->first();
00562   while( pPoint )
00563   {
00564     _x = m_zoomHandler->zoomItX((pPoint->x() / defWidth) * m_w);
00565     _y = m_zoomHandler->zoomItY((pPoint->y() / defHeight) * m_h);
00566 
00567     arr.setPoint( i, (int)_x, (int)_y );
00568 
00569     i++;
00570 
00571     pPoint = pList->next();
00572   }
00573 
00574   painter = pData->painter;
00575   painter->drawLineArray( arr );
00576 }
00577 
00578 void KivioSMLStencil::drawOutlineRectangle( KivioShape *pShape, KivioIntraStencilData *pData )
00579 {
00580   double _x, _y, _w, _h, defWidth, defHeight;
00581   KivioPainter *painter;
00582   KivioShapeData *pShapeData;
00583   KivioPoint *pPosition, *pDimensions;
00584 
00585   pShapeData = pShape->shapeData();
00586   pPosition = pShapeData->position();
00587   pDimensions = pShapeData->dimensions();
00588 
00589   defWidth = m_pSpawner->defWidth();
00590   defHeight = m_pSpawner->defHeight();
00591 
00592   _x = m_zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
00593   _y = m_zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
00594   _w = m_zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
00595   _h = m_zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
00596 
00597   painter = pData->painter;
00598   painter->setFGColor( QColor(0, 0, 0) );
00599   painter->drawRect( _x, _y, _w, _h );
00600 }
00601 
00602 void KivioSMLStencil::drawOutlineRoundRectangle( KivioShape *pShape, KivioIntraStencilData *pData )
00603 {
00604   double _rx, _ry, _x, _y, _w, _h, defWidth, defHeight;
00605   KivioPainter *painter;
00606   KivioShapeData *pShapeData;
00607   KivioPoint *pPosition, *pDimensions;
00608 
00609   pShapeData = pShape->shapeData();
00610   pPosition = pShapeData->position();
00611   pDimensions = pShapeData->dimensions();
00612 
00613   KivioPoint *pPoint;
00614 
00615   defWidth = m_pSpawner->defWidth();
00616   defHeight = m_pSpawner->defHeight();
00617 
00618   pPoint = pShapeData->pointList()->first();
00619   _rx = m_zoomHandler->zoomItX(pPoint->x());
00620   _ry = m_zoomHandler->zoomItY(pPoint->y());
00621 
00622 
00623   _x = m_zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
00624   _y = m_zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
00625   _w = m_zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
00626   _h = m_zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
00627 
00628 
00629   painter = pData->painter;
00630   painter->setFGColor( QColor(0, 0, 0) );
00631   painter->drawRoundRect( _x, _y, _w, _h, _rx, _ry );
00632 }
00633 
00634 void KivioSMLStencil::drawOutlinePie( KivioShape *, KivioIntraStencilData * )
00635 {
00636 
00637 }
00638 
00639 void KivioSMLStencil::drawOutlinePolygon( KivioShape *pShape, KivioIntraStencilData *pData )
00640 {
00641   double _x, _y, defWidth, defHeight;
00642   KivioPainter *painter;
00643   KivioShapeData *pShapeData;
00644   QPtrList <KivioPoint> *pList;
00645 
00646   pShapeData = pShape->shapeData();
00647 
00648   defWidth = m_pSpawner->defWidth();
00649   defHeight = m_pSpawner->defHeight();
00650 
00651   pList = pShapeData->pointList();
00652 
00653 
00654   QPointArray arr( pList->count() );
00655 
00656   KivioPoint *pPoint;
00657   int i=0;
00658   pPoint = pList->first();
00659   while( pPoint )
00660   {
00661     _x = m_zoomHandler->zoomItX((pPoint->x() / defWidth) * m_w);
00662     _y = m_zoomHandler->zoomItY((pPoint->y() / defHeight) * m_h);
00663 
00664     arr.setPoint( i, (int)_x, (int)_y );
00665 
00666     i++;
00667 
00668     pPoint = pList->next();
00669   }
00670 
00671   painter = pData->painter;
00672   painter->drawPolyline( arr );
00673 }
00674 
00675 void KivioSMLStencil::drawOutlinePolyline( KivioShape *pShape, KivioIntraStencilData *pData )
00676 {
00677   double _x, _y, defWidth, defHeight;
00678   KivioPainter *painter;
00679   KivioShapeData *pShapeData;
00680   QPtrList <KivioPoint> *pList;
00681 
00682   pShapeData = pShape->shapeData();
00683 
00684   defWidth = m_pSpawner->defWidth();
00685   defHeight = m_pSpawner->defHeight();
00686 
00687   pList = pShapeData->pointList();
00688 
00689 
00690   QPointArray arr( pList->count() );
00691 
00692   KivioPoint *pPoint;
00693   int i=0;
00694   pPoint = pList->first();
00695 
00696   while( pPoint )
00697   {
00698     _x = m_zoomHandler->zoomItX((pPoint->x() / defWidth) * m_w);
00699     _y = m_zoomHandler->zoomItY((pPoint->y() / defHeight) * m_h);
00700 
00701     arr.setPoint( i, (int)_x, (int)_y );
00702 
00703     i++;
00704 
00705     pPoint = pList->next();
00706   }
00707 
00708   painter = pData->painter;
00709   painter->drawPolyline( arr );
00710 }
00711 
00712 void KivioSMLStencil::drawOutlineTextBox( KivioShape *pShape, KivioIntraStencilData *pData )
00713 {
00714   double defWidth = m_pSpawner->defWidth();
00715   double defHeight = m_pSpawner->defHeight();
00716   int _x, _y, _w, _h;
00717   KivioShapeData *pShapeData = pShape->shapeData();
00718   KivioPoint *pPosition = pShapeData->position();
00719   KivioPoint *pDimensions = pShapeData->dimensions();
00720   KivioPainter *painter = pData->painter;
00721   KoZoomHandler* zoomHandler = pData->zoomHandler;
00722 
00723   if( pShapeData->text().length() <= 0 ) {
00724     return;
00725   }
00726 
00727 
00728   _x = zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
00729   _y = zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
00730   _w = zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
00731   _h = zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
00732 
00733 
00734   QPixmap pix(_w, _h);
00735   pix.fill();
00736   QPainter p(&pix);
00737   
00738   QFont f = pShapeData->textFont();
00739   f.setPointSizeFloat(f.pointSizeFloat() * (((float)zoomHandler->zoom()) / 100.0));
00740   p.setFont( f );
00741   p.setPen( QColor(0, 0, 0) );
00742   int tf = pShapeData->vTextAlign() | pShapeData->hTextAlign();
00743   p.drawText( 0, 0, _w, _h, tf | Qt::WordBreak, pShapeData->text() );
00744   QBitmap mask;
00745   mask = pix;
00746   pix.setMask(mask);
00747   painter->drawPixmap(_x, _y, pix);
00748 }
00749 
00750 
00754 void KivioSMLStencil::paint( KivioIntraStencilData *pData )
00755 {
00756   KivioShape *pShape;
00757   KivioShapeData *pShapeData;
00758 
00759 
00760   m_zoomHandler = pData->zoomHandler;
00761   pData->painter->saveState();
00762   pData->painter->setTranslation(m_zoomHandler->zoomItX(m_x), m_zoomHandler->zoomItY(m_y));
00763   rotatePainter(pData);  // Rotate the painter if needed
00764 
00765   pShape = m_pShapeList->first();
00766   while( pShape )
00767   {
00768     pShapeData = pShape->shapeData();
00769 
00770     switch( pShapeData->shapeType() )
00771     {
00772       case KivioShapeData::kstArc:
00773         drawArc( pShape, pData );
00774         break;
00775 
00776       case KivioShapeData::kstPie:
00777         drawPie( pShape, pData );
00778         break;
00779 
00780       case KivioShapeData::kstLineArray:
00781         drawLineArray( pShape, pData );
00782         break;
00783 
00784       case KivioShapeData::kstPolyline:
00785         drawPolyline( pShape, pData );
00786         break;
00787 
00788       case KivioShapeData::kstPolygon:
00789         drawPolygon( pShape, pData );
00790         break;
00791 
00792       case KivioShapeData::kstBezier:
00793         drawBezier( pShape, pData );
00794         break;
00795 
00796       case KivioShapeData::kstRectangle:
00797         drawRectangle( pShape, pData );
00798         break;
00799 
00800       case KivioShapeData::kstRoundRectangle:
00801         drawRoundRectangle( pShape, pData );
00802         break;
00803 
00804       case KivioShapeData::kstEllipse:
00805         drawEllipse( pShape, pData );
00806         break;
00807 
00808       case KivioShapeData::kstOpenPath:
00809         drawOpenPath( pShape, pData );
00810         break;
00811 
00812       case KivioShapeData::kstClosedPath:
00813         drawClosedPath( pShape, pData );
00814         break;
00815 
00816       case KivioShapeData::kstTextBox:
00817         drawTextBox( pShape, pData );
00818         break;
00819 
00820       case KivioShapeData::kstNone:
00821       default:
00822         break;
00823     }
00824 
00825     pShape = m_pShapeList->next();
00826   }
00827 
00828   pData->painter->restoreState();
00829 }
00830 
00831 
00835 void KivioSMLStencil::paintConnectorTargets( KivioIntraStencilData *pData )
00836 {
00837   // We don't draw these if we are selected!!!
00838   //if( isSelected() == true ) {
00839   //  return;
00840   //}
00841 
00842   QPixmap targetPic;
00843   KivioPainter *painter;
00844   int x, y;
00845 
00846   // Obtain the graphic used for KivioConnectorTargets
00847   targetPic = Kivio::connectorTargetPixmap();
00848 
00849 
00850   m_zoomHandler = pData->zoomHandler;
00851   painter = pData->painter;
00852 
00853   KivioConnectorTarget *pTarget;
00854   pTarget = m_pConnectorTargets->first();
00855   while( pTarget )
00856   {
00857     x = m_zoomHandler->zoomItX(pTarget->x());
00858     y = m_zoomHandler->zoomItY(pTarget->y());
00859 
00860     painter->drawPixmap( x-3, y-3, targetPic );
00861 
00862     pTarget = m_pConnectorTargets->next();
00863   }
00864 }
00865 
00866 
00867 void KivioSMLStencil::drawArc( KivioShape *pShape, KivioIntraStencilData *pData )
00868 {
00869   double defWidth, defHeight;
00870   int _a, _l, _x, _y, _w, _h;
00871   KivioPainter *painter;
00872   KivioShapeData *pShapeData;
00873   KivioPoint *pPosition, *pDimensions;
00874   KivioPoint *pPoint;
00875 
00876   pShapeData = pShape->shapeData();
00877   pPosition = pShapeData->position();
00878   pDimensions = pShapeData->dimensions();
00879 
00880   defWidth = m_pSpawner->defWidth();
00881   defHeight = m_pSpawner->defHeight();
00882 
00883   _x = m_zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
00884   _y = m_zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
00885   _w = m_zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
00886   _h = m_zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
00887 
00888   pPoint = pShapeData->pointList()->first();
00889   _a = m_zoomHandler->zoomItX(pPoint->x());
00890   _l = m_zoomHandler->zoomItY(pPoint->y());
00891 
00892   painter = pData->painter;
00893   painter->setLineStyle(pShapeData->lineStyle());
00894   double lineWidth = pShapeData->lineStyle()->width();
00895   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
00896 
00897   switch( pShapeData->fillStyle()->colorStyle() )
00898   {
00899     case KivioFillStyle::kcsNone:   // Hollow
00900       painter->drawArc( _x, _y, _w, _h, _a, _l );
00901       break;
00902 
00903     case KivioFillStyle::kcsSolid:  // Solid fill
00904     case KivioFillStyle::kcsGradient:               // Gradient
00905       painter->setFillStyle( pShapeData->fillStyle() );
00906       painter->drawArc( _x, _y, _w, _h, _a, _l );
00907       break;
00908 
00909     case KivioFillStyle::kcsPixmap:
00910     default:
00911       break;
00912   }
00913 }
00914 
00915 void KivioSMLStencil::drawBezier( KivioShape *pShape, KivioIntraStencilData *pData )
00916 {
00917   KivioPainter *painter;
00918   KivioShapeData *pShapeData = pShape->shapeData();
00919 
00920   double defWidth = m_pSpawner->defWidth();
00921   double defHeight = m_pSpawner->defHeight();
00922 
00923 
00924   painter = pData->painter;
00925   pShapeData = pShape->shapeData();
00926 
00927   KivioPoint *pPoint, *pPoint2, *pPoint3, *pPoint4;
00928   QPtrList <KivioPoint> *pPointList = pShapeData->pointList();
00929   QPointArray controlPoints( 4 );
00930 
00931 
00932   pPoint = pPointList->first();
00933   pPoint2 = pPointList->next();
00934   pPoint3 = pPointList->next();
00935   pPoint4 = pPointList->next();
00936 
00937 
00938   controlPoints.setPoint( 0, m_zoomHandler->zoomItX((pPoint->x() / defWidth)*m_w),
00939     m_zoomHandler->zoomItY((pPoint->y()/defHeight)*m_h));
00940   controlPoints.setPoint( 1, m_zoomHandler->zoomItX((pPoint2->x() / defWidth)*m_w),
00941     m_zoomHandler->zoomItY((pPoint2->y()/defHeight)*m_h));
00942   controlPoints.setPoint( 2, m_zoomHandler->zoomItX((pPoint3->x() / defWidth)*m_w),
00943     m_zoomHandler->zoomItY((pPoint3->y()/defHeight)*m_h));
00944   controlPoints.setPoint( 3, m_zoomHandler->zoomItX((pPoint4->x() / defWidth)*m_w),
00945     m_zoomHandler->zoomItY((pPoint4->y()/defHeight)*m_h));
00946 
00947   painter->setLineStyle(pShapeData->lineStyle());
00948   double lineWidth = pShapeData->lineStyle()->width();
00949   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
00950 
00951   painter->drawBezier( controlPoints );
00952 }
00953 
00954 void KivioSMLStencil::drawOpenPath( KivioShape *pShape, KivioIntraStencilData *pData )
00955 {
00956   KivioPainter *painter;
00957   KivioShapeData *pShapeData = pShape->shapeData();
00958   KivioPoint *pPoint, *pNewPoint;
00959 
00960   double defWidth = m_pSpawner->defWidth();
00961   double defHeight = m_pSpawner->defHeight();
00962 
00963   QPtrList <KivioPoint> *pPointList = pShapeData->pointList();
00964   QPtrList <KivioPoint> *pNewPoints = new QPtrList<KivioPoint>;
00965   pNewPoints->setAutoDelete(true);
00966 
00967   pPoint = pPointList->first();
00968   while( pPoint )
00969   {
00970     pNewPoint = new KivioPoint( m_zoomHandler->zoomItX((pPoint->x()/defWidth)*m_w),
00971                                 m_zoomHandler->zoomItY((pPoint->y()/defHeight)*m_h),
00972                                 pPoint->pointType() );
00973     pNewPoints->append(pNewPoint);
00974 
00975     pPoint = pPointList->next();
00976   }
00977 
00978   painter = pData->painter;
00979   painter->setLineStyle(pShapeData->lineStyle());
00980   double lineWidth = pShapeData->lineStyle()->width();
00981   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
00982 
00983   painter->drawOpenPath( pNewPoints );
00984 
00985   delete pNewPoints;
00986 }
00987 
00988 void KivioSMLStencil::drawClosedPath( KivioShape *pShape, KivioIntraStencilData *pData )
00989 {
00990   KivioPainter *painter;
00991   KivioShapeData *pShapeData = pShape->shapeData();
00992   KivioPoint *pPoint, *pNewPoint;
00993 
00994   double defWidth = m_pSpawner->defWidth();
00995   double defHeight = m_pSpawner->defHeight();
00996 
00997   QPtrList <KivioPoint> *pPointList = pShapeData->pointList();
00998   QPtrList <KivioPoint> *pNewPoints = new QPtrList<KivioPoint>;
00999   pNewPoints->setAutoDelete(true);
01000 
01001   pPoint = pPointList->first();
01002   while( pPoint )
01003   {
01004       pNewPoint = new KivioPoint( m_zoomHandler->zoomItX((pPoint->x()/defWidth)*m_w),
01005                                   m_zoomHandler->zoomItY((pPoint->y()/defHeight)*m_h),
01006                                   pPoint->pointType() );
01007       pNewPoints->append(pNewPoint);
01008 
01009       pPoint = pPointList->next();
01010   }
01011 
01012   painter = pData->painter;
01013   painter->setLineStyle(pShapeData->lineStyle());
01014   double lineWidth = pShapeData->lineStyle()->width();
01015   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
01016 
01017   switch( pShapeData->fillStyle()->colorStyle() )
01018   {
01019       case KivioFillStyle::kcsNone:   // Hollow
01020         painter->drawOpenPath( pNewPoints );
01021         break;
01022 
01023       case KivioFillStyle::kcsSolid:  // Solid fill
01024       case KivioFillStyle::kcsGradient:               // Gradient
01025         painter->setFillStyle( pShapeData->fillStyle() );
01026         painter->drawClosedPath( pNewPoints );
01027         break;
01028 
01029       case KivioFillStyle::kcsPixmap:
01030       default:
01031         break;
01032   }
01033 
01034   delete pNewPoints;
01035 }
01036 
01037 void KivioSMLStencil::drawPie( KivioShape *, KivioIntraStencilData * )
01038 {
01039 }
01040 
01041 void KivioSMLStencil::drawEllipse( KivioShape *pShape, KivioIntraStencilData *pData )
01042 {
01043   double defWidth, defHeight;
01044   int _x, _y, _w, _h;
01045   KivioPainter *painter;
01046   KivioShapeData *pShapeData;
01047   KivioPoint *pPosition, *pDimensions;
01048 
01049   pShapeData = pShape->shapeData();
01050   pPosition = pShapeData->position();
01051   pDimensions = pShapeData->dimensions();
01052 
01053   defWidth = m_pSpawner->defWidth();
01054   defHeight = m_pSpawner->defHeight();
01055 
01056   _x = m_zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
01057   _y = m_zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
01058   _w = m_zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
01059   _h = m_zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
01060 
01061   painter = pData->painter;
01062   painter->setLineStyle(pShapeData->lineStyle());
01063   double lineWidth = pShapeData->lineStyle()->width();
01064   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
01065 
01066   switch( pShapeData->fillStyle()->colorStyle() )
01067   {
01068     case KivioFillStyle::kcsNone:   // Hollow
01069       painter->drawEllipse( _x, _y, _w, _h );
01070       break;
01071 
01072     case KivioFillStyle::kcsSolid:  // Solid fill
01073     case KivioFillStyle::kcsGradient:               // Gradient
01074       painter->setFillStyle( pShapeData->fillStyle() );
01075       painter->fillEllipse( _x, _y, _w, _h );
01076       break;
01077 
01078     case KivioFillStyle::kcsPixmap:
01079     default:
01080       break;
01081   }
01082 }
01083 
01084 void KivioSMLStencil::drawLineArray( KivioShape *pShape, KivioIntraStencilData *pData )
01085 {
01086   double defWidth, defHeight;
01087   int _x, _y;
01088   KivioPainter *painter;
01089   KivioShapeData *pShapeData;
01090   QPtrList <KivioPoint> *pList;
01091 
01092   pShapeData = pShape->shapeData();
01093 
01094   defWidth = m_pSpawner->defWidth();
01095   defHeight = m_pSpawner->defHeight();
01096 
01097   pList = pShapeData->pointList();
01098 
01099 
01100   QPointArray arr( pList->count() );
01101 
01102   KivioPoint *pPoint;
01103   int i=0;
01104   pPoint = pList->first();
01105   while( pPoint )
01106   {
01107     _x = m_zoomHandler->zoomItX((pPoint->x() / defWidth) * m_w);
01108     _y = m_zoomHandler->zoomItY((pPoint->y() / defHeight) * m_h);
01109 
01110     arr.setPoint( i, _x, _y );
01111 
01112     i++;
01113 
01114     pPoint = pList->next();
01115   }
01116 
01117   painter = pData->painter;
01118   painter->setLineStyle(pShapeData->lineStyle());
01119   double lineWidth = pShapeData->lineStyle()->width();
01120   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
01121 
01122   painter->drawLineArray( arr );
01123 }
01124 
01125 void KivioSMLStencil::drawRectangle( KivioShape *pShape, KivioIntraStencilData *pData )
01126 {
01127   double defWidth, defHeight;
01128   int _x, _y, _w, _h;
01129   KivioPainter *painter;
01130   KivioShapeData *pShapeData;
01131   KivioPoint *pPosition, *pDimensions;
01132 
01133   pShapeData = pShape->shapeData();
01134   pPosition = pShapeData->position();
01135   pDimensions = pShapeData->dimensions();
01136 
01137   defWidth = m_pSpawner->defWidth();
01138   defHeight = m_pSpawner->defHeight();
01139 
01140   _x = m_zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
01141   _y = m_zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
01142   _w = m_zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
01143   _h = m_zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
01144 
01145   painter = pData->painter;
01146   painter->setLineStyle(pShapeData->lineStyle());
01147   double lineWidth = pShapeData->lineStyle()->width();
01148   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
01149 
01150   switch( pShapeData->fillStyle()->colorStyle() )
01151   {
01152     case KivioFillStyle::kcsNone:   // Hollow
01153       painter->drawRect( _x, _y, _w, _h );
01154       break;
01155 
01156     case KivioFillStyle::kcsSolid:  // Solid fill
01157     case KivioFillStyle::kcsGradient:               // Gradient
01158       painter->setFillStyle( pShapeData->fillStyle() );
01159       painter->fillRect( _x, _y, _w, _h );
01160       break;
01161 
01162     case KivioFillStyle::kcsPixmap:
01163     default:
01164       break;
01165   }
01166 }
01167 
01168 void KivioSMLStencil::drawRoundRectangle( KivioShape *pShape, KivioIntraStencilData *pData )
01169 {
01170   double defWidth, defHeight;
01171   int _rx, _ry, _x, _y, _w, _h;
01172   KivioPainter *painter;
01173   KivioShapeData *pShapeData;
01174   KivioPoint *pPosition, *pDimensions;
01175   KivioPoint *pPoint;
01176 
01177   pShapeData = pShape->shapeData();
01178   pPosition = pShapeData->position();
01179   pDimensions = pShapeData->dimensions();
01180 
01181   defWidth = m_pSpawner->defWidth();
01182   defHeight = m_pSpawner->defHeight();
01183 
01184   _x = m_zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
01185   _y = m_zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
01186   _w = m_zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
01187   _h = m_zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
01188 
01189   pPoint = pShapeData->pointList()->first();
01190   _rx = m_zoomHandler->zoomItX(pPoint->x());
01191   _ry = m_zoomHandler->zoomItY(pPoint->y());
01192 
01193   painter = pData->painter;
01194   painter->setLineStyle(pShapeData->lineStyle());
01195   double lineWidth = pShapeData->lineStyle()->width();
01196   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
01197 
01198   switch( pShapeData->fillStyle()->colorStyle() )
01199   {
01200     case KivioFillStyle::kcsNone:   // Hollow
01201       painter->drawRoundRect( _x, _y, _w, _h, _rx, _ry );
01202       break;
01203 
01204     case KivioFillStyle::kcsSolid:  // Solid fill
01205     case KivioFillStyle::kcsGradient:               // Gradient
01206       painter->setFillStyle( pShapeData->fillStyle() );
01207       painter->fillRoundRect( _x, _y, _w, _h, _rx, _ry );
01208       break;
01209 
01210     case KivioFillStyle::kcsPixmap:
01211     default:
01212       break;
01213   }
01214 }
01215 
01216 void KivioSMLStencil::drawPolygon( KivioShape *pShape, KivioIntraStencilData *pData )
01217 {
01218   double defWidth, defHeight;
01219   int _x, _y;
01220   KivioPainter *painter;
01221   KivioShapeData *pShapeData;
01222   QPtrList <KivioPoint> *pList;
01223 
01224   pShapeData = pShape->shapeData();
01225 
01226   defWidth = m_pSpawner->defWidth();
01227   defHeight = m_pSpawner->defHeight();
01228 
01229   pList = pShapeData->pointList();
01230 
01231 
01232   QPointArray arr( pList->count() );
01233 
01234 
01235   KivioPoint *pPoint;
01236   int i=0;
01237   pPoint = pList->first();
01238   while( pPoint )
01239   {
01240     _x = m_zoomHandler->zoomItX((pPoint->x() / defWidth) * m_w);
01241     _y = m_zoomHandler->zoomItY((pPoint->y() / defHeight) * m_h);
01242 
01243 
01244     arr.setPoint( i, _x, _y );
01245 
01246     i++;
01247 
01248     pPoint = pList->next();
01249   }
01250 
01251   painter = pData->painter;
01252   painter->setLineStyle(pShapeData->lineStyle());
01253   double lineWidth = pShapeData->lineStyle()->width();
01254   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
01255 
01256   switch( pShapeData->fillStyle()->colorStyle() )
01257   {
01258     case KivioFillStyle::kcsNone:   // Hollow
01259       painter->drawPolygon(arr);
01260       break;
01261 
01262     case KivioFillStyle::kcsSolid:  // Solid fill
01263     case KivioFillStyle::kcsGradient:               // Gradient
01264       painter->setFillStyle( pShapeData->fillStyle() );
01265       painter->drawPolygon(arr);
01266       break;
01267 
01268     case KivioFillStyle::kcsPixmap:
01269     default:
01270       break;
01271   }
01272 
01273 }
01274 
01275 void KivioSMLStencil::drawPolyline( KivioShape *pShape, KivioIntraStencilData *pData )
01276 {
01277   double defWidth, defHeight;
01278   int _x, _y;
01279   KivioPainter *painter;
01280   KivioShapeData *pShapeData;
01281   QPtrList <KivioPoint> *pList;
01282 
01283   pShapeData = pShape->shapeData();
01284 
01285   defWidth = m_pSpawner->defWidth();
01286   defHeight = m_pSpawner->defHeight();
01287 
01288   pList = pShapeData->pointList();
01289 
01290 
01291   QPointArray arr( pList->count() );
01292 
01293   KivioPoint *pPoint;
01294   int i=0;
01295   pPoint = pList->first();
01296   while( pPoint )
01297   {
01298     _x = m_zoomHandler->zoomItX((pPoint->x() / defWidth) * m_w);
01299     _y = m_zoomHandler->zoomItY((pPoint->y() / defHeight) * m_h);
01300 
01301     arr.setPoint( i, _x, _y );
01302 
01303     i++;
01304 
01305     pPoint = pList->next();
01306   }
01307 
01308   painter = pData->painter;
01309   painter->setLineStyle(pShapeData->lineStyle());
01310   double lineWidth = pShapeData->lineStyle()->width();
01311   painter->setLineWidth(m_zoomHandler->zoomItY(lineWidth));
01312 
01313   painter->drawPolyline(arr);
01314 }
01315 
01316 void KivioSMLStencil::drawTextBox( KivioShape *pShape, KivioIntraStencilData *pData )
01317 {
01318   double defWidth = m_pSpawner->defWidth();
01319   double defHeight = m_pSpawner->defHeight();
01320   KivioShapeData *pShapeData = pShape->shapeData();
01321   KivioPoint *pPosition = pShapeData->position();
01322   KivioPoint *pDimensions = pShapeData->dimensions();
01323   KivioPainter *painter = pData->painter;
01324   KoZoomHandler* zoomHandler = pData->zoomHandler;
01325 
01326 
01327   if(pShapeData->text().isEmpty()) {
01328     return;
01329   }
01330 
01331   int _x = zoomHandler->zoomItX((pPosition->x() / defWidth) * m_w);
01332   int _y = zoomHandler->zoomItY((pPosition->y() / defHeight) * m_h);
01333   int _w = zoomHandler->zoomItX((pDimensions->x() / defWidth) * m_w) + 1;
01334   int _h = zoomHandler->zoomItY((pDimensions->y() / defHeight) * m_h) + 1;
01335 
01336 
01337   QFont f = pShapeData->textFont();
01338   f.setPointSizeFloat(f.pointSizeFloat() * (((float)zoomHandler->zoom()) / 100.0));
01339   painter->setFont( f );
01340   painter->setTextColor( pShapeData->textColor() );
01341 
01342   int tf = pShapeData->vTextAlign() | pShapeData->hTextAlign();
01343   painter->drawText( _x, _y, _w, _h, tf | Qt::WordBreak, pShapeData->text() );
01344   // TODO Implement richtext support
01345 }
01346 
01347 
01348 
01349 
01353 void KivioSMLStencil::setFGColor( QColor c )
01354 {
01355     KivioShape *pShape;
01356 
01357 
01358     pShape = m_pShapeList->first();
01359     while( pShape )
01360     {
01361         pShape->shapeData()->lineStyle()->setColor( c );
01362 
01363         pShape = m_pShapeList->next();
01364     }
01365 }
01366 
01367 
01371 void KivioSMLStencil::setBGColor( QColor c )
01372 {
01373     KivioShape *pShape;
01374 
01375     pShape = m_pShapeList->first();
01376     while( pShape )
01377     {
01378         pShape->shapeData()->fillStyle()->setColor( c );
01379 
01380         pShape = m_pShapeList->next();
01381     }
01382 }
01383 
01384 void KivioSMLStencil::setFillPattern(int p)
01385 {
01386     KivioShape *pShape;
01387 
01388     pShape = m_pShapeList->first();
01389     while( pShape )
01390     {
01391         pShape->shapeData()->fillStyle()->setBrushStyle( static_cast<Qt::BrushStyle>(p) );
01392 
01393         pShape = m_pShapeList->next();
01394     }
01395 }
01396 
01400 void KivioSMLStencil::setTextColor( QColor c )
01401 {
01402     KivioShape *pShape;
01403 
01404 
01405     pShape = m_pShapeList->first();
01406     while( pShape )
01407     {
01408         pShape->shapeData()->setTextColor( c );
01409 
01410         pShape = m_pShapeList->next();
01411     }
01412 }
01413 
01417 void KivioSMLStencil::setTextFont( const QFont &f )
01418 {
01419     KivioShape *pShape;
01420 
01421 
01422     pShape = m_pShapeList->first();
01423     while( pShape )
01424     {
01425         pShape->shapeData()->setTextFont( f );
01426 
01427         pShape = m_pShapeList->next();
01428     }
01429 }
01430 
01431 
01435 void KivioSMLStencil::setLineWidth( double f )
01436 {
01437     KivioShape *pShape;
01438 
01439     pShape = m_pShapeList->first();
01440     while( pShape )
01441     {
01442         pShape->shapeData()->lineStyle()->setWidth( f );
01443 
01444         pShape = m_pShapeList->next();
01445     }
01446 }
01447 
01448 void KivioSMLStencil::setLinePattern(int p)
01449 {
01450     KivioShape *pShape = m_pShapeList->first();
01451 
01452     while( pShape )
01453     {
01454         pShape->shapeData()->lineStyle()->setStyle( p );
01455         pShape = m_pShapeList->next();
01456     }
01457 }
01458 
01466 KivioConnectorTarget *KivioSMLStencil::connectToTarget( KivioConnectorPoint *p, double threshHold )
01467 {
01468     double px = p->x();
01469     double py = p->y();
01470 
01471     double tx, ty;
01472 
01473     KivioConnectorTarget *pTarget = m_pConnectorTargets->first();
01474 
01475     while( pTarget )
01476     {
01477         tx = pTarget->x();
01478         ty = pTarget->y();
01479 
01480         if( px >= tx - threshHold &&
01481             px <= tx + threshHold &&
01482             py >= ty - threshHold &&
01483             py <= ty + threshHold )
01484         {
01485             // setTarget calls pTarget->addConnectorPoint() and removes
01486             // any previous connections from p
01487             p->setTarget( pTarget );
01488             return pTarget;
01489         }
01490 
01491         pTarget = m_pConnectorTargets->next();
01492     }
01493 
01494     return NULL;
01495 }
01496 
01497 KoPoint KivioSMLStencil::snapToTarget( const KoPoint& p, double thresh, bool& hit )
01498 {
01499     KoPoint retVal = p;
01500     double tx, ty;
01501     hit = false;
01502 
01503     KivioConnectorTarget *pTarget = m_pConnectorTargets->first();
01504 
01505     while( pTarget )
01506     {
01507         tx = pTarget->x();
01508         ty = pTarget->y();
01509 
01510         if( retVal.x() >= tx - thresh &&
01511             retVal.x() <= tx + thresh &&
01512             retVal.y() >= ty - thresh &&
01513             retVal.y() <= ty + thresh )
01514         {
01515             retVal.setX(tx);
01516             retVal.setY(ty);
01517             hit = true;
01518         }
01519 
01520         pTarget = m_pConnectorTargets->next();
01521     }
01522 
01523     return retVal;
01524 }
01525 
01531 KivioConnectorTarget *KivioSMLStencil::connectToTarget( KivioConnectorPoint *p, int /*targetID*/ )
01532 {
01533     int id = p->targetId();
01534 
01535     KivioConnectorTarget *pTarget = m_pConnectorTargets->first();
01536     while( pTarget )
01537     {
01538         if( pTarget->id() == id )
01539         {
01540             p->setTarget(pTarget);
01541 
01542             return pTarget;
01543         }
01544 
01545         pTarget = m_pConnectorTargets->next();
01546     }
01547 
01548     return NULL;
01549 }
01550 
01551 
01558 void KivioSMLStencil::updateGeometry()
01559 {
01560   //kdDebug(43000) << "m_x = " << m_x << " m_y = " << m_y << endl;
01561 
01562   QWMatrix m;
01563   m.translate(m_x, m_y);
01564   m.translate(m_w / 2.0, m_h / 2.0);
01565   m.rotate(m_rotation);
01566   m.translate(-m_w / 2.0, -m_h / 2.0);
01567 
01568   KivioConnectorTarget* pTarget = m_pConnectorTargets->first();
01569 
01570   while( pTarget )
01571   {
01572     double _x = pTarget->xOffset() * m_w;
01573     double _y = pTarget->yOffset() * m_h;
01574     double newX = _x * m.m11() + _y * m.m21() + m.dx();
01575     double newY = _x * m.m12() + _y * m.m22() + m.dy();
01576     pTarget->setPosition( newX, newY );
01577 
01578     pTarget = m_pConnectorTargets->next();
01579   }
01580 }
01581 
01582 
01586 QFont KivioSMLStencil::textFont()
01587 {
01588     KivioShape *pShape;
01589 
01590     pShape = m_pShapeList->first();
01591     while( pShape )
01592     {
01593         if( pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox )
01594         {
01595             return pShape->shapeData()->textFont();
01596         }
01597 
01598         pShape = m_pShapeList->next();
01599     }
01600 
01601     //return QFont("times",12);
01602     return KoGlobal::defaultFont();
01603 }
01604 
01605 QColor KivioSMLStencil::textColor()
01606 {
01607   KivioShape *pShape;
01608 
01609   pShape = m_pShapeList->first();
01610   while( pShape )
01611   {
01612     if( pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox )
01613     {
01614       return pShape->shapeData()->textColor();
01615     }
01616 
01617     pShape = m_pShapeList->next();
01618   }
01619 
01620   return QColor(0, 0, 0);
01621 }
01622 
01626 void KivioSMLStencil::setHTextAlign(int i)
01627 {
01628     KivioShape *pShape;
01629 
01630 
01631     pShape = m_pShapeList->first();
01632     while( pShape )
01633     {
01634         if( pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox )
01635             pShape->shapeData()->setHTextAlign( i );
01636 
01637         pShape = m_pShapeList->next();
01638     }
01639 }
01640 
01641 
01645 void KivioSMLStencil::setVTextAlign(int i)
01646 {
01647     KivioShape *pShape;
01648 
01649 
01650     pShape = m_pShapeList->first();
01651     while( pShape )
01652     {
01653         if( pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox )
01654             pShape->shapeData()->setVTextAlign( i );
01655 
01656         pShape = m_pShapeList->next();
01657     }
01658 }
01659 
01660 
01664 int KivioSMLStencil::hTextAlign()
01665 {
01666     KivioShape *pShape;
01667 
01668     pShape = m_pShapeList->first();
01669     while( pShape )
01670     {
01671         if( pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox )
01672         {
01673             return pShape->shapeData()->hTextAlign();
01674         }
01675 
01676         pShape = m_pShapeList->next();
01677     }
01678 
01679     return 1;
01680 }
01681 
01682 
01686 int KivioSMLStencil::vTextAlign()
01687 {
01688     KivioShape *pShape;
01689 
01690     pShape = m_pShapeList->first();
01691     while( pShape )
01692     {
01693         if( pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox )
01694         {
01695             return pShape->shapeData()->vTextAlign();
01696         }
01697 
01698         pShape = m_pShapeList->next();
01699     }
01700 
01701     return 1;
01702 }
01703 
01704 
01708 QString KivioSMLStencil::text()
01709 {
01710     KivioShape *pShape;
01711 
01712     pShape = m_pShapeList->first();
01713     while( pShape )
01714     {
01715         if( pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox )
01716         {
01717             return pShape->shapeData()->text();
01718         }
01719 
01720         pShape = m_pShapeList->next();
01721     }
01722 
01723     return QString("");
01724 }
01725 
01726 
01730 void KivioSMLStencil::setText( const QString &t )
01731 {
01732     KivioShape *pShape;
01733 
01734     pShape = m_pShapeList->first();
01735     while( pShape )
01736     {
01737         if( pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox )
01738         {
01739             pShape->shapeData()->setText(t);
01740         }
01741 
01742         pShape = m_pShapeList->next();
01743     }
01744 }
01745 
01746 
01750 double KivioSMLStencil::lineWidth()
01751 {
01752     KivioShape *pShape;
01753 
01754     pShape = m_pShapeList->first();
01755     if( pShape )
01756         return pShape->shapeData()->lineStyle()->width();
01757 
01758     return 1.0f;
01759 }
01760 
01761 int KivioSMLStencil::linePattern()
01762 {
01763     KivioShape *pShape = m_pShapeList->first();
01764 
01765     if( pShape )
01766         return pShape->shapeData()->lineStyle()->style();
01767 
01768     return 1;
01769 }
01770 
01774 QColor KivioSMLStencil::fgColor()
01775 {
01776     KivioShape *pShape;
01777 
01778     pShape = m_pShapeList->first();
01779     if( pShape )
01780         return pShape->shapeData()->lineStyle()->color();
01781 
01782     return QColor(0,0,0);
01783 }
01784 
01785 
01789 QColor KivioSMLStencil::bgColor()
01790 {
01791     KivioShape *pShape;
01792 
01793     pShape = m_pShapeList->first();
01794     if( pShape )
01795         return pShape->shapeData()->fillStyle()->color();
01796 
01797     return QColor(0,0,0);
01798 }
01799 
01800 int KivioSMLStencil::fillPattern()
01801 {
01802     KivioShape *pShape;
01803 
01804     pShape = m_pShapeList->first();
01805     if( pShape )
01806         return pShape->shapeData()->fillStyle()->brushStyle();
01807 
01808     return 1;
01809 }
01810 
01814 int KivioSMLStencil::generateIds( int nextAvailable )
01815 {
01816     KivioConnectorTarget *pTarget = m_pConnectorTargets->first();
01817 
01818     // Iterate through all the targets
01819     while( pTarget )
01820     {
01821         // If this target has something connected to it
01822         if( pTarget->hasConnections() )
01823         {
01824             // Set it's id to the next available id
01825             pTarget->setId( nextAvailable );
01826 
01827             // Increment the next available id
01828             nextAvailable++;
01829         }
01830         else
01831         {
01832             // Otherwise mark it as unused (-1)
01833             pTarget->setId( -1 );
01834         }
01835 
01836         pTarget = m_pConnectorTargets->next();
01837     }
01838 
01839     // Return the next availabe id
01840     return nextAvailable;
01841 }
01842 
01846 KivioCollisionType KivioSMLStencil::checkForCollision( KoPoint *pPoint, double )
01847 {
01848   KivioCollisionType type = kctNone;
01849 
01850   QWMatrix m;
01851   m.translate(m_x, m_y);
01852   m.translate(m_w / 2.0, m_h / 2.0);
01853   m.rotate(m_rotation);
01854   m.translate(-m_w / 2.0, -m_h / 2.0);
01855 
01856   KoPoint pPoints[4];
01857   pPoints[0].setX(0 * m.m11() + 0 * m.m21() + m.dx());
01858   pPoints[0].setY(0 * m.m12() + 0 * m.m22() + m.dy());
01859   pPoints[1].setX(m_w * m.m11() + 0 * m.m21() + m.dx());
01860   pPoints[1].setY(m_w * m.m12() + 0 * m.m22() + m.dy());
01861   pPoints[2].setX(m_w * m.m11() + m_h * m.m21() + m.dx());
01862   pPoints[2].setY(m_w * m.m12() + m_h * m.m22() + m.dy());
01863   pPoints[3].setX(0 * m.m11() + m_h * m.m21() + m.dx());
01864   pPoints[3].setY(0 * m.m12() + m_h * m.m22() + m.dy());
01865 
01866   if(PointInPoly(pPoints, 4, pPoint)) {
01867     type = kctBody;
01868   }
01869 
01870   return type;
01871 }
01872 
01873 bool KivioSMLStencil::checkCollisionArc( KivioShape *, KoPoint * )
01874 {
01875     return false;
01876 }
01877 
01878 
01879 bool KivioSMLStencil::checkCollisionBezier( KivioShape *, KoPoint * )
01880 {
01881     return false;
01882 }
01883 
01884 bool KivioSMLStencil::checkCollisionOpenPath( KivioShape *, KoPoint * )
01885 {
01886     return false;
01887 }
01888 
01889 bool KivioSMLStencil::checkCollisionClosedPath( KivioShape *, KoPoint * )
01890 {
01891     return false;
01892 }
01893 
01894 bool KivioSMLStencil::checkCollisionPie( KivioShape *, KoPoint * )
01895 {
01896     return false;
01897 }
01898 
01899 bool KivioSMLStencil::checkCollisionEllipse( KivioShape *, KoPoint * )
01900 {
01901     return false;
01902 }
01903 
01904 bool KivioSMLStencil::checkCollisionLineArray( KivioShape *, KoPoint * )
01905 {
01906     return false;
01907 }
01908 
01909 bool KivioSMLStencil::checkCollisionRectangle( KivioShape *, KoPoint * )
01910 {
01911     return false;
01912 }
01913 
01914 bool KivioSMLStencil::checkCollisionRoundRectangle( KivioShape *, KoPoint * )
01915 {
01916     return false;
01917 }
01918 
01919 bool KivioSMLStencil::checkCollisionPolygon( KivioShape *pShape, KoPoint *pCheckPoint )
01920 {
01921   double _x, _y, defWidth, defHeight;
01922   KivioShapeData *pShapeData;
01923   QPtrList<KivioPoint> *pList;
01924   KoPoint *pPoints;
01925 
01926   pShapeData = pShape->shapeData();
01927 
01928   defWidth = m_pSpawner->defWidth();
01929   defHeight = m_pSpawner->defHeight();
01930 
01931   pList = pShapeData->pointList();
01932 
01933   pPoints = new KoPoint[pList->count()];
01934 
01935   KivioPoint *pPoint;
01936   int i=0;
01937   pPoint = pList->first();
01938   while( pPoint )
01939   {
01940     _x = m_zoomHandler->zoomItX((pPoint->x() / defWidth) * m_w);
01941     _y = m_zoomHandler->zoomItY((pPoint->y() / defHeight) * m_h);
01942 
01943     pPoints[i].setX(_x);
01944     pPoints[i].setY(_y);
01945 
01946     i++;
01947 
01948     pPoint = pList->next();
01949   }
01950 
01951   if( PointInPoly( pPoints, i, pCheckPoint ) )
01952   {
01953     delete [] pPoints;
01954     return true;
01955   }
01956 
01957   delete [] pPoints;
01958 
01959   return false;
01960 }
01961 
01962 bool KivioSMLStencil::checkCollisionPolyline( KivioShape *, KoPoint * )
01963 {
01964     return false;
01965 }
01966 
01967 bool KivioSMLStencil::checkCollisionTextBox( KivioShape *, KoPoint * )
01968 {
01969     return false;
01970 }
01971 
01972 
01976 int KivioSMLStencil::resizeHandlePositions()
01977 {
01978    // Calculate the resize handle positions
01979    int mask = KIVIO_RESIZE_HANDLE_POSITION_ALL;
01980 
01981    if( m_pProtection->at( kpWidth ) )
01982    {
01983       mask &= ~(krhpNE | krhpNW | krhpSW | krhpSE | krhpE | krhpW);
01984    }
01985 
01986    if( m_pProtection->at( kpHeight ) )
01987    {
01988       mask &= ~(krhpNE | krhpNW | krhpSW | krhpSE | krhpN | krhpS);
01989    }
01990 
01991    if( m_pProtection->at( kpAspect ) )
01992    {
01993       mask = KIVIO_RESIZE_HANDLE_POSITION_CORNERS;
01994    }
01995 
01996    return mask;
01997 }
01998 
01999 KivioLineStyle KivioSMLStencil::lineStyle()
02000 {
02001     KivioShape *pShape = m_pShapeList->first();
02002 
02003     if( pShape )
02004         return *(pShape->shapeData()->lineStyle());
02005 
02006     return KivioLineStyle();
02007 }
02008 
02009 void KivioSMLStencil::setLineStyle(KivioLineStyle ls)
02010 {
02011     KivioShape *pShape = m_pShapeList->first();
02012 
02013     while( pShape )
02014     {
02015         pShape->shapeData()->setLineStyle(ls);;
02016         pShape = m_pShapeList->next();
02017     }
02018 }
02019 
02020 QString KivioSMLStencil::getTextBoxName(const KoPoint& p)
02021 {
02022   KivioShape* pShape = m_pShapeList->first();
02023   KivioShape* first = 0;
02024   KoPoint pos = p;
02025   
02026   // Calculate the rotation...
02027   QWMatrix m;
02028   m.translate(m_x, m_y);
02029   m.translate(m_w / 2.0, m_h / 2.0);
02030   m.rotate(m_rotation);
02031   m.translate(-m_w / 2.0, -m_h / 2.0);
02032   
02033   while(pShape)
02034   {
02035     if(pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox)
02036     {
02037       double x = pShape->shapeData()->x();
02038       double y = pShape->shapeData()->y();
02039       double x2 = pShape->shapeData()->w() + x;
02040       double y2 = pShape->shapeData()->h() + y;
02041       
02042       // Create the rotated rectangle
02043       KoPoint pPoints[4];
02044       pPoints[0].setX(x * m.m11() + y * m.m21() + m.dx());
02045       pPoints[0].setY(x * m.m12() + y * m.m22() + m.dy());
02046       pPoints[1].setX(x2 * m.m11() + y * m.m21() + m.dx());
02047       pPoints[1].setY(x2 * m.m12() + y * m.m22() + m.dy());
02048       pPoints[2].setX(x2 * m.m11() + y2 * m.m21() + m.dx());
02049       pPoints[2].setY(x2 * m.m12() + y2 * m.m22() + m.dy());
02050       pPoints[3].setX(x * m.m11() + y2 * m.m21() + m.dx());
02051       pPoints[3].setY(x * m.m12() + y2 * m.m22() + m.dy());
02052     
02053       if(PointInPoly(pPoints, 4, &pos)) {
02054         return pShape->shapeData()->name();
02055       }
02056       
02057       if(!first) {
02058         first = pShape;
02059       }
02060     }
02061 
02062     pShape = m_pShapeList->next();
02063   }
02064   
02065   if(first) {
02066     return first->shapeData()->name();
02067   }
02068   
02069   return QString::null;
02070 }
02071 
02072 void KivioSMLStencil::setText(const QString& text, const QString& name)
02073 {
02074   KivioShape* pShape = m_pShapeList->first();
02075   
02076   while(pShape)
02077   {
02078     if(pShape->shapeData()->name() == name)
02079     {
02080       pShape->shapeData()->setText(text);
02081       return;
02082     }
02083 
02084     pShape = m_pShapeList->next();
02085   }
02086 }
02087 
02088 QString KivioSMLStencil::text(const QString& name)
02089 {
02090   KivioShape* pShape = m_pShapeList->first();
02091   
02092   while(pShape)
02093   {
02094     if(pShape->shapeData()->name() == name)
02095     {
02096       return pShape->shapeData()->text();
02097     }
02098 
02099     pShape = m_pShapeList->next();
02100   }
02101   
02102   return QString::null;
02103 }
02104 
02105 void KivioSMLStencil::addConnectorTarget(const KoPoint& p)
02106 {
02107   KivioConnectorTarget* target = new KivioConnectorTarget(p.x(), p.y(), (p.x() - x())/ w(), (p.y() - y())/ h());
02108   m_pConnectorTargets->append(target);
02109 }
02110 
02111 void KivioSMLStencil::removeConnectorTarget(const KoPoint& pos)
02112 {
02113   KivioConnectorTarget* target = m_pConnectorTargets->first();
02114 
02115   while(target)
02116   {
02117     if(target->position() == pos)
02118     {
02119       m_pConnectorTargets->remove(target);
02120       return;
02121     }
02122 
02123     target = m_pConnectorTargets->next();
02124   }
02125 }
02126 
02127 bool KivioSMLStencil::hasTextBox() const
02128 {
02129   KivioShape* pShape = m_pShapeList->first();
02130   while(pShape) {
02131     if(pShape->shapeData()->shapeType() == KivioShapeData::kstTextBox) {
02132       return true;
02133     }
02134 
02135     pShape = m_pShapeList->next();
02136   }
02137 
02138   return false;
02139 }
02140 
02141 QColor KivioSMLStencil::textColor(const QString& textBoxName)
02142 {
02143   KivioShape* shape = locateShape(textBoxName);
02144 
02145   if(!shape)
02146     return textColor();
02147 
02148   return shape->shapeData()->textColor();
02149 }
02150 
02151 void KivioSMLStencil::setTextColor(const QString& textBoxName, const QColor& color)
02152 {
02153   KivioShape* shape = locateShape(textBoxName);
02154 
02155   // If we didn't find the shape set the color stencil wide
02156   if(!shape) {
02157     setTextColor(color);
02158     return;
02159   }
02160 
02161   shape->shapeData()->setTextColor(color);
02162 }
02163 
02164 QFont KivioSMLStencil::textFont(const QString& textBoxName)
02165 {
02166   KivioShape* shape = locateShape(textBoxName);
02167 
02168   if(!shape)
02169     return textFont();
02170 
02171   return shape->shapeData()->textFont();
02172 }
02173 
02174 void KivioSMLStencil::setTextFont(const QString& textBoxName, const QFont& font)
02175 {
02176   KivioShape* shape = locateShape(textBoxName);
02177 
02178   if(!shape) {
02179     setTextFont(font);
02180     return;
02181   }
02182 
02183   shape->shapeData()->setTextFont(font);
02184 }
02185 
02186 int KivioSMLStencil::hTextAlign(const QString& textBoxName)
02187 {
02188   KivioShape* shape = locateShape(textBoxName);
02189 
02190   if(!shape)
02191     return hTextAlign();
02192 
02193   return shape->shapeData()->hTextAlign();
02194 }
02195 
02196 int KivioSMLStencil::vTextAlign(const QString& textBoxName)
02197 {
02198   KivioShape* shape = locateShape(textBoxName);
02199 
02200   if(!shape)
02201     return vTextAlign();
02202 
02203   return shape->shapeData()->vTextAlign();
02204 }
02205 
02206 void KivioSMLStencil::setHTextAlign(const QString& textBoxName, int align)
02207 {
02208   KivioShape* shape = locateShape(textBoxName);
02209 
02210   if(!shape) {
02211     setHTextAlign(align);
02212     return;
02213   }
02214 
02215   shape->shapeData()->setHTextAlign(align);
02216 }
02217 
02218 void KivioSMLStencil::setVTextAlign(const QString& textBoxName, int align)
02219 {
02220   KivioShape* shape = locateShape(textBoxName);
02221 
02222   if(!shape) {
02223     setVTextAlign(align);
02224     return;
02225   }
02226 
02227   shape->shapeData()->setVTextAlign(align);
02228 }
KDE Home | KDE Accessibility Home | Description of Access Keys