[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/krita-testing-wolthera] krita/plugins/paintops: Added tangent swizzle functionality.
From: Wolthera van Hovell <griffinvalley () gmail ! com>
Date: 2015-04-26 17:54:01
Message-ID: E1YmQkj-0007cr-84 () scm ! kde ! org
[Download RAW message or body]
Git commit a9142e09f7129392bbff0b7113e8e0794fe42330 by Wolthera van Hovell.
Committed on 26/04/2015 at 17:50.
Pushed by woltherav into branch 'krita-testing-wolthera'.
Added tangent swizzle functionality.
Several things are added in this commit:
1. A UI for tangent normal map options.
2. The option to switch tangent encoding.
3. The ability to use tilt-direction, drawing angle or rotation for the
direction parameter.
4. A default brush for the tangent normal brush engine, but no clue how
this is supossed to work...
M +1 -0 krita/plugins/paintops/CMakeLists.txt
M +1 -0 krita/plugins/paintops/defaultpresets/CMakeLists.txt
A +- -- krita/plugins/paintops/defaultpresets/tangenttilt.kpp
M +2 -1 krita/plugins/paintops/tangentnormal/CMakeLists.txt
M +1 -0 krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop.cpp
M +4 -1 krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp
M +114 -2 krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.cpp
M +17 -0 krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.h
A +268 -0 krita/plugins/paintops/tangentnormal/wdgtangenttiltoption.ui
http://commits.kde.org/calligra/a9142e09f7129392bbff0b7113e8e0794fe42330
diff --git a/krita/plugins/paintops/CMakeLists.txt \
b/krita/plugins/paintops/CMakeLists.txt index baff8c2..685010f 100644
--- a/krita/plugins/paintops/CMakeLists.txt
+++ b/krita/plugins/paintops/CMakeLists.txt
@@ -16,3 +16,4 @@ add_subdirectory( gridbrush )
add_subdirectory( hatching)
add_subdirectory( sketch )
add_subdirectory( colorsmudge )
+add_subdirectory( tangentnormal )
diff --git a/krita/plugins/paintops/defaultpresets/CMakeLists.txt \
b/krita/plugins/paintops/defaultpresets/CMakeLists.txt index 34b8731..2f208c9 100644
--- a/krita/plugins/paintops/defaultpresets/CMakeLists.txt
+++ b/krita/plugins/paintops/defaultpresets/CMakeLists.txt
@@ -17,6 +17,7 @@ install( FILES
colorsmudge.kpp
sketchbrush.kpp
hatchingbrush.kpp
+ tangenttilt.kpp
DESTINATION ${DATA_INSTALL_DIR}/krita/defaultpresets)
diff --git a/krita/plugins/paintops/defaultpresets/tangenttilt.kpp \
b/krita/plugins/paintops/defaultpresets/tangenttilt.kpp new file mode 100644
index 0000000..d60a730
Binary files /dev/null and b/krita/plugins/paintops/defaultpresets/tangenttilt.kpp \
differ
diff --git a/krita/plugins/paintops/tangentnormal/CMakeLists.txt \
b/krita/plugins/paintops/tangentnormal/CMakeLists.txt index 93a6782..fbe11ff 100644
--- a/krita/plugins/paintops/tangentnormal/CMakeLists.txt
+++ b/krita/plugins/paintops/tangentnormal/CMakeLists.txt
@@ -6,8 +6,9 @@ set(kritatangentnormalpaintop_PART_SRCS
)
-kde4_add_plugin(kritatangentnormalpaintop ${kritatangentnormalpaintop_PART_SRCS})
+kde4_add_ui_files(kritatangentnormalpaintop_PART_SRCS wdgtangenttiltoption.ui )
+kde4_add_plugin(kritatangentnormalpaintop ${kritatangentnormalpaintop_PART_SRCS})
target_link_libraries(kritatangentnormalpaintop kritalibpaintop)
diff --git a/krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop.cpp \
b/krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop.cpp index \
5e2b8de..1444319 100644
--- a/krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop.cpp
+++ b/krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop.cpp
@@ -40,6 +40,7 @@ KisTangentNormalPaintOp::KisTangentNormalPaintOp(const \
KisBrushBasedPaintOpSetti
{
//Init, read settings, etc//
+ m_tangentTiltOption.readOptionSetting(settings);
m_sizeOption.readOptionSetting(settings);
m_opacityOption.readOptionSetting(settings);
m_spacingOption.readOptionSetting(settings);
diff --git a/krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp \
b/krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp \
index a1c9c10..3b1295f 100644
--- a/krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp
+++ b/krita/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp
@@ -36,10 +36,13 @@ \
KisTangentNormalPaintOpSettingsWidget::KisTangentNormalPaintOpSettingsWidget(QWi {
setObjectName("brush option widget");
setPrecisionEnabled(true);
- addPaintOpOption(new KisTangentTiltOption());
+
// addPaintOpOption(new KisCompositeOpOption(true)); No composite opp... for now.
addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption()));
+
+ addPaintOpOption(new KisTangentTiltOption());
+
addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption()));
addPaintOpOption(new KisPressureSpacingOptionWidget());
addMirrorOption();
diff --git a/krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.cpp \
b/krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.cpp index \
3f7e949..c3968d9 100644
--- a/krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.cpp
+++ b/krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.cpp
@@ -22,15 +22,92 @@
#include "kis_tangent_tilt_option.h"
#include <cmath>
+#include "ui_wdgtangenttiltoption.h"
+
+class KisTangentTiltOptionWidget: public QWidget, public Ui::WdgTangentTiltOptions
+{
+public:
+ KisTangentTiltOptionWidget(QWidget *parent = 0)
+ : QWidget(parent) {
+ setupUi(this);
+ }
+};
+
KisTangentTiltOption::KisTangentTiltOption()
: KisPaintOpOption(i18n("Tangent Tilt"), KisPaintOpOption::generalCategory(), false)
{
+ m_checkable = false;
+ m_options = new KisTangentTiltOptionWidget();
+ //Setup tangent tilt.
+ m_options->comboRed->setCurrentIndex(0);
+ m_options->comboGreen->setCurrentIndex(2);
+ m_options->comboBlue->setCurrentIndex(4);
+ //m_options->
+
+ connect(m_options->comboRed, SIGNAL(currentIndexChanged(int)), \
SLOT(emitSettingChanged())); + connect(m_options->comboGreen, \
SIGNAL(currentIndexChanged(int)), SLOT(emitSettingChanged())); + \
connect(m_options->comboBlue, SIGNAL(currentIndexChanged(int)), \
SLOT(emitSettingChanged())); +
+ connect(m_options->optionTilt, SIGNAL(toggled(bool)), \
SLOT(emitSettingChanged())); + connect(m_options->optionDirection, \
SIGNAL(toggled(bool)), SLOT(emitSettingChanged())); + \
connect(m_options->optionRotation, SIGNAL(toggled(bool)), \
SLOT(emitSettingChanged())); +
+ //connect tangent tilt
+ setConfigurationPage(m_options);
}
KisTangentTiltOption::~KisTangentTiltOption()
{
+ delete m_options;
+}
+//options
+int KisTangentTiltOption::redChannel() const
+{
+ return m_options->comboRed->currentIndex();
+}
+int KisTangentTiltOption::greenChannel() const
+{
+ return m_options->comboGreen->currentIndex();
+}
+int KisTangentTiltOption::blueChannel() const
+{
+ return m_options->comboBlue->currentIndex();
}
+
+int KisTangentTiltOption::directionType() const
+{
+ int type=0;
+
+ if (m_options->optionTilt->isChecked()==true) {
+ type=0;
+ }
+ else if (m_options->optionDirection->isChecked()==true) {
+ type=1;
+ }
+ else if (m_options->optionRotation->isChecked()==true) {
+ type=2;
+ }
+ else {
+ qWarning()<<"There's something odd with the radio buttons. We'll use Tilt";
+ }
+
+ return type;
+
+}
+
+void KisTangentTiltOption::swizzleAssign(qreal const horizontal, qreal const \
vertical, qreal const depth, quint8 *component, int index, qreal maxvalue) +{
+ switch(index) {
+ case 0: *component = horizontal; break;
+ case 1: *component = maxvalue-horizontal; break;
+ case 2: *component = vertical; break;
+ case 3: *component = maxvalue-vertical; break;
+ case 4: *component = depth; break;
+ case 5: *component = maxvalue-depth; break;
+ }
+}
+
void KisTangentTiltOption::apply(const KisPaintInformation& info,quint8 *r,quint8 \
*g,quint8 *b) {
//formula based on http://nl.mathworks.com/help/matlab/ref/sph2cart.html
@@ -42,6 +119,13 @@ void KisTangentTiltOption::apply(const KisPaintInformation& \
info,quint8 *r,quint
//have the azimuth and altitude in degrees.
qreal direction = KisPaintInformation::tiltDirection(info, true)*360.0;
+ if (directionType()==0) {
+ direction = KisPaintInformation::tiltDirection(info, true)*360.0;
+ } else if (directionType()==1) {
+ direction = (0.75 + info.drawingAngle() / (2.0 * M_PI))*360.0;
+ } else if (directionType()==2) {
+ direction = info.rotation();
+ }
qreal elevation= (info.tiltElevation(info, 60.0, 60.0, true)*90.0);
//TODO:subtract/add the rotation of the canvas.
@@ -79,8 +163,36 @@ void KisTangentTiltOption::apply(const KisPaintInformation& \
info,quint8 *r,quint
//TODO: Allow for swizzle to decide this.(or something...)
//assign right components to correct axes.
- *r = horizontal;
+ swizzleAssign(horizontal, vertical, depth, r, redChannel(), maxvalue);
+ swizzleAssign(horizontal, vertical, depth, g, greenChannel(), maxvalue);
+ swizzleAssign(horizontal, vertical, depth, b, blueChannel(), maxvalue);
+ /**r = horizontal;
*g = vertical;
- *b = depth;
+ *b = depth;*/
}
+/*settings*/
+void KisTangentTiltOption::writeOptionSetting(KisPropertiesConfiguration* setting) \
const +{
+ setting->setProperty(TANGENT_RED, redChannel());
+ setting->setProperty(TANGENT_GREEN, greenChannel());
+ setting->setProperty(TANGENT_BLUE, blueChannel());
+ setting->setProperty(TANGENT_TYPE, directionType());
+}
+
+void KisTangentTiltOption::readOptionSetting(const KisPropertiesConfiguration* \
setting) +{
+ m_options->comboRed->setCurrentIndex(setting->getInt(TANGENT_RED));
+ m_options->comboGreen->setCurrentIndex(setting->getInt(TANGENT_GREEN));
+ m_options->comboBlue->setCurrentIndex(setting->getInt(TANGENT_BLUE));
+
+ if (setting->getInt(TANGENT_TYPE)== 0){
+ m_options->optionTilt->setChecked(true);
+ }
+ else if (setting->getInt(TANGENT_TYPE)== 1) {
+ m_options->optionDirection->setChecked(true);
+ }
+ else if (setting->getInt(TANGENT_TYPE)== 2) {
+ m_options->optionRotation->setChecked(true);
+ }
+}
diff --git a/krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.h \
b/krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.h index \
f6e2c4b..7c989a0 100644
--- a/krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.h
+++ b/krita/plugins/paintops/tangentnormal/kis_tangent_tilt_option.h
@@ -26,18 +26,35 @@
#include <kis_paintop_option.h>
+const QString TANGENT_RED = "Tangent/swizzleRed";
+const QString TANGENT_GREEN = "Tangent/swizzleGreen";
+const QString TANGENT_BLUE = "Tangent/swizzleBlue";
+const QString TANGENT_TYPE = "Tangent/directionType";
+
class KisPropertiesConfiguration;
class KisPainter;
+class KisTangentTiltOptionWidget;
class KisTangentTiltOption: public KisPaintOpOption//not really//
{
public:
KisTangentTiltOption();
~KisTangentTiltOption();
+ /*These three give away which the index of the combobox for a given channel*/
+ int redChannel() const;
+ int greenChannel() const;
+ int blueChannel() const;
+ int directionType() const;
+ /*This assigns the right axis to the component, based on index and maximum \
value*/ + void swizzleAssign(qreal const horizontal, qreal const vertical, qreal \
const depth, quint8 *component, int index, qreal maxvalue);
//takes the RGB values and will deform them depending on tilt.
void apply(const KisPaintInformation& info,quint8 *r,quint8 *g,quint8 *b);
+
+ void writeOptionSetting(KisPropertiesConfiguration* setting) const;
+ void readOptionSetting(const KisPropertiesConfiguration* setting);
private:
+ KisTangentTiltOptionWidget * m_options;
};
#endif // KIS_TANGENT_TILT_OPTION_H
diff --git a/krita/plugins/paintops/tangentnormal/wdgtangenttiltoption.ui \
b/krita/plugins/paintops/tangentnormal/wdgtangenttiltoption.ui new file mode 100644
index 0000000..44edc73
--- /dev/null
+++ b/krita/plugins/paintops/tangentnormal/wdgtangenttiltoption.ui
@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>WdgTangentTiltOptions</class>
+ <widget class="QWidget" name="WdgTangentTiltOptions">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>425</width>
+ <height>264</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>255</horstretch>
+ <verstretch>255</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>425</width>
+ <height>260</height>
+ </size>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="TangentEncoding">
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>Tangent Encoding</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QFormLayout" name="swizzlebox">
+ <property name="labelAlignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="RedLabel">
+ <property name="text">
+ <string>Red:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="comboGreen">
+ <property name="currentIndex">
+ <number>2</number>
+ </property>
+ <item>
+ <property name="text">
+ <string extracomment="Positive horizontal axis">+ X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Negative horizontal axis">- X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Positive vertical axis">+ Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Negative vertical axis">- Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Postive height axis">+ Z</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="negative height axis">- Z</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="GreenLabel">
+ <property name="text">
+ <string>Green:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="comboRed">
+ <item>
+ <property name="text">
+ <string extracomment="Positive horizontal axis">+ X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Negative horizontal axis">- X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Positive vertical axis">+ Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Negative vertical axis">- Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Postive height axis">+ Z</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="negative height axis">- Z</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="BlueLabel">
+ <property name="text">
+ <string>Blue:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="comboBlue">
+ <property name="currentIndex">
+ <number>4</number>
+ </property>
+ <item>
+ <property name="text">
+ <string extracomment="Positive horizontal axis">+ X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Negative horizontal axis">- X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Positive vertical axis">+ Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Negative vertical axis">- Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="Postive height axis">+ Z</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string extracomment="negative height axis">- Z</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="TangentTiltPreview">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>100</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="text">
+ <string notr="true" extracomment="this is a frame that could contain a \
preview of the swizzle chosen"/> + </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="TiltOptions">
+ <property name="title">
+ <string>Tilt Options</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QRadioButton" name="optionTilt">
+ <property name="toolTip">
+ <string><html><head/><body><p>Use the tilt of the \
tablet to determine the normals.</p></body></html></string> + \
</property> + <property name="text">
+ <string>Tilt</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QRadioButton" name="optionDirection">
+ <property name="toolTip">
+ <string><html><head/><body><p>Use the drawing \
direction to determine the X and Y-axes, while tilt-elevation is used for the \
Z-axis.</p></body></html></string> + </property>
+ <property name="text">
+ <string>Direction</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QRadioButton" name="optionRotation">
+ <property name="toolTip">
+ <string><html><head/><body><p>Use the rotation \
sensor availeble in certain pens to determine the X and Y-axes, while tilt-elevation \
is used for the Z-axis.</p></body></html></string> + \
</property> + <property name="text">
+ <string>Rotation</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic