コード例 #1
0
void PatchMatrixComponent::paint (Graphics &g)
{
    if (getNumColumns() <= 0 || getNumRows() <= 0)
        return;
    
    const int xs = (offsetX % horizontalThickness);
    const int ys = (offsetY % verticalThickness);
    const int cs = getColumnForPixel(0);
    const int w = horizontalThickness;
    const int h = verticalThickness;
    
    int row = getRowForPixel (0);
    for (int y = ys; y < getHeight(); y += h)
    {
        int col = cs;
        for (int x = xs; x < getWidth(); x += w)
        {
            g.saveState();
            g.setOrigin (x, y);
            paintMatrixCell (g, w, h, row, col);
            g.restoreState();
            if (++col == getNumColumns())
                break;
        }
        if (++row == getNumRows())
            break;
    }
}
コード例 #2
0
ファイル: RtDesignMatrix.cpp プロジェクト: cccbauer/murfi2
vnl_vector<double> RtDesignMatrix::getArtifactTimepoints() {

  // initialize return vector
  vnl_vector<double> listOfTr(numArtifacts, 0);
  unsigned int foundArt = 0;

  // loop through all columns
  for (unsigned int col = 0; col < getNumColumns(); col++) {

    // look for column name "artifact"
    if (!strcmp(getColumnName(col).c_str(), "artifact")) {

      vnl_vector<double> curCol = getColumn(col);

      // go through rows to find artifact timepoint
      for (unsigned int row = 0; row < getNumRows(); row++) {
        if (curCol[row] == 1) {
          listOfTr.put(foundArt, row);
          foundArt++;
          break; // go to next col
        }
      }
    }
  }
  return listOfTr;
}
コード例 #3
0
void LLScrollListItem::draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding)
{
	// draw background rect
	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
	LLRect bg_rect = rect;
	gl_rect_2d( bg_rect, bg_color );

	S32 cur_x = rect.mLeft;
	S32 num_cols = getNumColumns();
	S32 cur_col = 0;

	for (LLScrollListCell* cell = getColumn(0); cur_col < num_cols; cell = getColumn(++cur_col))
	{
		// Two ways a cell could be hidden
		if (cell->getWidth() < 0
			|| !cell->getVisible()) continue;

		LLUI::pushMatrix();
		{
			LLUI::translate((F32) cur_x, (F32) rect.mBottom);

			cell->draw( fg_color, highlight_color );
		}
		LLUI::popMatrix();
		
		cur_x += cell->getWidth() + column_padding;
	}
}
コード例 #4
0
int main() {
    std::string filename{"TRCFileWithNANs.trc"};

    // There are two ways to read the file:
    // (1) Use the specific adapter to read the file. This requires you to know
    //     the format of the file. Use a TRCFileAdapter to read TRC file.
    // (2) Use the generic FileAdapter to read the file and let it take care
    //     of picking the right Adapter for the given file format.

    // First method. Knowing that the file is a TRC file, use the TRCFileAdapter
    // directly to read the flie.
    OpenSim::TRCFileAdapter trcfileadapter{};
    auto table1 = trcfileadapter.read(filename);

    // Second method. Use the generic FileAdapter. The result is a collection
    // of tables. For a TRC file, this collection will contain just one table. 
    // This table will be an AbstractDataTable. It will have to be casted to the
    //  concrete type to access the data.
    auto& abstable2 = OpenSim::FileAdapter::readFile(filename).at("markers");
    auto table2 = static_cast<OpenSim::TimeSeriesTableVec3*>(abstable2.get());

    // From this point on, both table1 and table2 represent the same type of
    // DataTable and so both support the same operations. Below code 
    // demonstrates operations on only table1 but they are applicable to table2
    // as well.

    // Metadata of the table.
    std::cout << table1.
                 getTableMetaData().
                 getValueForKey("DataRate").
                 getValue<std::string>() << std::endl;

    std::cout << table1.
                 getTableMetaData().
                 getValueForKey("Units").
                 getValue<std::string>() << std::endl;

    // Column labels of the table.
    auto& labels = table1.
                   getDependentsMetaData().
                   getValueArrayForKey("labels");
    for(size_t i = 0; i < labels.size(); ++i)
        std::cout << labels[i].getValue<std::string>() << "\t";
    std::cout << std::endl;

    // Dimensions of the table.
    std::cout << table1.getNumRows() << "\t"
              << table1.getNumColumns() << std::endl;

    // Individual rows of the table.
    for(size_t i = 0; i < table1.getNumRows(); ++i)
        std::cout << table1.getRowAtIndex(i) << std::endl;

    // See documentation for TimeSeriesTable for full set of operations
    // possible for table1 and table2.

    return 0;
}
コード例 #5
0
void PatchMatrixComponent::mouseDown (const MouseEvent& ev)
{
    const int row = getRowForPixel (ev.y);
    const int col = getColumnForPixel (ev.x);
    if (row >= 0 && col >= 0 && row < getNumRows() && col < getNumColumns())
        matrixCellClicked (row, col, ev);
    else
        matrixBackgroundClicked (ev);
}
コード例 #6
0
void
MFXAddEditTypedTable::setItemFromControl(FXint r, FXint c, FXWindow* control) {
    register FXTableItem* item = cells[r * ncols + c];
    if (item == NULL) {
        cells[r * ncols + c] = item = createItem("", NULL, NULL);
        if (isItemSelected(r, c)) {
            item->setSelected(FALSE);
        }
    }
    switch (getCellType(c)) {
        case CT_UNDEFINED:
        case CT_STRING:
            item->setFromControl(control);
            break;
        case CT_REAL:
            item->setText(toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
            break;
        case CT_INT:
            item->setText(toString((int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
            break;
        case CT_BOOL:
//        return myBoolEditor;
        case CT_ENUM:
//        return myEnumEditor;
        default:
            throw 1;
    }
//    current.row = -1;
//    current.col = -1;
    EditedTableItem edited;
    edited.item = item;
    edited.row = r;
    edited.col = c;
    edited.updateOnly = false;
    killSelection(true);
    bool accepted = true;
    if (target) {
        if (!target->handle(this, FXSEL(SEL_CHANGED, ID_TEXT_CHANGED), (void*) &edited)) {
            accepted = false;
            // !!! item->setText(myPreviousText);
        }
    }
    if (accepted) {
        if (edited.row == getNumRows() - 1) {
            insertRows(getNumRows(), 1, true);
            for (int i = 0; i < getNumColumns(); i++) {
                setItemText(getNumRows() - 1, i, "");
                setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
            }
        }
    }
    mode = MOUSE_NONE;
}
コード例 #7
0
std::string LLScrollListItem::getContentsCSV() const
{
	std::string ret;

	S32 count = getNumColumns();
	for (S32 i=0; i<count; ++i)
	{
		ret += getColumn(i)->getValue().asString();
		if (i < count-1)
		{
			ret += ", ";
		}
	}

	return ret;
}
コード例 #8
0
void PlotTableWidget::renderToPixmap(QPixmap& pixmap) {
  size_t numRows = getNumRows();
  size_t numColumns = getNumColumns();
  
  if (numRows && numColumns) {
    double plotWidth = (pixmap.width()-20.0*(numColumns-1.0))/numColumns;
    double plotHeight = (pixmap.height()-20.0*(numRows-1.0))/numRows;
    
    double y = 0.0;
    for (size_t row = 0; row < plotWidgets_.count();
        ++row, y += plotHeight+20.0) {
      double x = 0.0;
      
      for (size_t column = 0; column < plotWidgets_[row].count();
          ++column, x += plotWidth+20.0)
        plotWidgets_[row][column]->renderToPixmap(pixmap,
          QRectF(x, y, plotWidth, plotHeight));
    }
  }
}
コード例 #9
0
ファイル: grade.c プロジェクト: ricardomorita42/kellykey
/*--3--printGrade */
void printGrade(Rio **grade, int primeiraLinha, float tempoDecorrido) 
{
	int i, j; 
	
	i = primeiraLinha;
	printf("\033[2J\033[;H");
	if (getReportData()) 
		printInfoTopo(tempoDecorrido);
	
	do {
		i--;
		if (i < 0)
			i = getNumLines()-1;
		for (j = 0; j < getNumColumns(); j++) 
			printf ("%c", grade[i][j].terreno);
		if (getReportData()) 
			printInfoLinha(grade[i]);
		printf("\n");
	} while ( i != primeiraLinha );
	printf ("\n\n");
}
コード例 #10
0
//--------------------------------------------------------------
void ofPlanePrimitive::setRows( int rows ) {
    setResolution( getNumColumns(), rows );
}
コード例 #11
0
/**
 * Given a set of values, times how long it takes to find if a specified target
 * value can be made by summing a subset of the given set of values.
 * 
 * Command line args:
 * argv[1] - a file of numbers that are in our set of values. The first line of
 *           the file is the number of values in the file.
 * argv[2] - a file of 30 numbers that are the targets that we try to reach
 *           with a subset of the values in argv[1]
 * 
 * Compile: gcc proj1.c -fopenmp -o proj1
 * Run: ./proj1 set_I_filename targets_filename
 *
 * Authors: Gaurav Luthria <*****@*****.**>
 *          Rajan Patel <*****@*****.**>
 *          Michael Bishoff <*****@*****.**>
 */
int main(int argc, char* argv[]) {
  // Check if command line args are valid
  if (argc != 3) {
    printf("ERROR: Command line arguments are <set_I_filename> ");
    printf("<targets_filename>\n");
    return 1;
  }
  
  // Initializes I, the set of values, and the list of targets that we use
  // to see if a subset of I sums to the value of a target
  int* I = readSet(argv[1]);
  int* targets = readTargets(argv[2]);
  
  // Determines the number of columns needed in the Q table
  numCols = getNumColumns(I);

  // Allocates space for the Q table
  int** Q = malloc(sizeof(*Q)*numRows);
  for (int i = 0; i < numRows; i++) {
    Q[i] = malloc(sizeof(*(Q[i]))*numCols);
  }
  
  double totalTime = 0;

  for (int i = 0; i < NUM_TARGETS; i++) {
    clearQMatrix(Q);
    
    double startTime = omp_get_wtime();
    //clock_t startTime = clock();
    int solutionExists = findSolution(I, Q, targets[i]);
    double endTime = omp_get_wtime();
    //clock_t endTime = clock();
    
    totalTime += (double) (endTime - startTime);
    
    // Uncomment this to see the reconstructed solution!
    /*
    printf("%d: ", targets[i]);
    // If there's a solution, print it
    if (solutionExists) {
      // Uncomment this to see the Q table!
      // printPretty(I, Q);
      reconstructSolution(I, Q, targets[i]);
      
    } else {
      printf("NO SOUTION EXISTS! ");
    }
    */
  }

  printf("Average Time: %f\n", (totalTime / NUM_TARGETS));
  printf("Total Time: %f\n", totalTime);
  
  
  // Freeeee
  free(I);

  for (int i = 0; i < numRows; i++) {
    free(Q[i]);
  }
  free(Q);
  
  return 0;
}
コード例 #12
0
void renderDDRNote(int player, struct ARROW n, int x, int y)
{
	int numColumns = getNumColumns();

	// implement reverse - the stepzone will take care of itself, this is just the notes
	int originalY = y;
	if ( gs.player[player].reverseModifier != 0 )
	{
		y = DDR_STEP_ZONE_REV_Y - y + 64; // the +64 is to account for the height of the note
	}

	switch ( n.type )
	{
	case TAP:
		renderDDRArrow(player, n.columns[0], n.color, n.judgement, getColumnOffsetX_DDR(n.columns[0]), gs.player[player].isColumnReversed(n.columns[0]) ? y : originalY);
		break;
	case JUMP:
		renderDDRArrow(player, n.columns[0], n.color, n.judgement, getColumnOffsetX_DDR(n.columns[0]), gs.player[player].isColumnReversed(n.columns[0]) ? y : originalY);
		renderDDRArrow(player, n.columns[1], n.color, n.judgement, getColumnOffsetX_DDR(n.columns[1]), gs.player[player].isColumnReversed(n.columns[1]) ? y : originalY);
		break;
	//case HOLD_START:
	//case HOLD_END:
		// intentionally do nothing
		break;
	case SHOCK:
		if ( gs.isSolo )
		{
			for ( int i = 0; i < numColumns; i++ )
			{
				renderDDRArrow(player, i, 7, n.judgement, x, y);
			}
		}
		else
		{
			if ( gs.isDoubles )
			{
				renderDDRArrow(player, 0, 7, n.judgement, x, y);
				renderDDRArrow(player, 2, 7, n.judgement, x, y);
				renderDDRArrow(player, 3, 7, n.judgement, x, y);
				renderDDRArrow(player, 5, 7, n.judgement, x, y);
			}
			renderDDRArrow(player, 6, 7, n.judgement, x, y);
			renderDDRArrow(player, 7, 7, n.judgement, x, y);
			renderDDRArrow(player, 8, 7, n.judgement, x, y);
			renderDDRArrow(player, 9, 7, n.judgement, x, y);
		}

		for ( int i = 0; i < 6; i++ )
		{
			int width = numColumns * 64;
			//int seed = ((timeElapsed/32)%1024); // TODO: revert this change
			int seed = ((totalGameTime/32)%1024);			
			renderLightningBeamHorizontal(x, width, y, y+64, (seed+170*i)%1024, LIGHTNING_END_START);
		}
		break;
	case NEW_SECTION:
		break;
	case END_SONG:
		line(rm.m_backbuf, x, y+0, x+64*numColumns, y+0, END_SECTION_COLOR1);
		line(rm.m_backbuf, x, y+1, x+64*numColumns, y+1, END_SECTION_COLOR2);
		line(rm.m_backbuf, x, y+2, x+64*numColumns, y+2, END_SECTION_COLOR1);
		line(rm.m_backbuf, x, y+3, x+64*numColumns, y+3, COLOR_WHITE);
		break;
	case BPM_CHANGE:
		line(rm.m_backbuf, x, y+0, x+64*numColumns, y+0, BPM_CHANGE_COLOR1);
		line(rm.m_backbuf, x, y+1, x+64*numColumns, y+1, BPM_CHANGE_COLOR2);
		line(rm.m_backbuf, x, y+2, x+64*numColumns, y+2, BPM_CHANGE_COLOR1);
		line(rm.m_backbuf, x, y+3, x+64*numColumns, y+3, COLOR_WHITE);
		renderWhiteNumber(n.color, x, y-10);
		break;
	case SCROLL_STOP:
		line(rm.m_backbuf, x, y+0, x+64*numColumns, y+0, SCROLL_STOP_COLOR1);
		line(rm.m_backbuf, x, y+1, x+64*numColumns, y+1, SCROLL_STOP_COLOR2);
		line(rm.m_backbuf, x, y+2, x+64*numColumns, y+2, SCROLL_STOP_COLOR1);
		line(rm.m_backbuf, x, y+3, x+64*numColumns, y+3, COLOR_WHITE);
		renderWhiteNumber(n.color, x, y-10);
		break;
	}
}
コード例 #13
0
ファイル: MatrixStorage.cpp プロジェクト: fast-project/lama
void _MatrixStorage::setContext( ContextPtr context )
{
    if ( context.get() != mContext.get() )
    {
        LAMA_LOG_DEBUG( logger, *this << ": new location = " << *context << ", old location = " << *mContext )
    }

    mContext = context;
}

/* --------------------------------------------------------------------------- */

void _MatrixStorage::localize( const _MatrixStorage& global, const Distribution& rowDist )
{
    LAMA_ASSERT_EQUAL_ERROR( getNumColumns(), global.getNumColumns() )
    LAMA_ASSERT_EQUAL_ERROR( global.getNumRows(), rowDist.getGlobalSize() )

    LAMA_THROWEXCEPTION( "No default implementation for localize available, matrix = " << *this )
}

/* --------------------------------------------------------------------------- */

IndexType _MatrixStorage::getNumValues() const
{
    // Default implementation builds sum of row sizes

    LAMAArray<IndexType> sizes;
    buildCSRSizes( sizes );
    HostReadAccess<IndexType> csrSizes( sizes );
    IndexType numValues = OpenMPUtils::sum( csrSizes.get(), mNumRows );