tychoBCGEN  0.5
 All Data Structures Namespaces Files Functions Variables
Public Member Functions | Data Fields | Protected Member Functions | Private Slots | Private Attributes
MainWindow Class Reference

#include <mainwindow.h>

Inheritance diagram for MainWindow:
image_stack

Public Member Functions

 MainWindow (QWidget *parent=0)
 ~MainWindow ()
void mask_pixmap ()
void undo_mask_pixmap ()
void make_color_mask ()
void clear_many_pixel ()
void clear_many_pixel_1 ()
void mask_many_pixel ()
void mask_many_pixel_1 ()
void clear_individual_pixel ()
void mask_invidual_pixel ()
void insert_wind_emitter ()

Data Fields

QPixmap pixmap
QVector< QPoint > emitter_points
myscenescene
colormaskmycolormask
tutorialmytutorial
aboutmyabout
QString file
QString file_save
QString file_masked_image_save
QPointF point1
QPointF point2
QColor final_mark_color
QColor emitter_color_x
QColor emitter_color_mx
QColor emitter_color_y
QColor emitter_color_my
int imagewidth
int imageheight
int pixmapwidth
int pixmapheight
int maskwidth
int counter
int counter_wind_emitter
int counter_first_emitter
int toCheck
int alpha
int alpha_special_marking
int alpha_emitter
bool mousebutton_pressed
- Data Fields inherited from image_stack
QVector< QImage > imagestack
QImage image
QImage image1
QImage wind_emitter
QImage wind_emitter_save

Protected Member Functions

void resizeEvent (QResizeEvent *event)
void keyPressEvent (QKeyEvent *event)

Private Slots

void openfile ()
void scale_to_width ()
void scale_original ()
void zoom_in ()
void zoom_out ()
void memo_color_mask ()
void clear_last_color_mask ()
void open_color_mask ()
void quit ()
void value_change_int ()
void reset_mask ()
void savefile ()
void savefile_soundemitter ()
void save_wind_emitter ()
void save_masked_image ()
void invert_mask ()
void open_about ()
void open_tutorial ()
void wind_emitter_on ()
void wind_emitter_off ()
void reset_wind_emitter ()
void scale_image ()
void rotate_by_90 ()

Private Attributes

Ui::MainWindowui

Detailed Description

Definition at line 19 of file mainwindow.h.


Constructor & Destructor Documentation

MainWindow::MainWindow ( QWidget *  parent = 0)
explicit

Sets up the Mainwindow object

Definition at line 37 of file mainwindow.cpp.

References Ui_MainWindow::actionAbout, Ui_MainWindow::actionLoad_Image, Ui_MainWindow::actionQuit_tychoICGEN, Ui_MainWindow::actionSave_Boundary, Ui_MainWindow::actionSave_Masked_Image, Ui_MainWindow::actionSave_Sound_Emitter, Ui_MainWindow::actionSave_Wind_Emitter, Ui_MainWindow::actionTutorial, alpha, alpha_emitter, alpha_special_marking, blue_checked, blue_low, blue_up, clear_last_color_mask(), Ui_MainWindow::ColorMask, colormask_counter, counter, counter_first_emitter, counter_wind_emitter, emitter_color_mx, emitter_color_my, emitter_color_x, emitter_color_y, final_mark_color, green_checked, green_low, green_up, Ui_MainWindow::image_height, Ui_MainWindow::image_width, invert_mask(), Ui_MainWindow::invertmask, memo_color_mask(), Ui_MainWindow::memo_mask, no_image, open_about(), open_color_mask(), open_tutorial(), openfile(), Ui_MainWindow::original, quit(), red_checked, red_low, red_up, Ui_MainWindow::remove_mask, Ui_MainWindow::reset_mask, reset_mask(), reset_wind_emitter(), Ui_MainWindow::resetwindemitter, Ui_MainWindow::rotate_by_90, rotate_by_90(), save_masked_image(), save_wind_emitter(), savefile(), savefile_soundemitter(), scale_image(), scale_original(), Ui_MainWindow::scale_to_width, scale_to_width(), Ui_MainWindow::setupUi(), toCheck, ui, value, value_change_int(), wind_emitter_off(), wind_emitter_on(), Ui_MainWindow::windemitter, Ui_MainWindow::zoom_in, zoom_in(), Ui_MainWindow::zoom_out, and zoom_out().

:
QMainWindow(parent),
{
QTimer *timer = new QTimer(this);
ui->setupUi(this);
counter = 0;
red_low = 0;
red_up = 0;
green_low = 0;
green_up = 0;
blue_low = 0;
blue_up = 0;
value = 0;
alpha = 90;
red_checked = true;
green_checked = true;
blue_checked = true;
no_image = true;
final_mark_color.setRgb(Qt::black);
emitter_color_x.setRgb(255,0,0,alpha_emitter);
emitter_color_y.setRgb(0,255,0,alpha_emitter);
emitter_color_my.setRgb(100,255,200,alpha_emitter);
//to make changes on the colormask-window received by the mainwindow
connect(timer, SIGNAL(timeout()), this, SLOT(value_change_int()));
timer->start(200);
//menus
connect(ui->actionQuit_tychoICGEN, SIGNAL(triggered()), this, SLOT(quit()));
connect(ui->actionLoad_Image, SIGNAL(triggered()), this, SLOT(openfile()));
connect(ui->actionSave_Boundary, SIGNAL(triggered()), this, SLOT(savefile()));
connect(ui->actionSave_Sound_Emitter, SIGNAL(triggered()), this, SLOT(savefile_soundemitter()));
connect(ui->actionSave_Wind_Emitter, SIGNAL(triggered()), this, SLOT(save_wind_emitter()));
connect(ui->actionSave_Masked_Image, SIGNAL(triggered()), this, SLOT(save_masked_image()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(open_about()));
connect(ui->actionTutorial, SIGNAL(triggered()), this, SLOT(open_tutorial()));
//buttons
connect(ui->scale_to_width, SIGNAL(clicked()), this, SLOT(scale_to_width()));
connect(ui->original, SIGNAL(clicked()), this, SLOT(scale_original()));
connect(ui->zoom_in, SIGNAL(clicked()), this, SLOT(zoom_in()));
connect(ui->zoom_out, SIGNAL(clicked()), this, SLOT(zoom_out()));
connect(ui->ColorMask, SIGNAL(clicked()), this, SLOT(open_color_mask()));
connect(ui->invertmask, SIGNAL(clicked()), this, SLOT(invert_mask()));
connect(ui->rotate_by_90, SIGNAL(clicked()), this, SLOT(rotate_by_90()));
//mask memo, remove and reset
connect(ui->reset_mask, SIGNAL(clicked()), this, SLOT(reset_mask()));
connect(ui->memo_mask, SIGNAL(clicked()), this, SLOT(memo_color_mask()));
connect(ui->remove_mask, SIGNAL(clicked()), this, SLOT(clear_last_color_mask()));
//windemitter
connect(ui->windemitter, SIGNAL(clicked(bool)), this, SLOT(wind_emitter_on()));
connect(ui->windemitter, SIGNAL(toggled(bool)), this, SLOT(wind_emitter_off()));
connect(ui->resetwindemitter, SIGNAL(clicked()), this, SLOT(reset_wind_emitter()));
//rescaling of the image
connect(ui->image_width, SIGNAL(editingFinished()), this, SLOT(scale_image()));
connect(ui->image_height, SIGNAL(editingFinished()), this, SLOT(scale_image()));
}
MainWindow::~MainWindow ( )

Definition at line 113 of file mainwindow.cpp.

References ui.

{
delete ui;
}

Member Function Documentation

void MainWindow::clear_individual_pixel ( )

Clears indiviudal pixels

Definition at line 95 of file color_segmentation.cpp.

References Ui_MainWindow::graphicsView, image_stack::image, image_stack::imagestack, no_image, pixmap, point, scene, and ui.

Referenced by keyPressEvent().

{
if (no_image == false){
QColor tmp;
tmp = image_stack::imagestack.at(0).pixel(point.toPoint());
image.setPixel(point.toPoint(), tmp.rgba());
scene->clear();
pixmap = QPixmap::fromImage(image);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
}
void MainWindow::clear_last_color_mask ( )
privateslot

Deletes the last image in the stack

Definition at line 77 of file color_segmentation.cpp.

References Ui_MainWindow::graphicsView, image_stack::image, image_stack::imagestack, pixmap, scene, ui, and image_stack::wind_emitter.

Referenced by MainWindow().

{
if (image_stack::imagestack.size() > 1){
scene->clear();
pixmap = QPixmap::fromImage(image);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
}
void MainWindow::clear_many_pixel ( )

Clears many pixels until a mask is found

Definition at line 370 of file color_segmentation.cpp.

References alpha, image_stack::image, image_stack::imagestack, and point.

Referenced by clear_many_pixel_1().

{
QColor tmp;
int i;
int j;
if (qAlpha(image.pixel(point.toPoint())) == alpha){
for (j = 0; j < image.height() - point.toPoint().y(); j++){
i = 0;
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) != alpha) break;
while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) == alpha){
tmp = image_stack::imagestack.at(0).pixel(point.toPoint().x() + i, point.toPoint().y() + j);
image.setPixel(point.toPoint().x() + i, point.toPoint().y() + j, tmp.rgba());
if (point.toPoint().x() + i < image.width() - 1){
i++;
}
else{
break;
}
}
}
for (j = 0; j < image.height() - point.toPoint().y(); j++){
i = -1;
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) != alpha) break;
while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) == alpha){
tmp = image_stack::imagestack.at(0).pixel(point.toPoint().x() + i, point.toPoint().y() + j);
image.setPixel(point.toPoint().x() + i, point.toPoint().y() + j, tmp.rgba());
if (point.toPoint().x() + i > - 1){
i--;
}
else{
break;
}
}
}
for (j = 1; j < point.toPoint().y() + 1; j++){
i = 0;
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) != alpha) break;
while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) == alpha){
tmp = image_stack::imagestack.at(0).pixel(point.toPoint().x() + i, point.toPoint().y() - j);
image.setPixel(point.toPoint().x() + i, point.toPoint().y() - j, tmp.rgba());
if (point.toPoint().x() + i < image.width()-1){
i++;
}
else{
break;
}
}
}
for (j = 1; j < point.toPoint().y()+1; j++){
i = -1;
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) != alpha) break;
while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) == alpha){
tmp = image_stack::imagestack.at(0).pixel(point.toPoint().x() + i, point.toPoint().y() - j);
image.setPixel(point.toPoint().x() + i, point.toPoint().y() - j, tmp.rgba());
if (point.toPoint().x() + i > 0){
i--;
}
else{
break;
}
}
}
}
}
void MainWindow::clear_many_pixel_1 ( )

Clears islands in the mask

Definition at line 113 of file color_segmentation.cpp.

References alpha, alpha_special_marking, clear_many_pixel(), Ui_MainWindow::graphicsView, image_stack::image, image_stack::imagestack, pixmap, point, scene, ui, and image_stack::wind_emitter.

Referenced by keyPressEvent().

{
int boundarypixel[6];
QImage image_tmp_clear;
QColor special_color_for_marking;
bool stop;
bool stop_inner_while;
bool on;
int i;
int n;
int x;
int y;
int k;
int start_x;
int start_y;
int zero_decision;
int row_counter;
int break_condition;
stop = false;
stop_inner_while = false;
on = false;
i = 0;
n = 0;
x = 0;
y = 0;
k = 0;
start_x = 1;
start_y = 0;
zero_decision = 0;
row_counter = 0;
break_condition = 0;
for (n = 0; n < 6; n++) boundarypixel[n] = 0;
special_color_for_marking.setAlpha(alpha_special_marking);
image_tmp_clear = image;
if ((point.toPoint().x() >= 0)&&(point.toPoint().x()<image.width())
&&(point.toPoint().y() >= 0)
&&(point.toPoint().y()<image.height())
&& (qAlpha(image.pixel(point.toPoint().x(),point.toPoint().y()))) == alpha){
while (stop == false){
//first we go out of the whole in the mask
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y())) == alpha) {
if (point.toPoint().x() + i < image.width() - 1){
i++;
}
else{
//This is no island in the mask, we stop this procedure here
stop = true;
break;
}
}
else
{
//The first pixel in the boundary is found.
//If boundary is not a mask point the vluse 1 in the vector at the highlighted place
//| |2| |
//|1|x|3|
//| |4| |
//1 - boundarypixel[2]
//2 - boundarypixel[3]
//3 - boundarypixel[4]
//4 - boundarypixel[5]
x = point.toPoint().x() + i;
y = point.toPoint().y();
start_x = x;
start_y = y;
//now lets walk counter-clockwise in the domain along the boundary
while (stop_inner_while == false){
if (qAlpha(image.pixel(x - 1, y + 0)) == alpha){
boundarypixel[2] = 1;
}
else{
boundarypixel[2] = 0;
}
if (qAlpha(image.pixel(x + 0, y + 1)) == alpha){
boundarypixel[3] = 1;
}
else{
boundarypixel[3] = 0;
}
if (qAlpha(image.pixel(x + 1, y - 0)) == alpha){
boundarypixel[4] = 1;
}
else{
boundarypixel[4] = 0;
}
if (qAlpha(image.pixel(x + 0, y - 1)) == alpha){
boundarypixel[5] = 1;
}
else{
boundarypixel[5] = 0;
}
//now lets decide the next point
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
if (zero_decision == 2) x--;
if (zero_decision == 3) y++;
if (zero_decision == 4) x++;
if (zero_decision == 5) y--;
if (zero_decision == 6) x--;
if (zero_decision == 7) x--;
if (zero_decision == 8) y--;
if (zero_decision == 9) y++;
if (zero_decision == 10) y++;
if (zero_decision == 11) x++;
if (zero_decision == 12) x--;
if (zero_decision == 13) y--;
if (zero_decision == 14) x++;
if (zero_decision == 15) y++;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
y--;
zero_decision = 2;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
x--;
zero_decision = 3;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
y++;
zero_decision = 4;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
x++;
zero_decision = 5;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
y--;
zero_decision = 6;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
y--;
zero_decision = 7;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
x++;
zero_decision = 8;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
x--;
zero_decision = 9;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
x--;
zero_decision = 10;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
y++;
zero_decision = 11;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
y--;
zero_decision = 12;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
x++;
zero_decision = 13;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
y++;
zero_decision = 14;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
x--;
zero_decision = 15;
}
for (n = 0; n < 6; n++) boundarypixel[n] = 0;
if ((x<0)||(y>image.width())) break;
break_condition++;
image_tmp_clear.setPixel(x,y,special_color_for_marking.rgba());
if (break_condition == image.width()*image.height()) stop_inner_while = true;
if ((x == start_x)&&(y == start_y)) stop_inner_while = true;
}
stop = true;
}
}
}
if ((x == start_x)&&(y == start_y)){
//Now we make a first check through the image to search for the numbers of the special_mark_color in a row
//for a further changes
for (n = 0; n < image.height(); n++){
for (k = 0; k < image.width(); k++){
if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()){
row_counter++;
}
}
//Now change the marking starting and stopping at the special_mark_color
on = false;
if (row_counter > 1){
for (k = 0; k < image.width(); k++){
if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) row_counter--;
if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) on = false;
if ((image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())&&
(image_tmp_clear.pixel(k+1,n) != special_color_for_marking.rgba()))
{
if (on == false){
on = true;
}
else{
on = false;
}
}
if (row_counter == 0) on = false;
if (on == true) image.setPixel(k+1,n,image_stack::imagestack.at(0).pixel(k+1,n));
}
}
//reset the row_counter
row_counter = 0;
}
}
else{
//first get rid of artefacts of the more intelligent try
for (n = 0; n < image.height(); n++){
for (k = 0; k < image.width(); k++){
if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())
image.setPixel(k,n,image_stack::imagestack.at(0).pixel(k,n));
}
}
}
scene->clear();
pixmap = QPixmap::fromImage(image);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
void MainWindow::insert_wind_emitter ( )

Definition at line 47 of file wind_emitter.cpp.

References counter_wind_emitter, emitter_color_mx, emitter_color_my, emitter_color_x, emitter_color_y, final_mark_color, Ui_MainWindow::graphicsView, Ui_MainWindow::mxdir, Ui_MainWindow::mydir, no_image, pixmap, point, point1, point2, scene, ui, image_stack::wind_emitter, image_stack::wind_emitter_save, Ui_MainWindow::xdir, and Ui_MainWindow::ydir.

Referenced by keyPressEvent().

{
if (no_image == false){
int i;
int j;
i = 0;
j = 0;
if (point1.y() < point2.y()){
if (ui->xdir->isChecked() == true){
for (j = point1.toPoint().y(); j < point2.toPoint().y(); j++){
i = point1.toPoint().x();
if ((wind_emitter.pixel(i,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i+1,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i-1,j) !=final_mark_color.rgba())){
wind_emitter.setPixel(i,j, emitter_color_x.rgba());
wind_emitter_save.setPixel(i,j, emitter_color_x.rgba());
}
}
}
if (ui->mxdir->isChecked() == true){
for (j = point1.toPoint().y(); j < point2.toPoint().y(); j++){
i = point1.toPoint().x();
if ((wind_emitter.pixel(i,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i+1,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i-1,j) !=final_mark_color.rgba())){
wind_emitter.setPixel(i,j, emitter_color_mx.rgba());
wind_emitter_save.setPixel(i,j, emitter_color_mx.rgba());
}
}
}
}
else{
if (ui->xdir->isChecked() == true){
for (j = point2.toPoint().y(); j < point1.toPoint().y(); j++){
i = point2.toPoint().x();
if ((wind_emitter.pixel(i,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i+1,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i-1,j) !=final_mark_color.rgba())) {
wind_emitter.setPixel(i,j, emitter_color_x.rgba());
wind_emitter_save.setPixel(i,j, emitter_color_x.rgba());
}
}
}
if (ui->mxdir->isChecked() == true){
for (j = point2.toPoint().y(); j < point1.toPoint().y(); j++){
i = point2.toPoint().x();
if ((wind_emitter.pixel(i,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i+1,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i-1,j) !=final_mark_color.rgba())){
wind_emitter.setPixel(i,j, emitter_color_mx.rgba());
wind_emitter_save.setPixel(i,j, emitter_color_mx.rgba());
}
}
}
}
if (point1.x() < point2.x()){
if (ui->ydir->isChecked() == true){
for (i = point1.toPoint().x(); i < point2.toPoint().x(); i++){
j = point1.toPoint().y();
if ((wind_emitter.pixel(i,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i,j+1) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i,j-1) !=final_mark_color.rgba())) {
wind_emitter.setPixel(i,j, emitter_color_y.rgba());
wind_emitter_save.setPixel(i,j, emitter_color_y.rgba());
}
}
}
if (ui->mydir->isChecked() == true){
for (i = point1.toPoint().x(); i < point2.toPoint().x(); i++){
j = point1.toPoint().y();
if ((wind_emitter.pixel(i,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i,j+1) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i,j-1) !=final_mark_color.rgba())){
wind_emitter.setPixel(i,j, emitter_color_my.rgba());
wind_emitter_save.setPixel(i,j, emitter_color_my.rgba());
}
}
}
}
else{
if (ui->ydir->isChecked() == true){
for (i = point2.toPoint().x(); i < point1.toPoint().x(); i++){
j = point2.toPoint().y();
if ((wind_emitter.pixel(i,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i,j+1) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i,j-1) !=final_mark_color.rgba())) {
wind_emitter.setPixel(i,j, emitter_color_y.rgba());
wind_emitter_save.setPixel(i,j, emitter_color_y.rgba());
}
}
}
if (ui->mydir->isChecked() == true){
for (i = point2.toPoint().x(); i < point1.toPoint().x(); i++){
j = point2.toPoint().y();
if ((wind_emitter.pixel(i,j) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i,j+1) !=final_mark_color.rgba())&&
(wind_emitter.pixel(i,j-1) !=final_mark_color.rgba())) {
wind_emitter.setPixel(i,j, emitter_color_my.rgba());
wind_emitter_save.setPixel(i,j, emitter_color_my.rgba());
}
}
}
}
}
scene->clear();
pixmap = QPixmap::fromImage(wind_emitter);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
}
void MainWindow::invert_mask ( )
privateslot

Invert the mask

Definition at line 794 of file color_segmentation.cpp.

References final_mark_color, Ui_MainWindow::graphicsView, image_stack::image, image_stack::imagestack, pixmap, scene, ui, and image_stack::wind_emitter.

Referenced by MainWindow().

{
for (int i = 0; i < image.width(); i++){
for (int j = 0; j < image.height(); j++){
if (image.pixel(i,j) == final_mark_color.rgba()){
image.setPixel(i,j,image_stack::imagestack.at(0).pixel(i,j));
}
else{
image.setPixel(i,j,final_mark_color.rgba());
}
}
}
scene->clear();
pixmap = QPixmap::fromImage(image);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
void MainWindow::keyPressEvent ( QKeyEvent *  event)
protected

All the keypress events are defined here

Definition at line 148 of file mainwindow.cpp.

References clear_individual_pixel(), clear_many_pixel_1(), Ui_MainWindow::clearmode, Ui_MainWindow::clearpixel, counter_first_emitter, image_stack::imagestack, insert_wind_emitter(), make_color_mask(), Ui_MainWindow::maksmode, mask_invidual_pixel(), mask_many_pixel_1(), Ui_MainWindow::maskislands, Ui_MainWindow::maskpixel, pick_blue, pick_green, pick_red, point, ui, Ui_MainWindow::windemitter, zoom_in(), and zoom_out().

{
if (event->key() == Qt::Key_E){
}
if (event->key() == Qt::Key_W){
}
if ((event->key() == 16777249)&&(ui->maksmode->isChecked()== true)){
pick_red = qRed(image_stack::imagestack.at(0).pixel(point.toPoint()));
pick_green = qGreen(image_stack::imagestack.at(0).pixel(point.toPoint()));
pick_blue = qBlue(image_stack::imagestack.at(0).pixel(point.toPoint()));
}
if ((event->key() == 16777249)&&(ui->clearmode->isChecked() == true)){
//clear_pixel();
}
if ((event->key() == 16777249)&&(ui->clearpixel->isChecked() == true)){
}
if ((event->key() == 16777249)&&(ui->maskpixel->isChecked() == true)){
}
if ((event->key() == 16777249)&&(ui->maskislands->isChecked() == true)){
}
if ((event->key() == 16777249)&&(ui->windemitter->isChecked() == true)){
}
}
void MainWindow::make_color_mask ( )

This is tychoICGEN - color segmentation file. The core is a maksing of pixels in the same color-range.

Masks the pixels in the given color range.

Definition at line 22 of file color_segmentation.cpp.

References blue_low, blue_up, final_mark_color, Ui_MainWindow::graphicsView, green_low, green_up, image_stack::image, image_stack::imagestack, no_image, pick_blue, pick_green, pick_red, pixmap, red_low, red_up, scene, ui, and image_stack::wind_emitter.

Referenced by keyPressEvent(), and value_change_int().

{
if (no_image == false){
for (int i = 0; i < image.width(); i++){
for (int j = 0; j < image.height(); j++){
if ((qRed(image_stack::imagestack.at(0).pixel(i,j)) >= pick_red - red_low)&&(qRed(image_stack::imagestack.at(0).pixel(i,j)) <= pick_red + red_up)
&&(qGreen(image_stack::imagestack.at(0).pixel(i,j)) >= pick_green - green_low)&&(qGreen(image_stack::imagestack.at(0).pixel(i,j)) <= pick_green + green_up)
&&(qBlue(image_stack::imagestack.at(0).pixel(i,j)) >= pick_blue - blue_low)&&(qBlue(image_stack::imagestack.at(0).pixel(i,j)) <= pick_blue + blue_up)){
image.setPixel(i,j,final_mark_color.rgba());
}
}
}
scene->clear();
pixmap = QPixmap::fromImage(image_stack::imagestack.last());
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
}
void MainWindow::mask_invidual_pixel ( )

Masks individual pixels

Definition at line 777 of file color_segmentation.cpp.

References final_mark_color, Ui_MainWindow::graphicsView, image_stack::image, no_image, pixmap, point, scene, and ui.

Referenced by keyPressEvent().

{
if (no_image == false){
image.setPixel(point.toPoint(), final_mark_color.rgba());
scene->clear();
pixmap = QPixmap::fromImage(image);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
}
void MainWindow::mask_many_pixel ( )

Masks many pixels until a mask pixel is found

Definition at line 705 of file color_segmentation.cpp.

References alpha, final_mark_color, image_stack::image, and point.

Referenced by mask_many_pixel_1().

{
int i;
int j;
if ((point.toPoint().x() >= 0)&&(point.toPoint().x()<image.width())&&(point.toPoint().y() >= 0)
&&(point.toPoint().y()<image.height())){
if (qAlpha(image.pixel(point.toPoint())) != alpha){
for (j = 0; j < image.height() - point.toPoint().y(); j++){
i = 0;
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) == alpha) break;
while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) != alpha){
image.setPixel(point.toPoint().x() + i, point.toPoint().y() + j, final_mark_color.rgba());
if (point.toPoint().x() + i < image.width()-1){
i++;
}
else{
break;
}
}
}
for (j = 0; j < image.height() - point.toPoint().y(); j++){
i = -1;
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) == alpha) break;
while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) != alpha){
image.setPixel(point.toPoint().x() + i, point.toPoint().y() + j, final_mark_color.rgba());
if (point.toPoint().x() + i > 0){
i--;
}
else{
break;
}
}
}
for (j = 1; j < point.toPoint().y()+1; j++){
i = 0;
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) == alpha) break;
while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) != alpha){
image.setPixel(point.toPoint().x() + i, point.toPoint().y() - j, final_mark_color.rgba());
if (point.toPoint().x() + i < image.width()-1){
i++;
}
else{
break;
}
}
}
for (j = 1; j < point.toPoint().y()+1; j++){
i = -1;
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) == alpha) break;
while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) != alpha){
image.setPixel(point.toPoint().x() + i, point.toPoint().y() - j, final_mark_color.rgba());
if (point.toPoint().x() + i > 0){
i--;
}
else{
break;
}
}
}
}
}
}
void MainWindow::mask_many_pixel_1 ( )

Masks many pixels, good to mask islands in the mask

Definition at line 445 of file color_segmentation.cpp.

References alpha, alpha_special_marking, final_mark_color, Ui_MainWindow::graphicsView, image_stack::image, image_stack::imagestack, mask_many_pixel(), pixmap, point, scene, ui, and image_stack::wind_emitter.

Referenced by keyPressEvent().

{
int boundarypixel[6];
QImage image_tmp_clear;
QColor special_color_for_marking;
bool stop;
bool stop_inner_while;
bool on;
int i;
int n;
int x;
int y;
int k;
int start_x;
int start_y;
int zero_decision;
int row_counter;
int break_condition;
stop = false;
stop_inner_while = false;
on = false;
i = 0;
n = 0;
x = 0;
y = 0;
k = 0;
start_x = 1;
start_y = 0;
zero_decision = 0;
row_counter = 0;
break_condition = 0;
for (n = 0; n < 6; n++) boundarypixel[n] = 0;
special_color_for_marking.setAlpha(alpha_special_marking);
image_tmp_clear = image;
if ((point.toPoint().x() >= 0)&&(point.toPoint().x()<image.width())
&&(point.toPoint().y() >= 0)
&&(point.toPoint().y()<image.height())
&& (qAlpha(image.pixel(point.toPoint().x(),point.toPoint().y()))) != alpha){
while (stop == false){
//first we go out of the whole in the mask
if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y())) != alpha) {
if (point.toPoint().x() + i < image.width() - 1){
i++;
}
else{
//This is no island in the mask, we stop this procedure here
stop = true;
break;
}
}
else
{
//The first pixel in the boundary is found.
//If boundary is not a mask point the vluse 1 in the vector at the highlighted place
//| |2| |
//|1|x|3|
//| |4| |
//1 - boundarypixel[2]
//2 - boundarypixel[3]
//3 - boundarypixel[4]
//4 - boundarypixel[5]
x = point.toPoint().x() + i;
y = point.toPoint().y();
start_x = x;
start_y = y;
//now lets walk counter-clockwise in the domain along the boundary
while (stop_inner_while == false){
if (qAlpha(image.pixel(x - 1, y + 0)) != alpha){
boundarypixel[2] = 1;
}
else{
boundarypixel[2] = 0;
}
if (qAlpha(image.pixel(x + 0, y + 1)) != alpha){
boundarypixel[3] = 1;
}
else{
boundarypixel[3] = 0;
}
if (qAlpha(image.pixel(x + 1, y - 0)) != alpha){
boundarypixel[4] = 1;
}
else{
boundarypixel[4] = 0;
}
if (qAlpha(image.pixel(x + 0, y - 1)) != alpha){
boundarypixel[5] = 1;
}
else{
boundarypixel[5] = 0;
}
//now lets decide the next point
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
if (zero_decision == 2) x--;
if (zero_decision == 3) y++;
if (zero_decision == 4) x++;
if (zero_decision == 5) y--;
if (zero_decision == 6) x--;
if (zero_decision == 7) x--;
if (zero_decision == 8) y--;
if (zero_decision == 9) y++;
if (zero_decision == 10) y++;
if (zero_decision == 11) x++;
if (zero_decision == 12) x--;
if (zero_decision == 13) y--;
if (zero_decision == 14) x++;
if (zero_decision == 15) y++;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
y--;
zero_decision = 2;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
x--;
zero_decision = 3;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
y++;
zero_decision = 4;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
x++;
zero_decision = 5;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
y--;
zero_decision = 6;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
y--;
zero_decision = 7;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
x++;
zero_decision = 8;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
x--;
zero_decision = 9;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
x--;
zero_decision = 10;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
y++;
zero_decision = 11;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
y--;
zero_decision = 12;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
x++;
zero_decision = 13;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
y++;
zero_decision = 14;
}
if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
x--;
zero_decision = 15;
}
if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
break;
}
for (n = 0; n < 6; n++) boundarypixel[n] = 0;
if ((x<0)||(y>image.width())) break;
break_condition++;
image_tmp_clear.setPixel(x,y,special_color_for_marking.rgba());
if (break_condition == image.width()*image.height()) stop_inner_while = true;
if ((x == start_x)&&(y == start_y)) stop_inner_while = true;
}
stop = true;
}
}
}
if ((x == start_x)&&(y == start_y)){
//Now we make a first check through the image to search for the numbers of the special_mark_color in a row
//for a further changes
for (n = 0; n < image.height(); n++){
for (k = 0; k < image.width(); k++){
if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()){
row_counter++;
}
}
//Now change the marking starting and stopping at the special_mark_color
on = false;
if (row_counter > 1){
for (k = 0; k < image.width(); k++){
if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) row_counter--;
if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) on = false;
if ((image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())&&
(image_tmp_clear.pixel(k+1,n) != special_color_for_marking.rgba()))
{
if (on == false){
on = true;
}
else{
on = false;
}
}
if (row_counter == 0) on = false;
if (on == true) image.setPixel(k+1,n,final_mark_color.rgba());//image_stack::imagestack.at(0).pixel(k+1,n));
}
}
//reset the row_counter
row_counter = 0;
}
}
else{
//first get rid of artefacts of the more intelligent try
for (n = 0; n < image.height(); n++){
for (k = 0; k < image.width(); k++){
if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())
image.setPixel(k,n,image_stack::imagestack.at(0).pixel(k,n));
}
}
}
scene->clear();
pixmap = QPixmap::fromImage(image);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
void MainWindow::mask_pixmap ( )
void MainWindow::memo_color_mask ( )
privateslot

A maks is put on the mask-stack

Definition at line 56 of file color_segmentation.cpp.

References counter, Ui_MainWindow::graphicsView, image_stack::image, image_stack::imagestack, Ui_MainWindow::invertmask, pixmap, scene, and ui.

Referenced by MainWindow().

{
scene->clear();
pixmap = QPixmap::fromImage(image);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
//now we can enable mask inverter
ui->invertmask->setEnabled(true);
}
void MainWindow::open_about ( )
privateslot

Opens the about window

Definition at line 258 of file mainwindow.cpp.

References myabout.

Referenced by MainWindow().

{
myabout = new about;
myabout->show();
}
void MainWindow::open_color_mask ( )
privateslot

Open the colormask window

Definition at line 248 of file mainwindow.cpp.

References mycolormask.

Referenced by MainWindow().

{
mycolormask->show();
}
void MainWindow::open_tutorial ( )
privateslot

Opens the tutorial window

Definition at line 268 of file mainwindow.cpp.

References mytutorial.

Referenced by MainWindow().

{
mytutorial->show();
}
void MainWindow::openfile ( )
privateslot

Open / Save files

Opens an Image

Definition at line 17 of file openfile.cpp.

References file, Ui_MainWindow::graphicsView, image_stack::image, Ui_MainWindow::image_depth, Ui_MainWindow::image_height, Ui_MainWindow::image_width, imageheight, image_stack::imagestack, imagewidth, no_image, pixmap, pixmapheight, pixmapwidth, Ui_MainWindow::reset_mask, scene, ui, image_stack::wind_emitter, and image_stack::wind_emitter_save.

Referenced by MainWindow().

{
file = QFileDialog::getOpenFileName(this, tr("Open File"),"/home/kapf/tmp",tr("Images (*.jpeg *.jpg *.png *.bmp *.gif *.tif)"));
image.load(file);
image = image.convertToFormat(QImage::Format_ARGB32,Qt::AutoColor);
image = image.mirrored(false, true);
wind_emitter_save.fill(Qt::white);
imagewidth = image.width();
imageheight = image.height();
ui->image_width->setText(QString::number(imagewidth));
ui->image_height->setText(QString::number(imageheight));
pixmap = QPixmap::fromImage(image_stack::imagestack.at(0));
pixmapwidth = pixmap.width();
pixmapheight = pixmap.height();
scene = new myscene();
scene->addPixmap(pixmap);
ui->reset_mask->setEnabled(true);
ui->graphicsView->setScene(scene);
ui->graphicsView->rotate(180);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
QApplication::setOverrideCursor(Qt::ArrowCursor);
ui->graphicsView->setFocus();
no_image = false;
//now we activate the high, width and depth fields
ui->image_width->setEnabled(true);
ui->image_height->setEnabled(true);
ui->image_depth->setEnabled(true);
}
void MainWindow::quit ( )
privateslot

Standard quit

Definition at line 279 of file mainwindow.cpp.

Referenced by MainWindow().

{
qApp->exit();
}
void MainWindow::reset_mask ( )
privateslot

resets the mask

Definition at line 206 of file mainwindow.cpp.

References counter, counter_first_emitter, counter_wind_emitter, file, Ui_MainWindow::graphicsView, image_stack::image, Ui_MainWindow::image_depth, Ui_MainWindow::image_height, Ui_MainWindow::image_width, imageheight, image_stack::imagestack, imagewidth, Ui_MainWindow::invertmask, pixmap, pixmapheight, pixmapwidth, Ui_MainWindow::reset_mask, scene, ui, image_stack::wind_emitter, and image_stack::wind_emitter_save.

Referenced by MainWindow().

{
counter = 0;
ui->invertmask->setEnabled(false);
image.load(file);
image = image.convertToFormat(QImage::Format_ARGB32,Qt::AutoColor);
image = image.mirrored(false, true);
imagewidth = image.width();
imageheight = image.height();
ui->image_width->setText(QString::number(imagewidth));
ui->image_height->setText(QString::number(imageheight));
ui->image_depth->setText("0");
pixmap = QPixmap::fromImage(image_stack::imagestack.at(0));
pixmapwidth = pixmap.width();
pixmapheight = pixmap.height();
scene = new myscene();
scene->addPixmap(pixmap);
ui->reset_mask->setEnabled(true);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
void MainWindow::reset_wind_emitter ( )
privateslot

Definition at line 202 of file wind_emitter.cpp.

References Ui_MainWindow::graphicsView, image_stack::image, no_image, pixmap, scene, ui, image_stack::wind_emitter, and image_stack::wind_emitter_save.

Referenced by MainWindow().

{
if (no_image == false){
scene->clear();
pixmap = QPixmap::fromImage(wind_emitter);
scene->addPixmap(pixmap);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
ui->graphicsView->setFocus();
}
}
void MainWindow::resizeEvent ( QResizeEvent *  event)
protected

Changes the size of the viewer at resizing the mainwindiw

Definition at line 136 of file mainwindow.cpp.

References Ui_MainWindow::graphicsView, and ui.

{
int width = MainWindow::width()-20;
int heigth = MainWindow::height()-200;
ui->graphicsView->setGeometry(10,140,width, heigth);
}
void MainWindow::rotate_by_90 ( )
privateslot

*rotate by 90 degree

Definition at line 322 of file mainwindow.cpp.

References Ui_MainWindow::graphicsView, and ui.

Referenced by MainWindow().

{
ui->graphicsView->rotate(90);
}
void MainWindow::save_masked_image ( )
privateslot

saves a masked image for further masking action

Definition at line 63 of file openfile.cpp.

References file, file_masked_image_save, image_stack::image, and no_image.

Referenced by MainWindow().

{
if (no_image == false){
file_masked_image_save = QFileDialog::getSaveFileName(this, tr("Save Masked Image"),"/home/kapf/tmp",tr("Images (*.png)"));
if(file.suffix().isEmpty()) file_masked_image_save += ".png";
}
}
void MainWindow::save_wind_emitter ( )
privateslot

Saves a TYCHO Wind-Emitter file

Definition at line 180 of file openfile.cpp.

References emitter_color_mx, emitter_color_my, emitter_color_x, emitter_color_y, file, file_save, image_stack::image, Ui_MainWindow::image_depth, no_image, ui, and image_stack::wind_emitter_save.

Referenced by MainWindow().

{
if(no_image == false){
FILE *fd;
QString filename;
QColor tmp1;
int tmp;
file_save = QFileDialog::getSaveFileName(this, tr("Save Wind - Emitter"),"/home/kapf/tmp",tr("tycho IC (*.tyc)"));
QFileInfo file(file_save);
if(file.suffix().isEmpty()) file_save += ".tyc";
if ((file_save != NULL)&&(no_image == false)){
filename = file_save;
fd = fopen(filename.toUtf8(), "w");
fprintf(fd,"This is a TYCHO wind-emitter file.\n");
fprintf(fd,"X %i\n", image.width());
fprintf(fd,"Y %i\n", image.height());
fprintf(fd,"Y %i\n", ui->image_depth->text().toInt());
fseek(fd, 200, SEEK_SET);
for (int j = 0; j < image.width(); j++) {
for (int k = 0; k < image.height(); k++) {
for (int i = 0; i < ui->image_depth->text().toInt(); i++) {
tmp1 = wind_emitter_save.pixel(j,k);
if (tmp1 == emitter_color_x.rgba()) {
tmp=2;
if (!fwrite(&tmp, 1, sizeof (int), fd)) break;
}
else if (tmp1 == emitter_color_mx.rgba()) {
tmp=3;
if (!fwrite(&tmp, 1, sizeof (int), fd)) break;;
}
else if (tmp1 == emitter_color_y.rgba()) {
tmp=4;
if (!fwrite(&tmp, 1, sizeof (int), fd)) break;;
}
else if (tmp1 == emitter_color_my.rgba()) {
tmp=5;
if (!fwrite(&tmp, 1, sizeof (int), fd)) break;;
}
else{
tmp=0;
if (!fwrite(&tmp, 1, sizeof (int), fd)) break;;
}
}
}
}
fclose(fd);
}
}
}
void MainWindow::savefile ( )
privateslot

Saves a TYCHO boundary file

Definition at line 80 of file openfile.cpp.

References file, file_save, final_mark_color, image_stack::image, Ui_MainWindow::image_depth, image_stack::imagestack, no_image, and ui.

Referenced by MainWindow().

{
if(no_image == false){
FILE *fd;
QString filename;
QColor tmp1;
int tmp;
file_save = QFileDialog::getSaveFileName(this, tr("Save File"),"/home/kapf/tmp",tr("tycho IC (*.tyc)"));
QFileInfo file(file_save);
if(file.suffix().isEmpty()) file_save += ".tyc";
if ((file_save != NULL)&&(no_image == false)){
filename = file_save;
fd = fopen(filename.toUtf8(), "w");
fprintf(fd,"This is a TYCHO boundary condition file.\n");
fprintf(fd,"X %i\n", image.width());
fprintf(fd,"Y %i\n", image.height());
fprintf(fd,"Z %i\n", ui->image_depth->text().toInt());
fseek(fd, 200, SEEK_SET);
for (int j = 0; j < image.width(); j++) {
for (int k = 0; k < image.height(); k++) {
tmp1 = image.pixel(j,k);
if (tmp1 == final_mark_color.rgba()) {
tmp=1;
for (int i = 0; i < ui->image_depth->text().toInt(); i++) if (!fwrite(&tmp, 1, sizeof (int), fd)) break;;
}
else{
tmp=0;
for (int i = 0; i < ui->image_depth->text().toInt(); i++) if (!fwrite(&tmp, 1, sizeof (int), fd)) break;;
}
}
}
fclose(fd);
}
}
}
void MainWindow::savefile_soundemitter ( )
privateslot

Saves a TYCHO soundemitter file

Definition at line 130 of file openfile.cpp.

References file, file_save, final_mark_color, image_stack::image, Ui_MainWindow::image_depth, image_stack::imagestack, no_image, and ui.

Referenced by MainWindow().

{
if(no_image == false){
FILE *fd;
QString filename;
QColor tmp1;
int tmp;
file_save = QFileDialog::getSaveFileName(this, tr("Save File"),"/home/kapf/tmp",tr("tycho IC (*.tyc)"));
QFileInfo file(file_save);
if(file.suffix().isEmpty()) file_save += ".tyc";
if ((file_save != NULL)&&(no_image == false)){
filename = file_save;
fd = fopen(filename.toUtf8(), "w");
fprintf(fd,"This is a TYCHO soundemitter file.\n");
fprintf(fd,"X %i\n", image.width());
fprintf(fd,"Y %i\n", image.height());
fprintf(fd,"Z %i\n", ui->image_depth->text().toInt());
fseek(fd, 200, SEEK_SET);
for (int j = 0; j < image.width(); j++) {
for (int k = 0; k < image.height(); k++) {
tmp1 = image.pixel(j,k);
if (tmp1 == final_mark_color.rgba()) {
tmp=1;
for (int i = 0; i < ui->image_depth->text().toInt(); i++) if (!fwrite(&tmp, 1, sizeof (int), fd)) break;;
}
else{
tmp=0;
for (int i = 0; i < ui->image_depth->text().toInt(); i++) if (!fwrite(&tmp, 1, sizeof (int), fd)) break;;
}
}
}
fclose(fd);
}
}
}
void MainWindow::scale_image ( )
privateslot

Rescale the image

Definition at line 287 of file mainwindow.cpp.

References Ui_MainWindow::graphicsView, image_stack::image, Ui_MainWindow::image_height, Ui_MainWindow::image_width, image_stack::imagestack, pixmap, pixmapheight, pixmapwidth, Ui_MainWindow::reset_mask, scene, ui, image_stack::wind_emitter, and image_stack::wind_emitter_save.

Referenced by MainWindow().

{
int x, y;
x = ui->image_width->text().toInt();
y = ui->image_width->text().toInt();
ui->image_width->setText(QString::number(x));
ui->image_height->setText(QString::number(y));
image = image.scaled(x,y,Qt::KeepAspectRatio,Qt::FastTransformation);
wind_emitter = wind_emitter.scaled(x,y,Qt::KeepAspectRatio,Qt::FastTransformation);
//pixmap = QPixmap::fromImage(image_stack::imagestack.last());
pixmap = QPixmap::fromImage(wind_emitter);
pixmapwidth = pixmap.width();
pixmapheight = pixmap.height();
scene = new myscene();
scene->addPixmap(pixmap);
ui->reset_mask->setEnabled(true);
ui->graphicsView->setScene(scene);
ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
QApplication::setOverrideCursor(Qt::ArrowCursor);
ui->graphicsView->setFocus();
}
void MainWindow::scale_original ( )
privateslot

Definition at line 22 of file viewing.cpp.

References Ui_MainWindow::graphicsView, and ui.

Referenced by MainWindow().

{
ui->graphicsView->resetTransform();
ui->graphicsView->setAlignment(Qt::AlignTop);
}
void MainWindow::scale_to_width ( )
privateslot

Zooming and viewing

Definition at line 15 of file viewing.cpp.

References Ui_MainWindow::graphicsView, image_stack::image, and ui.

Referenced by MainWindow().

{
ui->graphicsView->fitInView(image.rect(), Qt::KeepAspectRatio);
ui->graphicsView->setAlignment(Qt::AlignTop);
}
void MainWindow::undo_mask_pixmap ( )
void MainWindow::value_change_int ( )
privateslot

checks when the colormask values are changed

Definition at line 195 of file mainwindow.cpp.

References make_color_mask(), toCheck, and value.

Referenced by MainWindow().

{
if (value != toCheck){
}
}
void MainWindow::wind_emitter_off ( )
privateslot

Definition at line 29 of file wind_emitter.cpp.

References Ui_MainWindow::mxdir, Ui_MainWindow::mydir, Ui_MainWindow::resetwindemitter, ui, Ui_MainWindow::xdir, and Ui_MainWindow::ydir.

Referenced by MainWindow().

{
ui->xdir->setChecked(true);
ui->mxdir->setChecked(false);
ui->ydir->setChecked(false);
ui->mydir->setChecked(false);
ui->xdir->setDisabled(true);
ui->ydir->setDisabled(true);
ui->mxdir->setDisabled(true);
ui->mydir->setDisabled(true);
ui->resetwindemitter->setDisabled(true);
}
void MainWindow::wind_emitter_on ( )
privateslot

Setting up a wind-emitter

Definition at line 16 of file wind_emitter.cpp.

References Ui_MainWindow::mxdir, Ui_MainWindow::mydir, Ui_MainWindow::resetwindemitter, ui, Ui_MainWindow::xdir, and Ui_MainWindow::ydir.

Referenced by MainWindow().

{
ui->xdir->setEnabled(true);
ui->ydir->setEnabled(true);
ui->mxdir->setEnabled(true);
ui->mydir->setEnabled(true);
ui->resetwindemitter->setEnabled(true);
ui->xdir->setChecked(true);
}
void MainWindow::zoom_in ( )
privateslot

Definition at line 29 of file viewing.cpp.

References Ui_MainWindow::graphicsView, image_stack::image, ui, and Ui_MainWindow::zoom_factor.

Referenced by keyPressEvent(), and MainWindow().

{
qreal zoomfactor;
zoomfactor = (100.0 + ui->zoom_factor->text().toDouble())/100.0;
if (image.isNull()==false) ui->graphicsView->scale(zoomfactor,zoomfactor);
}
void MainWindow::zoom_out ( )
privateslot

Definition at line 40 of file viewing.cpp.

References Ui_MainWindow::graphicsView, image_stack::image, ui, and Ui_MainWindow::zoom_factor.

Referenced by keyPressEvent(), and MainWindow().

{
qreal zoomfactor;
zoomfactor = (100.0 + ui->zoom_factor->text().toDouble())/100.0;
zoomfactor = 1.0/zoomfactor;
if (image.isNull()==false) ui->graphicsView->scale(zoomfactor,zoomfactor);
}

Field Documentation

int MainWindow::alpha

Definition at line 52 of file mainwindow.h.

Referenced by clear_many_pixel(), clear_many_pixel_1(), MainWindow(), mask_many_pixel(), and mask_many_pixel_1().

int MainWindow::alpha_emitter

Definition at line 54 of file mainwindow.h.

Referenced by MainWindow().

int MainWindow::alpha_special_marking

Definition at line 53 of file mainwindow.h.

Referenced by clear_many_pixel_1(), MainWindow(), and mask_many_pixel_1().

int MainWindow::counter

Definition at line 48 of file mainwindow.h.

Referenced by MainWindow(), memo_color_mask(), and reset_mask().

int MainWindow::counter_first_emitter

Definition at line 50 of file mainwindow.h.

Referenced by keyPressEvent(), MainWindow(), and reset_mask().

int MainWindow::counter_wind_emitter

Definition at line 49 of file mainwindow.h.

Referenced by insert_wind_emitter(), MainWindow(), and reset_mask().

QColor MainWindow::emitter_color_mx

Definition at line 39 of file mainwindow.h.

Referenced by insert_wind_emitter(), MainWindow(), and save_wind_emitter().

QColor MainWindow::emitter_color_my

Definition at line 41 of file mainwindow.h.

Referenced by insert_wind_emitter(), MainWindow(), and save_wind_emitter().

QColor MainWindow::emitter_color_x

Definition at line 38 of file mainwindow.h.

Referenced by insert_wind_emitter(), MainWindow(), and save_wind_emitter().

QColor MainWindow::emitter_color_y

Definition at line 40 of file mainwindow.h.

Referenced by insert_wind_emitter(), MainWindow(), and save_wind_emitter().

QVector<QPoint> MainWindow::emitter_points

Definition at line 28 of file mainwindow.h.

QString MainWindow::file

Definition at line 33 of file mainwindow.h.

Referenced by openfile(), reset_mask(), save_masked_image(), save_wind_emitter(), savefile(), and savefile_soundemitter().

QString MainWindow::file_masked_image_save

Definition at line 35 of file mainwindow.h.

Referenced by save_masked_image().

QString MainWindow::file_save

Definition at line 34 of file mainwindow.h.

Referenced by save_wind_emitter(), savefile(), and savefile_soundemitter().

QColor MainWindow::final_mark_color

Definition at line 37 of file mainwindow.h.

Referenced by insert_wind_emitter(), invert_mask(), MainWindow(), make_color_mask(), mask_invidual_pixel(), mask_many_pixel(), mask_many_pixel_1(), savefile(), and savefile_soundemitter().

int MainWindow::imageheight

Definition at line 44 of file mainwindow.h.

Referenced by openfile(), and reset_mask().

int MainWindow::imagewidth

Definition at line 43 of file mainwindow.h.

Referenced by openfile(), and reset_mask().

int MainWindow::maskwidth

Definition at line 47 of file mainwindow.h.

bool MainWindow::mousebutton_pressed

Definition at line 55 of file mainwindow.h.

about* MainWindow::myabout

Definition at line 32 of file mainwindow.h.

Referenced by open_about().

colormask* MainWindow::mycolormask

Definition at line 30 of file mainwindow.h.

Referenced by open_color_mask().

tutorial* MainWindow::mytutorial

Definition at line 31 of file mainwindow.h.

Referenced by open_tutorial().

QPixmap MainWindow::pixmap

Definition at line 27 of file mainwindow.h.

Referenced by clear_individual_pixel(), clear_last_color_mask(), clear_many_pixel_1(), insert_wind_emitter(), invert_mask(), make_color_mask(), mask_invidual_pixel(), mask_many_pixel_1(), memo_color_mask(), openfile(), reset_mask(), reset_wind_emitter(), and scale_image().

int MainWindow::pixmapheight

Definition at line 46 of file mainwindow.h.

Referenced by openfile(), reset_mask(), and scale_image().

int MainWindow::pixmapwidth

Definition at line 45 of file mainwindow.h.

Referenced by openfile(), reset_mask(), and scale_image().

QPointF MainWindow::point1

Definition at line 36 of file mainwindow.h.

Referenced by insert_wind_emitter().

QPointF MainWindow::point2

Definition at line 36 of file mainwindow.h.

Referenced by insert_wind_emitter().

myscene* MainWindow::scene

Definition at line 29 of file mainwindow.h.

Referenced by clear_individual_pixel(), clear_last_color_mask(), clear_many_pixel_1(), insert_wind_emitter(), invert_mask(), make_color_mask(), mask_invidual_pixel(), mask_many_pixel_1(), memo_color_mask(), openfile(), reset_mask(), reset_wind_emitter(), and scale_image().

int MainWindow::toCheck

Definition at line 51 of file mainwindow.h.

Referenced by MainWindow(), and value_change_int().

Ui::MainWindow* MainWindow::ui
private

Definition at line 71 of file mainwindow.h.

Referenced by clear_individual_pixel(), clear_last_color_mask(), clear_many_pixel_1(), insert_wind_emitter(), invert_mask(), keyPressEvent(), MainWindow(), make_color_mask(), mask_invidual_pixel(), mask_many_pixel_1(), memo_color_mask(), openfile(), reset_mask(), reset_wind_emitter(), resizeEvent(), rotate_by_90(), save_wind_emitter(), savefile(), savefile_soundemitter(), scale_image(), scale_original(), scale_to_width(), wind_emitter_off(), wind_emitter_on(), zoom_in(), zoom_out(), and ~MainWindow().


The documentation for this class was generated from the following files: