当前位置: 首页>>代码示例>>C++>>正文


C++ recalculate函数代码示例

本文整理汇总了C++中recalculate函数的典型用法代码示例。如果您正苦于以下问题:C++ recalculate函数的具体用法?C++ recalculate怎么用?C++ recalculate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了recalculate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void
GeneralMaster::focusNext(bool& leave, int& newRow, int& newCol, int type)
{
    int row = _table->currentRow();
    int col = _table->currentColumn();

    fixed remain = 0.0;
    for (int r = 0; r < _table->rows(); ++r) {
	remain += _table->cellValue(r, 1, false).toFixed();
	remain -= _table->cellValue(r, 2, false).toFixed();
    }

    if (type == Table::MoveNext && col == 0) {
	Id id = _table->cellValue(row, col).toId();
	fixed debit = _table->cellValue(row, 1).toFixed();
	fixed credit = _table->cellValue(row, 2).toFixed();
	if (id == INVALID_ID && row == _table->rows() - 1) {
	    leave = true;
	} else if (debit == 0.0 && credit == 0.0 && remain < 0.0) {
	    _table->setCellValue(row, 1, -remain);
	    recalculate();
	}
    } else if (type == Table::MoveNext && col == 1) {
	fixed debit = _table->cellValue(row, 1).toFixed();
	fixed credit = _table->cellValue(row, 2).toFixed();
	if (debit != 0.0) {
	    newRow = QMIN(row + 1, _table->rows() - 1);
	    newCol = 0;
	} else if (credit == 0.0 && remain > 0.0) {
	    _table->setCellValue(row, 2, remain);
	    recalculate();
	}
    } else if (type == Table::MovePrev && col == 0 && row > 0) {
	fixed debit = _table->cellValue(row - 1, 1).toFixed();
	newRow = row - 1;
	if (debit != 0.0)
	    newCol = 1;
	else
	    newCol = 2;
    } else if (type == Table::MovePrev && col == 2) {
	fixed debit = _table->cellValue(row, 1).toFixed();
	newRow = row;
	if (debit != 0.0)
	    newCol = 1;
	else
	    newCol = 0;
    }
}
开发者ID:thomasn,项目名称:quasar,代码行数:48,代码来源:general_master.cpp

示例2: next_block_index

void Planner::plan_move(const std::vector<int>& steps,
			float length,
			float speed,
			float acceleration,
			float entry_speed)
{
  PlanBlock *block = &block_buffer[block_buffer_head];
  block->move.steps = steps;
  block->move.length = length;
  block->move.speed = speed;
  block->move.acceleration = acceleration;
  block->entry_speed_sqr = 0;
  block->nominal_speed_sqr = speed*speed;
  block->max_change_speed_sqr = 2*length*acceleration;

  if (block_buffer_head == block_buffer_tail) {
    block->max_entry_speed_sqr = 0;
  }
  else {
    // Not first block, compute entry speed
    float prev_nominal_speed_sqr = 
      block_buffer[prev_block_index(block_buffer_head)].nominal_speed_sqr;
    block->max_entry_speed_sqr = std::min(std::min(entry_speed*entry_speed,
						   block->nominal_speed_sqr),
					  prev_nominal_speed_sqr);
  }
  
  block_buffer_head = next_buffer_head;  
  next_buffer_head = next_block_index(block_buffer_head);
  
  // Finish up by recalculating the plan with the new block.
  recalculate();
}
开发者ID:stela111,项目名称:oofw,代码行数:33,代码来源:planner.cpp

示例3: menu

void KFFWin_Flightplan::showFavoriteContextMenu( const QPoint &pos )
{
	KIconLoader loader;
	QPixmap pixmap;
	QIcon icon;
	QAction* remove;
	QAction* clear;
	QAction* edit;
	QAction* moveup;
	QAction* movedown;
	QAction* calc;
	KMenu menu( this );

	pixmap = loader.loadIcon( "edit-delete", KIconLoader::Small );
	icon.addPixmap( pixmap );
	remove = new QAction( icon, i18n( "&Remove waypoint" ), this );
	remove->setStatusTip( i18n( "Remove this waypoint" ) );
	connect( remove, SIGNAL( triggered() ), this, SLOT( removeNavaids() ) );

	pixmap = loader.loadIcon( "edit-clear-list", KIconLoader::Small );
	icon.addPixmap( pixmap );
	clear = new QAction( icon, i18n( "&Clear all waypoints" ), this );
	clear->setStatusTip( i18n( "Clear waypoint list" ) );
	connect( clear, SIGNAL( triggered() ), ui_widget.treewidget_navaids, SLOT( clear() ) );

	pixmap = loader.loadIcon( "edit-rename", KIconLoader::Small );
	icon.addPixmap( pixmap );
	edit = new QAction( icon, i18n( "&Edit waypoint altitude" ), this );
	edit->setStatusTip( i18n( "Edit this waypoint" ) );
	connect( edit, SIGNAL( triggered() ), this, SLOT( edit() ) );

	pixmap = loader.loadIcon( "arrow-up", KIconLoader::Small );
	icon.addPixmap( pixmap );
	moveup = new QAction( icon, i18n( "&Move waypoint up" ), this );
	moveup->setStatusTip( i18n( "Move this waypoint up" ) );
	connect( moveup, SIGNAL( triggered() ), this, SLOT( moveItemUp() ) );

	pixmap = loader.loadIcon( "arrow-down", KIconLoader::Small );
	icon.addPixmap( pixmap );
	movedown = new QAction( icon, i18n( "&Move waypoint down" ), this );
	movedown->setStatusTip( i18n( "Move this waypoint down" ) );
	connect( movedown, SIGNAL( triggered() ), this, SLOT( moveItemDown() ) );

	pixmap = loader.loadIcon( "view-refresh", KIconLoader::Small );
	icon.addPixmap( pixmap );
	calc = new QAction( icon, i18n( "&Recalculate Distance" ), this );
	calc->setStatusTip( i18n( "Force recalculate distance between all waypoints" ) );
	connect( calc, SIGNAL( triggered() ), this, SLOT( recalculate() ) );
	
	menu.addAction( remove );
	menu.addAction( edit );
	menu.addSeparator();
	menu.addAction( clear );
	menu.addSeparator();
	menu.addAction( moveup );
	menu.addAction( movedown );
	menu.addSeparator();
	menu.addAction( calc );
	menu.exec( mapToGlobal( pos + ui_widget.treewidget_navaids->pos() ) );
}
开发者ID:ac001,项目名称:ffs-central,代码行数:60,代码来源:win_flightplan.cpp

示例4: switch

int Spreadsheet::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QTableWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: modified(); break;
        case 1: cut(); break;
        case 2: copy(); break;
        case 3: paste(); break;
        case 4: del(); break;
        case 5: selectCurrentRow(); break;
        case 6: selectCurrentColumn(); break;
        case 7: recalculate(); break;
        case 8: setAutoRecalculate((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 9: findNext((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< Qt::CaseSensitivity(*)>(_a[2]))); break;
        case 10: findPrevious((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< Qt::CaseSensitivity(*)>(_a[2]))); break;
        case 11: somethingChanged(); break;
        default: ;
        }
        _id -= 12;
    }
    return _id;
}
开发者ID:xianjunzhengbackup,项目名称:LinuxBackup,代码行数:25,代码来源:moc_spreadsheet.cpp

示例5: recalculate

void
BankDeposit::slotAll()
{
    for (int row = 0; row < _tenders->rows(); ++row)
	_tenders->setCellValue(row, 2, _tenders->cellValue(row, 1));
    recalculate();
}
开发者ID:cwarden,项目名称:quasar,代码行数:7,代码来源:bank_deposit.cpp

示例6: assert

        Node *removeAt(size_t index, Node **toDelete) {
            assert(index < size);
            if (this == &emptyLeafNode)
                throw "Illegal argument";

            size_t leftSize = left->size;
            if (index < leftSize)
                left = left->removeAt(index, toDelete);
            else if (index > leftSize)
                right = right->removeAt(index - leftSize - 1, toDelete);
            else if (left == &emptyLeafNode && right == &emptyLeafNode) {
                assert(*toDelete == NULL);
                *toDelete = this;
                return &emptyLeafNode;
            } else if (left != &emptyLeafNode && right == &emptyLeafNode) {
                Node *result = left;
                left = NULL;
                assert(*toDelete == NULL);
                *toDelete = this;
                return result;
            } else if (left == &emptyLeafNode && right != &emptyLeafNode) {
                Node *result = right;
                right = NULL;
                assert(*toDelete == NULL);
                *toDelete = this;
                return result;
            } else {
                // We can remove the successor or the predecessor
                std::swap(value, getSuccessor());
                right = right->removeAt(0, toDelete);
            }
            recalculate();
            return balance();
        }
开发者ID:gepser,项目名称:Nayuki-web-published-code,代码行数:34,代码来源:AvlTreeList.hpp

示例7: findItem

// Set the widgets from the data object.
void 
ItemTransfer::dataToWidget()
{
    _gltxFrame->setData(_curr);
    _toNumber->setText(_link.number());
    _toShift->setId(_link.shiftId());
    _toStore->setId(_link.storeId());
    _account->setId(_curr.accountId());
    _inactive->setChecked(!_curr.isActive());

    // Load the items
    _items->setUpdatesEnabled(false);
    _items->clear();
    _lines.clear();
    _lookup->store_id = _curr.storeId();
    for (unsigned int i = 0; i < _curr.items().size(); ++i) {
	const ItemLine& line = _curr.items()[i];
	if (line.voided) continue;

	Item item;
	findItem(line.item_id, item);

	fixed on_hand, total_cost, on_order;
	_quasar->db()->itemGeneral(item.id(), "", _curr.storeId(),
				   QDate::currentDate(), on_hand, total_cost,
				   on_order);

	VectorRow* row = new VectorRow(_items->columns());
	row->setValue(0, Plu(line.item_id, line.number));
	row->setValue(1, item.description());
	row->setValue(2, line.size);
	row->setValue(3, on_hand / item.sizeQty(line.size));
	row->setValue(4, -line.quantity);
	row->setValue(5, -line.inv_cost);
	if (_company.depositAccount() != INVALID_ID)
	    row->setValue(6, -line.ext_deposit);
	_items->appendRow(row);

	AdjItem& iline = _lines[_items->rows() - 1];
	iline.item = item;
	iline.number = line.number;
	iline.size = line.size;
	iline.size_qty = line.size_qty;
	iline.quantity = -line.quantity;
	iline.inv_cost = -line.inv_cost;
	iline.ext_deposit = -line.ext_deposit;

	if (i == 0) {
	    for (unsigned int i = 0; i < iline.item.sizes().size(); ++i) {
		_size->insertItem(item.sizes()[i].name);
		if (item.sizes()[i].name == line.size)
		    _size->setCurrentItem(_size->count() - 1);
	    }
	}
    }
    _items->appendRow(new VectorRow(_items->columns()));
    _items->setUpdatesEnabled(true);

    recalculate();
}
开发者ID:cwarden,项目名称:quasar,代码行数:61,代码来源:item_transfer.cpp

示例8: VectorRow

// Set the widgets from the data object.
void 
GeneralMaster::dataToWidget()
{
    _gltxFrame->setData(_curr);
    _inactive->setChecked(!_curr.isActive());
    _reverse->setChecked(false);

    // Load the table model
    const vector<AccountLine>& lines = _curr.accounts();
    _table->clear();
    for (unsigned int line = 0; line < lines.size(); ++line) {
	Id account_id = lines[line].account_id;
	fixed amount = lines[line].amount;

	VectorRow* row = new VectorRow(_table->columns());
	row->setValue(0, account_id);
	if (amount > 0.0)
	    row->setValue(1, amount);
	else
	    row->setValue(2, -amount);
	_table->appendRow(row);
    }
    _table->appendRow(new VectorRow(_table->columns()));

    recalculate();
}
开发者ID:thomasn,项目名称:quasar,代码行数:27,代码来源:general_master.cpp

示例9: recalculate

void MouseSpectrogram::setTime(int from, int to)
{
  currentFrom = from;
  currentTo = to;
  // Recalculate and flush
  recalculate();
}
开发者ID:SidneyTTW,项目名称:PCHMS-Remake,代码行数:7,代码来源:mousespectrogram.cpp

示例10: recalculate

void tscrollbar_::place(const tpoint& origin, const tpoint& size)
{
	// Inherited.
	tcontrol::place(origin, size);

	recalculate();
}
开发者ID:Heark,项目名称:wesnoth,代码行数:7,代码来源:scrollbar.cpp

示例11: recalculate

void RedstoneWireTile::onPlace(TileSource* region, int x, int y, int z) {
	Tile::onPlace(region, x, y, z);
	recalculate(region, x, y, z);
	region->updateNeighborsAt({x, y + 1, z}, id);
	region->updateNeighborsAt({x, y - 1, z}, id);
	updateWires(region, x - 1, y, z);
	updateWires(region, x + 1, y, z);
	updateWires(region, x, y, z - 1);
	updateWires(region, x, y, z + 1);

	if(Tile::solid[region->getTile(x - 1, y, z).id])
		updateWires(region, x - 1, y + 1, z);
	else
		updateWires(region, x - 1, y - 1, z);

	if(Tile::solid[region->getTile(x + 1, y, z).id])
		updateWires(region, x + 1, y + 1, z);
	else
		updateWires(region, x + 1, y - 1, z);

	if(Tile::solid[region->getTile(x, y, z - 1).id])
		updateWires(region, x, y + 1, z - 1);
	else
		updateWires(region, x, y - 1, z - 1);

	if(Tile::solid[region->getTile(x, y, z + 1).id])
		updateWires(region, x, y + 1, z + 1);
	else
		updateWires(region, x, y - 1, z + 1);
}
开发者ID:DanHerePE,项目名称:PocketPower,代码行数:30,代码来源:RedstoneWireTile.cpp

示例12: recalculate

gui2::tpoint ttext::get_column_line(const gui2::tpoint& position) const
{
	recalculate();

	// Get the index of the character.
	int index, trailing;
	pango_layout_xy_to_index(layout_, position.x * PANGO_SCALE,
		position.y * PANGO_SCALE, &index, &trailing);

	// Extract the line and the offset in pixels in that line.
	int line, offset;
	pango_layout_index_to_line_x(layout_, index, trailing, &line, &offset);
	offset = PANGO_PIXELS(offset);

	// Now convert this offset to a column, this way is a bit hacky but haven't
	// found a better solution yet.

	/**
	 * @todo There's still a bug left. When you select a text which is in the
	 * ellipses on the right side the text gets reformatted with ellipses on
	 * the left and the selected character is not the one under the cursor.
	 * Other widget toolkits don't show ellipses and have no indication more
	 * text is available. Haven't found what the best thing to do would be.
	 * Until that time leave it as is.
	 */
	for(size_t i = 0; ; ++i) {
		const int pos = get_cursor_position(i, line).x;

		if(pos == offset) {
			return  gui2::tpoint(i, line);
		}
	}
}
开发者ID:PoignardAzur,项目名称:wesnoth,代码行数:33,代码来源:text.cpp

示例13: addAudioInput

//-----------------------------------------------------------------------------
tresult PLUGIN_API MultiBandProcessor::initialize (FUnknown* context)
{
	tresult res = BaseProcessor::initialize (context);
	if (res == kResultTrue)
	{
		addAudioInput (USTRING("Stereo In"), SpeakerArr::kStereo);
		addAudioOutput (USTRING("Stereo Out"), SpeakerArr::kStereo);

		params[0] = 1.00; //Listen: L/M/H/out
		params[1] = 0.103; //xover1
		params[2] = 0.878; //xover2
		params[3] = 0.54; //L drive    (1)
		params[4] = 0.00; //M drive
		params[5] = 0.60; //H drive
		params[6] = 0.45; //L trim     (2)
		params[7] = 0.50; //M trim
		params[8] = 0.50; //H trim
		params[9] = 0.22; //attack    (3) 
		params[10] = 0.602; //release   (4)
		params[11] = 0.55; //width
		params[12] = 0.; //MS swap

		fb1 = fb2 = fb3 = 0.f;
		gain1 = gain2 = gain3 = 0.f;

		recalculate ();
	}
	return res;
}
开发者ID:eriser,项目名称:Voltex,代码行数:30,代码来源:mdaMultiBandProcessor.cpp

示例14: recalculate

Pose *SKFRegion::generatePose( Point2D p ) {
	if( poses.empty() )
	{
		return NULL;
	}
	
	recalculate(); //TODO: only call this if points change

	assert(interpolator != NULL);

	unsigned nchannels = poses[0]->getChannelCount();
	float *data = new float[nchannels];

	for( unsigned i = 0; i < nchannels; i++ )
	{
		vector<float> values;
		for( unsigned j = 0; j < poses.size(); j++ )
		{
			values.push_back(poses[j]->getJointAngle(i));
		}
		data[i] = interpolator->interpolate( Rbf::point(p.x, p.y), values);
	}

	return new Pose( nchannels, 
		             poses[0]->getMaxOffset(), 
					 data,
					 poses[0]->getSkeleton());
}
开发者ID:dtbinh,项目名称:canvas,代码行数:28,代码来源:SKFRegion.cpp

示例15: recalculate

void Spreadsheet::somethingChanged()
{
    if(autoRecalc)
        recalculate();

    emit modified();
}
开发者ID:KleineKarsten,项目名称:CppGuiWithQt,代码行数:7,代码来源:spreadsheet.cpp


注:本文中的recalculate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。