void MainWnd::on_btn_down_clicked() { int count = ui->tableWidget->rowCount(); int row = GetSelectedRow(); if(row >= 0 && row < count - 1) SwitchRows(row, row + 1); }
void MatrixControl::MessageReceived( BMessage *message) { switch (message->what) { case CONST_dragrow: { int32 source_row; BPoint target; BRect *rect; MatrixControl *con; void **x; message->FindInt32("row", &source_row); message->FindPoint("_drop_point_", &target); message->FindPointer("matrix_control", x); con = (MatrixControl *) *x; if (con != this) { extra::OKBox ("You can´t drag from another window!"); break; } target = ConvertFromScreen(target); for (int i=0; i<matrix_dimension; ++i) { rect = new BRect( 20, (i+1)*square_size+5, square_size * (matrix_dimension+1) ,(i+1)*square_size+10 ); if (i != source_row) { if (rect->Contains(target)==true) { SwitchRows(source_row, i); Invalidate(); } // if clause } delete rect; } // for loop } //case diferentiation case CONST_dragcolumn: { int32 source_row; BPoint target; BRect *rect; MatrixControl *con; void **x; message->FindInt32("column", &source_row); message->FindPoint("_drop_point_", &target); message->FindPointer("matrix_control", x); con = (MatrixControl *) *x; if (con != this) { extra::OKBox("You can´t drag from another window!"); break; } target = ConvertFromScreen(target); for (int i=0; i<matrix_dimension; ++i) { rect = new BRect((i+1)*square_size-10, 20 ,(i+1)*square_size-5 , square_size * matrix_dimension); if (i != source_row) { if (rect->Contains(target)==true) { SwitchColumns(source_row, i); Invalidate(); } // if clause } delete rect; } // for loop } //case diferentiation } //switch statement } //function
void MainWnd::on_btn_up_clicked() { int row = GetSelectedRow(); if(row > 0) SwitchRows(row, row - 1); }
void MatrixControl::Run(alNormalWindow *win) { //Optimizer Section int i ,k, x; int counted_zeros[matrix_dimension]; int bestline,val; float value; for (i=0; i < matrix_dimension; ++i) { counted_zeros[i] = 0; for (x=0; x < matrix_dimension; ++x) { value = float_matrix[i*matrix_dimension +x]; if (value == 0.0) ++counted_zeros[i]; } } for (i=0; i < matrix_dimension; ++i) { bestline = -1; val = 0; for (k = i; k < matrix_dimension; ++k) { if (counted_zeros[k] > val) { val = counted_zeros[k]; bestline = k; } } if (bestline > i) SwitchRows(bestline, i); } //Optimizer End oneisrunning = true; MasterMatrix = this; loaded_threads = 0; answers = 0; MatrixResult = 0.0; BString nam ("Progress "); nam += extra::StringOutOf(matrix_dimension); nam.Append("x"); nam += extra::StringOutOf(matrix_dimension); alLooper *master_matrix_calculator = new alLooper(&MasterMatrixReceiver,"Master Matrix Calculator",B_LOW_PRIORITY); theone = new ShowProgressWin(400,100,nam.String(),100); theone->stat_bar->SetMaxValue( (float) matrix_dimension ); theone->tonotify = win; theone->toshutLooper = master_matrix_calculator; theone->Show(); master_matrix_calculator->Parent = (char *) this; master_matrix_calculator->Run(); master_matrix_calculator->PostMessage(1); }