Back to index

scribus-ng  1.3.4.dfsg+svn20071115
frameedit.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "frameedit.h"
00008 #include "frameedit.moc"
00009 #include "page.h"
00010 #include "pageitem.h"
00011 #include "scribusview.h"
00012 #include "selection.h"
00013 #include "units.h"
00014 #include "undomanager.h"
00015 #include "undostate.h"
00016 
00017 extern QPixmap loadIcon(QString nam);
00018 
00019 NodePalette::NodePalette( QWidget* parent) : ScrPaletteBase( parent, "nodePalette", false, 0)
00020 {
00021        doc=0;
00022        unitRatio=1.0;
00023        setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
00024        NodePaletteLayout = new QVBoxLayout( this );
00025        NodePaletteLayout->setSpacing( 2 );
00026        NodePaletteLayout->setMargin( 5 );
00027        gridLayout = new QGridLayout();
00028        gridLayout->setSpacing(0);
00029        gridLayout->setMargin(0);
00030 
00031        MoveNode = new QToolButton(this);
00032        MoveNode->setText( "" );
00033        MoveNode->setPixmap(loadIcon("MoveNode.png"));
00034        MoveNode->setToggleButton( true );
00035        MoveNode->setOn(true);
00036        gridLayout->addWidget(MoveNode, 0, 0);
00037 
00038        AddNode = new QToolButton(this);
00039        AddNode->setPixmap(loadIcon("AddNode.png"));
00040        AddNode->setEnabled(true);
00041        AddNode->setToggleButton(true);
00042        gridLayout->addWidget(AddNode, 0, 1);
00043 
00044        DeleteNode = new QToolButton(this);
00045        DeleteNode->setPixmap(loadIcon("DeleteNode.png"));
00046        DeleteNode->setEnabled(true);
00047        DeleteNode->setToggleButton(true);
00048        gridLayout->addWidget(DeleteNode, 0, 2);
00049 
00050        ResNode = new QToolButton(this);
00051        ResNode->setPixmap(loadIcon("ResetNode.png"));
00052        ResNode->setEnabled(true);
00053        gridLayout->addWidget(ResNode, 0, 3);
00054 
00055        MoveControl = new QToolButton(this);
00056        MoveControl->setPixmap(loadIcon("MoveKontrol.png"));
00057        MoveControl->setToggleButton(true);
00058        gridLayout->addWidget(MoveControl, 1, 0);
00059 
00060        AsymMove = new QToolButton(this);
00061        AsymMove->setPixmap(loadIcon("MoveAsym.png"));
00062        AsymMove->setEnabled(false);
00063        AsymMove->setToggleButton(true);
00064        gridLayout->addWidget(AsymMove, 1, 1);
00065 
00066        SymMove = new QToolButton(this);
00067        SymMove->setPixmap(loadIcon("MoveSym.png"));
00068        SymMove->setEnabled(false);
00069        SymMove->setToggleButton(true);
00070        gridLayout->addWidget(SymMove, 1, 2);
00071 
00072        Res1Node = new QToolButton(this);
00073        Res1Node->setPixmap(loadIcon("Reset1Node.png"));
00074        Res1Node->setEnabled(false);
00075        gridLayout->addWidget(Res1Node, 1, 3);
00076 
00077        PolySplit = new QToolButton(this);
00078        PolySplit->setEnabled( false );
00079        PolySplit->setToggleButton( true );
00080        PolySplit->setPixmap(loadIcon("PolyCut.png"));
00081        gridLayout->addWidget(PolySplit, 2, 0);
00082 
00083        BezierClose = new QToolButton(this);
00084        BezierClose->setEnabled( false );
00085        BezierClose->setPixmap(loadIcon("BezierClose.png"));
00086        gridLayout->addWidget(BezierClose, 2, 1);
00087 
00088        PolyMirrorH = new QToolButton(this);
00089        PolyMirrorH->setPixmap(loadIcon("hmirror.png"));
00090        gridLayout->addWidget(PolyMirrorH, 2, 2);
00091 
00092        PolyMirrorV = new QToolButton(this);
00093        PolyMirrorV->setPixmap(loadIcon("vmirror.png"));
00094        gridLayout->addWidget(PolyMirrorV, 2, 3);
00095 
00096        PolyShearL = new QToolButton(this);
00097        PolyShearL->setPixmap(loadIcon("22/transform-shear-left.png"));
00098        PolyShearL->setAutoRepeat(true);
00099        gridLayout->addWidget(PolyShearL, 3, 0);
00100 
00101        PolyShearR = new QToolButton(this);
00102        PolyShearR->setPixmap(loadIcon("22/transform-shear-right.png"));
00103        PolyShearR->setAutoRepeat(true);
00104        gridLayout->addWidget(PolyShearR, 3, 1);
00105 
00106        PolyShearU = new QToolButton(this);
00107        PolyShearU->setPixmap(loadIcon("22/transform-shear-up.png"));
00108        PolyShearU->setAutoRepeat(true);
00109        gridLayout->addWidget(PolyShearU, 3, 2);
00110 
00111        PolyShearD = new QToolButton(this);
00112        PolyShearD->setPixmap(loadIcon("22/transform-shear-down.png"));
00113        PolyShearD->setAutoRepeat(true);
00114        gridLayout->addWidget(PolyShearD, 3, 3);
00115        NodePaletteLayout->addLayout(gridLayout);
00116 
00117        gridLayout1 = new QGridLayout();
00118        gridLayout1->setSpacing(0);
00119        gridLayout1->setMargin(0);
00120 
00121        RotateCCW = new QToolButton(this);
00122        RotateCCW->setPixmap(loadIcon("rotate_ccw.png"));
00123        RotateCCW->setAutoRepeat(true);
00124        gridLayout1->addWidget(RotateCCW, 0, 0);
00125 
00126        RotateCW = new QToolButton(this);
00127        RotateCW->setPixmap(loadIcon("rotate_cw.png"));
00128        RotateCW->setAutoRepeat(true);
00129        gridLayout1->addWidget(RotateCW, 0, 1);
00130 
00131        RotVal = new QSpinBox(this, "RotVal");
00132        RotVal->setMinValue(1);
00133        RotVal->setMaxValue(180);
00134        RotVal->setValue(1);
00135        RotVal->setSuffix( QString::fromUtf8(" °"));
00136        gridLayout1->addWidget(RotVal, 0, 2);
00137 
00138        Expand = new QToolButton(this);
00139        Expand->setPixmap(loadIcon("expand.png"));
00140        Expand->setAutoRepeat(true);
00141        gridLayout1->addWidget(Expand, 1, 0);
00142 
00143        Shrink = new QToolButton(this);
00144        Shrink->setPixmap(loadIcon("crop.png"));
00145        Shrink->setAutoRepeat(true);
00146        gridLayout1->addWidget(Shrink, 1, 1);
00147 
00148        scalePercentage = new QSpinBox( this, "scalePercentage");
00149        scalePercentage->setMinValue(1);
00150        scalePercentage->setMaxValue(100);
00151        scalePercentage->setValue(10);
00152        gridLayout1->addWidget(scalePercentage, 1, 2);
00153 
00154        Enlarge = new QToolButton(this);
00155        Enlarge->setPixmap(loadIcon("expand.png"));
00156        Enlarge->setAutoRepeat(true);
00157        gridLayout1->addWidget(Enlarge, 2, 0);
00158 
00159        Reduce = new QToolButton(this);
00160        Reduce->setPixmap(loadIcon("crop.png"));
00161        Reduce->setAutoRepeat(true);
00162        gridLayout1->addWidget(Reduce, 2, 1);
00163 
00164        scaleDistance = new MSpinBox( 1, 30000, this, 2);
00165        scaleDistance->setValue(10);
00166        scaleDistance->setSuffix("");
00167        gridLayout1->addWidget(scaleDistance, 2, 2);
00168        NodePaletteLayout->addLayout(gridLayout1);
00169 
00170        gridLayout2 = new QGridLayout();
00171        gridLayout2->setSpacing(2);
00172        gridLayout2->setMargin(0);
00173 
00174        AbsMode = new QCheckBox( "&Absolute Coordinates", this, "Textflow" );
00175        AbsMode->setChecked(false);
00176        gridLayout2->addMultiCellWidget(AbsMode, 0, 0, 0, 1);
00177 
00178        TextLabel1 = new QLabel(this);
00179        gridLayout2->addWidget(TextLabel1, 1, 0);
00180 
00181        XSpin = new MSpinBox( this, 2 );
00182        XSpin->setMaxValue(30000);
00183        XSpin->setEnabled(false);
00184        gridLayout2->addWidget(XSpin, 1, 1);
00185 
00186        TextLabel2 = new QLabel(this);
00187        gridLayout2->addWidget(TextLabel2, 2, 0);
00188 
00189        YSpin = new MSpinBox( this, 2 );
00190        YSpin->setMaxValue(30000);
00191        YSpin->setEnabled(false);
00192        gridLayout2->addWidget(YSpin, 2, 1);
00193        TextLabel1->setBuddy(XSpin);
00194        TextLabel2->setBuddy(YSpin);
00195 
00196        EditCont = new QCheckBox(this);
00197        EditCont->setChecked(false);
00198        gridLayout2->addMultiCellWidget(EditCont, 3, 3, 0, 1);
00199 
00200        ResetCont = new QPushButton(this);
00201        ResetCont->setEnabled(false);
00202        gridLayout2->addMultiCellWidget(ResetCont, 4, 4, 0, 1);
00203 
00204        ResetContClip = new QPushButton(this);
00205        ResetContClip->setEnabled(true);
00206        gridLayout2->addMultiCellWidget(ResetContClip, 5, 5, 0, 1);
00207 
00208        editEditButton = new QPushButton(this);
00209        editEditButton->setDefault(true);
00210        gridLayout2->addMultiCellWidget(editEditButton, 6, 6, 0, 1);
00211 
00212        NodePaletteLayout->addLayout(gridLayout2);
00213        languageChange();
00214 //     connectSignals();    
00215 }
00216 
00217 void NodePalette::connectSignals()
00218 {
00219        // signals and slots connections
00220        connect(editEditButton, SIGNAL(clicked()), this, SLOT(EndEdit()));
00221        connect(DeleteNode, SIGNAL(clicked()), this, SLOT(DelN()));
00222        connect(AddNode, SIGNAL(clicked()), this, SLOT(AddN()));
00223        connect(MoveNode, SIGNAL(clicked()), this, SLOT(MoveN()));
00224        connect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
00225        connect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
00226        connect(ResNode, SIGNAL(clicked()), this, SLOT(ResetControl()));
00227        connect(Res1Node, SIGNAL(clicked()), this, SLOT(Reset1Control()));
00228        connect(BezierClose, SIGNAL(clicked()), this, SLOT(CloseBezier()));
00229        connect(PolySplit, SIGNAL(clicked()), this, SLOT(SplitPoly()));
00230        connect(MoveControl, SIGNAL(clicked()), this, SLOT(MoveK()));
00231        connect(XSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00232        connect(YSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00233        connect(PolyMirrorH, SIGNAL(clicked()), this, SLOT(MirrorH()));
00234        connect(PolyMirrorV, SIGNAL(clicked()), this, SLOT(MirrorV()));
00235        connect(PolyShearR, SIGNAL(clicked()), this, SLOT(ShearR()));
00236        connect(PolyShearL, SIGNAL(clicked()), this, SLOT(ShearL()));
00237        connect(PolyShearU, SIGNAL(clicked()), this, SLOT(ShearU()));
00238        connect(PolyShearD, SIGNAL(clicked()), this, SLOT(ShearD()));
00239        connect(RotateCCW, SIGNAL(clicked()), this, SLOT(doRotCCW()));
00240        connect(RotateCW, SIGNAL(clicked()), this, SLOT(doRotCW()));
00241        connect(Shrink, SIGNAL(clicked()), this, SLOT(doShrink()));
00242        connect(Expand, SIGNAL(clicked()), this, SLOT(doExpand()));
00243        connect(Reduce, SIGNAL(clicked()), this, SLOT(doReduce()));
00244        connect(Enlarge, SIGNAL(clicked()), this, SLOT(doEnlarge()));  
00245        connect(AbsMode, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
00246        connect(EditCont, SIGNAL(clicked()), this, SLOT(ToggleConMode()));
00247        connect(ResetCont, SIGNAL(clicked()), this, SLOT(ResetContour()));
00248        connect(ResetContClip, SIGNAL(clicked()), this, SLOT(ResetContourToImageClip()));
00249 }
00250 
00251 void NodePalette::disconnectSignals()
00252 {
00253        // signals and slots disconnetions
00254        disconnect(editEditButton, SIGNAL(clicked()), this, SLOT(EndEdit()));
00255        disconnect(DeleteNode, SIGNAL(clicked()), this, SLOT(DelN()));
00256        disconnect(AddNode, SIGNAL(clicked()), this, SLOT(AddN()));
00257        disconnect(MoveNode, SIGNAL(clicked()), this, SLOT(MoveN()));
00258        disconnect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
00259        disconnect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
00260        disconnect(ResNode, SIGNAL(clicked()), this, SLOT(ResetControl()));
00261        disconnect(Res1Node, SIGNAL(clicked()), this, SLOT(Reset1Control()));
00262        disconnect(BezierClose, SIGNAL(clicked()), this, SLOT(CloseBezier()));
00263        disconnect(PolySplit, SIGNAL(clicked()), this, SLOT(SplitPoly()));
00264        disconnect(MoveControl, SIGNAL(clicked()), this, SLOT(MoveK()));
00265        disconnect(XSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00266        disconnect(YSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00267        disconnect(PolyMirrorH, SIGNAL(clicked()), this, SLOT(MirrorH()));
00268        disconnect(PolyMirrorV, SIGNAL(clicked()), this, SLOT(MirrorV()));
00269        disconnect(PolyShearR, SIGNAL(clicked()), this, SLOT(ShearR()));
00270        disconnect(PolyShearL, SIGNAL(clicked()), this, SLOT(ShearL()));
00271        disconnect(PolyShearU, SIGNAL(clicked()), this, SLOT(ShearU()));
00272        disconnect(PolyShearD, SIGNAL(clicked()), this, SLOT(ShearD()));
00273        disconnect(RotateCCW, SIGNAL(clicked()), this, SLOT(doRotCCW()));
00274        disconnect(RotateCW, SIGNAL(clicked()), this, SLOT(doRotCW()));
00275        disconnect(Shrink, SIGNAL(clicked()), this, SLOT(doShrink()));
00276        disconnect(Expand, SIGNAL(clicked()), this, SLOT(doExpand()));
00277        disconnect(Reduce, SIGNAL(clicked()), this, SLOT(doReduce()));
00278        disconnect(Enlarge, SIGNAL(clicked()), this, SLOT(doEnlarge()));      
00279 //     disconnect(AbsMode, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
00280 //     disconnect(EditCont, SIGNAL(clicked()), this, SLOT(ToggleConMode()));
00281        disconnect(ResetCont, SIGNAL(clicked()), this, SLOT(ResetContour()));
00282        disconnect(ResetContClip, SIGNAL(clicked()), this, SLOT(ResetContourToImageClip()));
00283 }
00284 
00285 void NodePalette::setDoc(ScribusDoc *dc, ScribusView *vi)
00286 {
00287        doc = dc;
00288        view = vi;
00289 
00290        unitChange();
00291        disconnect(EditCont, SIGNAL(clicked()), this, SLOT(ToggleConMode()));
00292        disconnect(AbsMode, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
00293        if (doc!=0)
00294        {
00295               YSpin->setSuffix(unitGetSuffixFromIndex(doc->unitIndex()));
00296               XSpin->setSuffix(unitGetSuffixFromIndex(doc->unitIndex()));
00297        }
00298        AbsMode->setChecked(false);
00299        EditCont->setChecked(false);
00300        if (doc==0)
00301               disconnectSignals();
00302        else
00303               connectSignals();
00304 }
00305 
00306 void NodePalette::SplitPoly()
00307 {
00308        if (doc==0)
00309               return;
00310        MoveN();
00311        doc->EditClipMode = 3;
00312        PolySplit->setOn(true);
00313 }
00314 
00315 void NodePalette::IsOpen()
00316 {
00317        if (doc==0)
00318               return;
00319        PolySplit->setOn(false);
00320        BezierClose->setEnabled(true);
00321        PolySplit->setEnabled(true);
00322        EditCont->setEnabled(false);
00323 }
00324 
00325 void NodePalette::PolyStatus(int typ, uint size)
00326 {
00327        if (doc==0)
00328               return;
00329        bool setter;
00330        switch (typ)
00331        {
00332        case 6:
00333               PolySplit->setEnabled(true);
00334               BezierClose->setEnabled(false);
00335               break;
00336        case 7:
00337               setter = size > 7 ? true : false;
00338               BezierClose->setEnabled(setter);
00339               PolySplit->setEnabled(setter);
00340               break;
00341        default:
00342               BezierClose->setEnabled(false);
00343               PolySplit->setEnabled(false);
00344               break;
00345        }
00346 }
00347 
00348 void NodePalette::CloseBezier()
00349 {
00350        if (doc==0)
00351               return;
00352        MoveN();
00353        view->Bezier2Poly();
00354        BezierClose->setEnabled(false);
00355        PolySplit->setEnabled(true);
00356        EditCont->setEnabled(true);
00357 }
00358 
00359 void NodePalette::doRotCCW()
00360 {
00361        if (doc != 0)
00362               view->TransformPoly(0, RotVal->value());
00363 }
00364 
00365 void NodePalette::doRotCW()
00366 {
00367        if (doc != 0)
00368               view->TransformPoly(1, RotVal->value());
00369 }
00370 
00371 void NodePalette::doShrink()
00372 {
00373        if (doc != 0)
00374               view->TransformPoly(2, 1, scalePercentage->value());
00375 }
00376 
00377 void NodePalette::doExpand()
00378 {
00379        if (doc != 0)
00380               view->TransformPoly(3, 1, scalePercentage->value());
00381 }
00382 
00383 void NodePalette::doReduce()
00384 {
00385        if (doc != 0)
00386               view->TransformPoly(8, 1, scaleDistance->value()/unitGetRatioFromIndex(doc->unitIndex()));
00387 }
00388 
00389 void NodePalette::doEnlarge()
00390 {
00391        if (doc != 0)
00392               view->TransformPoly(9, 1, scaleDistance->value()/unitGetRatioFromIndex(doc->unitIndex()));
00393 }
00394 
00395 void NodePalette::ShearR()
00396 {
00397        if (doc != 0)
00398               view->TransformPoly(5);
00399 }
00400 
00401 void NodePalette::ShearL()
00402 {
00403        if (doc != 0)
00404               view->TransformPoly(4);
00405 }
00406 
00407 void NodePalette::ShearU()
00408 {
00409        if (doc != 0)
00410               view->TransformPoly(6);
00411 }
00412 
00413 void NodePalette::ShearD()
00414 {
00415        if (doc != 0)
00416               view->TransformPoly(7);
00417 }
00418 
00419 void NodePalette::MirrorH()
00420 {
00421        if (doc != 0)
00422               doc->MirrorPolyH(doc->m_Selection->itemAt(0));
00423 }
00424 
00425 void NodePalette::MirrorV()
00426 {
00427        if (doc != 0)
00428               doc->MirrorPolyV(doc->m_Selection->itemAt(0));
00429 }
00430 
00431 void NodePalette::ResetControl()
00432 {
00433        if (doc != 0)
00434               view->ResetControl();
00435 }
00436 
00437 void NodePalette::Reset1Control()
00438 {
00439        if (doc != 0)
00440               view->Reset1Control();
00441 }
00442 
00443 void NodePalette::ResetContour()
00444 {
00445        if (doc != 0)
00446        {
00447               if (UndoManager::undoEnabled())
00448               {
00449                      ItemState<FPointArray> *is = new ItemState<FPointArray>(Um::ResetContourLine, "",Um::IBorder);
00450                      is->set("RESET_CONTOUR", "reset_contour");
00451                      //is->setItem(view->SelItem.at(0)->ContourLine);
00452                      is->setItem(doc->m_Selection->itemAt(0)->ContourLine);
00453                      //UndoManager::instance()->action(view->SelItem.at(0), is);
00454                      UndoManager::instance()->action(doc->m_Selection->itemAt(0), is);
00455               }
00456               //view->SelItem.at(0)->ContourLine = view->SelItem.at(0)->PoLine.copy();
00457               //FIXME make an internal item copy poline to contourline member
00458               doc->m_Selection->itemAt(0)->ContourLine = doc->m_Selection->itemAt(0)->PoLine.copy();
00459               //view->SelItem.at(0)->ClipEdited = true;
00460               doc->m_Selection->itemAt(0)->ClipEdited = true;
00461               view->updateContents();
00462        }
00463 }
00464 
00465 void NodePalette::ResetContourToImageClip()
00466 {
00467        if (doc != 0)
00468        {
00469 /*            if (UndoManager::undoEnabled())
00470               {
00471                      ItemState<FPointArray> *is = new ItemState<FPointArray>(Um::ResetContourLine, "",Um::IBorder);
00472                      is->set("RESET_CONTOUR", "reset_contour");
00473                      is->setItem(doc->m_Selection->itemAt(0)->ContourLine);
00474                      UndoManager::instance()->action(doc->m_Selection->itemAt(0), is);
00475               } */
00476               doc->m_Selection->itemAt(0)->ContourLine = doc->m_Selection->itemAt(0)->imageClip.copy();
00477               doc->m_Selection->itemAt(0)->ClipEdited = true;
00478               view->updateContents();
00479        }
00480 }
00481 
00482 void NodePalette::MovePoint()
00483 {
00484        if (doc==0)
00485               return;
00486        if (doc->EditClipMode == 0)
00487        {
00488               FPoint np(XSpin->value()/doc->unitRatio(), YSpin->value()/doc->unitRatio());
00489               FPoint zp(doc->m_Selection->itemAt(0)->xPos(), doc->m_Selection->itemAt(0)->yPos());
00490               if (AbsMode->isChecked())
00491                      np -= zp;
00492               view->MoveClipPoint(doc->m_Selection->itemAt(0), np);
00493               doc->AdjustItemSize(doc->m_Selection->itemAt(0));
00494               emit DocChanged();
00495        }
00496 }
00497 
00498 void NodePalette::SetSym()
00499 {
00500        if (doc != 0)
00501               view->MoveSym = true;
00502        SymMove->setOn(true);
00503        AsymMove->setOn(false);
00504 }
00505 
00506 void NodePalette::SetAsym()
00507 {
00508        if (doc != 0)
00509               view->MoveSym = false;
00510        SymMove->setOn(false);
00511        AsymMove->setOn(true);
00512 }
00513 
00514 void NodePalette::SetXY(double x, double y)
00515 {
00516        if (doc==0)
00517               return;
00518        FPoint zp(0.0, 0.0);
00519        disconnect(XSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00520        disconnect(YSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00521        if (AbsMode->isChecked())
00522               zp = FPoint(doc->m_Selection->itemAt(0)->xPos() - doc->currentPage()->xOffset(), doc->m_Selection->itemAt(0)->yPos() - doc->currentPage()->yOffset());
00523        XSpin->setValue((x + zp.x())*doc->unitRatio());
00524        YSpin->setValue((y + zp.y())*doc->unitRatio());
00525        connect(XSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00526        connect(YSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00527 }
00528 
00529 void NodePalette::ToggleAbsMode()
00530 {
00531        if (doc==0)
00532               return;
00533        FPoint zp(doc->m_Selection->itemAt(0)->xPos() - doc->currentPage()->xOffset(), doc->m_Selection->itemAt(0)->yPos() - doc->currentPage()->yOffset());
00534        disconnect(XSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00535        disconnect(YSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00536        double unitRatio=doc->unitRatio();
00537        FPoint np(XSpin->value()/unitRatio, YSpin->value()/unitRatio);
00538        if (AbsMode->isChecked())
00539               np += zp;
00540        else
00541               np -= zp;
00542        XSpin->setValue(np.x()*unitRatio);
00543        YSpin->setValue(np.y()*unitRatio);
00544        connect(XSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00545        connect(YSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00546 }
00547 
00548 void NodePalette::ToggleConMode()
00549 {
00550        disconnect(XSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00551        disconnect(YSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00552        if (doc != 0)
00553        {
00554               view->EditContour = EditCont->isChecked();
00555               view->updateContents();
00556               if (EditCont->isChecked())
00557               {
00558                      BezierClose->setEnabled(false);
00559                      PolySplit->setEnabled(false);
00560                      ResetCont->setEnabled(true);
00561                      ResetContClip->setEnabled(true);
00562                      XSpin->setMinValue(-3000);
00563                      YSpin->setMinValue(-3000);
00564               }
00565               else
00566               {
00567                      BezierClose->setEnabled(false);
00568                      PolySplit->setEnabled(true);
00569                      ResetCont->setEnabled(false);
00570                      ResetContClip->setEnabled(false);
00571                      XSpin->setMinValue(0);
00572                      YSpin->setMinValue(0);
00573               }
00574        }
00575        connect(XSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00576        connect(YSpin, SIGNAL(valueChanged(int)), this, SLOT(MovePoint()));
00577 }
00578 
00579 void NodePalette::HaveNode(bool have, bool mov)
00580 {
00581        if (doc==0)
00582               return;
00583        bool setter = have ? true : false;
00584        XSpin->setEnabled(setter);
00585        YSpin->setEnabled(setter);
00586        if (setter == true)
00587        {
00588               if (view->EdPoints)
00589                      ResNode->setEnabled(setter);
00590               else
00591                      Res1Node->setEnabled(setter);
00592        }
00593        else
00594        {
00595               ResNode->setEnabled(setter);
00596               Res1Node->setEnabled(setter);
00597        }
00598        if (doc->EditClipMode == 0)
00599        {
00600               disconnect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
00601               disconnect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
00602               if (mov)
00603               {
00604                      SymMove->setOn(true);
00605                      AsymMove->setOn(false);
00606               }
00607               else
00608               {
00609                      AsymMove->setOn(true);
00610                      SymMove->setOn(false);
00611               }
00612               connect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
00613               connect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
00614        }
00615        if (doc->EditClipMode == 2)
00616        {
00617               uint cc;
00618               bool leaveEd = false;
00619               PageItem*currItem=doc->m_Selection->itemAt(0);
00620               if (view->EditContour)
00621                      cc = currItem->ContourLine.size();
00622               else
00623                      cc = currItem->PoLine.size();
00624               if (currItem->asPolyLine())
00625               {
00626                      if (cc < 5)
00627                             leaveEd = true;
00628               }
00629               else
00630               {
00631                      if (cc < 13)
00632                             leaveEd = true;
00633               }
00634               if (leaveEd)
00635               {
00636                      MoveN();
00637                      MoveControl->setEnabled(true);
00638               }
00639        }
00640 }
00641 
00642 void NodePalette::MoveK()
00643 {
00644        if (doc==0)
00645               return;
00646        doc->EditClipMode = 0;
00647        view->EdPoints = false;
00648        PageItem *currItem = doc->m_Selection->itemAt(0);
00649        if (view->EditContour)
00650               view->MarkClip(currItem, currItem->ContourLine, true);
00651        else
00652               view->MarkClip(currItem, currItem->PoLine, true);
00653        SymMove->setEnabled(true);
00654        AsymMove->setEnabled(true);
00655        Res1Node->setEnabled(true);
00656        ResNode->setEnabled(false);
00657        AddNode->setEnabled(false);
00658        DeleteNode->setEnabled(false);
00659        MoveNode->setOn(false);
00660        MoveControl->setOn(true);
00661        DeleteNode->setOn(false);
00662        AddNode->setOn(false);
00663 }
00664 
00665 void NodePalette::MoveN()
00666 {
00667        if (doc==0)
00668               return;
00669        doc->EditClipMode = 0;
00670        view->EdPoints = true;
00671        view->ClRe = -1;
00672        view->ClRe2 = -1;
00673        view->SegP1 = -1;
00674        view->SegP2 = -1;
00675        PageItem *currItem = doc->m_Selection->itemAt(0);
00676        if (view->EditContour)
00677               view->MarkClip(currItem, currItem->ContourLine, true);
00678        else
00679               view->MarkClip(currItem, currItem->PoLine, true);
00680        AddNode->setEnabled(true);
00681        DeleteNode->setEnabled(true);
00682        SymMove->setEnabled(false);
00683        AsymMove->setEnabled(false);
00684        Res1Node->setEnabled(false);
00685        MoveNode->setOn(true);
00686        MoveControl->setOn(false);
00687        DeleteNode->setOn(false);
00688        AddNode->setOn(false);
00689 }
00690 
00691 void NodePalette::AddN()
00692 {
00693        if (doc==0)
00694               return;
00695        doc->EditClipMode = 1;
00696        view->EdPoints = true;
00697        SymMove->setEnabled(false);
00698        AsymMove->setEnabled(false);
00699        ResNode->setEnabled(false);
00700        Res1Node->setEnabled(false);
00701        AddNode->setOn(true);
00702        DeleteNode->setOn(false);
00703 }
00704 
00705 void NodePalette::DelN()
00706 {
00707        if (doc==0)
00708               return;
00709        doc->EditClipMode = 2;
00710        view->EdPoints = true;
00711        SymMove->setEnabled(false);
00712        AsymMove->setEnabled(false);
00713        ResNode->setEnabled(false);
00714        Res1Node->setEnabled(false);
00715        AddNode->setOn(false);
00716        DeleteNode->setOn(true);
00717 }
00718 
00719 void NodePalette::closeEvent(QCloseEvent *ce)
00720 {
00721        if (doc != 0)
00722        {
00723               MoveN();
00724               view->ClRe = -1;
00725               view->ClRe2 = -1;
00726               view->SegP1 = -1;
00727               view->SegP2 = -1;
00728               view->SelNode.clear();
00729        }
00730        PolySplit->setEnabled( false );
00731        BezierClose->setEnabled( false );
00732        emit Schliessen();
00733        ScrPaletteBase::closeEvent(ce);
00734 }
00735 
00736 void NodePalette::EndEdit()
00737 {
00738        if (doc != 0)
00739        {
00740               MoveN();
00741               view->ClRe = -1;
00742               view->ClRe2 = -1;
00743               view->SegP1 = -1;
00744               view->SegP2 = -1;
00745               view->SelNode.clear();
00746               EditCont->setChecked(false);
00747               ToggleConMode();
00748        }
00749        PolySplit->setEnabled( false );
00750        BezierClose->setEnabled( false );
00751        EditCont->setChecked(false);
00752        emit Schliessen();
00753 }
00754 
00755 void NodePalette::languageChange()
00756 {
00757        setCaption( tr( "Nodes" ) );
00758        scalePercentage->setSuffix( tr(" %"));
00759        
00760        AbsMode->setText( tr("&Absolute Coordinates"));
00761        TextLabel1->setText( tr("&X-Pos:"));
00762        TextLabel2->setText( tr("&Y-Pos:"));
00763        EditCont->setText( tr("Edit &Contour Line"));
00764        ResetCont->setText( tr("&Reset Contour Line"));
00765        ResetContClip->setText( tr("Set Contour to Image Clip"));
00766        editEditButton->setText( tr("&End Editing"));
00767        QToolTip::add(MoveNode, tr("Move Nodes"));
00768        QToolTip::add(MoveControl, tr("Move Control Points"));
00769        QToolTip::add(AddNode, tr("Add Nodes"));
00770        QToolTip::add(DeleteNode, tr("Delete Nodes"));
00771        QToolTip::add(AsymMove, tr("Move Control Points Independently"));
00772        QToolTip::add(SymMove, tr("Move Control Points Symmetrical"));
00773        QToolTip::add(ResNode, tr("Reset Control Points"));
00774        QToolTip::add(Res1Node, tr("Reset this Control Point"));
00775        QToolTip::add(PolySplit, tr("Open a Polygon or Cuts a Bezier Curve"));
00776        QToolTip::add(BezierClose, tr("Close this Bezier Curve"));
00777        QToolTip::add(PolyMirrorH, tr("Mirror the Path Horizontally"));
00778        QToolTip::add(PolyMirrorV, tr("Mirror the Path Vertically"));
00779        QToolTip::add(PolyShearR, tr("Shear the Path Horizontally to the Right"));
00780        QToolTip::add(PolyShearL, tr("Shear the Path Horizontally to the Left"));
00781        QToolTip::add(PolyShearU, tr("Shear the Path Vertically Up"));
00782        QToolTip::add(PolyShearD, tr("Shear the Path Vertically Down"));
00783        QToolTip::add(RotateCCW, tr("Rotate the Path Counter-Clockwise"));
00784        QToolTip::add(RotateCW, tr("Rotate the Path Clockwise"));
00785        QToolTip::add(Shrink, tr("Shrink the Size of the Path by shown %"));
00786        QToolTip::add(Expand, tr("Enlarge the Size of the Path by shown %"));
00787        QToolTip::add(Reduce, tr("Reduce the Size of the Path by the shown value"));
00788        QToolTip::add(Enlarge, tr("Enlarge the Size of the Path by the shown value"));
00789        QToolTip::add(RotVal, tr("Angle of Rotation"));
00790        QToolTip::add(scalePercentage, tr("% to Enlarge or Shrink By"));
00791        QToolTip::add(scaleDistance, tr("Value to Enlarge or Shrink By"));
00792        QToolTip::add(EditCont, tr("Activate Contour Line Editing Mode"));
00793        QToolTip::add(ResetCont, tr("Reset the Contour Line to the Original Shape of the Frame"));
00794        QToolTip::add(ResetContClip, tr("Reset the Contour Line to the Clipping Path of the Image"));
00795        QToolTip::add(AbsMode,  "<qt>" + tr("When checked use coordinates relative to the page, otherwise coordinates are relative to the Object.") + "</qt>");
00796 }
00797 
00798 void NodePalette::unitChange()
00799 {
00800        if (doc==0)
00801               return;
00802        double oldRatio = unitRatio;
00803        unitRatio = doc->unitRatio();
00804        double maxVal=30000 * unitRatio;
00805        double minVal=-30000 * unitRatio;
00806        double newScaleDistance = scaleDistance->value() * unitRatio / oldRatio;
00807        scaleDistance->setSuffix( unitGetSuffixFromIndex(doc->unitIndex()) );
00808        int decimals = unitGetDecimalsFromIndex(doc->unitIndex());
00809        scaleDistance->setValues( minVal, maxVal, decimals, newScaleDistance );
00810 }
00811 
00812 ScribusDoc* NodePalette::currentDocument() const
00813 {
00814        return doc;
00815 }