krita
kis_filter.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "kis_filter.h"
00019
00020 #include <qstring.h>
00021
00022 #include "kis_types.h"
00023 #include "kis_filter_configuration.h"
00024
00025 KisFilter::KisFilter(const KisID& id, const QString & category, const QString & entry)
00026 : KisProgressSubject(0, id.id().latin1())
00027 , m_id(id)
00028 , m_progressDisplay(0)
00029 , m_category(category)
00030 , m_entry(entry)
00031 {
00032 }
00033
00034 KisFilterConfiguration * KisFilter::configuration(QWidget*)
00035 {
00036 return new KisFilterConfiguration(m_id.id(), 0);
00037 }
00038
00039 KisFilterConfiguration * KisFilter::configuration()
00040 {
00041 return new KisFilterConfiguration(m_id.id(), 0);
00042 }
00043
00044 KisFilterConfigWidget * KisFilter::createConfigurationWidget(QWidget *, KisPaintDeviceSP)
00045 {
00046 return 0;
00047 }
00048
00049 void KisFilter::setProgressDisplay(KisProgressDisplayInterface * progressDisplay)
00050 {
00051 m_progressDisplay = progressDisplay;
00052 }
00053
00054
00055 void KisFilter::enableProgress() {
00056 m_progressEnabled = true;
00057 m_cancelRequested = false;
00058 }
00059
00060 void KisFilter::disableProgress() {
00061 m_progressEnabled = false;
00062 m_cancelRequested = false;
00063 m_progressDisplay = 0;
00064 }
00065
00066 void KisFilter::setProgressTotalSteps(Q_INT32 totalSteps)
00067 {
00068 if (m_progressEnabled) {
00069
00070 m_progressTotalSteps = totalSteps;
00071 m_lastProgressPerCent = 0;
00072 m_progressSteps = 0;
00073 emit notifyProgress(0);
00074 }
00075 }
00076
00077 void KisFilter::setProgress(Q_INT32 progress)
00078 {
00079 if (m_progressEnabled) {
00080 Q_INT32 progressPerCent = (progress * 100) / m_progressTotalSteps;
00081 m_progressSteps = progress;
00082
00083 if (progressPerCent != m_lastProgressPerCent) {
00084
00085 m_lastProgressPerCent = progressPerCent;
00086 emit notifyProgress(progressPerCent);
00087 }
00088 }
00089 }
00090
00091 void KisFilter::incProgress()
00092 {
00093 setProgress(++m_progressSteps);
00094
00095 }
00096
00097 void KisFilter::setProgressStage(const QString& stage, Q_INT32 progress)
00098 {
00099 if (m_progressEnabled) {
00100
00101 Q_INT32 progressPerCent = (progress * 100) / m_progressTotalSteps;
00102
00103 m_lastProgressPerCent = progressPerCent;
00104 emit notifyProgressStage(stage, progressPerCent);
00105 }
00106 }
00107
00108 void KisFilter::setProgressDone()
00109 {
00110 if (m_progressEnabled) {
00111 emit notifyProgressDone();
00112 }
00113 }
00114
00115
00116 bool KisFilter::autoUpdate() {
00117 return m_autoUpdate;
00118 }
00119
00120 void KisFilter::setAutoUpdate(bool set) {
00121 m_autoUpdate = set;
00122 }
00123
00124 QRect KisFilter::enlargeRect(QRect rect, KisFilterConfiguration* c) const {
00125 int margin = overlapMarginNeeded(c);
00126 rect.rLeft() -= margin;
00127 rect.rTop() -= margin;
00128 rect.rRight() += margin;
00129 rect.rBottom() += margin;
00130 return rect;
00131 }
00132
00133 #include "kis_filter.moc"
|