Subversion Repositories Scribus

Rev

Rev 24615 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
10859 cbradney 7
 
8
#include <QEvent>
9
 
10862 cbradney 10
#include "nodeeditpalette.h"
16736 jghali 11
#include "pageitem.h"
16729 fschmid 12
#include "scpage.h"
23474 jghali 13
#include "scribusapp.h"
19093 craig 14
#include "scribusdoc.h"
22909 jghali 15
#include "scribusview.h" 
3934 cbradney 16
#include "selection.h"
1518 tsoots 17
#include "undomanager.h"
18
#include "undostate.h"
10862 cbradney 19
#include "units.h"
20185 craig 20
#include "iconmanager.h"
3 paul 21
 
24027 jghali 22
NodePalette::NodePalette( QWidget* parent) : ScrPaletteBase(parent, "nodePalette", false, Qt::WindowFlags())
3 paul 23
{
9441 fschmid 24
        QSize iconSize = QSize(22, 22);
24621 jghali 25
        QSize buttonSize = QSize(24, 24);
26
        QSize maxButtonSize = QSize(16777215, buttonSize.height());
27
        QSizePolicy::Policy buttonSizePolicy = static_cast<QSizePolicy::Policy>(QSizePolicy::GrowFlag | QSizePolicy::ExpandFlag);
28
 
23474 jghali 29
        m_doc = nullptr;
24615 jghali 30
        m_unitRatio = 1.0;
9041 fschmid 31
        vboxLayout = new QVBoxLayout(this);
24607 craig 32
        vboxLayout->setSpacing(6);
24621 jghali 33
        vboxLayout->setContentsMargins(6, 6, 6, 6);
24607 craig 34
 
9041 fschmid 35
        MoveNode = new QToolButton(this);
9441 fschmid 36
        MoveNode->setIconSize(iconSize);
24607 craig 37
        MoveNode->setMinimumSize(buttonSize);
24621 jghali 38
        MoveNode->setMaximumSize(maxButtonSize);
39
        MoveNode->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 40
        MoveNode->setCheckable(true);
41
        MoveNode->setChecked(true);
3 paul 42
 
9041 fschmid 43
        AddNode = new QToolButton(this);
9441 fschmid 44
        AddNode->setIconSize(iconSize);
24607 craig 45
        AddNode->setMinimumSize(buttonSize);
24621 jghali 46
        AddNode->setMaximumSize(maxButtonSize);
47
        AddNode->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 48
        AddNode->setEnabled(true);
49
        AddNode->setCheckable(true);
3 paul 50
 
9041 fschmid 51
        DeleteNode = new QToolButton(this);
9441 fschmid 52
        DeleteNode->setIconSize(iconSize);
24607 craig 53
        DeleteNode->setMinimumSize(buttonSize);
24621 jghali 54
        DeleteNode->setMaximumSize(maxButtonSize);
55
        DeleteNode->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 56
        DeleteNode->setEnabled(true);
57
        DeleteNode->setCheckable(true);
3 paul 58
 
9041 fschmid 59
        ResNode = new QToolButton(this);
9441 fschmid 60
        ResNode->setIconSize(iconSize);
24607 craig 61
        ResNode->setMinimumSize(buttonSize);
24621 jghali 62
        ResNode->setMaximumSize(maxButtonSize);
63
        ResNode->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 64
        ResNode->setEnabled(true);
3 paul 65
 
9041 fschmid 66
        MoveControl = new QToolButton(this);
9441 fschmid 67
        MoveControl->setIconSize(iconSize);
24607 craig 68
        MoveControl->setMinimumSize(buttonSize);
24621 jghali 69
        MoveControl->setMaximumSize(maxButtonSize);
70
        MoveControl->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 71
        MoveControl->setCheckable(true);
72
 
73
        AsymMove = new QToolButton(this);
9441 fschmid 74
        AsymMove->setIconSize(iconSize);
24607 craig 75
        AsymMove->setMinimumSize(buttonSize);
24621 jghali 76
        AsymMove->setMaximumSize(maxButtonSize);
77
        AsymMove->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 78
        AsymMove->setEnabled(false);
79
        AsymMove->setCheckable(true);
80
 
81
        SymMove = new QToolButton(this);
9441 fschmid 82
        SymMove->setIconSize(iconSize);
24607 craig 83
        SymMove->setMinimumSize(buttonSize);
24621 jghali 84
        SymMove->setMaximumSize(maxButtonSize);
85
        SymMove->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 86
        SymMove->setEnabled(false);
87
        SymMove->setCheckable(true);
88
 
89
        Res1Node = new QToolButton(this);
9441 fschmid 90
        Res1Node->setIconSize(iconSize);
24607 craig 91
        Res1Node->setMinimumSize(buttonSize);
24621 jghali 92
        Res1Node->setMaximumSize(maxButtonSize);
93
        Res1Node->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 94
        Res1Node->setEnabled(false);
95
 
96
        PolySplit = new QToolButton(this);
19606 craig 97
        PolySplit->setEnabled(false);
98
        PolySplit->setCheckable(true);
9441 fschmid 99
        PolySplit->setIconSize(iconSize);
24607 craig 100
        PolySplit->setMinimumSize(buttonSize);
24621 jghali 101
        PolySplit->setMaximumSize(maxButtonSize);
102
        PolySplit->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
9041 fschmid 103
 
104
        BezierClose = new QToolButton(this);
19606 craig 105
        BezierClose->setEnabled(false);
9441 fschmid 106
        BezierClose->setIconSize(iconSize);
24607 craig 107
        BezierClose->setMinimumSize(buttonSize);
24621 jghali 108
        BezierClose->setMaximumSize(maxButtonSize);
109
        BezierClose->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
3 paul 110
 
9041 fschmid 111
        PolyMirrorH = new QToolButton(this);
9441 fschmid 112
        PolyMirrorH->setIconSize(iconSize);
24607 craig 113
        PolyMirrorH->setMinimumSize(buttonSize);
24621 jghali 114
        PolyMirrorH->setMaximumSize(maxButtonSize);
115
        PolyMirrorH->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
3 paul 116
 
9041 fschmid 117
        PolyMirrorV = new QToolButton(this);
9441 fschmid 118
        PolyMirrorV->setIconSize(iconSize);
24607 craig 119
        PolyMirrorV->setMinimumSize(buttonSize);
24621 jghali 120
        PolyMirrorV->setMaximumSize(maxButtonSize);
121
        PolyMirrorV->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
3 paul 122
 
9041 fschmid 123
        PolyShearL = new QToolButton(this);
9441 fschmid 124
        PolyShearL->setIconSize(iconSize);
24607 craig 125
        PolyShearL->setMinimumSize(buttonSize);
24621 jghali 126
        PolyShearL->setMaximumSize(maxButtonSize);
127
        PolyShearL->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
161 Franz 128
        PolyShearL->setAutoRepeat(true);
9041 fschmid 129
 
130
        PolyShearR = new QToolButton(this);
9441 fschmid 131
        PolyShearR->setIconSize(iconSize);
24607 craig 132
        PolyShearR->setMinimumSize(buttonSize);
24621 jghali 133
        PolyShearR->setMaximumSize(maxButtonSize);
134
        PolyShearR->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
161 Franz 135
        PolyShearR->setAutoRepeat(true);
9041 fschmid 136
 
137
        PolyShearU = new QToolButton(this);
9441 fschmid 138
        PolyShearU->setIconSize(iconSize);
24607 craig 139
        PolyShearU->setMinimumSize(buttonSize);
24621 jghali 140
        PolyShearU->setMaximumSize(maxButtonSize);
141
        PolyShearU->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
161 Franz 142
        PolyShearU->setAutoRepeat(true);
9041 fschmid 143
 
144
        PolyShearD = new QToolButton(this);
9441 fschmid 145
        PolyShearD->setIconSize(iconSize);
24607 craig 146
        PolyShearD->setMinimumSize(buttonSize);
24621 jghali 147
        PolyShearD->setMaximumSize(maxButtonSize);
148
        PolyShearD->setSizePolicy(QSizePolicy(buttonSizePolicy, QSizePolicy::Fixed));
161 Franz 149
        PolyShearD->setAutoRepeat(true);
13 Franz 150
 
9041 fschmid 151
        RotateCCW = new QToolButton(this);
9441 fschmid 152
        RotateCCW->setIconSize(iconSize);
24607 craig 153
        RotateCCW->setMinimumSize(buttonSize);
154
        RotateCCW->setMaximumSize(buttonSize);
161 Franz 155
        RotateCCW->setAutoRepeat(true);
9041 fschmid 156
 
157
        RotateCW = new QToolButton(this);
9441 fschmid 158
        RotateCW->setIconSize(iconSize);
24607 craig 159
        RotateCW->setMinimumSize(buttonSize);
160
        RotateCW->setMaximumSize(buttonSize);
161 Franz 161
        RotateCW->setAutoRepeat(true);
9041 fschmid 162
 
10495 cbradney 163
        RotVal = new QSpinBox(this);
10427 cbradney 164
        RotVal->setMinimum(1);
165
        RotVal->setMaximum(180);
9041 fschmid 166
        RotVal->setValue(1);
343 Franz 167
        RotVal->setSuffix( QString::fromUtf8(" °"));
168
 
9041 fschmid 169
        Expand = new QToolButton(this);
9441 fschmid 170
        Expand->setIconSize(iconSize);
24607 craig 171
        Expand->setMinimumSize(buttonSize);
172
        Expand->setMaximumSize(buttonSize);
161 Franz 173
        Expand->setAutoRepeat(true);
9041 fschmid 174
 
175
        Shrink = new QToolButton(this);
9441 fschmid 176
        Shrink->setIconSize(iconSize);
24607 craig 177
        Shrink->setMinimumSize(buttonSize);
178
        Shrink->setMaximumSize(buttonSize);
4619 cbradney 179
        Shrink->setAutoRepeat(true);
9041 fschmid 180
 
10495 cbradney 181
        scalePercentage = new QSpinBox(this);
10427 cbradney 182
        scalePercentage->setMinimum(1);
183
        scalePercentage->setMaximum(100);
9041 fschmid 184
        scalePercentage->setValue(10);
185
 
186
        Enlarge = new QToolButton(this);
9441 fschmid 187
        Enlarge->setIconSize(iconSize);
24607 craig 188
        Enlarge->setMinimumSize(buttonSize);
189
        Enlarge->setMaximumSize(buttonSize);
4619 cbradney 190
        Enlarge->setAutoRepeat(true);
9041 fschmid 191
 
192
        Reduce = new QToolButton(this);
9441 fschmid 193
        Reduce->setIconSize(iconSize);
24607 craig 194
        Reduce->setMinimumSize(buttonSize);
195
        Reduce->setMaximumSize(buttonSize);
4619 cbradney 196
        Reduce->setAutoRepeat(true);
9041 fschmid 197
 
13257 jghali 198
        scaleDistance = new ScrSpinBox( 1, 16777215, this, 0);
24607 craig 199
        scaleDistance->setMaximumSize(114, 16777215); // ScrSpinBox is bigger for 4px than expected
13257 jghali 200
        scaleDistance->setValues(-16777215, 16777215, 2, 30);
132 Franz 201
 
24607 craig 202
        gridLayout = new QGridLayout();
203
        gridLayout->setSpacing(6);
204
        gridLayout->setContentsMargins(0, 0, 0, 0);
24609 craig 205
        gridLayout->addWidget(MoveNode,        0, 1, 1, 1);
206
        gridLayout->addWidget(AddNode,         0, 2, 1, 1);
207
        gridLayout->addWidget(DeleteNode,      0, 3, 1, 1);
24611 craig 208
        gridLayout->addWidget(ResNode,         0, 4, 1, 1);
209
        gridLayout->addWidget(MoveControl,     1, 1, 1, 1);
210
        gridLayout->addWidget(AsymMove,        1, 2, 1, 1);
211
        gridLayout->addWidget(SymMove,         1, 3, 1, 1);
24609 craig 212
        gridLayout->addWidget(Res1Node,        1, 4, 1, 1);
213
        gridLayout->addWidget(PolySplit,       2, 1, 1, 1);
214
        gridLayout->addWidget(BezierClose,     2, 2, 1, 1);
215
        gridLayout->addWidget(PolyMirrorH,     2, 3, 1, 1);
216
        gridLayout->addWidget(PolyMirrorV,     2, 4, 1, 1);
217
        gridLayout->addWidget(PolyShearL,      3, 1, 1, 1);
218
        gridLayout->addWidget(PolyShearR,      3, 2, 1, 1);
219
        gridLayout->addWidget(PolyShearU,      3, 3, 1, 1);
220
        gridLayout->addWidget(PolyShearD,      3, 4, 1, 1);
24607 craig 221
        vboxLayout->addLayout(gridLayout);
222
 
9041 fschmid 223
        gridLayout2 = new QGridLayout();
24607 craig 224
        gridLayout2->setSpacing(6);
24545 craig 225
        gridLayout2->setContentsMargins(0, 0, 0, 0);
24611 craig 226
        gridLayout2->addWidget(RotVal,          0, 0, 1, 4);
227
        gridLayout2->addWidget(RotateCCW,       0, 4, 1, 1);
228
        gridLayout2->addWidget(RotateCW,        0, 5, 1, 1);
229
        gridLayout2->addWidget(scalePercentage, 1, 0, 1, 4);
230
        gridLayout2->addWidget(Expand,          1, 4, 1, 1);
231
        gridLayout2->addWidget(Shrink,          1, 5, 1, 1);
232
        gridLayout2->addWidget(scaleDistance,   2, 0, 1, 4);
233
        gridLayout2->addWidget(Enlarge,         2, 4, 1, 1);
234
        gridLayout2->addWidget(Reduce,          2, 5, 1, 1);
235
        vboxLayout->addLayout(gridLayout2);
13 Franz 236
 
24607 craig 237
        QSpacerItem* spacer = new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed );
11145 fschmid 238
        vboxLayout->addItem(spacer);
21262 fschmid 239
 
11145 fschmid 240
        AbsMode = new QGroupBox( "&Absolute Coordinates", this );
241
        AbsMode->setCheckable(true);
161 Franz 242
        AbsMode->setChecked(false);
11145 fschmid 243
        vboxLayout1 = new QVBoxLayout(AbsMode);
24607 craig 244
        vboxLayout1->setSpacing(6);
245
        vboxLayout1->setContentsMargins(9, 9, 9, 9);
11145 fschmid 246
        absToCanvas = new QRadioButton( tr("to Canvas"), AbsMode);
247
        vboxLayout1->addWidget(absToCanvas);
248
        absToPage = new QRadioButton( tr("to Page"), AbsMode);
249
        vboxLayout1->addWidget(absToPage);
250
        absToCanvas->setChecked(true);
24607 craig 251
        vboxLayout->addWidget(AbsMode);
97 Franz 252
 
24611 craig 253
        gridLayout3 = new QGridLayout();
254
        gridLayout3->setSpacing(6);
255
        gridLayout3->setContentsMargins(0, 0, 0, 0);
256
        gridLayout3->setColumnStretch(0, 0);
257
        gridLayout3->setColumnStretch(1, 1);
24607 craig 258
 
9041 fschmid 259
        TextLabel1 = new QLabel(this);
24611 craig 260
        gridLayout3->addWidget(TextLabel1, 0, 0, 1, 1);
9041 fschmid 261
 
11724 fschmid 262
        XSpin = new ScrSpinBox( 0, 16777215, this, 2 );
24607 craig 263
        XSpin->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed));
360 Franz 264
        XSpin->setEnabled(false);
24611 craig 265
        gridLayout3->addWidget(XSpin, 0, 1, 1, 1);
9041 fschmid 266
 
267
        TextLabel2 = new QLabel(this);
24611 craig 268
        gridLayout3->addWidget(TextLabel2, 1, 0, 1, 1);
9041 fschmid 269
 
11724 fschmid 270
        YSpin = new ScrSpinBox( 0, 16777215, this, 2 );
24607 craig 271
        YSpin->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed));
161 Franz 272
        YSpin->setEnabled(false);
24611 craig 273
        gridLayout3->addWidget(YSpin, 1, 1, 1, 1);
274
        vboxLayout->addLayout(gridLayout3);
24607 craig 275
 
9041 fschmid 276
        TextLabel1->setBuddy(XSpin);
277
        TextLabel2->setBuddy(YSpin);
3 paul 278
 
9041 fschmid 279
        EditCont = new QCheckBox(this);
340 Franz 280
        EditCont->setChecked(false);
24607 craig 281
        vboxLayout->addWidget(EditCont);
340 Franz 282
 
21291 fschmid 283
        PreviewMode = new QCheckBox(this);
284
        PreviewMode->setChecked(false);
24607 craig 285
        vboxLayout->addWidget(PreviewMode);
21291 fschmid 286
 
9041 fschmid 287
        ResetCont = new QPushButton(this);
288
        ResetCont->setEnabled(false);
24607 craig 289
        vboxLayout->addWidget(ResetCont);
343 Franz 290
 
9041 fschmid 291
        ResetContClip = new QPushButton(this);
292
        ResetContClip->setEnabled(true);
9441 fschmid 293
        ResetContClip->hide();
24607 craig 294
        vboxLayout->addWidget(ResetContClip);
9041 fschmid 295
 
12681 fschmid 296
        ResetShape2Clip = new QPushButton(this);
297
        ResetShape2Clip->setEnabled(true);
298
        ResetShape2Clip->hide();
24607 craig 299
        vboxLayout->addWidget(ResetShape2Clip);
12681 fschmid 300
 
18040 fschmid 301
        resetDefaultButton = new QPushButton(this);
302
        resetDefaultButton->setEnabled(true);
24607 craig 303
        vboxLayout->addWidget(resetDefaultButton);
18040 fschmid 304
 
24611 craig 305
        hboxLayout = new QHBoxLayout();
24607 craig 306
        hboxLayout->setSpacing(6);
307
        hboxLayout->setContentsMargins(0, 0, 0, 0);
23054 craig 308
        editEditButton = new QPushButton(IconManager::instance().loadIcon("22/exit.png"), tr("OK"), this);
18040 fschmid 309
        editEditButton->setEnabled(true);
4866 cbradney 310
        editEditButton->setDefault(true);
24607 craig 311
        hboxLayout->addWidget(editEditButton);
18040 fschmid 312
        cancelEditButton = new QPushButton( tr("Cancel"), this);
313
        cancelEditButton->setEnabled(true);
24607 craig 314
        hboxLayout->addWidget(cancelEditButton);
315
        vboxLayout->addLayout(hboxLayout);
18040 fschmid 316
 
9441 fschmid 317
        resize(QSize(170, 380).expandedTo(minimumSizeHint()));
24609 craig 318
        layout()->setSizeConstraint(QLayout::SetFixedSize);
24607 craig 319
        iconSetChange();
2210 cbradney 320
        languageChange();
23474 jghali 321
 
322
        connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange()));
6531 cbradney 323
}
324
 
325
void NodePalette::connectSignals()
326
{
218 Franz 327
        // signals and slots connections
4866 cbradney 328
        connect(editEditButton, SIGNAL(clicked()), this, SLOT(EndEdit()));
18040 fschmid 329
        connect(cancelEditButton, SIGNAL(clicked()), this, SLOT(CancelEdit()));
330
        connect(resetDefaultButton, SIGNAL(clicked()), this, SLOT(ResetToEditDefaults()));
218 Franz 331
        connect(DeleteNode, SIGNAL(clicked()), this, SLOT(DelN()));
332
        connect(AddNode, SIGNAL(clicked()), this, SLOT(AddN()));
333
        connect(MoveNode, SIGNAL(clicked()), this, SLOT(MoveN()));
334
        connect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
335
        connect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
336
        connect(ResNode, SIGNAL(clicked()), this, SLOT(ResetControl()));
337
        connect(Res1Node, SIGNAL(clicked()), this, SLOT(Reset1Control()));
338
        connect(BezierClose, SIGNAL(clicked()), this, SLOT(CloseBezier()));
339
        connect(PolySplit, SIGNAL(clicked()), this, SLOT(SplitPoly()));
340
        connect(MoveControl, SIGNAL(clicked()), this, SLOT(MoveK()));
8713 fschmid 341
        connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
342
        connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
218 Franz 343
        connect(PolyMirrorH, SIGNAL(clicked()), this, SLOT(MirrorH()));
344
        connect(PolyMirrorV, SIGNAL(clicked()), this, SLOT(MirrorV()));
21309 jghali 345
        connect(PolyShearR, SIGNAL(clicked()), this, SLOT(ShearR()));
346
        connect(PolyShearL, SIGNAL(clicked()), this, SLOT(ShearL()));
218 Franz 347
        connect(PolyShearU, SIGNAL(clicked()), this, SLOT(ShearU()));
348
        connect(PolyShearD, SIGNAL(clicked()), this, SLOT(ShearD()));
349
        connect(RotateCCW, SIGNAL(clicked()), this, SLOT(doRotCCW()));
350
        connect(RotateCW, SIGNAL(clicked()), this, SLOT(doRotCW()));
4619 cbradney 351
        connect(Shrink, SIGNAL(clicked()), this, SLOT(doShrink()));
218 Franz 352
        connect(Expand, SIGNAL(clicked()), this, SLOT(doExpand()));
4619 cbradney 353
        connect(Reduce, SIGNAL(clicked()), this, SLOT(doReduce()));
9041 fschmid 354
        connect(Enlarge, SIGNAL(clicked()), this, SLOT(doEnlarge()));
161 Franz 355
        connect(AbsMode, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
11145 fschmid 356
        connect(absToCanvas, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
357
        connect(absToPage, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
340 Franz 358
        connect(EditCont, SIGNAL(clicked()), this, SLOT(ToggleConMode()));
343 Franz 359
        connect(ResetCont, SIGNAL(clicked()), this, SLOT(ResetContour()));
8445 fschmid 360
        connect(ResetContClip, SIGNAL(clicked()), this, SLOT(ResetContourToImageClip()));
12681 fschmid 361
        connect(ResetShape2Clip, SIGNAL(clicked()), this, SLOT(ResetShapeToImageClip()));
21262 fschmid 362
        connect(PreviewMode, SIGNAL(clicked()), this, SLOT(TogglePreview()));
3 paul 363
}
364
 
6531 cbradney 365
void NodePalette::disconnectSignals()
366
{
367
        // signals and slots disconnetions
368
        disconnect(editEditButton, SIGNAL(clicked()), this, SLOT(EndEdit()));
18040 fschmid 369
        disconnect(cancelEditButton, SIGNAL(clicked()), this, SLOT(CancelEdit()));
370
        disconnect(resetDefaultButton, SIGNAL(clicked()), this, SLOT(ResetToEditDefaults()));
6531 cbradney 371
        disconnect(DeleteNode, SIGNAL(clicked()), this, SLOT(DelN()));
372
        disconnect(AddNode, SIGNAL(clicked()), this, SLOT(AddN()));
373
        disconnect(MoveNode, SIGNAL(clicked()), this, SLOT(MoveN()));
374
        disconnect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
375
        disconnect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
376
        disconnect(ResNode, SIGNAL(clicked()), this, SLOT(ResetControl()));
377
        disconnect(Res1Node, SIGNAL(clicked()), this, SLOT(Reset1Control()));
378
        disconnect(BezierClose, SIGNAL(clicked()), this, SLOT(CloseBezier()));
379
        disconnect(PolySplit, SIGNAL(clicked()), this, SLOT(SplitPoly()));
380
        disconnect(MoveControl, SIGNAL(clicked()), this, SLOT(MoveK()));
8713 fschmid 381
        disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
382
        disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
6531 cbradney 383
        disconnect(PolyMirrorH, SIGNAL(clicked()), this, SLOT(MirrorH()));
384
        disconnect(PolyMirrorV, SIGNAL(clicked()), this, SLOT(MirrorV()));
385
        disconnect(PolyShearR, SIGNAL(clicked()), this, SLOT(ShearR()));
386
        disconnect(PolyShearL, SIGNAL(clicked()), this, SLOT(ShearL()));
387
        disconnect(PolyShearU, SIGNAL(clicked()), this, SLOT(ShearU()));
388
        disconnect(PolyShearD, SIGNAL(clicked()), this, SLOT(ShearD()));
389
        disconnect(RotateCCW, SIGNAL(clicked()), this, SLOT(doRotCCW()));
390
        disconnect(RotateCW, SIGNAL(clicked()), this, SLOT(doRotCW()));
391
        disconnect(Shrink, SIGNAL(clicked()), this, SLOT(doShrink()));
392
        disconnect(Expand, SIGNAL(clicked()), this, SLOT(doExpand()));
393
        disconnect(Reduce, SIGNAL(clicked()), this, SLOT(doReduce()));
9041 fschmid 394
        disconnect(Enlarge, SIGNAL(clicked()), this, SLOT(doEnlarge()));
6531 cbradney 395
        disconnect(ResetCont, SIGNAL(clicked()), this, SLOT(ResetContour()));
8445 fschmid 396
        disconnect(ResetContClip, SIGNAL(clicked()), this, SLOT(ResetContourToImageClip()));
12681 fschmid 397
        disconnect(ResetShape2Clip, SIGNAL(clicked()), this, SLOT(ResetShapeToImageClip()));
21262 fschmid 398
        disconnect(PreviewMode, SIGNAL(clicked()), this, SLOT(TogglePreview()));
6531 cbradney 399
}
400
 
456 fschmid 401
void NodePalette::setDoc(ScribusDoc *dc, ScribusView *vi)
3 paul 402
{
18330 jghali 403
        m_doc = dc;
404
        m_view = vi;
6531 cbradney 405
 
4619 cbradney 406
        unitChange();
341 Franz 407
        disconnect(EditCont, SIGNAL(clicked()), this, SLOT(ToggleConMode()));
97 Franz 408
        disconnect(AbsMode, SIGNAL(clicked()), this, SLOT(ToggleAbsMode()));
22603 craig 409
        if (m_doc!=nullptr)
6531 cbradney 410
        {
18330 jghali 411
                YSpin->setNewUnit(m_doc->unitIndex());
412
                XSpin->setNewUnit(m_doc->unitIndex());
6531 cbradney 413
        }
97 Franz 414
        AbsMode->setChecked(false);
341 Franz 415
        EditCont->setChecked(false);
22790 jghali 416
        if (m_doc == nullptr)
6531 cbradney 417
                disconnectSignals();
418
        else
419
                connectSignals();
3 paul 420
}
421
 
422
void NodePalette::SplitPoly()
423
{
22790 jghali 424
        if (m_doc == nullptr)
6531 cbradney 425
                return;
3 paul 426
        MoveN();
19946 craig 427
        m_doc->nodeEdit.setSubMode(NodeEditContext::SPLIT_PATH);
9041 fschmid 428
        PolySplit->setChecked(true);
3 paul 429
}
430
 
431
void NodePalette::IsOpen()
432
{
22790 jghali 433
        if (m_doc == nullptr)
6531 cbradney 434
                return;
9041 fschmid 435
        PolySplit->setChecked(false);
3 paul 436
        BezierClose->setEnabled(true);
437
        PolySplit->setEnabled(true);
340 Franz 438
        EditCont->setEnabled(false);
3 paul 439
}
440
 
441
void NodePalette::PolyStatus(int typ, uint size)
442
{
22790 jghali 443
        if (m_doc == nullptr)
6531 cbradney 444
                return;
80 Franz 445
        bool setter;
3 paul 446
        switch (typ)
161 Franz 447
        {
16105 fschmid 448
                case PageItem::Polygon:
449
                        PolySplit->setEnabled(true);
450
                        BezierClose->setEnabled(false);
451
                        break;
452
                case PageItem::PolyLine:
22639 craig 453
                        setter = size > 7;
16105 fschmid 454
                        BezierClose->setEnabled(setter);
455
                        PolySplit->setEnabled(setter);
456
                        break;
457
                default:
458
                        BezierClose->setEnabled(false);
459
                        PolySplit->setEnabled(false);
460
                        break;
161 Franz 461
        }
3 paul 462
}
463
 
464
void NodePalette::CloseBezier()
465
{
22790 jghali 466
        if (m_doc == nullptr)
6531 cbradney 467
                return;
3 paul 468
        MoveN();
18330 jghali 469
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
470
        PageItem* newItem = m_doc->convertItemTo(currItem, PageItem::Polygon);
471
        m_doc->m_Selection->clear();
472
        m_doc->m_Selection->addItem(newItem);
11089 fschmid 473
        newItem->update();
3 paul 474
        BezierClose->setEnabled(false);
475
        PolySplit->setEnabled(true);
340 Franz 476
        EditCont->setEnabled(true);
3 paul 477
}
478
 
132 Franz 479
void NodePalette::doRotCCW()
480
{
22790 jghali 481
        if (m_doc == nullptr)
482
                return;
483
        m_view->TransformPoly(0, RotVal->value());
132 Franz 484
}
485
 
486
void NodePalette::doRotCW()
487
{
22790 jghali 488
        if (m_doc == nullptr)
489
                return;
490
        m_view->TransformPoly(1, RotVal->value());
132 Franz 491
}
492
 
4619 cbradney 493
void NodePalette::doShrink()
132 Franz 494
{
22790 jghali 495
        if (m_doc == nullptr)
496
                return;
497
        m_view->TransformPoly(2, 1, scalePercentage->value());
132 Franz 498
}
499
 
500
void NodePalette::doExpand()
501
{
22790 jghali 502
        if (m_doc == nullptr)
503
                return;
504
        m_view->TransformPoly(3, 1, scalePercentage->value());
132 Franz 505
}
506
 
4619 cbradney 507
void NodePalette::doReduce()
508
{
22790 jghali 509
        if (m_doc == nullptr)
510
                return;
511
        m_view->TransformPoly(8, 1, value2pts(scaleDistance->value(),m_doc->unitIndex()));
4619 cbradney 512
}
513
 
514
void NodePalette::doEnlarge()
515
{
22790 jghali 516
        if (m_doc == nullptr)
517
                return;
518
        m_view->TransformPoly(9, 1, value2pts(scaleDistance->value(),m_doc->unitIndex()));
4619 cbradney 519
}
520
 
13 Franz 521
void NodePalette::ShearR()
522
{
22790 jghali 523
        if (m_doc == nullptr)
524
                return;
525
        m_view->TransformPoly(4);
13 Franz 526
}
527
 
528
void NodePalette::ShearL()
529
{
22790 jghali 530
        if (m_doc == nullptr)
531
                return;
532
        m_view->TransformPoly(5);
13 Franz 533
}
534
 
535
void NodePalette::ShearU()
536
{
22790 jghali 537
        if (m_doc == nullptr)
538
                return;
539
        m_view->TransformPoly(6);
13 Franz 540
}
541
 
542
void NodePalette::ShearD()
543
{
22790 jghali 544
        if (m_doc == nullptr)
545
                return;
546
        m_view->TransformPoly(7);
13 Franz 547
}
548
 
3 paul 549
void NodePalette::MirrorH()
550
{
22790 jghali 551
        if (m_doc == nullptr)
552
                return;
553
        m_doc->MirrorPolyH(m_doc->m_Selection->itemAt(0));
3 paul 554
}
555
 
556
void NodePalette::MirrorV()
557
{
22790 jghali 558
        if (m_doc == nullptr)
559
                return;
560
        m_doc->MirrorPolyV(m_doc->m_Selection->itemAt(0));
3 paul 561
}
562
 
563
void NodePalette::ResetControl()
564
{
22790 jghali 565
        if (m_doc == nullptr)
566
                return;
567
        m_doc->nodeEdit.resetControl(m_doc->m_Selection->itemAt(0));
3 paul 568
}
569
 
570
void NodePalette::Reset1Control()
571
{
22790 jghali 572
        if (m_doc == nullptr)
573
                return;
574
        m_doc->nodeEdit.reset1Control(m_doc->m_Selection->itemAt(0));
3 paul 575
}
576
 
343 Franz 577
void NodePalette::ResetContour()
578
{
22790 jghali 579
        if (m_doc == nullptr)
580
                return;
581
 
582
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
583
        if (UndoManager::undoEnabled())
343 Franz 584
        {
22790 jghali 585
                ScItemState<FPointArray> *is = new ScItemState<FPointArray>(Um::ResetContourLine, "",Um::IBorder);
586
                is->set("RESET_CONTOUR");
587
                is->setItem(m_doc->m_Selection->itemAt(0)->ContourLine);
588
                UndoManager::instance()->action(currItem, is);
343 Franz 589
        }
22790 jghali 590
        //FIXME make an internal item copy poline to contourline member
591
        currItem->ContourLine = currItem->PoLine.copy();
592
        currItem->ClipEdited = true;
593
        m_doc->regionsChanged()->update(QRectF());
594
        emit DocChanged();
343 Franz 595
}
596
 
8445 fschmid 597
void NodePalette::ResetContourToImageClip()
598
{
22790 jghali 599
        if (m_doc == nullptr)
600
                return;
601
 
602
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
603
        currItem->ContourLine = currItem->imageClip.copy();
604
        currItem->ClipEdited = true;
605
        m_doc->regionsChanged()->update(QRectF());
606
        emit DocChanged();
8445 fschmid 607
}
608
 
12681 fschmid 609
void NodePalette::ResetShapeToImageClip()
610
{
22790 jghali 611
        if (m_doc == nullptr)
612
                return;
613
 
614
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
615
        currItem->PoLine = currItem->imageClip.copy();
616
        currItem->ClipEdited = true;
617
        currItem->FrameType = 3;
618
        m_doc->adjustItemSize(currItem);
619
        if (currItem->itemType() == PageItem::PathText)
620
                currItem->updatePolyClip();
621
        m_doc->regionsChanged()->update(QRectF());
622
        emit DocChanged();
12681 fschmid 623
}
624
 
3 paul 625
void NodePalette::MovePoint()
626
{
22790 jghali 627
        if (m_doc == nullptr)
6531 cbradney 628
                return;
19946 craig 629
        if (m_doc->nodeEdit.submode() == NodeEditContext::MOVE_POINT)
161 Franz 630
        {
18330 jghali 631
                PageItem *currItem = m_doc->m_Selection->itemAt(0);
11145 fschmid 632
                FPoint zp;
24615 jghali 633
                FPoint np(XSpin->value() / m_doc->unitRatio(), YSpin->value() / m_doc->unitRatio());
97 Franz 634
                if (AbsMode->isChecked())
11145 fschmid 635
                {
636
                        if (absToCanvas->isChecked())
12681 fschmid 637
                                zp = FPoint(currItem->xPos(), currItem->yPos());
11145 fschmid 638
                        else
18330 jghali 639
                                zp = FPoint(currItem->xPos() - m_doc->currentPage()->xOffset(), currItem->yPos() - m_doc->currentPage()->yOffset());
97 Franz 640
                        np -= zp;
11145 fschmid 641
                }
18330 jghali 642
                m_doc->nodeEdit.moveClipPoint(currItem, np);
23277 jghali 643
                m_doc->adjustItemSize(currItem, true);
17260 fschmid 644
                if (currItem->itemType() == PageItem::PathText)
645
                        currItem->updatePolyClip();
18330 jghali 646
                m_doc->regionsChanged()->update(QRectF());
4078 fschmid 647
                emit DocChanged();
161 Franz 648
        }
3 paul 649
}
650
 
651
void NodePalette::SetSym()
652
{
22603 craig 653
        if (m_doc != nullptr)
19946 craig 654
                m_doc->nodeEdit.setMoveSym(true);
9041 fschmid 655
        SymMove->setChecked(true);
656
        AsymMove->setChecked(false);
19606 craig 657
        PolySplit->setChecked(false);
3 paul 658
}
659
 
660
void NodePalette::SetAsym()
661
{
22603 craig 662
        if (m_doc != nullptr)
19946 craig 663
                m_doc->nodeEdit.setMoveSym(false);
9041 fschmid 664
        SymMove->setChecked(false);
665
        AsymMove->setChecked(true);
19606 craig 666
        PolySplit->setChecked(false);
3 paul 667
}
668
 
80 Franz 669
void NodePalette::SetXY(double x, double y)
3 paul 670
{
22790 jghali 671
        if (m_doc == nullptr)
6531 cbradney 672
                return;
3934 cbradney 673
        FPoint zp(0.0, 0.0);
8713 fschmid 674
        disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
675
        disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
97 Franz 676
        if (AbsMode->isChecked())
11145 fschmid 677
        {
678
                if (absToCanvas->isChecked())
18330 jghali 679
                        zp = FPoint(m_doc->m_Selection->itemAt(0)->xPos(), m_doc->m_Selection->itemAt(0)->yPos());
11145 fschmid 680
                else
18330 jghali 681
                        zp = FPoint(m_doc->m_Selection->itemAt(0)->xPos() - m_doc->currentPage()->xOffset(), m_doc->m_Selection->itemAt(0)->yPos() - m_doc->currentPage()->yOffset());
11145 fschmid 682
        }
18330 jghali 683
        XSpin->setValue((x + zp.x()) * m_doc->unitRatio());
684
        YSpin->setValue((y + zp.y()) * m_doc->unitRatio());
8713 fschmid 685
        connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
686
        connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
3 paul 687
}
688
 
97 Franz 689
void NodePalette::ToggleAbsMode()
690
{
22603 craig 691
        if (m_doc == nullptr)
6531 cbradney 692
                return;
11145 fschmid 693
        FPoint zp(0.0, 0.0);
8713 fschmid 694
        disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
695
        disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
11145 fschmid 696
        FPointArray Clip;
11151 fschmid 697
        FPoint np(0.0, 0.0);
11145 fschmid 698
        if (EditCont->isChecked())
18330 jghali 699
                Clip = m_doc->m_Selection->itemAt(0)->ContourLine;
11145 fschmid 700
        else
18330 jghali 701
                Clip = m_doc->m_Selection->itemAt(0)->PoLine;
22909 jghali 702
        if (m_doc->nodeEdit.selectionCount() != 0)
19946 craig 703
                np = Clip.point(m_doc->nodeEdit.selNode().at(0));
97 Franz 704
        if (AbsMode->isChecked())
11145 fschmid 705
        {
11724 fschmid 706
                XSpin->setMinimum(-16777215);
707
                YSpin->setMinimum(-16777215);
11145 fschmid 708
                if (absToCanvas->isChecked())
18330 jghali 709
                        zp = FPoint(m_doc->m_Selection->itemAt(0)->xPos(), m_doc->m_Selection->itemAt(0)->yPos());
11145 fschmid 710
                else
18330 jghali 711
                        zp = FPoint(m_doc->m_Selection->itemAt(0)->xPos() - m_doc->currentPage()->xOffset(), m_doc->m_Selection->itemAt(0)->yPos() - m_doc->currentPage()->yOffset());
11145 fschmid 712
        }
97 Franz 713
        else
11145 fschmid 714
        {
715
                XSpin->setMinimum(0);
716
                YSpin->setMinimum(0);
717
        }
18330 jghali 718
        XSpin->setValue((np.x() + zp.x()) * m_doc->unitRatio());
719
        YSpin->setValue((np.y() + zp.y()) * m_doc->unitRatio());
8713 fschmid 720
        connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
721
        connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
97 Franz 722
}
723
 
340 Franz 724
void NodePalette::ToggleConMode()
725
{
22790 jghali 726
        if (m_doc == nullptr)
727
                return;
728
 
8713 fschmid 729
        disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
730
        disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
22790 jghali 731
 
732
        m_doc->nodeEdit.setIsContourLine(EditCont->isChecked());
733
        m_doc->nodeEdit.setSubMode(NodeEditContext::MOVE_POINT);
734
        m_doc->nodeEdit.setClre(-1);
735
        m_doc->nodeEdit.setClre2(-1);
736
        m_doc->nodeEdit.setSegP1(-1);
737
        m_doc->nodeEdit.setSegP2(-1);
738
        if (EditCont->isChecked())
340 Franz 739
        {
22790 jghali 740
                BezierClose->setEnabled(false);
741
                PolySplit->setEnabled(false);
742
                ResetCont->setEnabled(true);
743
                ResetContClip->setEnabled(true);
744
                XSpin->setMinimum(-16777215);
745
                YSpin->setMinimum(-16777215);
746
        }
747
        else
748
        {
749
                BezierClose->setEnabled(false);
750
                PolySplit->setEnabled(true);
751
                ResetCont->setEnabled(false);
752
                ResetContClip->setEnabled(false);
753
                if (AbsMode->isChecked())
340 Franz 754
                {
11724 fschmid 755
                        XSpin->setMinimum(-16777215);
756
                        YSpin->setMinimum(-16777215);
340 Franz 757
                }
758
                else
759
                {
22790 jghali 760
                        XSpin->setMinimum(0);
761
                        YSpin->setMinimum(0);
340 Franz 762
                }
763
        }
22790 jghali 764
        m_view->DrawNew();
765
 
8713 fschmid 766
        connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
767
        connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
340 Franz 768
}
769
 
21262 fschmid 770
void NodePalette::TogglePreview()
771
{
22790 jghali 772
        if (m_doc == nullptr)
773
                return;
774
        m_doc->nodeEdit.setPreviewMode(PreviewMode->isChecked());
775
        m_doc->regionsChanged()->update(QRectF());
21262 fschmid 776
}
777
 
3 paul 778
void NodePalette::HaveNode(bool have, bool mov)
779
{
22790 jghali 780
        if (m_doc == nullptr)
6531 cbradney 781
                return;
22639 craig 782
        bool setter = have;
22909 jghali 783
        if (m_doc->nodeEdit.selectionCount() > 1)
12584 fschmid 784
        {
785
                XSpin->setEnabled(false);
786
                YSpin->setEnabled(false);
787
        }
788
        else
789
        {
790
                XSpin->setEnabled(setter);
791
                YSpin->setEnabled(setter);
792
        }
22639 craig 793
        if (setter)
80 Franz 794
        {
19946 craig 795
                if (m_doc->nodeEdit.edPoints())
218 Franz 796
                        ResNode->setEnabled(setter);
3 paul 797
                else
218 Franz 798
                        Res1Node->setEnabled(setter);
80 Franz 799
        }
3 paul 800
        else
80 Franz 801
        {
218 Franz 802
                ResNode->setEnabled(setter);
803
                Res1Node->setEnabled(setter);
80 Franz 804
        }
19946 craig 805
        if (m_doc->nodeEdit.submode() == NodeEditContext::MOVE_POINT)
3586 fschmid 806
        {
807
                disconnect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
808
                disconnect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
809
                if (mov)
9041 fschmid 810
                {
811
                        SymMove->setChecked(true);
812
                        AsymMove->setChecked(false);
813
                }
3586 fschmid 814
                else
9041 fschmid 815
                {
816
                        AsymMove->setChecked(true);
817
                        SymMove->setChecked(false);
818
                }
3586 fschmid 819
                connect(AsymMove, SIGNAL(clicked()), this, SLOT(SetAsym()));
820
                connect(SymMove, SIGNAL(clicked()), this, SLOT(SetSym()));
821
        }
19946 craig 822
        if (m_doc->nodeEdit.submode() == NodeEditContext::DEL_POINT)
3586 fschmid 823
        {
824
                uint cc;
825
                bool leaveEd = false;
18330 jghali 826
                PageItem*currItem=m_doc->m_Selection->itemAt(0);
19946 craig 827
                if (m_doc->nodeEdit.isContourLine())
3934 cbradney 828
                        cc = currItem->ContourLine.size();
3586 fschmid 829
                else
3934 cbradney 830
                        cc = currItem->PoLine.size();
23794 craig 831
                if (currItem->isPolyLine())
3586 fschmid 832
                {
833
                        if (cc < 5)
834
                                leaveEd = true;
835
                }
836
                else
837
                {
838
                        if (cc < 13)
839
                                leaveEd = true;
840
                }
841
                if (leaveEd)
842
                {
843
                        MoveN();
844
                        MoveControl->setEnabled(true);
845
                }
846
        }
3 paul 847
}
848
 
849
void NodePalette::MoveK()
850
{
22790 jghali 851
        if (m_doc == nullptr)
6531 cbradney 852
                return;
19946 craig 853
        m_doc->nodeEdit.setSubMode(NodeEditContext::MOVE_POINT);
854
        m_doc->nodeEdit.setEdPoints(false);
855
        m_doc->nodeEdit.setClre(-1);
856
        m_doc->nodeEdit.setClre2(-1);
857
        m_doc->nodeEdit.setSegP1(-1);
858
        m_doc->nodeEdit.setSegP2(-1);
18330 jghali 859
        if (m_doc->m_Selection->count() > 0)
860
                m_doc->m_Selection->itemAt(0)->update();
161 Franz 861
        SymMove->setEnabled(true);
862
        AsymMove->setEnabled(true);
18844 jghali 863
        Res1Node->setEnabled(false);
161 Franz 864
        ResNode->setEnabled(false);
9041 fschmid 865
        AddNode->setEnabled(false);
866
        DeleteNode->setEnabled(false);
867
        MoveNode->setChecked(false);
868
        MoveControl->setChecked(true);
869
        DeleteNode->setChecked(false);
870
        AddNode->setChecked(false);
19606 craig 871
        PolySplit->setChecked(false);
3 paul 872
}
873
 
874
void NodePalette::MoveN()
875
{
22790 jghali 876
        if (m_doc == nullptr)
6531 cbradney 877
                return;
19946 craig 878
        m_doc->nodeEdit.setSubMode(NodeEditContext::MOVE_POINT);
879
        m_doc->nodeEdit.setEdPoints(true);
880
        m_doc->nodeEdit.setClre(-1);
881
        m_doc->nodeEdit.setClre2(-1);
882
        m_doc->nodeEdit.setSegP1(-1);
883
        m_doc->nodeEdit.setSegP2(-1);
18330 jghali 884
        if (m_doc->m_Selection->count() > 0)
885
                m_doc->m_Selection->itemAt(0)->update();
18847 jghali 886
        ResNode->setEnabled(false);
9041 fschmid 887
        AddNode->setEnabled(true);
888
        DeleteNode->setEnabled(true);
161 Franz 889
        SymMove->setEnabled(false);
890
        AsymMove->setEnabled(false);
891
        Res1Node->setEnabled(false);
9041 fschmid 892
        MoveNode->setChecked(true);
893
        MoveControl->setChecked(false);
894
        DeleteNode->setChecked(false);
895
        AddNode->setChecked(false);
19606 craig 896
        PolySplit->setChecked(false);
3 paul 897
}
898
 
899
void NodePalette::AddN()
900
{
22790 jghali 901
        if (m_doc == nullptr)
6531 cbradney 902
                return;
19946 craig 903
        m_doc->nodeEdit.setSubMode(NodeEditContext::ADD_POINT);
904
        m_doc->nodeEdit.setEdPoints(true);
161 Franz 905
        SymMove->setEnabled(false);
906
        AsymMove->setEnabled(false);
907
        ResNode->setEnabled(false);
908
        Res1Node->setEnabled(false);
9041 fschmid 909
        AddNode->setChecked(true);
910
        DeleteNode->setChecked(false);
19606 craig 911
        PolySplit->setChecked(false);
3 paul 912
}
913
 
914
void NodePalette::DelN()
915
{
22790 jghali 916
        if (m_doc == nullptr)
6531 cbradney 917
                return;
19946 craig 918
        m_doc->nodeEdit.setSubMode(NodeEditContext::DEL_POINT);
919
        m_doc->nodeEdit.setEdPoints(true);
161 Franz 920
        SymMove->setEnabled(false);
921
        AsymMove->setEnabled(false);
922
        ResNode->setEnabled(false);
218 Franz 923
        Res1Node->setEnabled(false);
9041 fschmid 924
        AddNode->setChecked(false);
925
        DeleteNode->setChecked(true);
19606 craig 926
        PolySplit->setChecked(false);
3 paul 927
}
928
 
1525 cbradney 929
void NodePalette::closeEvent(QCloseEvent *ce)
3 paul 930
{
22603 craig 931
        if (m_doc != nullptr)
161 Franz 932
        {
3 paul 933
                MoveN();
19946 craig 934
                m_doc->nodeEdit.setClre(-1);
935
                m_doc->nodeEdit.setClre2(-1);
936
                m_doc->nodeEdit.setSegP1(-1);
937
                m_doc->nodeEdit.setSegP2(-1);
938
                m_doc->nodeEdit.selNode().clear();
18330 jghali 939
                PageItem *currItem = m_doc->m_Selection->itemAt(0);
17260 fschmid 940
                if (currItem->itemType() == PageItem::PathText)
941
                        currItem->updatePolyClip();
161 Franz 942
        }
19606 craig 943
        PolySplit->setEnabled(false);
944
        BezierClose->setEnabled(false);
16546 jghali 945
        emit paletteClosed();
1525 cbradney 946
        ScrPaletteBase::closeEvent(ce);
3 paul 947
}
948
 
949
void NodePalette::EndEdit()
950
{
22603 craig 951
        if (m_doc != nullptr)
161 Franz 952
        {
3 paul 953
                MoveN();
19946 craig 954
                m_doc->nodeEdit.setClre(-1);
955
                m_doc->nodeEdit.setClre2(-1);
956
                m_doc->nodeEdit.setSegP1(-1);
957
                m_doc->nodeEdit.setSegP2(-1);
958
                m_doc->nodeEdit.selNode().clear();
21262 fschmid 959
                m_doc->nodeEdit.setPreviewMode(false);
340 Franz 960
                EditCont->setChecked(false);
341 Franz 961
                ToggleConMode();
18330 jghali 962
                PageItem *currItem = m_doc->m_Selection->itemAt(0);
19218 jghali 963
                if (currItem && currItem->itemType() == PageItem::PathText)
17260 fschmid 964
                        currItem->updatePolyClip();
161 Franz 965
        }
19606 craig 966
        PolySplit->setEnabled(false);
967
        BezierClose->setEnabled(false);
340 Franz 968
        EditCont->setChecked(false);
16546 jghali 969
        emit paletteClosed();
3 paul 970
}
2210 cbradney 971
 
18040 fschmid 972
void NodePalette::CancelEdit()
973
{
22603 craig 974
        if (m_doc != nullptr)
18040 fschmid 975
        {
976
                MoveN();
19946 craig 977
                m_doc->nodeEdit.setClre(-1);
978
                m_doc->nodeEdit.setClre2(-1);
979
                m_doc->nodeEdit.setSegP1(-1);
980
                m_doc->nodeEdit.setSegP2(-1);
981
                m_doc->nodeEdit.selNode().clear();
21262 fschmid 982
                m_doc->nodeEdit.setPreviewMode(false);
18040 fschmid 983
                EditCont->setChecked(false);
984
                ToggleConMode();
18330 jghali 985
                PageItem *currItem = m_doc->m_Selection->itemAt(0);
23528 jghali 986
 
987
                // Calculate the difference of the current position and the original
988
                // position in the item's coordinate space (which is rotated and translated,
989
                // but the translation does not matter for the delta)
990
                QTransform m = QTransform().rotate(-currItem->rotation());
24615 jghali 991
                QPointF delta = m.map(QPointF(m_xPos, m_yPos)) - m.map(QPointF(currItem->xPos(), currItem->yPos()));
23528 jghali 992
                // During operation the image offsets and possibly other values are changed.
993
                // To not remember everything we move the clip path to the original position
994
                // relative to the current position (in the item's coordinate space).
995
                // adjustItemSize will then take care of moving the position and changing
996
                // image offsets, etc.
24615 jghali 997
                currItem->PoLine = m_itemPath.copy();
23528 jghali 998
                currItem->PoLine.translate(delta.x(), delta.y());
24615 jghali 999
                currItem->ContourLine = m_itemContourPath.copy();
20694 craig 1000
                m_doc->adjustItemSize(currItem);
18040 fschmid 1001
                if (currItem->itemType() == PageItem::PathText)
1002
                        currItem->updatePolyClip();
21224 fschmid 1003
                m_doc->regionsChanged()->update(QRectF());
18040 fschmid 1004
        }
19606 craig 1005
        PolySplit->setEnabled(false);
1006
        BezierClose->setEnabled(false);
18040 fschmid 1007
        EditCont->setChecked(false);
1008
        emit paletteClosed();
1009
}
1010
 
1011
void NodePalette::ResetToEditDefaults()
1012
{
22790 jghali 1013
        if (m_doc == nullptr)
1014
                return;
1015
 
1016
        m_doc->nodeEdit.setClre(-1);
1017
        m_doc->nodeEdit.setClre2(-1);
1018
        m_doc->nodeEdit.setSegP1(-1);
1019
        m_doc->nodeEdit.setSegP2(-1);
1020
        m_doc->nodeEdit.selNode().clear();
1021
        m_doc->nodeEdit.setPreviewMode(false);
1022
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
23528 jghali 1023
 
1024
        // See comment in NodePalette::CancelEdit
1025
        QTransform m = QTransform().rotate(-currItem->rotation());
24615 jghali 1026
        QPointF delta = m.map(QPointF(m_xPos, m_yPos)) - m.map(QPointF(currItem->xPos(), currItem->yPos()));
22790 jghali 1027
        if (EditCont->isChecked())
23528 jghali 1028
        {
24615 jghali 1029
                currItem->ContourLine = m_itemContourPath.copy();
23528 jghali 1030
                currItem->ContourLine.translate(delta.x(), delta.y());
1031
        }
22790 jghali 1032
        else
18040 fschmid 1033
        {
23528 jghali 1034
                // See comment in NodePalette::CancelEdit
24615 jghali 1035
                currItem->PoLine = m_itemPath;
23528 jghali 1036
                currItem->PoLine.translate(delta.x(), delta.y());
24615 jghali 1037
                currItem->ContourLine = m_itemContourPath;
22790 jghali 1038
                m_doc->adjustItemSize(currItem);
18040 fschmid 1039
        }
22790 jghali 1040
        if (currItem->itemType() == PageItem::PathText)
1041
                currItem->updatePolyClip();
1042
        currItem->update();
1043
        m_doc->regionsChanged()->update(QRectF());
18040 fschmid 1044
}
1045
 
10859 cbradney 1046
void NodePalette::changeEvent(QEvent *e)
1047
{
1048
        if (e->type() == QEvent::LanguageChange)
1049
        {
1050
                languageChange();
1051
        }
10903 cbradney 1052
        else
1053
                QWidget::changeEvent(e);
10859 cbradney 1054
}
1055
 
19388 jghali 1056
void NodePalette::reject()
1057
{
1058
        EndEdit();
1059
        ScrPaletteBase::reject();
1060
}
1061
 
18040 fschmid 1062
void NodePalette::setDefaults(PageItem* currItem)
1063
{
24615 jghali 1064
        m_xPos = currItem->xPos();
1065
        m_yPos = currItem->yPos();
1066
        m_itemPath = currItem->PoLine.copy();
1067
        m_itemContourPath = currItem->ContourLine.copy();
18040 fschmid 1068
}
1069
 
23474 jghali 1070
void NodePalette::iconSetChange()
1071
{
1072
        IconManager& im = IconManager::instance();
1073
 
1074
        MoveNode->setIcon(im.loadIcon("MoveNode.png"));
1075
        AddNode->setIcon(im.loadIcon("AddNode.png"));
1076
        DeleteNode->setIcon(im.loadIcon("DeleteNode.png"));
1077
        ResNode->setIcon(im.loadIcon("ResetNode.png"));
1078
        MoveControl->setIcon(im.loadIcon("MoveKontrol.png"));
1079
        AsymMove->setIcon(im.loadIcon("MoveAsym.png"));
1080
        SymMove->setIcon(im.loadIcon("MoveSym.png"));
1081
        Res1Node->setIcon(im.loadIcon("Reset1Node.png"));
1082
        PolySplit->setIcon(im.loadIcon("PolyCut.png"));
1083
        BezierClose->setIcon(im.loadIcon("BezierClose.png"));
1084
        PolyMirrorH->setIcon(im.loadIcon("hmirror.png"));
1085
        PolyMirrorV->setIcon(im.loadIcon("vmirror.png"));
1086
        PolyShearL->setIcon(im.loadIcon("22/transform-shear-left.png"));
1087
        PolyShearR->setIcon(im.loadIcon("22/transform-shear-right.png"));
1088
        PolyShearU->setIcon(im.loadIcon("22/transform-shear-up.png"));
1089
        PolyShearD->setIcon(im.loadIcon("22/transform-shear-down.png"));
1090
        RotateCCW->setIcon(im.loadIcon("rotate_ccw.png"));
1091
        RotateCW->setIcon(im.loadIcon("rotate_cw.png"));
1092
        Expand->setIcon(im.loadIcon("expand.png"));
1093
        Shrink->setIcon(im.loadIcon("crop.png"));
1094
        Enlarge->setIcon(im.loadIcon("expand.png"));
1095
        Reduce->setIcon(im.loadIcon("crop.png"));
1096
}
1097
 
2210 cbradney 1098
void NodePalette::languageChange()
1099
{
10495 cbradney 1100
        setWindowTitle( tr( "Nodes" ) );
4619 cbradney 1101
        scalePercentage->setSuffix( tr(" %"));
9041 fschmid 1102
 
11145 fschmid 1103
        AbsMode->setTitle( tr("&Absolute Coordinates"));
1104
        absToCanvas->setText( tr("to Canvas"));
1105
        absToPage->setText( tr("to Page"));
2397 cbradney 1106
        TextLabel1->setText( tr("&X-Pos:"));
1107
        TextLabel2->setText( tr("&Y-Pos:"));
21292 fschmid 1108
        PreviewMode->setText( tr("Hide Nodes"));
2397 cbradney 1109
        EditCont->setText( tr("Edit &Contour Line"));
1110
        ResetCont->setText( tr("&Reset Contour Line"));
8445 fschmid 1111
        ResetContClip->setText( tr("Set Contour to Image Clip"));
12681 fschmid 1112
        ResetShape2Clip->setText( tr("Set Shape to Image Clip"));
18040 fschmid 1113
        editEditButton->setText( tr("OK"));
1114
        cancelEditButton->setText( tr("Cancel"));
1115
        resetDefaultButton->setText( tr("Reset all edits"));
1116
//      editEditButton->setText( tr("&End Editing"));
10397 cbradney 1117
        MoveNode->setToolTip( tr("Move Nodes"));
1118
        MoveControl->setToolTip( tr("Move Control Points"));
1119
        AddNode->setToolTip( tr("Add Nodes"));
1120
        DeleteNode->setToolTip( tr("Delete Nodes"));
1121
        AsymMove->setToolTip( tr("Move Control Points Independently"));
1122
        SymMove->setToolTip( tr("Move Control Points Symmetrical"));
1123
        ResNode->setToolTip( tr("Reset Control Points"));
1124
        Res1Node->setToolTip( tr("Reset this Control Point"));
1125
        PolySplit->setToolTip( tr("Open a Polygon or Cuts a Bezier Curve"));
1126
        BezierClose->setToolTip( tr("Close this Bezier Curve"));
1127
        PolyMirrorH->setToolTip( tr("Mirror the Path Horizontally"));
1128
        PolyMirrorV->setToolTip( tr("Mirror the Path Vertically"));
1129
        PolyShearR->setToolTip( tr("Shear the Path Horizontally to the Right"));
1130
        PolyShearL->setToolTip( tr("Shear the Path Horizontally to the Left"));
1131
        PolyShearU->setToolTip( tr("Shear the Path Vertically Up"));
1132
        PolyShearD->setToolTip( tr("Shear the Path Vertically Down"));
1133
        RotateCCW->setToolTip( tr("Rotate the Path Counter-Clockwise"));
1134
        RotateCW->setToolTip( tr("Rotate the Path Clockwise"));
1135
        Shrink->setToolTip( tr("Shrink the Size of the Path by shown %"));
1136
        Expand->setToolTip( tr("Enlarge the Size of the Path by shown %"));
1137
        Reduce->setToolTip( tr("Reduce the Size of the Path by the shown value"));
1138
        Enlarge->setToolTip( tr("Enlarge the Size of the Path by the shown value"));
1139
        RotVal->setToolTip( tr("Angle of Rotation"));
1140
        scalePercentage->setToolTip( tr("% to Enlarge or Shrink By"));
1141
        scaleDistance->setToolTip( tr("Value to Enlarge or Shrink By"));
1142
        EditCont->setToolTip( tr("Activate Contour Line Editing Mode"));
1143
        ResetCont->setToolTip( tr("Reset the Contour Line to the Original Shape of the Frame"));
1144
        ResetContClip->setToolTip( tr("Reset the Contour Line to the Clipping Path of the Image"));
12681 fschmid 1145
        ResetShape2Clip->setToolTip( tr("Set the Shape to the Clipping Path of the Image"));
20270 craig 1146
        AbsMode->setToolTip(  "<qt>" + tr("When checked use coordinates relative to the page, otherwise coordinates are relative to the Object") + "</qt>");
2210 cbradney 1147
}
3934 cbradney 1148
 
4619 cbradney 1149
void NodePalette::unitChange()
1150
{
22790 jghali 1151
        if (m_doc == nullptr)
4619 cbradney 1152
                return;
24615 jghali 1153
        m_unitRatio = m_doc->unitRatio();
19622 jghali 1154
 
1155
        bool sigBlocked1 = XSpin->blockSignals(true);
1156
        bool sigBlocked2 = YSpin->blockSignals(true);
1157
        bool sigBlocked3 = scaleDistance->blockSignals(true);
1158
 
1159
        XSpin->setNewUnit(m_doc->unitIndex());
1160
        YSpin->setNewUnit(m_doc->unitIndex());
18330 jghali 1161
        scaleDistance->setNewUnit(m_doc->unitIndex());
19622 jghali 1162
 
1163
        XSpin->blockSignals(sigBlocked1);
1164
        YSpin->blockSignals(sigBlocked2);
1165
        scaleDistance->blockSignals(sigBlocked3);
4619 cbradney 1166
}
6531 cbradney 1167
 
1168
ScribusDoc* NodePalette::currentDocument() const
1169
{
18330 jghali 1170
        return m_doc;
6531 cbradney 1171
}