/trunk/Subik/scribus-colorwheel/colorwheel/cwdialog.h |
---|
17,6 → 17,11 |
class QPushButton; |
class QSpinBox; |
/** \brief GUI dialog for Color Wheel Plugin. |
Quite everything in this class is self explanatory (except few things ;)). |
\author Petr Vanek; petr@yarpen.cz |
\date April 2005 |
*/ |
class ColorWheelDialog : public QDialog |
{ |
Q_OBJECT |
36,6 → 41,8 |
QPushButton* cancelButton; |
protected: |
/** It fills a colors into list view. It takes colors |
from ColorWheel widget. */ |
void fillColorList(); |
QGridLayout* formLayout; |
QHBoxLayout* mainLayout; |
46,6 → 53,7 |
QHBoxLayout* buttonLayout; |
/** Configuration structure */ |
PrefsContext* prefs; |
/** Draws a strange colorful things as preview of the color schema. */ |
void setPreview(); |
public slots: |
/trunk/Subik/scribus-colorwheel/colorwheel/colorwheel.cpp |
---|
17,7 → 17,7 |
int ID() |
{ |
return 66; |
return 13; |
} |
46,22 → 46,10 |
return true; |
} |
/** |
Create dialog and insert font into Style menu when user accepts. |
*/ |
/** Create dialog. Everything else is handled in separated classes. */ |
void run(QWidget *d, ScribusApp */*plug*/) |
{ |
ColorWheelDialog *dlg = new ColorWheelDialog(d, "dlg", TRUE, 0); |
// run it and wait for user's reaction |
if (dlg->exec() == QDialog::Accepted) |
{ |
qDebug("exec"); |
/* |
if (plug->pluginManager->dllInput == "") |
plug->SetNewFont(dlg->fontList->currentItem()->text(0)); |
else |
plug->pluginManager->dllReturn = dlg->fontList->currentItem()->text(0); |
*/ |
} |
dlg->exec(); |
delete dlg; |
} |
/trunk/Subik/scribus-colorwheel/colorwheel/colorwheelwidget.cpp |
---|
8,10 → 8,6 |
ColorWheel::ColorWheel(QWidget * parent, const char * name) : QLabel(parent, name, 0) |
{ |
xsize = 100; |
ysize = 100; |
actualPoint = QPoint(xsize, ysize); |
angle = 5; |
} |
ColorWheel::~ColorWheel() |
34,11 → 30,6 |
QImage image; |
const QPixmap *pm = pixmap(); |
image = pm->convertToImage(); |
/* |
qDebug(QString("pc: %1 %2").arg(p1.x()).arg(p1.y())); |
*/ |
//qDebug(QString("pcrgb: %1 %2 %3").arg(qRed(image.pixel(p1.x(), p1.y()))).arg(qGreen(image.pixel(p1.x(), p1.y()))).arg(qBlue(image.pixel(p1.x(), p1.y())))); |
return image.pixel(p1.x(), p1.y()); |
} |
55,18 → 46,16 |
void ColorWheel::paintWheel(QValueVector<QPoint> selectedPoints) |
{ |
xsize = width(); |
ysize = height(); |
QPixmap pm(xsize, ysize); |
QPixmap pm(width(), height()); |
pm.fill(Qt::white); |
QPainter *p = new QPainter(&pm); |
p->setWindow( 0, 0, xsize, ysize); |
p->setWindow( 0, 0, width(), height()); |
p->setPen(Qt::white); |
p->drawRect(0, 0, xsize, ysize); |
p->drawRect(0, 0, width(), height()); |
for (int i = 0; i < 361; ++i) |
{ |
QWMatrix matrix; |
matrix.translate(xsize/2, ysize/2); |
matrix.translate(width()/2, height()/2); |
matrix.rotate((float)i); |
p->setWorldMatrix(matrix); |
QColor c; |
135,25 → 124,18 |
return 0.0; |
} |
//#include <iostream.h> |
void ColorWheel::sampleByAngle(double angle, QString name) |
{ |
/* |
x2:=cpx+round(x*cos(radang)-y*sin(radang)); |
y2:=cpy+round(y*cos(radang)+x*sin(radang)); |
*/ |
double radang = M_PI * angle/180; |
//cout << "angle: " << radang << endl; |
int x = actualPoint.x() - xsize/2; |
int y = actualPoint.y() - ysize/2; |
int x = actualPoint.x() - width()/2; |
int y = actualPoint.y() - height()/2; |
//cout << " xy: " << actualPoint.x() << " " << actualPoint.y() << endl; |
//cout << "oxy: " << x << " " << y << endl; |
//int dx = sqrt(x*x + y*y) * cos(atan(y / x) + M_PI*angle/180); |
//int dy = sqrt(x*x + y*y) * sin(atan(y / x) + M_PI*angle/180); |
int dx = (int) round(x * cos(radang) - y * sin(radang)); |
int dy = (int) round(y * cos(radang) + x * sin(radang)); |
//cout << "dxy: " << dx << " " << dy << endl; |
QRgb rgb = getPointColor(QPoint(dx + xsize/2, dy + ysize/2)); |
QRgb rgb = getPointColor(QPoint(dx + width()/2, dy + height()/2)); |
//cout << "nxy: " << dx + xsize/2 << " " << dy + ysize/2 << endl; |
// create color |
colorList[name] = cmykColor(rgb); |
/trunk/Subik/scribus-colorwheel/colorwheel/colorwheel.h |
---|
5,6 → 5,15 |
#include "scribus.h" |
#include "pluginmanager.h" |
/** \brief This is a simple "Color Theory" plugin for Scribus 1.3 and later. |
Harmonious colors are colors that work well together, that produce a color |
scheme that looks attractive; the color wheel can be used as a valuable |
tool for determining harmonious colors. |
More on: http://en.wikipedia.org/wiki/Color_wheel |
\author Petr Vanek; petr@yarpen.cz |
\date April 2005 |
*/ |
/** Calls the Plugin with the main Application window as parent |
* and the main Application Class as parameter */ |
extern "C" void run(QWidget *d, ScribusApp *plug); |
15,13 → 24,12 |
extern "C" QString name(); |
/** Returns the Type of the Plugin. |
* 1 = the Plugin is a normal Plugin, which appears in the Extras Menue |
* 2 = the Plugin is a Import Plugin, which appears in the Import Menue |
* 3 = the Plugin is a Export Plugin, which appears in the Export Menue |
* 4 = the Plugin is a resident Plugin */ |
/** Returns the Type of the Plugin. */ |
extern "C" PluginManager::PluginType type(); |
/** ID for plugin registry */ |
extern "C" int ID(); |
/** menu settings */ |
extern "C" QString actionName(); |
extern "C" QString actionKeySequence(); |
extern "C" QString actionMenu(); |
/trunk/Subik/scribus-colorwheel/colorwheel/cwdialog.cpp |
---|
91,6 → 91,7 |
prefs = prefsFile->getPluginContext("colorwheel"); |
typeCombo->setCurrentItem(prefs->getInt("cw_type", 0)); |
angleSpin->setValue(prefs->getInt("cw_angle", 15)); |
colorWheel->angle = angleSpin->value(); |
QValueVector<QPoint> vp; |
int x = prefs->getInt("cw_x", 0); |
int y = prefs->getInt("cw_y", 0); |
144,7 → 145,14 |
angleLabel->setText(tr("Angle (0 - 365 degrees):")); |
addButton->setText(tr("&Add Colors")); |
cancelButton->setText(tr("&Cancel")); |
// tips |
QToolTip::add(addButton, "<qt>" + tr("Appends created colors into socument colors") + "</qt>"); |
QToolTip::add(cancelButton, "<qt>" + tr("Leave colors untouched") + "</qt>"); |
QToolTip::add(angleSpin, "<qt>" + tr("Difference between selected value and counted ones. See documentation for more info") + "</qt>"); |
QToolTip::add(colorWheel, "<qt>" + tr("Click the wheel to get base color") + "</qt>"); |
QToolTip::add(previewLabel, "<qt>" + tr("Here you have the sample color schema") + "</qt>"); |
QToolTip::add(typeCombo, "<qt>" + tr("Select one of the method to create color schema. See documentation for more info") + "</qt>"); |
QToolTip::add(colorList, "<qt>" + tr("Here you have the color of your chosen color schema") + "</qt>"); |
} |
void ColorWheelDialog::fillColorList() |
/trunk/Subik/scribus-colorwheel/colorwheel/colorwheelwidget.h |
---|
7,7 → 7,13 |
#include <cmykcolor.h> |
#include <scribusstructs.h> |
/** |
\brief Widget ColorWheel graphicaly shows a color wheel for color theory. |
Class ColorWheel is new widget inherited from the QLabel. |
See e.g. http://en.wikipedia.org/wiki/Color_wheel for more info. |
\author Petr Vanek; petr@yarpen.cz |
\date April 2005 |
*/ |
class ColorWheel : public QLabel |
{ |
Q_OBJECT |
16,6 → 22,7 |
ColorWheel(QWidget * parent, const char * name = 0); |
~ColorWheel(); |
/** It can handle these color theory methods */ |
enum MethodType { |
Monochromatic, |
Analogous, |
25,34 → 32,95 |
Tetradic |
}; |
uint xsize; |
uint ysize; |
/** \brief Difference between selected value and counted ones. |
Let's set angle = 15 and base point e.g. 60 (everything in grades). |
Now you will have Analogous angles 60 (base) and 75 (+15) and 45 (-15). |
Exact interpretation of the angle value depends on the MethodType value. |
*/ |
int angle; |
/** Coordinates of the leading point. */ |
QPoint actualPoint; |
/** RGB interpretation of the leading point. */ |
QRgb actualRgb; |
/** \brief List of the colors created in this widget. |
Colors can be added into Scribus color list later. */ |
ColorList colorList; |
/** \brief Draw a color wheel. |
\param QValueVector<QPoint> points to be drawed. |
*/ |
void paintWheel(QValueVector<QPoint>); |
/** \brief Returns localized name of the type */ |
QString getTypeDescription(MethodType aType); |
/** Draws a sample square filled with specified color. */ |
QPixmap sample(QColor); |
/** \brief Counts the monochromatic colors. |
The monochromatic color scheme uses variations in lightness |
and saturation of a single color. It's clean and elegant color |
schema. I like it's minimalism ;) */ |
void makeMonochromatic(); |
/** \brief Counts the analogous colors. |
The analogous color scheme uses colors that are changed by an angle |
in the color wheel. It looks richer than mono scheme. */ |
void makeAnalogous(); |
/** \brief Counts the complementary colors. |
It takes two opposite colors (180 deg). It looks great when you choose a warm |
color against a cool one. E.g. dark green vs. wine red. Hmmm wine... */ |
void makeComplementary(); |
/** \brief Counts the split-complementary colors. |
It's enthanced complementary method. It takes base and opposite colors |
with applied angle differences. */ |
void makeSplit(); |
/** \brief Counts the triadic colors. |
It takes three colors balanced on the wheel (by 120 grades). */ |
void makeTriadic(); |
/** \brief Counts the tetradic colors. |
It's two times complementary. */ |
void makeTetradic(); |
signals: |
/** \brief Signal raised by mouse click on widget by user. |
\param int Mouse button number. See Qt docs. |
\param QPoint Coordinates of the mouse pointer. */ |
void clicked(int, const QPoint &); |
protected: |
/** \brief An event for mouse actions handling. |
See \see clicked() for more info. |
\param QMouseEvent Mouse properties. */ |
void mouseReleaseEvent(QMouseEvent *); |
/** Finds the color of the point in this widget |
\param QPoint Coordinates of the point. |
\return QRgb value with color of the point. */ |
QRgb getPointColor(QPoint); |
/** \brief Appends a color into \see colorList. |
\param double an angle for transformation counting. |
E.g. base angle is 30, param is 90 - transformation is 120. |
\param QString name of the color. */ |
void sampleByAngle(double, QString); |
/** \brief Counts an angle of the point in color wheel |
\param QPoint coordinates of the point. */ |
double pointAngle(QPoint); |
/** Appends the base color into color list. */ |
void baseColor(); |
/** Creates a Scribus CMYKColor from rgb value. |
\param QRgb a rgb value of the color. */ |
CMYKColor cmykColor(QRgb rgb); |
}; |