Exemplo n.º 1
0
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;
    }
}
Exemplo n.º 2
0
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();
}
Exemplo n.º 3
0
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() ) );
}
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;
}
Exemplo n.º 5
0
void
BankDeposit::slotAll()
{
    for (int row = 0; row < _tenders->rows(); ++row)
	_tenders->setCellValue(row, 2, _tenders->cellValue(row, 1));
    recalculate();
}
        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();
        }
Exemplo n.º 7
0
// 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();
}
Exemplo n.º 8
0
// 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();
}
Exemplo n.º 9
0
void MouseSpectrogram::setTime(int from, int to)
{
  currentFrom = from;
  currentTo = to;
  // Recalculate and flush
  recalculate();
}
Exemplo n.º 10
0
void tscrollbar_::place(const tpoint& origin, const tpoint& size)
{
	// Inherited.
	tcontrol::place(origin, size);

	recalculate();
}
Exemplo n.º 11
0
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);
}
Exemplo n.º 12
0
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);
		}
	}
}
Exemplo n.º 13
0
void RedstoneWireTile::playerDestroy(Player* player, int x, int y, int z, int side) {
	player->region.updateNeighborsAt({x, y + 1, z}, id);
	player->region.updateNeighborsAt({x, y - 1, z}, id);
	player->region.updateNeighborsAt({x + 1, y, z}, id);
	player->region.updateNeighborsAt({x - 1, y, z}, id);
	player->region.updateNeighborsAt({x, y, z + 1}, id);
	player->region.updateNeighborsAt({x, y, z - 1}, id);
	recalculate(&player->region, x, y, z);
	updateWires(&player->region, x - 1, y, z);
	updateWires(&player->region, x + 1, y, z);
	updateWires(&player->region, x, y, z - 1);
	updateWires(&player->region, x, y, z + 1);

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

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

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

	if(Tile::solid[player->region.getTile(x, y, z + 1).id])
		updateWires(&player->region, x, y + 1, z + 1);
	else
		updateWires(&player->region, x, y - 1, z + 1);
		
	Tile::playerDestroy(player, x, y, z, side);
}
Exemplo n.º 14
0
//-----------------------------------------------------------------------------
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;
}
Exemplo n.º 15
0
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());
}
Exemplo n.º 16
0
void Spreadsheet::somethingChanged()
{
    if(autoRecalc)
        recalculate();

    emit modified();
}
Exemplo n.º 17
0
std::string ttext::get_token(const gui2::tpoint & position, const char * delim) const
{
	recalculate();

	// Get the index of the character.
	int index, trailing;
	if (!pango_layout_xy_to_index(layout_, position.x * PANGO_SCALE,
		position.y * PANGO_SCALE, &index, &trailing)) {
		return "";
	}

	std::string txt = pango_layout_get_text(layout_);

	std::string d(delim);

	if (index < 0 || (static_cast<size_t>(index) >= txt.size()) || d.find(txt.at(index)) != std::string::npos) {
		return ""; // if the index is out of bounds, or the index character is a delimiter, return nothing
	}

	size_t l = index;
	while (l > 0 && (d.find(txt.at(l-1)) == std::string::npos)) {
		--l;
	}

	size_t r = index + 1;
	while (r < txt.size() && (d.find(txt.at(r)) == std::string::npos)) {
		++r;
	}

	return txt.substr(l,r-l);
}
Exemplo n.º 18
0
//-----------------------------------------------------------------------------
tresult PLUGIN_API AmbienceProcessor::initialize (FUnknown* context)
{
	tresult res = BaseProcessor::initialize (context);
	if (res == kResultTrue)
	{
		addAudioInput (USTRING("Stereo In"), SpeakerArr::kStereo);
		addAudioOutput (USTRING("Stereo Out"), SpeakerArr::kStereo);

		//inits here!
		params[0] = 0.7; //size
		params[1] = 0.7; //hf
		params[2] = 0.9; //mix
		params[3] = 0.5; //output

		buf1 = new float[1024];
		buf2 = new float[1024];
		buf3 = new float[1024];
		buf4 = new float[1024];

		fil = 0.0f;
		den = pos = 0;
		recalculate ();
	}
	return res;
}
Exemplo n.º 19
0
// Set from normal value
void DoubleExp::set(double value)
{
	if (fabs(value) > std::numeric_limits<double>::min()) exponent_ = floor(log10(fabs(value)));
	else exponent_ = 0;
	mantissa_ = value / pow(10.0,exponent_);
	recalculate();
// 	printf("Input value %f gives mantissa of %f and exponent of %i\n", value, mantissa_, exponent_);
}
Exemplo n.º 20
0
void ofxTextBox::setText(string value){
	if(allText != value)
	{
		// store all text without split by lines
		allText =  value;
		recalculate(allText);
	}
}
Exemplo n.º 21
0
QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &value)
{
	if (change == ItemPositionHasChanged) {
		recalculate();
		ruler->recalculate();
	}
	return QGraphicsEllipseItem::itemChange(change, value);
}
Exemplo n.º 22
0
void BBox::height(Real _h, bool _recalc) noexcept
{
  m_height=_h;
  if(_recalc)
  {
    recalculate();
  }
}
Exemplo n.º 23
0
/* Checks if recalculation is needed and runs it if yes. */
static void
recalculate_if_needed(columns_t cols, size_t max_width)
{
	if(recalculation_is_needed(cols, max_width))
	{
		recalculate(cols, max_width);
	}
}
Exemplo n.º 24
0
void BBox::width(Real _w, bool _recalc) noexcept
{
  m_width=_w;
  if(_recalc)
  {
    recalculate();
  }
}
Exemplo n.º 25
0
void BBox::depth(Real _d, bool _recalc) noexcept
{
  m_depth=_d;
  if(_recalc)
  {
    recalculate();
  }
}
Exemplo n.º 26
0
void RulerNodeItem2::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
	qreal x = event->scenePos().x();
	if (x < 0.0)
		x = 0.0;
	setPos(x, event->scenePos().y());
	recalculate();
	ruler->recalculate();
}
Exemplo n.º 27
0
void RulerItem2::setPlotInfo(plot_info info)
{
	pInfo = info;
	dest->setPlotInfo(info);
	source->setPlotInfo(info);
	dest->recalculate();
	source->recalculate();
	recalculate();
}
Exemplo n.º 28
0
void RedstoneWireTile::neighborChanged(TileSource* region, int x, int y, int z, int newX, int newY, int newZ) {
	if(!canSurvive(region, x, y, z)) {
		popResource(region, x, y, z, ItemInstance(Item::items[getResource(NULL, 0, 0)]));
		region->removeTile(x, y, z);
		return;
	}
	recalculate(region, x, y, z);
	Tile::neighborChanged(region, x, y, z, newX, newY, newZ);
}
Exemplo n.º 29
0
void ttext::rerender(const bool force) const
{
	if(surface_dirty_ || force) {
		assert(layout_);

		recalculate(force);
		surface_dirty_ = false;

		int width = rect_.x + rect_.width;
		int height = rect_.y + rect_.height;
		if (maximum_width_  > 0 && width  > maximum_width_ ) width  = maximum_width_;
		if (maximum_height_ > 0 && height > maximum_height_) height = maximum_height_;
		const unsigned stride = width * 4;
		create_surface_buffer(stride * height);

		cairo_surface_t *cairo_surface =
			cairo_image_surface_create_for_data(surface_buffer_,
				CAIRO_FORMAT_ARGB32, width, height, stride);
		cairo_t *cr = cairo_create(cairo_surface);

		/* set color (used for foreground). */
		cairo_set_source_rgba(cr,
			 (foreground_color_ >> 24)         / 256.0,
			((foreground_color_ >> 16) & 0xFF) / 256.0,
			((foreground_color_ >> 8)  & 0xFF) / 256.0,
			(foreground_color_         & 0xFF) / 256.0);

		pango_cairo_show_layout(cr, layout_);

#ifndef _WIN32

		// The cairo surface is in CAIRO_FORMAT_ARGB32 which uses
		// pre-multiplied alpha. SDL doesn't use that so the pixels need to be
		// decoded again.
		for (int y = 0; y < height; ++y) {
			for (int x = 0; x < width; ++x)
			{
				unsigned char *pixel = &surface_buffer_[(y * width + x) * 4];
				decode_pixel(pixel);
			}
		}
#else
		// The solution code above doesn't seem to work properly on windows so
		// use the old trick of drawing the same text a few times.
		pango_cairo_show_layout(cr, layout_);
		pango_cairo_show_layout(cr, layout_);
		pango_cairo_show_layout(cr, layout_);
#endif
		surface_.assign(SDL_CreateRGBSurfaceFrom(
			surface_buffer_, width, height, 32, stride,
			0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000));
#ifdef SDL_GPU
		texture_ = sdl::timage(surface_);
#endif
		cairo_destroy(cr);
		cairo_surface_destroy(cairo_surface);
	}
Exemplo n.º 30
0
ATEN_USING_NAMESPACE

// Constructors
DoubleExp::DoubleExp()
{
	mantissa_ = 0.0;
	exponent_ = 0.0;
	recalculate();
}