Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 4753 → Rev 4754

/branches/Version13x/Scribus/scribus/util.cpp
1199,6 → 1199,18
return sqrt(x*x+y*y);
}
 
double constrainAngle(double angle)
{
double newAngle=angle;
double constrainTo=15.0;
if (newAngle<0.0)
newAngle+=360.0;
newAngle=qRound(angle/constrainTo)*constrainTo;
if (newAngle==360.0)
newAngle=0.0;
return newAngle;
}
 
const QString getStringFromSequence(DocumentSectionType type, uint position)
{
QString retVal("");
/branches/Version13x/Scribus/scribus/scribusview.h
205,7 → 205,7
bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
void moveGroup(double x, double y, bool fromMP = false);
void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false);
bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
void RotateGroup(double win);
void scaleGroup(double scx, double scy, bool scaleText=true);
void RotateItem(double win, int ite);
/branches/Version13x/Scribus/scribus/scribusview.cpp
2092,36 → 2092,9
np += QPoint(qRound(Doc->minCanvasCoordinate.x()), qRound(Doc->minCanvasCoordinate.y()));
np = ApplyGrid(np);
double newRot=xy2Deg(np.x(), np.y());
//Constrain rotation angle, when the mouse is released from drawing a line
if (m->state() & ControlButton)
{
if (newRot<0.0)
newRot+=360.0;
if (newRot<22.5)
newRot=0.0;
else
if (newRot>22.5 && newRot<67.5)
newRot=45.0;
else
if (newRot>67.5 && newRot<112.5)
newRot=90.0;
else
if (newRot>112. && newRot<157.5)
newRot=135.0;
else
if (newRot>157.5 && newRot<202.5)
newRot=180.0;
else
if (newRot>202.5 && newRot<247.5)
newRot=225.0;
else
if (newRot>247.5 && newRot<292.5)
newRot=270.0;
else
if (newRot>292.5 && newRot<337.5)
newRot=315.0;
else
newRot=0.0;
}
newRot=constrainAngle(newRot);
currItem->setRotation(newRot);
currItem->setWidthHeight(sqrt(pow(np.x(),2.0)+pow(np.y(),2.0)), 1.0);
currItem->Sizing = false;
2397,6 → 2370,7
}
else
{
qDebug("3");
if (sav)
{
double nx = m->pos().x()/Scale + Doc->minCanvasCoordinate.x();
3356,41 → 3330,15
newY = static_cast<int>(qRound(newY / Doc->guidesSettings.minorGrid) * Doc->guidesSettings.minorGrid);
}
double newRot=xy2Deg(newX - currItem->xPos(), newY - currItem->yPos());
//Constrain rotation angle, when the mouse is being dragged around for a new line
if (m->state() & ControlButton)
{
//Flip our angles around here
if (newRot<0.0)
newRot=-newRot;
else
newRot=360-newRot;
if (newRot<0.0)
newRot+=360.0;
if (newRot<22.5)
newRot=0.0;
else
if (newRot>22.5 && newRot<67.5)
newRot=45.0;
else
if (newRot>67.5 && newRot<112.5)
newRot=90.0;
else
if (newRot>112. && newRot<157.5)
newRot=135.0;
else
if (newRot>157.5 && newRot<202.5)
newRot=180.0;
else
if (newRot>202.5 && newRot<247.5)
newRot=225.0;
else
if (newRot>247.5 && newRot<292.5)
newRot=270.0;
else
if (newRot>292.5 && newRot<337.5)
newRot=315.0;
else
newRot=0.0;
newRot=constrainAngle(newRot);
double hlen=sqrt(pow(newX - currItem->xPos(),2)+pow(newY - currItem->yPos(),2));
newX = currItem->xPos()+(hlen * cos(newRot/(180.0/M_PI)));
newY = currItem->yPos()-(hlen * sin(newRot/(180.0/M_PI)));
3682,9 → 3630,19
p.translate(qRound(-Doc->minCanvasCoordinate.x()), qRound(-Doc->minCanvasCoordinate.y()));
np = p.xFormDev(QPoint(m->x(), m->y()));
p.end();
double sizeItemX=np.x(), sizeItemY=np.y();
//Constrain rotation angle, when the mouse is moving the non-origin point of a line
if (m->state() & ControlButton)
{
double newRot=xy2Deg(np.x(), np.y());
rba=constrainAngle(newRot);
double hlen=sqrt(pow(newX - currItem->xPos(),2)+pow(newY - currItem->yPos(),2));
sizeItemX = hlen * cos(rba/(180.0/M_PI));
sizeItemY = hlen * sin(rba/(180.0/M_PI));
}
currItem->setRotation(rba);
np = ApplyGrid(np);
erf = SizeItem(np.x(), np.y(), currItem->ItemNr);
erf = SizeItem(sizeItemX, sizeItemY, currItem->ItemNr);
if (Doc->SnapGuides)
{
p.begin(viewport());
3704,7 → 3662,7
{
double sav = Doc->SnapGuides;
npf2 = FPoint(newX-Mxp, newY-Myp);
erf = MoveSizeItem(npf2, FPoint(0, 0), currItem->ItemNr);
erf = MoveSizeItem(npf2, FPoint(0, 0), currItem->ItemNr, false, (m->state() & ControlButton));
Doc->SnapGuides = sav;
if (sav)
currItem->Sizing = true;
6074,7 → 6032,7
}
 
//CB-->Doc
bool ScribusView::MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP)
bool ScribusView::MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP, bool constrainRotation)
{
PageItem *currItem = Doc->Items->at(ite);
QRect oldR(currItem->getRedrawBounding(Scale));
6083,10 → 6041,14
QWMatrix ma;
ma.translate(currItem->xPos(), currItem->yPos());
ma.rotate(currItem->rotation());
double mx = ma.m11() * currItem->width() + ma.dx();
double mx = ma.m11() * currItem->width() + ma.dx();
double my = ma.m12() * currItem->width() + ma.dy();
MoveItem(newX.x(), newX.y(), currItem, fromMP);
currItem->setRotation(xy2Deg(mx - currItem->xPos(), my - currItem->yPos()));
double newRot=xy2Deg(mx - currItem->xPos(), my - currItem->yPos());
//CB Hmm should work, doesnt. (constraining on the first point of a line)
//if (constrainRotation)
// qDebug(QString("%1").arg(constrainAngle(newRot)));
currItem->setRotation(newRot);
currItem->setWidthHeight(sqrt(pow(mx - currItem->xPos(),2)+pow(my - currItem->yPos(),2)), 1.0);
currItem->updateClip();
Doc->setRedrawBounding(currItem);
/branches/Version13x/Scribus/scribus/util.h
135,6 → 135,12
void SCRIBUS_API sDebug(QString message);
inline double SCRIBUS_API square(double);
inline double SCRIBUS_API distance(double, double);
/*! \brief Constrains an angle of rotation to 45 degree intervals
Will make code simpler and reduce interval or provide as a parameter
\param double angle Angle in degrees
\retval double Constrained angle
*/
double SCRIBUS_API constrainAngle(double angle);
const QString SCRIBUS_API getStringFromSequence(DocumentSectionType type, uint position);
const QString SCRIBUS_API arabicToRoman(uint i);
const QString SCRIBUS_API numberToLetterSequence(uint i);