lenseffects.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 /*************************************************************************** 00008 * Copyright (C) 2007 by Franz Schmid * 00009 * franz.schmid@altmuehlnet.de * 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 * This program is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00019 * GNU General Public License for more details. * 00020 * * 00021 * You should have received a copy of the GNU General Public License * 00022 * along with this program; if not, write to the * 00023 * Free Software Foundation, Inc., * 00024 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00025 ****************************************************************************/ 00026 00027 #include "lenseffects.h" 00028 #include "lensdialog.h" 00029 #include "scribuscore.h" 00030 00031 int lenseffects_getPluginAPIVersion() 00032 { 00033 return PLUGIN_API_VERSION; 00034 } 00035 00036 ScPlugin* lenseffects_getPlugin() 00037 { 00038 LensEffectsPlugin* plug = new LensEffectsPlugin(); 00039 Q_CHECK_PTR(plug); 00040 return plug; 00041 } 00042 00043 void lenseffects_freePlugin(ScPlugin* plugin) 00044 { 00045 LensEffectsPlugin* plug = dynamic_cast<LensEffectsPlugin*>(plugin); 00046 Q_ASSERT(plug); 00047 delete plug; 00048 } 00049 00050 LensEffectsPlugin::LensEffectsPlugin() : ScActionPlugin() 00051 { 00052 // Set action info in languageChange, so we only have to do 00053 // it in one place. 00054 languageChange(); 00055 } 00056 00057 LensEffectsPlugin::~LensEffectsPlugin() {}; 00058 00059 void LensEffectsPlugin::languageChange() 00060 { 00061 // Note that we leave the unused members unset. They'll be initialised 00062 // with their default ctors during construction. 00063 // Action name 00064 m_actionInfo.name = "LensEffects"; 00065 // Action text for menu, including accel 00066 m_actionInfo.text = tr("Lens Effects..."); 00067 // Menu 00068 m_actionInfo.menu = "ItemPathOps"; 00069 m_actionInfo.parentMenu = "Item"; 00070 m_actionInfo.subMenuName = tr("Path Tools"); 00071 m_actionInfo.enabledOnStartup = true; 00072 m_actionInfo.notSuitableFor.append(PageItem::Line); 00073 m_actionInfo.needsNumObjects = 3; 00074 } 00075 00076 const QString LensEffectsPlugin::fullTrName() const 00077 { 00078 return QObject::tr("Lens Effects"); 00079 } 00080 00081 const ScActionPlugin::AboutData* LensEffectsPlugin::getAboutData() const 00082 { 00083 AboutData* about = new AboutData; 00084 Q_CHECK_PTR(about); 00085 about->authors = QString::fromUtf8("Franz Schmid <Franz.Schmid@altmuehlnet.de>"); 00086 about->shortDescription = tr("Lens Effects"); 00087 about->description = tr("Apply fancy lens effects"); 00088 // about->version 00089 // about->releaseDate 00090 // about->copyright 00091 about->license = "GPL"; 00092 return about; 00093 } 00094 00095 void LensEffectsPlugin::deleteAboutData(const AboutData* about) const 00096 { 00097 Q_ASSERT(about); 00098 delete about; 00099 } 00100 00101 bool LensEffectsPlugin::run(ScribusDoc* doc, QString) 00102 { 00103 ScribusDoc* currDoc = doc; 00104 if (currDoc == 0) 00105 currDoc = ScCore->primaryMainWindow()->doc; 00106 if (currDoc->m_Selection->count() > 0) 00107 { 00108 LensDialog *dia = new LensDialog(currDoc->scMW(), currDoc); 00109 if (dia->exec()) 00110 { 00111 for (int a = 0; a < dia->origPathItem.count(); a++) 00112 { 00113 PageItem *currItem = currDoc->m_Selection->itemAt(a); 00114 if (currItem->itemType() == PageItem::Line) 00115 continue; 00116 QPainterPath path = dia->origPathItem[a]->path(); 00117 FPointArray points; 00118 points.fromQPainterPath(path); 00119 currItem->PoLine = points; 00120 currItem->Frame = false; 00121 currItem->ClipEdited = true; 00122 currItem->FrameType = 3; 00123 currDoc->AdjustItemSize(currItem); 00124 currItem->OldB2 = currItem->width(); 00125 currItem->OldH2 = currItem->height(); 00126 currItem->updateClip(); 00127 currItem->ContourLine = currItem->PoLine.copy(); 00128 } 00129 currDoc->changed(); 00130 } 00131 delete dia; 00132 } 00133 return true; 00134 }
