~ubuntu-branches/ubuntu/karmic/kst/karmic

« back to all changes in this revision

Viewing changes to kst/kst/kstalignment.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2006-06-30 19:11:30 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060630191130-acumuar75bz4puty
Tags: 1.2.1-1ubuntu1
Merge from debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
KstAlignment KST::alignment;
21
21
 
22
 
bool operator<( const QPoint &p1, const QPoint &p2 ) {
23
 
  bool bRetVal = false;
24
 
 
25
 
  if (p1.x() < p2.x()) {
26
 
    bRetVal = true;
27
 
  } else if (p1.x() == p2.x()) {
28
 
    if (p1.y() < p2.y()) {
29
 
      bRetVal = true;
30
 
    }
31
 
  }
32
 
 
33
 
  return bRetVal;
 
22
int operator<(const QPoint &p1, const QPoint &p2) {
 
23
  return p1.x() < p2.x() || (p1.x() == p2.x() && p1.y() < p2.y());
34
24
}
35
25
 
36
26
 
45
35
 
46
36
 
47
37
void KstAlignment::setPosition(const QRect& geometry, const QRect& plotRegion) {
48
 
  QPoint xAllRegion;
49
 
  QPoint yAllRegion;
50
 
  QPoint xPlotRegion;
51
 
  QPoint yPlotRegion;
52
 
  QPoint xPlotRegionCurrent;
53
 
  QPoint yPlotRegionCurrent;
54
 
 
55
 
  xAllRegion.setX(geometry.left());
56
 
  xAllRegion.setY(geometry.right());
57
 
  yAllRegion.setX(geometry.top());
58
 
  yAllRegion.setY(geometry.bottom());
59
 
 
60
 
  xPlotRegion.setX(plotRegion.left());
61
 
  xPlotRegion.setY(plotRegion.right());
62
 
  yPlotRegion.setX(plotRegion.top());
63
 
  yPlotRegion.setY(plotRegion.bottom());  
 
38
  QPoint xAllRegion(geometry.left(), geometry.right());
 
39
  QPoint yAllRegion(geometry.top(), geometry.bottom());
 
40
  QPoint xPlotRegion(plotRegion.left(), plotRegion.right());
 
41
  QPoint yPlotRegion(plotRegion.top(), plotRegion.bottom());
64
42
 
65
43
  if (_xAlignments.contains(xAllRegion)) {
66
 
    xPlotRegionCurrent = _xAlignments[xAllRegion];
 
44
    QPoint xPlotRegionCurrent = _xAlignments[xAllRegion];
67
45
 
68
46
    if (xPlotRegion.x() > xPlotRegionCurrent.x()) {
69
47
      xPlotRegionCurrent.setX(xPlotRegion.x());
77
55
  }
78
56
 
79
57
  if (_yAlignments.contains(yAllRegion)) {
80
 
    yPlotRegionCurrent = _yAlignments[yAllRegion];
 
58
    QPoint yPlotRegionCurrent = _yAlignments[yAllRegion];
81
59
 
82
60
    if (yPlotRegion.x() > yPlotRegionCurrent.x()) {
83
61
      yPlotRegionCurrent.setX(yPlotRegion.x());
93
71
 
94
72
 
95
73
void KstAlignment::limits(const QRect& geometry, double& xleft, double& xright, double& ytop, double& ybottom, double dFactor) {
96
 
  QPoint xAllRegion;
97
 
  QPoint yAllRegion;
98
 
 
99
 
  xAllRegion.setX(geometry.left());
100
 
  xAllRegion.setY(geometry.right());
101
 
  yAllRegion.setX(geometry.top());
102
 
  yAllRegion.setY(geometry.bottom());
103
 
 
104
 
  if (_xAlignments.contains(xAllRegion)) {
105
 
    xleft = (double)_xAlignments[xAllRegion].x();
106
 
    xright = (double)_xAlignments[xAllRegion].y();
 
74
  QPoint xAllRegion(geometry.left(), geometry.right());
 
75
  QPoint yAllRegion(geometry.top(), geometry.bottom());
 
76
 
 
77
  alignmentMap::ConstIterator allRef = _xAlignments.find(xAllRegion);
 
78
  if (allRef != _xAlignments.end()) {
 
79
    xleft = double((*allRef).x()) * dFactor;
 
80
    xright = double((*allRef).y()) * dFactor;
107
81
  } else {
108
82
    xleft = 0.0;
109
83
    xright = 0.0;
110
84
  }
111
85
 
112
 
  if (_yAlignments.contains(yAllRegion)) {
113
 
    ytop = (double)_yAlignments[yAllRegion].x();
114
 
    ybottom = (double)_yAlignments[yAllRegion].y();
 
86
  allRef = _yAlignments.find(yAllRegion);
 
87
  if (allRef != _yAlignments.end()) {
 
88
    ytop = double((*allRef).x()) * dFactor;
 
89
    ybottom = double((*allRef).y()) * dFactor;
115
90
  } else {
116
91
    ytop = 0.0;
117
92
    ybottom = 0.0;
118
93
  }
119
 
 
120
 
  xleft   *= dFactor;
121
 
  xright  *= dFactor;
122
 
  ytop    *= dFactor;
123
 
  ybottom *= dFactor;
124
94
}
125
95
 
126
96
 
127
97
QRect KstAlignment::limits(const QRect& geometry) {
128
 
  QPoint xAllRegion;
129
 
  QPoint yAllRegion;
 
98
  QPoint xAllRegion(geometry.left(), geometry.right());
 
99
  QPoint yAllRegion(geometry.top(), geometry.bottom());
130
100
  QRect plotRegion;
131
101
 
132
 
  xAllRegion.setX(geometry.left());
133
 
  xAllRegion.setY(geometry.right());
134
 
  yAllRegion.setX(geometry.top());
135
 
  yAllRegion.setY(geometry.bottom());
136
 
 
137
 
  if (_xAlignments.contains(xAllRegion)) {
138
 
    plotRegion.setLeft(_xAlignments[xAllRegion].x());
139
 
    plotRegion.setRight(_xAlignments[xAllRegion].y());
 
102
  alignmentMap::ConstIterator allRef = _xAlignments.find(xAllRegion);
 
103
  if (allRef != _xAlignments.end()) {
 
104
    plotRegion.setLeft((*allRef).x());
 
105
    plotRegion.setRight((*allRef).y());
140
106
  } else {
141
107
    plotRegion.setLeft(0);
142
108
    plotRegion.setRight(0);
143
109
  }
144
110
 
145
 
  if (_yAlignments.contains(yAllRegion)) {
146
 
    plotRegion.setTop(_yAlignments[yAllRegion].x());
147
 
    plotRegion.setBottom(_yAlignments[yAllRegion].y());
 
111
  allRef = _yAlignments.find(yAllRegion);
 
112
  if (allRef != _yAlignments.end()) {
 
113
    plotRegion.setTop((*allRef).x());
 
114
    plotRegion.setBottom((*allRef).y());
148
115
  } else {
149
116
    plotRegion.setTop(0);
150
117
    plotRegion.setBottom(0);
152
119
 
153
120
  return plotRegion;
154
121
}
 
122
 
 
123
// vim: ts=2 sw=2 et