//generate selection
void MainWindow::generate()
{
    if (distributions.isEmpty())
        return;

    selectionSize = ui.selectionDimention->value();

    //generate selections for all distributions
    for (int i = 0; i < distributions.size(); ++i)
    {
        int selection_size_for_current_distribution = static_cast<int>(static_cast<double>(selectionSize)*distributions[i].parameters.get_a_priori_probability());

        distributions[i].selection.SetSize(selection_size_for_current_distribution, distributions[i].parameters.get_m());

        distributions[i].selectionVectorsInfo.resize(selection_size_for_current_distribution);

        //generate random vectors with a given distribution
        distributions[i].parameters.generate_selection(distributions[i].selection);

        //set true distribution for all generated random vectors
        for (int j = 0; j < distributions[i].selectionVectorsInfo.size(); ++j)
        {
            distributions[i].selectionVectorsInfo[j].trueDistribution = i;
            distributions[i].selectionVectorsInfo[j].recognizedDistribution = 65535;
        }
    }

    selectionGenerated = true;

    calculate_values();
}
void MainWindow::setup_connections()
{
    //connect buttons for choosing colors for distribution visualization
    connect(ui.chooseColorButton1, SIGNAL(clicked()), this, SLOT(choose_color_1()));
    connect(ui.chooseColorButton2, SIGNAL(clicked()), this, SLOT(choose_color_2()));

    //connect button for load distributions from file
    connect(ui.loadButton, SIGNAL(clicked()), this, SLOT(load()));

    //connect button for load regret matrix
//    connect(ui.loadRegretMatrixPushButton, SIGNAL(clicked()), this, SLOT(load_regret_matrix()));

    //connect button for saving selection
    connect(ui.buttonSaveSelection, SIGNAL(clicked()), this, SLOT(save_selection()));

    //connect button for generate selection
    connect(ui.generateButton, SIGNAL(clicked()), this, SLOT(generate()));

    //connect button for recognizing
    connect(ui.recognizeButton, SIGNAL(clicked()), this, SLOT(recognize()));

    //connect button for calculate values
    connect(ui.drawButton, SIGNAL(clicked()), this, SLOT(calculate_values()));
    connect(ui.component1, SIGNAL(editingFinished()), this, SLOT(calculate_values()));
    connect(ui.component2, SIGNAL(editingFinished()), this, SLOT(calculate_values()));

    //connect zoom sliders
    connect(ui.zoomX, SIGNAL(valueChanged(int)), this, SLOT(draw()));
    connect(ui.zoomY, SIGNAL(valueChanged(int)), this, SLOT(draw()));

    //connect checkboxes
    connect(ui.checkBoxDrawAxises, SIGNAL(clicked()), this, SLOT(draw()));
    connect(ui.checkBoxDrawReal, SIGNAL(clicked()), this, SLOT(draw()));
    connect(ui.checkBoxIsolines, SIGNAL(clicked()), this, SLOT(draw()));
    connect(ui.checkBoxMiddle, SIGNAL(clicked()), this, SLOT(draw()));
    connect(ui.checkBoxRecognized, SIGNAL(clicked()), this, SLOT(draw()));
    connect(ui.checkBoxSelection, SIGNAL(clicked()), this, SLOT(draw()));

    //connect button click action to transformationMatrixDialog show action
    connect(ui.transformationButton, SIGNAL(clicked()), this, SLOT(show_transformation_matrix()));
    connect(ui.showCorrelationMatrixPushButton1, SIGNAL(clicked()), this, SLOT(show_matrix_of_correlations1()));
    connect(ui.showCorrelationMatrixPushButton2, SIGNAL(clicked()), this, SLOT(show_matrix_of_correlations2()));
}
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags),
    m(0), a(NULL), b(NULL), __a__(NULL), x(NULL), selectionSize(100),
    inputDataLoaded(false), selectionGenerated(false), kxy(0.0), middleX(0.0), middleY(0.0),
    shiftX(10.0), shiftY(10.0), sigmaX(0.0), sigmaY(0.0), r(0.0), scene(NULL)
{
    ui.setupUi(this);

    connect(ui.loadButton, SIGNAL(clicked()), this, SLOT(load()));
    connect(ui.generateButton, SIGNAL(clicked()), this, SLOT(generate()));
    connect(ui.drawButton, SIGNAL(clicked()), this, SLOT(calculate_values()));
    //connect(ui.drawButton, SIGNAL(clicked()), this, SLOT(draw()));
    connect(ui.zoomX, SIGNAL(valueChanged(int)), this, SLOT(draw()));
    connect(ui.zoomY, SIGNAL(valueChanged(int)), this, SLOT(draw()));
    connect(ui.checkBoxSelection, SIGNAL(stateChanged(int)), this, SLOT(draw()));
    connect(ui.checkBoxMiddle, SIGNAL(stateChanged(int)), this, SLOT(draw()));
    connect(ui.checkBoxIsolines, SIGNAL(stateChanged(int)), this, SLOT(draw()));
    connect(ui.component1, SIGNAL(editingFinished()), this, SLOT(calculate_values()));
    connect(ui.component2, SIGNAL(editingFinished()), this, SLOT(calculate_values()));
    connect(ui.buttonSaveSelection, SIGNAL(clicked()), this, SLOT(saveSelection()));

    srand(QTime::currentTime().elapsed());
}
Ejemplo n.º 4
0
void stop_edit()
{
	if (is_edit)
	{
		cell_box.flags &= ~ed_focus;
		if (cells[sel_x][sel_y])
			freemem(cells[sel_x][sel_y]);
		if (strlen(edit_text) > 0)
		{
			cells[sel_x][sel_y] = (char*)allocmem(strlen(edit_text)+1);
			strcpy(cells[sel_x][sel_y], edit_text);
		}
		else
			cells[sel_x][sel_y] = NULL;
		//memset((Byte*)edit_text,0, 256);
		calculate_values();
	}
}
Ejemplo n.º 5
0
 /**
  * @param data_count sets the data count
  */
 inline void set_data_count(int data_count) {
   data_count_ = data_count;
   calculate_values();
 };
Ejemplo n.º 6
0
 /**
  * @param value changes the quantity by the value
  */
 inline void change_quantity_by(int value) {
   quantity_ += value;
   calculate_values();
 };
Ejemplo n.º 7
0
 /**
  * @param quantity sets the quantity of the data the object represents
  */
 inline void set_quantity(int quantity) {
   quantity_ = quantity;
   calculate_values();
 };
Ejemplo n.º 8
0
void process_key()
{
	Dword mouse_btn, ckeys, shift, ctrl;
	int mouse_x, mouse_y, dx = 0, dy = 0;

	// key pressed, read it 
	Byte keyCode;
	ckeys = kos_GetSpecialKeyState();
	shift = ckeys & 0x3;
	ctrl = ckeys & 0x0c;
	//if (ctrl)
	//	rtlDebugOutString("control pressed!");
	dx = 0, dy = 0;
	sel_moved = 0;
	sel_end_move = 0;
	kos_GetKey(keyCode);

	__asm
	{
		mov ah, keyCode
	}
	edit_box_key((dword)&cell_box);
	edit_box_key((dword)&file_box);


	switch (keyCode)
	{
		case 178:			// стрелки
			//dx = 0;
			dy = -1;
			break;
		case 176:
			dx = -1;
			//dy = 0;
			break;
		case 179:
			dx = 1;
			//dy = 0;
			break;
		case 177:
			//dx = 0;
			dy = 1;
			break;
		/*
		case 183:
			if (sel_y < row_count-(ny - scroll_y))	// page down
				dy = ny - scroll_y;
			else
				dy = row_count-(ny - scroll_y) - sel_y;
			dx = 0;
			redraw = 1;
			break;
		case 184:
			if (sel_y > ny - scroll_y)		// page up
				dy= - (ny - scroll_y);
			else
				dy = - (ny - scroll_y) + sel_y;
			dx = 0;
			redraw = 1;
			break;
		*/
		case 180: //home
			dx = -sel_x + 1;
			dy = 0;
			draw_grid(); //draw_window(); 
			break;
		case 181: //end
			dx = col_count - (nx - scroll_x) - 1 - sel_x;
			dy = 0;
			draw_grid(); //draw_window();
			break;
		case 27:		// escape
			cancel_edit();
			break;
		case 182:			// delete
			{
				int i,j,n0,n1,k0,k1;
				n0 = min(sel_x, sel_end_x);
				n1 = max(sel_x, sel_end_x);
				k0 = min(sel_y, sel_end_y);
				k1 = max(sel_y, sel_end_y);

				for (i = n0; i <= n1; i++)
					for (j = k0; j <= k1; j++)
					{
						if (cells[i][j])
						{
							freemem(cells[i][j]);
							cells[i][j] = NULL;
						}
					}
				calculate_values();
				draw_grid();
				break;
			}
		case 0x0D:			// enter
			if (is_edit)
			{
				stop_edit();
				draw_window();
			}
			break;
		case 22:	// contol-v
			{
				if (ctrl)
				{
					//rtlDebugOutString("control-v!");
					int i, j, x0, y0;
					x0 = min(sel_x, sel_end_x);
					y0 = min(sel_y, sel_end_y);
					int delta_x = x0 - buf_old_x;
					int delta_y = y0 - buf_old_y;

					for (i = 0; i < buf_col; i++)
						for (j = 0; j < buf_row; j++)
						{
							if (i + x0 >= col_count || j + y0 >= row_count)
								continue;
							if (cells[i + x0][j + y0])
								freemem(cells[i + x0][j + y0]);
							if (buffer[i][j])
							{
								cf_x0 = buf_old_x; cf_y0 = buf_old_y;
								cf_x1 = buf_old_x + buf_col;
								cf_y1 = buf_old_y + buf_row;
								cells[i + x0][j + y0] = change_formula(buffer[i][j], delta_x, delta_y);
								//cells[i + x0][j + y0] = (char*)allocmem(strlen(buffer[i][j]));
								//strcpy(cells[i + x0][j + y0], buffer[i][j]);
							}
							else
								cells[i + x0][j + y0] = NULL;
						}

					calculate_values();
					draw_window();
					break;
				}
			}
			case 24:	// control-x
			case 03:	// control-c
			{
				if (ctrl)
				{
					//rtlDebugOutString("control-c!");
					int i, j, x0, y0;

					freeBuffer();

					buf_col = abs(sel_end_x - sel_x) + 1;
					buf_row = abs(sel_end_y - sel_y) + 1;
					x0 = min(sel_x, sel_end_x);
					y0 = min(sel_y, sel_end_y);
					buf_old_x = x0;
					buf_old_y = y0;

					//sprintf(debuf, "%U %U %U %U", buf_col, buf_row, x0, y0);
					//rtlDebugOutString(debuf);
				
					buffer = (char***)allocmem(buf_col * sizeof(char**));
					for (i = 0; i < buf_col; i++)
					{
						buffer[i] = (char**)allocmem(buf_row * sizeof(char*));
						for (j = 0; j < buf_row; j++)
						{
							if (cells[i + x0][j + y0])
							{
								if (keyCode == 03)	// ctrl-c
								{
									buffer[i][j] = (char*)allocmem(strlen(cells[i + x0][j + y0]));
									strcpy(buffer[i][j], cells[i + x0][j + y0]);
								}
								else
								{
									buffer[i][j] = cells[i + x0][j + y0];
									cells[i + x0][j + y0] = NULL;
								}
							}
							else
								buffer[i][j] = NULL;
						}
					}
					if (keyCode == 24) 
						calculate_values();
					draw_window();
					break;
				}
			}
		case 06:		// control-f
			{
				display_formulas = !display_formulas;
				draw_grid(); //draw_window();
				break;
			}
		default:
			
			if (!is_edit && !(file_box.flags & ed_focus))
			{
				start_edit(sel_x, sel_y);
				if (keyCode == 8)
				{
					cell_box.pos = strlen(edit_text);
				}
				else
				{
					__asm
					{
						mov ah, keyCode
					}
					edit_box_key((dword)&cell_box);
				}
			}
			if (is_edit)
				edit_box_draw((dword)&cell_box);
			break;
	}
	if (dx != 0)
	{
		if (shift)
		{
			sel_end_x += dx;
			if (sel_end_x <= 1)
				sel_end_x = 1;
			else if (sel_end_x >= col_count)
				sel_end_x = col_count - 1;
		//	sprintf(debuf,"sel end x change. sel end %U %U",sel_end_x,sel_end_y);
		//	rtlDebugOutString(debuf);
			sel_moved = sel_end_move = 1;
			//stop_edit();
			//draw_grid();
		}
		else
		{
		}
	}
	if (dy != 0)
	{
		if (shift)
		{
			sel_end_y += dy;
			if (sel_end_y <= 1)
				sel_end_y = 1;
			else if (sel_end_y >= row_count)
				sel_end_y = row_count - 1;
		//	sprintf(debuf,"sel end y change. sel end %U %U",sel_end_x,sel_end_y);
		//	rtlDebugOutString(debuf);
			sel_moved = sel_end_move = 1;
			//stop_edit();
			//draw_grid();
		}
	}
	/*
	if (sel_end_x < sel_x)
	{
		Dword tmp = sel_end_x; sel_end_x = sel_x; sel_x = tmp;
	}
	if (sel_end_y < sel_y)
	{
		Dword tmp = sel_end_y; sel_end_y = sel_y; sel_y = tmp;
	}
	*/
	if ((dx || dy))
	{
		if (!shift)
		{
			if ((sel_end_x + dx) >= (col_count-1)) {dx=0;} //заглушка
			else if ((sel_end_y + dy) >= (row_count-1)) {dy=0;}
			else {
			move_sel(sel_x + dx, sel_y + dy);
			}
		}
		else
		{
			sel_moved = 0;
			stop_edit();
			draw_grid();
		}
	}
}
Ejemplo n.º 9
0
void process_button()
{
	Dword mouse_btn, ckeys, shift, ctrl;
	int mouse_x, mouse_y, i, p, dx = 0, dy = 0;
	int redraw = 0;

	Dword button;
	kos_GetButtonID(button);

	/*
	sprintf(debuf, "button %U", button);
	rtlDebugOutString(debuf);
	//*/

	switch (button)
	{
	case 1:
		kos_ExitApp();

	case SCROLL_LEFT_BUTTON:
		//rtlDebugOutString("scroll left btn");
		stop_edit();
		scroll_x--;
		if (scroll_x <= 0)
			scroll_x = 1;
		sel_moved = 0;
		/*if (sel_x > nx - 1)
		{
			nx - 1;
			sel_end_x = sel_x;
		}*/
		draw_window();
		return;

	case SCROLL_RIGHT_BUTTON:
		//rtlDebugOutString("scroll right btn");
		stop_edit();
		scroll_x++;
		if (scroll_x >= col_count - 1)
			scroll_x = col_count - 1;
		sel_moved = 0;/*
		if (sel_x < scroll_x)
		{
			sel_x = scroll_x;
			sel_end_x = sel_x;
		}*/
		draw_window();
		return;

	case SCROLL_WIDTH:
		{
			//rtlDebugOutString("scroll width btn");
			stop_edit();
			kos_GetMouseState(mouse_btn, mouse_x, mouse_y);
			mouse_x -= 5;
			mouse_y -= kos_GetSkinHeight();

			// всего: wi - SCROLL_BAR_WIDTH - 2 * 14

			int tmp_w = (nx - scroll_x) * (wi - SCROLL_BAR_WIDTH - 3 * 14) / (col_count + 1);
			if (tmp_w < 16)
				tmp_w = 16;
			scroll_x = (mouse_x - 14 - tmp_w / 2) * (col_count + 1) / (wi - SCROLL_BAR_WIDTH - 3 * 14) + 1;
			if (scroll_x <= 0)
				scroll_x = 1;
			else if (scroll_x >= col_count - 1)
				scroll_x = col_count - 1;
			sel_moved = 0;
			draw_window();
			return;
		}

	case SCROLL_UP_BUTTON:
		stop_edit();
		scroll_y--;
		if (scroll_y <= 0)
			scroll_y = 1;
		sel_moved = 0;
		//draw_window();
		draw_grid();
		/*
		if (sel_y > ny - 1)
		{
			sel_y = ny - 1;
			sel_end_y = sel_y;
		}*/
		return;

	case SCROLL_DOWN_BUTTON:
		stop_edit();
		scroll_y++;
		if (scroll_y >= row_count - 1)
			scroll_y = row_count - 1;
		sel_moved = 0;/*
		if (sel_y < scroll_y)
		{
			sel_y = scroll_y;
			sel_end_y = sel_y;
		}*/
		draw_grid();
		return;

	case SCROLL_HEIGHT:
		{
			stop_edit();
			kos_GetMouseState(mouse_btn, mouse_x, mouse_y);
			mouse_x -= 5;
			mouse_y -= kos_GetSkinHeight();
			int tmp_h = (ny - scroll_y) * (he - SCROLL_BAR_HEIGHT - 2 * 14) / row_count;
			if (tmp_h < 16)
				tmp_h = 16;
			scroll_y = (mouse_y - 2 * 14) * (row_count + 1) / (he - SCROLL_BAR_HEIGHT - 3 * 14) + 1;
			if (scroll_y <= 0)
				scroll_y = 1;
			else if (scroll_y >= row_count - 1)
				scroll_y = row_count - 1;
			sel_moved = 0;
			draw_grid();
			return;
		}

	case NEW_BUTTON:	// clear the table
		reinit();
		draw_window();
		break;

	case FILENAME_BUTTON:
		sel_moved = 1;
		stop_edit();
		fn_edit = 1;
		strcpy(edit_text, fname);
		draw_window();
		break;

	case SAVE_BUTTON:
		stop_edit();
		kos_DrawBar(320, panel_y, wi - 320 - 10, 10, 0xe4dfe1);
		if (SaveFile(fname))
			kos_WriteTextToWindow(320, panel_y, 0, 0x000000, (char*)msg_save, strlen(msg_save));
		break;

	case LOAD_BUTTON:
		stop_edit();
		int r = LoadFile(fname);
		kos_DrawBar(320, panel_y, wi - 320 - 10, 10, 0xe4dfe1);
		if (r > 0)
		{
			calculate_values();
			sel_moved = 0;
			draw_window();
			kos_WriteTextToWindow(320, panel_y,0,0x000000,(char*)msg_load, strlen(msg_load));
		}
		else if (r == -1)
			kos_WriteTextToWindow(320, panel_y,0,0x000000,(char*)er_file_not_found,strlen(er_file_not_found));
		else if (r == -2)
			kos_WriteTextToWindow(320, panel_y,0,0x000000,(char*)er_format,strlen(er_format));
		break;
	}
	if (button >= COL_HEAD_BUTTON && button < ROW_HEAD_BUTTON)
	{
		sel_end_x = sel_x = button - COL_HEAD_BUTTON;
		sel_y = 1;
		sel_end_y = row_count - 1;
		stop_edit();
		draw_window();
		return;
	}
	else if (button >= ROW_HEAD_BUTTON && button < CELL_BUTTON)
	{
		sel_end_y = sel_y = button - ROW_HEAD_BUTTON;
		sel_x = 1;
		sel_end_x = col_count - 1;
		stop_edit();
		draw_window();
		return;
	}

}
Ejemplo n.º 10
0
void fill_cells(int sel_x, int sel_y, int sel_end_x, int sel_end_y, int old_end_x, int old_end_y)
{
    // итак, (sel_x, sel_y) :: (old_end_x, old_end_y) - источник
    // результат хранится либо в строке sel_x .. sel_end_x, либо в столбце sel_y .. sel_end_y

    int i, start, end, step, gdir = -1;
    int pdir = -1;
    char *source;

    cf_x0 = cf_y0 = 0;
    cf_x1 = col_count;
    cf_y1 = row_count;

    if (sel_end_x == -1)
        sel_end_x = sel_x;
    if (sel_end_y == -1)
        sel_end_y = sel_y;

    // если направления выделений перпендикулярны, то просто в цикле повторяем то же, что для 1 ячейки:

    if (old_end_x == sel_end_x && sel_y == old_end_y)
    {
        gdir = 0;
    }
    else if (old_end_y == sel_end_y && sel_x == old_end_x)
    {
        gdir = 1;
    }

    //sprintf(debuf, "f**k in ass %U %U %U %U %U %U dir %U",sel_x,sel_y,sel_end_x,sel_end_y,old_end_x,old_end_y,gdir);
    //rtlDebugOutString(debuf);
    if (gdir != -1)
    {
        int gstep = gdir ? sign(old_end_y - sel_y) : sign(old_end_x - sel_x);
        if (gstep == 0)
        {
            /*	if (gdir)
            	{
            		//old_end_y += 1;
            	}
            	else
            	{
            		//old_end_x += 1;
            	}
            */
            gstep = 1;
        }

        for (; gdir ? (sel_y != old_end_y + gstep) : (sel_x != old_end_x + gstep);
                gdir ? (sel_y += gstep) : (sel_x += gstep))
        {
            //sprintf(debuf, "cycle %U %U %U %U %U %U dir %U",sel_x,sel_y,sel_end_x,sel_end_y,old_end_x,old_end_y,gdir);
            //rtlDebugOutString(debuf);
            int dir;
            source = cells[sel_x][sel_y];
            if (gdir == 0)
            {
                start = sel_y;
                end = sel_end_y;
                step = (sel_y < sel_end_y ? 1 : -1);
                dir = 1;
            }
            else
            {
                start = sel_x;
                end = sel_end_x;
                step = (sel_x < sel_end_x ? 1 : -1);
                dir = 0;
            }

            //sprintf(debuf, "cyc %U %U %U %U",start,end,step,dir);
            //rtlDebugOutString(debuf);
            for (i = start + step; i != end + step; i += step)
            {
                //char **p = &cells[dir ? sel_x : i][dir ? i : sel_end_y];
                //sprintf(debuf, "to %U %U dir %U copying '%S'",dir ? sel_x : i,dir ? i : sel_y,dir,source);
                //rtlDebugOutString(debuf);
                if (cells[dir ? sel_x : i][dir ? i : sel_y])
                {
                    freemem(cells[dir ? sel_x : i][dir ? i : sel_y]);
                }
                if (source)
                {
                    cells[dir ? sel_x : i][dir ? i : sel_y] = change_formula(source, dir ? 0 : (i - start), dir ? (i - start) : 0);
                    //cells[dir ? sel_x : i][dir ? i : sel_y] = (char *)allocmem(strlen(source) + 1);
                    //strcpy(cells[dir ? sel_x : i][dir ? i : sel_y], source);
                }
                else
                    cells[dir ? sel_x : i][dir ? i : sel_y] = NULL;
            }
        }
    }

    // а вот если параллельны...
    /*

    if (sel_x == sel_end_x && sel_x == old_end_x)
    {
    	pdir = 0;
    }
    if (sel_y == sel_end_y && sel_y == old_end_y)
    {
    	pdir = 1;
    }
    if (pdir != -1)
    {
    	// арифметическая прогрессия - если числа. и тупо размножитьт последнее, если нет

    	sprintf(debuf, "maybe arith dir %U", pdir);
    	rtlDebugOutString(debuf);

    	int is_arith = 1;
    	int gstep = pdir ? sign(old_end_y - sel_y) : sign(old_end_x - sel_x);
    	if (gstep == 0)
    		gstep = 1;

    	for (int i = pdir ? sel_y : sel_x; i != pdir ? (old_end_y + gstep) : (old_end_x + gstep); i++)
    	{
    		convert_error = 0;
    		sprintf(debuf,"cell %U %U", !pdir ? sel_x : i, !pdir ? i : sel_y);
    		rtlDebugOutString(debuf);
    		if (cells[!pdir ? sel_x : i][!pdir ? i : sel_y])
    		{
    			double d = atof(cells[!pdir ? sel_x : i][!pdir ? i : sel_y]);
    			if (convert_error)
    			{
    				rtlDebugOutString("failed arith");
    				is_arith = 0;
    				break;
    			}
    		}
    		else
    		{
    			is_arith = 0;
    			rtlDebugOutString("failed arith in null");
    			break;
    		}
    	}

    	double arith_first, arith_step;
    	if (is_arith)
    	{
    		rtlDebugOutString("really arith");
    		arith_first = atof(cells[sel_x][sel_y]);
    		arith_step = atof(cells[pdir ? sel_x : old_end_x][pdir ? sel_y : old_end_y]) - arith_first;
    		arith_first += arith_step * pdir ? abs(sel_end_x - old_end_x) : abs(sel_end_y - old_end_y);
    	}
    	else
    		rtlDebugOutString("none arith");

    	// собственно заполнение
    	for (i = pdir ? old_end_y : old_end_x; i != pdir ? (sel_end_y + gstep) : (sel_end_x + gstep); i++)
    	{
    		if (cells[pdir ? sel_x : i][pdir ? i : sel_y])
    			freemem(cells[pdir ? sel_x : i][pdir ? i : sel_y]);
    		if (is_arith)
    		{
    			cells[pdir ? sel_x : i][pdir ? i : sel_y] = ftoa(arith_first);
    			arith_first += arith_step;
    		}
    		else
    		{
    			if (cells[sel_x][sel_y])
    			{
    				cells[pdir ? sel_x : i][pdir ? i : sel_y] = (char*)allocmem(strlen(cells[sel_x][sel_y]) + 1);
    				strcpy(cells[pdir ? sel_x : i][pdir ? i : sel_y], cells[sel_x][sel_y]);
    			}
    		}
    	}
    }
    */

    calculate_values();
}