Commit b45ec641 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Fix showing of the paintops.

svn path=/trunk/koffice/; revision=738812
parent 8fbfb399
......@@ -31,7 +31,6 @@ K_EXPORT_COMPONENT_FACTORY( krita_colorspaces_extensions, ExtensionsPluginFactor
ExtensionsPlugin::ExtensionsPlugin(QObject *parent, const QStringList &)
{
kDebug() << "Loading ExtensionsPlugin";
KoColorTransformationFactoryRegistry::addColorTransformationFactory(new KisHSVAdjustementFactory);
}
......
......@@ -307,4 +307,3 @@ void KisRgbFloatHDRColorSpaceTest::testF16Channels()
QTEST_KDEMAIN(KisRgbFloatHDRColorSpaceTest, NoGUI)
#include "kis_rgb_float_hdr_colorspace_test.moc"
......@@ -294,7 +294,7 @@ KisPaintDeviceSP KisPaintOp::source()
}
bool KisPaintOpFactory::userVisible(KoColorSpace * cs )
bool KisPaintOpFactory::userVisible(const KoColorSpace * cs )
{
return cs && cs->id() != "WET";
}
......
......@@ -151,7 +151,7 @@ public:
* in various tools. If false, it won't show up in the toolchest.
* The KoColorSpace argument can be used when certain paintops only support a specific cs
*/
virtual bool userVisible(KoColorSpace * cs = 0);
virtual bool userVisible(const KoColorSpace * cs = 0);
/**
* Create and return an (abstracted) widget with options for this paintop when used with the
......
......@@ -87,7 +87,7 @@ KisPaintOpSettings * KisPaintOpRegistry::settings(const KoID& id, QWidget * pare
return 0;
}
bool KisPaintOpRegistry::userVisible(const KoID & id, KoColorSpace* cs) const
bool KisPaintOpRegistry::userVisible(const KoID & id, const KoColorSpace* cs) const
{
KisPaintOpFactorySP f = value(id.id());
......
......@@ -56,7 +56,7 @@ public:
KisPaintOpSettings * settings(const KoID& id, QWidget * parent, const KoInputDevice& inputDevice, KisImageSP image) const;
// Whether we should show this paintop in the toolchest
bool userVisible(const KoID & id, KoColorSpace* cs) const;
bool userVisible(const KoID & id, const KoColorSpace* cs) const;
// Get the name of the icon to show in the toolchest
QString pixmap(const KoID & id) const;
......
......@@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <math.h>
#include <QPainter>
#include <QRect>
......@@ -24,6 +25,7 @@
#include <KoColor.h>
#include <kis_vec.h>
#include <kis_random_accessor.h>
#include <kis_paint_device.h>
#include "brush.h"
......@@ -96,6 +98,59 @@ void Stroke::drawLine( KisPaintDeviceSP dev, double x1, double y1, double x2, do
}
}
void Stroke::drawWuLine(KisPaintDeviceSP dev, double x1, double y1, double x2, double y2, double width, const KoColor & color )
{
// From Wikipedia...
if (!dev) return;
if (x2 < x1) {
double tmp = x2;
x2 = x1;
x1 = tmp;
tmp = y2;
y2 = y1;
y1 = tmp;
}
double dx = x2 - x1;
double dy = y2 - y1;
double gradient = dy / dx;
double xend = round(x1);
double yend = y1 + gradient * (xend - x1);
double tmp;
double xgap = 1 - modf(x1 + 0.5, &tmp);
double xpxl1 = xend; // this will be used in the main loop
double ypxl1 = static_cast<int>(yend); // Remove the fractional part the fast way
dev->setPixel(xpxl1, ypxl1, Qt::black, (1 - modf(yend, &tmp)) * xgap);
dev->setPixel(xpxl1, ypxl1 + 1, Qt::black, modf(yend, &tmp) * xgap);
double intery = yend + gradient; // first y-intersection for the main loop
// handle second endpoint
xend = round(x2);
yend = y2 + gradient * (xend - x2);
xgap = modf(x2 + 0.5, &tmp);
double xpxl2 = xend; // this will be used in the main loop
double ypxl2 = static_cast<int>(yend);
dev->setPixel(xpxl2, ypxl2, Qt::black, (1 - modf(yend, &tmp)) * xgap);
dev->setPixel(xpxl2, ypxl2 + 1, Qt::black, modf(yend, &tmp) * xgap);
// main loop
for (int x = xpxl1 + 1; x < xpxl2; ++x) {
dev->setPixel(x, static_cast<int>(intery), Qt::black, (1 - modf(intery, &tmp)));
dev->setPixel(x, static_cast<int>(intery) + 1, Qt::black, modf(intery, &tmp));
intery = intery + gradient;
}
}
// draw the stroke by drawing the old paths, then the new segment
void Stroke::draw (KisPaintDeviceSP dev)
{
......
......@@ -50,6 +50,7 @@ public:
private:
void drawLine( KisPaintDeviceSP dev, double x1, double y1, double x2, double y2, double width, const KoColor & color );
void drawWuLine(KisPaintDeviceSP dev, double x1, double y1, double x2, double y2, double width, const KoColor & color );
// test whether a bristle is touching the paper or not
// by testing the pressure threshold and test if there is any ink
......
......@@ -114,46 +114,6 @@
<iconset>brush6.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset>images/brush2.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset>images/brush3.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset>images/brush4.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset>images/brush5.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset>images/brush6.png</iconset>
</property>
</item>
</widget>
</item>
<item>
......
......@@ -37,7 +37,7 @@ public:
virtual KisPaintOp * createOp(const KisPaintOpSettings *settings, KisPainter * painter, KisImageSP image);
virtual QString id() const { return "paintSmeary"; }
virtual QString name() const { return i18n("Smeary Brush"); }
virtual bool userVisible(KoColorSpace * ) { return false; }
virtual bool userVisible( const KoColorSpace * ) { return false; }
virtual QString pixmap() { return ""; }
};
......
......@@ -286,7 +286,7 @@ void KisToolTransform::setFunctionalCursor()
int rotOctant = 8 + int(8.5 + m_a* 4 / M_PI);
int s;
if(m_scaleX*m_scaleY<0)
if ( (m_scaleX * m_scaleY) < 0 )
s = -1;
else
s=1;
......
......@@ -37,6 +37,7 @@
#include <kstandarddirs.h>
#include <KoToolManager.h>
#include <KoColorSpace.h>
#include <kis_paintop_registry.h>
#include <kis_resource_provider.h>
......@@ -63,7 +64,7 @@ KisPaintopBox::KisPaintopBox (KisView2 * view, QWidget *parent, const char * nam
m_cmbPaintops = new QComboBox(this);
m_cmbPaintops->setObjectName("KisPaintopBox::m_cmbPaintops");
m_cmbPaintops->setMinimumWidth(150);
m_cmbPaintops->setToolTip("Styles of painting for the painting tools");
m_cmbPaintops->setToolTip(i18n("Artist's materials"));
m_layout = new QHBoxLayout(this);
m_layout->setMargin(1);
......@@ -76,12 +77,13 @@ KisPaintopBox::KisPaintopBox (KisView2 * view, QWidget *parent, const char * nam
// XXX: Let's see... Are all paintops loaded and ready?
QList<KoID> keys = KisPaintOpRegistry::instance()->listKeys();
for ( QList<KoID>::Iterator it = keys.begin(); it != keys.end(); ++it ) {
kDebug() << it->name();
// add all paintops, and show/hide them afterwards
addItem(*it);
}
connect(view->layerManager(), SIGNAL(currentColorSpaceChanged(KoColorSpace*)),
this, SLOT(colorSpaceChanged(KoColorSpace*)));
connect(view->layerManager(), SIGNAL(currentColorSpaceChanged(const KoColorSpace*)),
this, SLOT(colorSpaceChanged(const KoColorSpace*)));
connect(view->layerManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(slotCurrentLayerChanged(KisLayerSP)));
connect(KoToolManager::instance(),
......@@ -113,14 +115,17 @@ void KisPaintopBox::slotItemSelected(int index)
}
}
void KisPaintopBox::colorSpaceChanged(KoColorSpace *cs)
void KisPaintopBox::colorSpaceChanged(const KoColorSpace *cs)
{
kDebug() << "colorSpaceChanged" << cs;
m_displayedOps.clear();
m_cmbPaintops->clear();
foreach (KoID paintopId, m_paintops) {
kDebug() << paintopId;
if (KisPaintOpRegistry::instance()->userVisible(paintopId, cs)) {
kDebug() << " visible: ";
QPixmap pm = paintopPixmap(paintopId);
if (pm.isNull()) {
......@@ -160,8 +165,6 @@ QPixmap KisPaintopBox::paintopPixmap(const KoID & paintop)
void KisPaintopBox::slotInputDeviceChanged(const KoInputDevice & inputDevice)
{
KoID paintop;
InputDevicePaintopMap::iterator it = m_currentID.find(inputDevice);
......@@ -226,6 +229,7 @@ const KoID& KisPaintopBox::currentPaintop()
void KisPaintopBox::setCurrentPaintop(const KoID & paintop)
{
kDebug() << paintop.name();
m_currentID[KoToolManager::instance()->currentInputDevice()] = paintop;
updateOptionWidget();
......
......@@ -71,7 +71,7 @@ private slots:
private slots:
void slotItemSelected(int index);
void colorSpaceChanged(KoColorSpace *cs);
void colorSpaceChanged(const KoColorSpace *cs);
void slotInputDeviceChanged(const KoInputDevice & inputDevice);
void slotCurrentLayerChanged(KisLayerSP layer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment