Subversion Repositories Scribus

Rev

Rev 18007 | Rev 20694 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10928 fschmid 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
*/
7
/***************************************************************************
8
*   Copyright (C) 2007 by Franz Schmid                                     *
9
*   franz.schmid@altmuehlnet.de                                            *
10
*                                                                          *
11
*   This program is free software; you can redistribute it and/or modify   *
12
*   it under the terms of the GNU General Public License as published by   *
13
*   the Free Software Foundation; either version 2 of the License, or      *
14
*   (at your option) any later version.                                    *
15
*                                                                          *
16
*   This program is distributed in the hope that it will be useful,        *
17
*   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
18
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
19
*   GNU General Public License for more details.                           *
20
*                                                                          *
21
*   You should have received a copy of the GNU General Public License      *
22
*   along with this program; if not, write to the                          *
23
*   Free Software Foundation, Inc.,                                        *
18122 mrdocs 24
*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.              *
10928 fschmid 25
****************************************************************************/
26
 
27
#include "lenseffects.h"
28
#include "lensdialog.h"
29
#include "scribuscore.h"
13805 jghali 30
#include "selection.h"
10928 fschmid 31
 
32
int lenseffects_getPluginAPIVersion()
33
{
34
        return PLUGIN_API_VERSION;
35
}
36
 
37
ScPlugin* lenseffects_getPlugin()
38
{
39
        LensEffectsPlugin* plug = new LensEffectsPlugin();
40
        Q_CHECK_PTR(plug);
41
        return plug;
42
}
43
 
44
void lenseffects_freePlugin(ScPlugin* plugin)
45
{
46
        LensEffectsPlugin* plug = dynamic_cast<LensEffectsPlugin*>(plugin);
47
        Q_ASSERT(plug);
48
        delete plug;
49
}
50
 
51
LensEffectsPlugin::LensEffectsPlugin() : ScActionPlugin()
52
{
53
        // Set action info in languageChange, so we only have to do
54
        // it in one place.
55
        languageChange();
56
}
57
 
58
LensEffectsPlugin::~LensEffectsPlugin() {};
59
 
60
void LensEffectsPlugin::languageChange()
61
{
62
        // Note that we leave the unused members unset. They'll be initialised
63
        // with their default ctors during construction.
64
        // Action name
65
        m_actionInfo.name = "LensEffects";
66
        // Action text for menu, including accel
67
        m_actionInfo.text = tr("Lens Effects...");
68
        // Menu
11035 fschmid 69
        m_actionInfo.menu = "ItemPathOps";
11050 fschmid 70
        m_actionInfo.parentMenu = "Item";
71
        m_actionInfo.subMenuName = tr("Path Tools");
12566 cbradney 72
        m_actionInfo.enabledOnStartup = false;
10956 fschmid 73
        m_actionInfo.notSuitableFor.append(PageItem::Line);
12119 fschmid 74
        m_actionInfo.notSuitableFor.append(PageItem::TextFrame);
75
        m_actionInfo.notSuitableFor.append(PageItem::ImageFrame);
76
        m_actionInfo.notSuitableFor.append(PageItem::PathText);
77
        m_actionInfo.notSuitableFor.append(PageItem::LatexFrame);
15060 fschmid 78
        m_actionInfo.notSuitableFor.append(PageItem::Symbol);
16191 fschmid 79
        m_actionInfo.notSuitableFor.append(PageItem::RegularPolygon);
16215 fschmid 80
        m_actionInfo.notSuitableFor.append(PageItem::Arc);
16311 fschmid 81
        m_actionInfo.notSuitableFor.append(PageItem::Spiral);
10956 fschmid 82
        m_actionInfo.needsNumObjects = 3;
10928 fschmid 83
}
84
 
85
const QString LensEffectsPlugin::fullTrName() const
86
{
87
        return QObject::tr("Lens Effects");
88
}
89
 
90
const ScActionPlugin::AboutData* LensEffectsPlugin::getAboutData() const
91
{
92
        AboutData* about = new AboutData;
93
        Q_CHECK_PTR(about);
94
        about->authors = QString::fromUtf8("Franz Schmid <Franz.Schmid@altmuehlnet.de>");
95
        about->shortDescription = tr("Lens Effects");
96
        about->description = tr("Apply fancy lens effects");
97
        // about->version
98
        // about->releaseDate
99
        // about->copyright
100
        about->license = "GPL";
101
        return about;
102
}
103
 
104
void LensEffectsPlugin::deleteAboutData(const AboutData* about) const
105
{
106
        Q_ASSERT(about);
107
        delete about;
108
}
109
 
110
bool LensEffectsPlugin::run(ScribusDoc* doc, QString)
111
{
112
        ScribusDoc* currDoc = doc;
113
        if (currDoc == 0)
114
                currDoc = ScCore->primaryMainWindow()->doc;
115
        if (currDoc->m_Selection->count() > 0)
116
        {
117
                LensDialog *dia = new LensDialog(currDoc->scMW(), currDoc);
118
                if (dia->exec())
119
                {
120
                        for (int a = 0; a < dia->origPathItem.count(); a++)
121
                        {
16115 fschmid 122
                                PageItem *currItem = dia->origPageItem[a];
10956 fschmid 123
                                if (currItem->itemType() == PageItem::Line)
124
                                        continue;
10928 fschmid 125
                                QPainterPath path = dia->origPathItem[a]->path();
126
                                FPointArray points;
127
                                points.fromQPainterPath(path);
128
                                currItem->PoLine = points;
11016 fschmid 129
                                currItem->ClipEdited = true;
130
                                currItem->FrameType = 3;
16118 fschmid 131
                                double oW = currItem->width();
132
                                double oH = currItem->height();
16115 fschmid 133
                                currDoc->AdjustItemSize(currItem, true);
11016 fschmid 134
                                currItem->OldB2 = currItem->width();
135
                                currItem->OldH2 = currItem->height();
16118 fschmid 136
                                if (currItem->isGroup())
137
                                {
138
                                        currItem->groupWidth = currItem->groupWidth * (currItem->OldB2 / oW);
139
                                        currItem->groupHeight = currItem->groupHeight * (currItem->OldH2 / oH);
140
                                }
11016 fschmid 141
                                currItem->updateClip();
142
                                currItem->ContourLine = currItem->PoLine.copy();
10928 fschmid 143
                        }
10936 fschmid 144
                        currDoc->changed();
10928 fschmid 145
                }
146
                delete dia;
147
        }
148
        return true;
149
}