41 if(
document()->selection()->objects().count() <= 2 )
49 VObjectListIterator itr( objs );
51 TQMap<double,VObject*> sortedPos;
54 for( ; itr.current(); ++itr )
56 bbox = itr.current()->boundingBox();
57 switch( m_distribute )
59 case DISTRIBUTE_HORIZONTAL_CENTER:
60 sortedPos[bbox.center().x()] = itr.current();
62 case DISTRIBUTE_HORIZONTAL_GAP:
63 case DISTRIBUTE_HORIZONTAL_LEFT:
64 sortedPos[bbox.left()] = itr.current();
65 extent += bbox.width();
67 case DISTRIBUTE_HORIZONTAL_RIGHT:
68 sortedPos[bbox.right()] = itr.current();
70 case DISTRIBUTE_VERTICAL_CENTER:
71 sortedPos[bbox.center().y()] = itr.current();
73 case DISTRIBUTE_VERTICAL_GAP:
74 case DISTRIBUTE_VERTICAL_BOTTOM:
75 sortedPos[bbox.bottom()] = itr.current();
76 extent += bbox.height();
78 case DISTRIBUTE_VERTICAL_TOP:
79 sortedPos[bbox.top()] = itr.current();
84 VObject* first = sortedPos.begin().data();
85 VObject* last = (--sortedPos.end()).data();
88 double space = getAvailableSpace( first, last, extent );
89 double pos = 0.0, step = space / double(objs.count() - 1);
91 VTranslateCmd *trafoCmd = 0L;
92 TQMapIterator<double,VObject*> it = sortedPos.begin(), et = sortedPos.end();
94 for( ; it != et; ++it )
96 if( it.data() == first || it.data() == last )
103 bbox = it.data()->boundingBox();
105 switch( m_distribute )
107 case DISTRIBUTE_HORIZONTAL_CENTER:
108 dx = first->
boundingBox().center().x() + pos - bbox.center().x();
111 case DISTRIBUTE_HORIZONTAL_GAP:
112 dx = first->
boundingBox().right() + pos + 0.5 * bbox.width() - bbox.center().x();
116 case DISTRIBUTE_HORIZONTAL_LEFT:
117 dx = first->
boundingBox().left() + pos - bbox.left();
120 case DISTRIBUTE_HORIZONTAL_RIGHT:
121 dx = first->
boundingBox().right() + pos - bbox.right();
124 case DISTRIBUTE_VERTICAL_CENTER:
126 dy = first->
boundingBox().center().y() + pos - bbox.center().y();
128 case DISTRIBUTE_VERTICAL_GAP:
130 dy = first->
boundingBox().bottom() + pos + 0.5 * bbox.height() - bbox.center().y();
131 pos += bbox.height();
133 case DISTRIBUTE_VERTICAL_BOTTOM:
135 dy = first->
boundingBox().bottom() + pos - bbox.bottom();
137 case DISTRIBUTE_VERTICAL_TOP:
139 dy = first->
boundingBox().top() + pos - bbox.top();
143 trafoCmd =
new VTranslateCmd(
document(), dx, dy );
144 m_trafoCmds.append( trafoCmd );
150 for( ; itr.current() ; ++itr )