void KIconEditGrid::loadBlank( int w, int h ) { img->create(w, h, 32); img->fill(TRANSPARENT); setNumRows(h); setNumCols(w); fill(TRANSPARENT); emit sizechanged(numCols(), numRows()); emit colorschanged(numColors(), data()); }
void Matrix::exportEMF(const QString& fileName) { int width = numRows(); int height = numCols(); EmfPaintDevice emf(QSize(width, height), fileName); QPainter p(&emf); p.drawImage (QRect(0, 0, width, height), d_matrix_model->renderImage()); p.end(); }
// TEST void TableHead::checkProfile() { QRect viewR = viewRect(); // if(viewR.y()!=0) printf(" qps: ooooohss....\n"); int maxViewCol = findCol(viewR.width()); if (maxViewCol < 0) maxViewCol = numCols(); tablecache.setCol(maxViewCol); tablecache.setRow(1); }
QwtDoubleRect Matrix::boundingRect() { int rows = numRows(); int cols = numCols(); double dx = fabs(x_end - x_start)/(double)(cols - 1); double dy = fabs(y_end - y_start)/(double)(rows - 1); return QwtDoubleRect(QMIN(x_start, x_end) - 0.5*dx, QMIN(y_start, y_end) - 0.5*dy, fabs(x_end - x_start) + dx, fabs(y_end - y_start) + dy).normalized(); }
//================================================================== QSize KCharSelectTable::sizeHint() const { int w = cellWidth(); int h = cellHeight(); w *= numCols(); h *= numRows(); return QSize( w, h ); }
void Matrix::invert() { if (numRows() != numCols()){ QMessageBox::critical((ApplicationWindow *)applicationWindow(), tr("QtiPlot - Error"), tr("Inversion failed, the matrix is not square!")); return; } if(d_matrix_model->initWorkspace()) d_undo_stack->push(new MatrixSymmetryOperation(d_matrix_model, Invert, tr("Invert"))); }
void Matrix::goToColumn(int col) { if(col < 1 || col > numCols()) return; if (d_view_type == ImageView) d_undo_stack->push(new MatrixSetViewCommand(this, d_view_type, TableView, tr("Set Data Mode"))); d_table_view->selectColumn(col - 1); d_table_view->scrollTo(d_matrix_model->index(0, col - 1), QAbstractItemView::PositionAtCenter); }
bool IMS_Matrix<T>::operator==(const IMS_Matrix<T> &other) const { if (numRows() != other.numRows() || numCols() != other.numCols()) { throw MatrixArithmeticException("Can't compare matrixes of different sizes."); } for (unsigned int row = 0; row < numRows(); ++row) { for (unsigned int col = 0; col < numCols(); ++col) { //if an element is not the same, return false if ((*this)(row, col) != other(row, col)) { return false; } } } return true; }
void KIconEditGrid::editSelectAll() { start.setX(0); start.setY(0); end.setX(numCols()); end.setY(numRows()); isselecting = true; drawRect(false); emit newmessage(i18n("All selected")); }
//================================================================== void KCharSelectTable::paintCell( class QPainter* p, int row, int col ) { const int w = cellWidth(); const int h = cellHeight(); const int x2 = w - 1; const int y2 = h - 1; //if( row == 0 && col == 0 ) { // printf("Repaint %d\n", temp++); // fflush( stdout ); // } QFont font = QFont( vFont ); font.setPixelSize( int(.7 * h) ); unsigned short c = vTableNum * 256; c += row * numCols(); c += col; if ( c == vChr.unicode() ) { p->setBrush( QBrush( colorGroup().highlight() ) ); p->setPen( NoPen ); p->drawRect( 0, 0, w, h ); p->setPen( colorGroup().highlightedText() ); vPos = QPoint( col, row ); } else { QFontMetrics fm = QFontMetrics( font ); if( fm.inFont( c ) ) p->setBrush( QBrush( colorGroup().base() ) ); else p->setBrush( QBrush( colorGroup().button() ) ); p->setPen( NoPen ); p->drawRect( 0, 0, w, h ); p->setPen( colorGroup().text() ); } if ( c == focusItem.unicode() && hasFocus() ) { style().drawPrimitive( QStyle::PE_FocusRect, p, QRect( 2, 2, w - 4, h - 4 ), colorGroup() ); focusPos = QPoint( col, row ); } p->setFont( font ); p->drawText( 0, 0, x2, y2, AlignHCenter | AlignVCenter, QString( QChar( c ) ) ); p->setPen( colorGroup().text() ); p->drawLine( x2, 0, x2, y2 ); p->drawLine( 0, y2, x2, y2 ); if ( row == 0 ) p->drawLine( 0, 0, x2, 0 ); if ( col == 0 ) p->drawLine( 0, 0, 0, y2 ); }
/*! Reimplement this function to change the contents of the well array. */ void WellArray::paintCellContents(QPainter *p, int row, int col, const QRect &r) { if (d) { p->fillRect(r, d->brush[row*numCols()+col]); } else { p->fillRect(r, Qt::white); p->setPen(Qt::black); p->drawLine(r.topLeft(), r.bottomRight()); p->drawLine(r.topRight(), r.bottomLeft()); } }
void Matrix::rotate90(bool clockwise) { initWorkspace(numRows()*numCols()); if (!d_workspace) return; if (clockwise) d_undo_stack->push(new MatrixSymmetryOperation(d_matrix_model, RotateClockwise, tr("Rotate 90°"))); else d_undo_stack->push(new MatrixSymmetryOperation(d_matrix_model, RotateCounterClockwise, tr("Rotate -90°"))); }
void TableEditor::copy() { QString s; for(int r=0;r<numRows();r++) { s+=text(r,0); for(int c=1;c<numCols();c++) s+=(","+text(r,c)); s+="\n"; } QApplication::clipboard()->setText(s,QClipboard::Clipboard); }
void KColorGrid::setNumCols(int n) { //kdDebug(4640) << "setNumCols" << endl; if(n < 0) return; int on = numCols(); KColorArray gc(gridcolors); gc.detach(); //kdDebug(4640) << "gc size: " << gc.size() << " numrows: " << numRows() << endl; gridcolors.resize(n*numRows()); cols = n; totalwidth = (n * cellsize) + 1; resize(totalwidth, totalheight); //kdDebug(4640) << "numRows: " << numRows() << endl; //kdDebug(4640) << "gridcolor: " << gridcolors.size() << " grid: " << numRows()*numCols() << endl; if(numRows() == 0) return; for(int i = 0; i < numRows(); i++) { for(int j = 0; j < n; j++) { //kdDebug(4640) << "row " << i << " , col " << j << endl; if(j < on ) //If there's something to read here -- i.e. we're within the original grid { //kdDebug(4640) << (i*numCols())+j << " " << (i*on)+j << endl; gridcolors.at((i*numCols())+j) = gc.at((i*on)+j); } else //Initialize to something.. { if (gc.size()) //Have some pixels originally.. gridcolors.at((i*numCols())+j) = gc.at(0); else gridcolors.at((i*numCols())+j) = 0; //Picks something #### Update numcolors? } } } //kdDebug(4640) << "setNumCols() - gridcolors: " << gridcolors.size() << " size: " << numCols()*numRows() << endl; }
void PreviewTable::updateDecimalSeparators(const QLocale& oldSeparators) { QLocale locale = ((QWidget *)parent())->locale(); for (int i=0; i<numCols(); i++){ for (int j=0; j<numRows(); j++){ if (!text(j, i).isEmpty()){ double val = oldSeparators.toDouble(text(j, i)); setText(j, i, locale.toString(val, 'g', d_numeric_precision)); } } } }
void Map::deSelectUnit() { selectedUnit = nullptr; int r; for (r = 0; r < (int)numRows(); r++) { int c; for (c = 0; c < (int)numCols(); c++) { tiles[r][c]->currentMoveCost = 0; tiles[r][c]->stacked = false; } } rcStackLoc = 0; }
//does the operation firstRow = firstRow + scaleFactor * secondRow IMS_Matrix<T> & IMS_Matrix<T>::replacementRowOp(unsigned int firstRow, unsigned int secondRow, T scaleFactor) { if (firstRow >= numRows() || secondRow >= numRows()) { throw MatrixArithmeticException("Can't replace rows, rows out of bounds"); } for (unsigned int col = 0; col < numCols(); ++col) { (*this)(firstRow, col) += scaleFactor * (*this)(secondRow, col); } return *this; }
QSize KDateTable::sizeHint() const { if(maxCell.height()>0 && maxCell.width()>0) { return QSize(maxCell.width()*numCols()+2*frameWidth(), (maxCell.height()+2)*numRows()+2*frameWidth()); } else { kdDebug() << "KDateTable::sizeHint: obscure failure - " << endl; return QSize(-1, -1); } }
//================================================================== void KCharSelectTable::resizeEvent( QResizeEvent * e ) { const int new_w = (e->size().width() - 2*(margin()+frameWidth())) / numCols(); const int new_h = (e->size().height() - 2*(margin()+frameWidth())) / numRows(); if( new_w != cellWidth()) setCellWidth( new_w ); if( new_h != cellHeight()) setCellHeight( new_h ); setToolTips(); }
//row = row * scaleFactor IMS_Matrix<T> & IMS_Matrix<T>::scaleRowOp(unsigned int row, T scaleFactor) { if (row >= numRows()) { throw MatrixArithmeticException("Can't scale row, row out of bounds"); } for (unsigned int col = 0; col < numCols(); ++col) { (*this)(row, col) *= scaleFactor; } return *this; }
void postProcess(const std::string& output_file) { const int numPixels = numRows() * numCols(); //copy the output back to the host checkCudaErrors(cudaMemcpy(imageGrey.ptr<unsigned char>(0), d_greyImage__, sizeof(unsigned char) * numPixels, cudaMemcpyDeviceToHost)); //output the image cv::imwrite(output_file.c_str(), imageGrey); //cleanup cudaFree(d_rgbaImage__); cudaFree(d_greyImage__); }
bool CLinkMatrix::leftMultiply(const CMatrix< C_FLOAT64> & m, CMatrix< C_FLOAT64> & p) const { bool success = true; if (m.numRows() != numCols()) { return false; } // p := L * m = (I, L0) * m = (m, L0 * m) = (p1, p2) p.resize(mRowPivots.size(), m.numCols()); p = 0.0; // p1 := m memcpy(p.array(), m.array(), sizeof(C_FLOAT64) * m.size()); // p2 := L0 * m // p2 (numDependent x m.numCols()) char T = 'N'; C_INT M = (C_INT) m.numCols(); /* LDA, LDC */ C_INT N = (C_INT) getNumDependent(); C_INT K = (C_INT) numCols(); C_INT LDA = (C_INT) m.numCols(); C_INT LDB = (C_INT) numCols(); C_INT LDC = (C_INT) p.numCols(); C_FLOAT64 Alpha = 1.0; C_FLOAT64 Zero = 0.0; // DGEMM (TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC) // C := alpha A B + beta C dgemm_(&T, &T, &M, &N, &K, &Alpha, const_cast< C_FLOAT64 * >(m.array()), &LDA, const_cast< C_FLOAT64 * >(array()), &LDB, &Zero, p.array() + m.size(), &LDC); return success; }
void KColorGrid::setColor( int colNum, uint col, bool update ) { //debug("KColorGrid::setColor"); uint oldcolor = gridcolors[colNum]; gridcolors[colNum] = col; if(!update) return; //debug("KColorGrid::setColor - before adding"); if(!numcolors.contains(col)) { //debug("KColorGrid::setColor() - adding %u - %d %d %d", // col, qRed(col), qGreen(col), qBlue(col)); numcolors.append(col); //debug("KColorGrid::setColor() - adding done %d", numcolors.size()-1); //numcolors++; emit addingcolor(col); } //debug("KColorGrid::setColor - before removing"); if(!gridcolors.contains(oldcolor)) { int idx = numcolors.find(oldcolor); if(idx != -1) { //debug("KColorGrid::setColor() - removing %u - %d %d %d", // oldcolor, qRed(oldcolor), qGreen(oldcolor), qBlue(oldcolor)); numcolors.remove(idx); //debug("KColorGrid::setColor() - removing done"); emit colorschanged(numcolors.size(), numcolors.data()); } //numcolors--; } //debug("KColorGrid::setColor - before updateCell"); repaint((colNum%numCols())*cellsize,(colNum/numCols())*cellsize, cellsize, cellsize); //updateCell( colNum/numCols(), colNum%numCols(), false ); //debug("KColorGrid::setColor - after updateCell"); }
QString Matrix::saveAsTemplate(const QString &info) { QString s= "<matrix>\t"; s+= QString::number(numRows())+"\t"; s+= QString::number(numCols())+"\n"; s+= info; s+= "ColWidth\t" + QString::number(d_table->columnWidth(0))+"\n"; s+= "<formula>\n" + formula_str + "\n</formula>\n"; s+= "TextFormat\t" + QString(txt_format) + "\t" + QString::number(num_precision) + "\n"; s+= "Coordinates\t" + QString::number(x_start,'g',15) + "\t" +QString::number(x_end,'g',15) + "\t"; s+= QString::number(y_start,'g',15) + "\t" + QString::number(y_end,'g',15) + "\n"; return s; }
void Calender::addDayLine(int row, int col, QString s) { QString txtLine; CalenderDay *cDay = NULL; assert((row >= 0 && row < numRows()) && (col >= 0 && col < numCols())); cDay = (CalenderDay *) item(row, col); txtLine = cDay->text(); txtLine.append("\n" + s); cDay->setText(txtLine); cDay->setNrOfLines(cDay->getNrOfLines() + 1); }
void CustomPalette::clear() { cur_row = 0; cur_col = 0; sel_row = -1; sel_col = -1; for ( int i = 0; i < numRows(); i++ ) for ( int j = 0; j < numCols(); j++ ) { color_matrix[i][j] = invalid_color; updateCell( i, j ); } for ( int i = 0; i < numRows(); i++ ) for ( int j = 0; j < numCols(); j++ ) color_names[i][j] = ""; for ( int i = 0; i < numRows(); i++ ) for ( int j = 0; j < numCols(); j++ ) alpha_matrix[i][j] = -1; }
void Matrix::fft(bool inverse) { double *buffer = d_matrix_model->dataCopy(); if (buffer){ QString commandText = inverse ? tr("Inverse FFT") : tr("Forward FFT"); d_undo_stack->push(new MatrixFftCommand(inverse, d_matrix_model, 0, numRows() - 1, 0, numCols() - 1, buffer, commandText)); emit modifiedWindow(this); } else if (ignoreUndo()){ d_matrix_model->fft(inverse); emit modifiedWindow(this); } }
void PreviewTable::setHeader() { Q3Header *head = horizontalHeader(); for (int i=0; i<numCols(); i++){ QString s = col_label[i]; int lines = columnWidth(i)/head->fontMetrics().averageCharWidth(); #ifdef Q_OS_MAC head->setLabel(i, s.remove("\n")); #else head->setLabel(i, s.remove("\n") + "\n" + QString(lines, '_') + "\n" + comments[i]); #endif } }
bool wDBTable::beginInsert() { if ( !sqlCursor() || isReadOnly() || !numCols() ) return FALSE; if ( !sqlCursor()->canInsert() ) return FALSE; bool result = Q3DataTable::beginInsert(); endEdit( currentRow(), currentColumn(), false, false); setCurrentCell( numRows(), 0 ); return result; }
IMS_Matrix<T> & IMS_Matrix<T>::operator=(const IMS_Matrix<T> &rhs) { //check for self assignment, this will explode if we don't check for it and try to do this if (this != &rhs) { //only actually do the assignment if this and rhs are different objects //check to see if matrixes are the same size if (numRows() != rhs.numRows() || numCols() != rhs.numCols()) { throw MatrixArithmeticException("Can't assign matrixes of different sizes."); } //otherwise just set it, element by element for (unsigned int row = 0; row < numRows(); ++row) { for (unsigned int col = 0; col < numCols(); ++col) { (*this)(row, col) = rhs(row, col); } } } return *this; }