void DataManager::changeGridElevation(int x, int y, int elevation) {
	CellData* cd = &GET_GRID_ITEM(grid,x,y);
	if (cd->elevation != elevation) {
		cd->elevation = elevation;
		gridChanged(x, y, cd);
	}
}
Esempio n. 2
0
/*!
  \brief Assign a y axis division
  \param sy Scale division
  \warning QwtPlotGrid uses implicit sharing (see Qt Manual) for
  the scale divisions.
  \sa QwtScaleDiv
*/
void QwtPlotGrid::setYDiv(const QwtScaleDiv &sy)
{
    if ( d_data->sdy != sy )
    {
        d_data->sdy = sy;    
        gridChanged();
    }
}
Esempio n. 3
0
/*!
  \brief Assign a pen for the minor gridlines
  \param p Pen
*/
void QwtPlotGrid::setMinPen(const QPen &p)
{
    if ( d_data->minPen != p )
    {
        d_data->minPen = p;  
        gridChanged();
    }
}
Esempio n. 4
0
/*!
  \brief Enable or disable horizontal gridlines
  \param tf Enable (true) or disable
  \sa Minor gridlines can be enabled or disabled with QwtPlotGrid::enableYMin()
*/
void QwtPlotGrid::enableY(bool tf)
{
    if ( d_data->yEnabled != tf )
    {
        d_data->yEnabled = tf;  
        gridChanged();
    }
}
Esempio n. 5
0
/*!
  \brief Enable or disable  minor vertical gridlines.
  \param tf Enable (true) or disable
  \sa QwtPlotGrid::enableX()
*/
void QwtPlotGrid::enableXMin(bool tf)
{
    if ( d_data->xMinEnabled != tf )
    {
        d_data->xMinEnabled = tf;
        gridChanged();
    }
}
Esempio n. 6
0
/*!
  \brief Assign an x axis scale division
  \param sx Scale division
  \warning QwtPlotGrid uses implicit sharing (see Qt Manual) for
  the scale divisions.
  \sa QwtScaleDiv
*/
void QwtPlotGrid::setXDiv(const QwtScaleDiv &sx)
{
    if ( d_data->sdx != sx )
    {
        d_data->sdx = sx;
        gridChanged();
    }
}
void DataManager::addGridObject(int x, int y, ObjectPtr object) {
	assert(x >= 0);
	assert(y >= 0);
	assert(x < GRID_WIDTH);
	assert(y < GRID_HEIGHT);
	CellData* cd = &GET_GRID_ITEM(grid,x,y);
	cd->objects.push_back(object);
	gridChanged(x, y, cd);
}
Esempio n. 8
0
void GridConfig::accept()
{
    int n = ui->lineEdit->text().toInt();
    if (n != m_num) {
        m_num = n;
        emit gridChanged(m_num);
    }

    QDialog::accept();
}
void DataManager::removeGridObject(int x, int y, ObjectPtr object) {
	CellData* cd = &GET_GRID_ITEM(grid,x,y);
	ObjectList* objects = &cd->objects;
	for (ObjectList::iterator it = objects->begin(); it != objects->end(); it++) {
		if (*it == object) {
			objects->erase(it);
			gridChanged(x, y, cd);
			break;
		}
	}
}
// grid on or off
void ffmpegWidget::setGrid(bool grid) {
    if (_grid != grid) {
        _grid = grid;
        emit gridChanged(grid);
        if (!disableUpdates) {
            // Grid changed, so redraw it on current image
            if (this->xv_format >= 0) makeFullFrame();        
            update();
        }
    }
}
Esempio n. 11
0
void HashLife::setGrid(const BigInteger &x, const BigInteger &y, int state)
{
	if (m_running)
		return;
	m_writeLock->lock();
	BigInteger my_x = x - m_x, my_y = y - m_y;
	// out of range
	// TODO: optimization
	while (my_x.sgn() < 0 || my_x.bitCount() > m_depth || my_y.sgn() < 0 || my_y.bitCount() > m_depth)
	{
		expand();
		my_x = x - m_x;
		my_y = y - m_y;
	}
    Node *p = m_root, **stack = new Node *[m_depth + 1];
    int *cid_stack = new int[m_depth + 1];
	size_t depth = m_depth;
	while (depth > Block::DEPTH)
	{
		stack[depth] = p;
		int cid = (my_y.bit(depth - 1) << 1) | my_x.bit(depth - 1);
		cid_stack[depth] = cid;
		depth--;
		p = p->child[cid];
	}
	Block *block = reinterpret_cast<Block *>(p);
	int cid = (my_y.lowbits<int>(Block::DEPTH) << 1) | my_x.lowbits<int>(Block::DEPTH);
	if (block->child[cid] != state)
	{
		unsigned char c[4];
		c[0] = block->child[0];
		c[1] = block->child[1];
		c[2] = block->child[2];
		c[3] = block->child[3];
		c[cid] = state;
		p = reinterpret_cast<Node *>(m_blockHash->get(c[0], c[1], c[2], c[3]));
		while (depth++ < m_depth)
		{
			Node *c[4], *node = stack[depth];
			c[0] = node->child[0];
			c[1] = node->child[1];
			c[2] = node->child[2];
			c[3] = node->child[3];
			c[cid_stack[depth]] = p;
			p = m_nodeHash->get(c[0], c[1], c[2], c[3]);
		}
		m_root = p;
	}
    delete stack;
    delete cid_stack;
	m_writeLock->unlock();
	emit gridChanged();
}
Esempio n. 12
0
ApplicationSettingsDialog::ApplicationSettingsDialog(QWidget *parent)
    : Dialog(parent) {

  setWindowTitle(tr("Kst Settings"));

  _generalTab = new GeneralTab(this);
  _gridTab = new GridTab(this);
  connect(_generalTab, SIGNAL(apply()), this, SLOT(generalChanged()));
  connect(_gridTab, SIGNAL(apply()), this, SLOT(gridChanged()));

  DialogPage *general = new DialogPage(this);
  general->setPageTitle(tr("General"));
  general->addDialogTab(_generalTab);
  addDialogPage(general);

  DialogPage *grid = new DialogPage(this);
  grid->setPageTitle(tr("Grid"));
  grid->addDialogTab(_gridTab);
  addDialogPage(grid);

  setupGeneral();
  setupGrid();
}
Esempio n. 13
0
void HashLife::receive(DataChannel *channel)
{
	//m_writeLock->lock();
	//m_readLock->lock();
	// out of range
	// TODO: optimization
	BigInteger x1 = mc_x - m_x, y1 = mc_y - m_y, x2 = x1 + BigInteger(mc_w - 1), y2 = y1 + BigInteger(mc_h - 1);
	while (x1.sgn() < 0 || x2.sgn() < 0 || x2.bitCount() > m_depth || y1.sgn() < 0 || y2.sgn() < 0 || y2.bitCount() > m_depth)
	{
		expand();
		x1 = mc_x - m_x;
		y1 = mc_y - m_y;
		x2 = x1 + BigInteger(mc_w - 1);
		y2 = y1 + BigInteger(mc_h - 1);
	}

	BigInteger x = mc_x, y = mc_y;
	int state;
	quint64 cnt;
	while (channel->receive(&state, &cnt), state != DATACHANNEL_EOF)
	{
		if (state == DATACHANNEL_EOLN)
		{
			x = mc_x;
			y += cnt;
		}
		else
			for (int i = 0; i < cnt; i++)
			{
				setGrid(x, y, state);
				x += 1;
			}
	}
	//m_readLock->unlock();
	//m_writeLock->unlock();
	emit gridChanged();
}
Esempio n. 14
0
/**
 * The PuzzleView class constructor.
 * It takes a PuzzleModel pointer, then layout a grid of tiles 
 * accroding to the model.
 */
PuzzleView::PuzzleView(PuzzleModel *pm, QWidget *parent) :
QWidget(parent), m_Model(pm)
{
	// Construct and install a grid layout to the PuzzleView widget.
	// Passing 'this' as parent now is equivalent to calling 
	// setLayout(m_Layout) later.
	m_Layout = new QGridLayout(this);
	
	m_Layout->setContentsMargins(0, 0, 0, 0);
	m_Layout->setSpacing(0);
	
	int numRows = m_Model->rowCount();
	int numCols = m_Model->colCount();
	
	// Add 15 buttons to button group and lay them out.
	for(int r = 0; r < numRows; ++r)
	{
		for(int c = 0; c < numCols; ++c)
		{
			int id = m_Model->value(r, c);
			if(id != 0)
			{
				Tile *t = new Tile(id);
				m_Buttons.addButton(t, id); // Button ID 1 ~ 15.
				m_Layout->addWidget(t, r, c);
			}
		}
	}
		
	// Refresh puzzle view when puzzle model changes.
	connect(m_Model, SIGNAL(gridChanged()),
	        this, SLOT(refresh()));
	
	// Try sliding cells when a button is clicked.     
	connect(&m_Buttons, SIGNAL(buttonClicked(QAbstractButton *)),
	        this, SLOT(tryToSlide(QAbstractButton *)));
}
Esempio n. 15
0
void HashLife::run()
{
	QTime timer;
	timer.start();
	m_running = true;
	m_writeLock->lock();
	m_readLock->lock();
	while (m_increment + 2 > m_depth)
		expand();
	Node *e = emptyNode(m_depth - 2);
	// Test boundary to be empty, or we have to expand() to guarantee the result fits in the boundary
	// This requires m_depth to be at least Block::DEPTH + 2
	if ((m_root->ul->ul != e || m_root->ul->ur != e || m_root->ul->dl != e)
		|| (m_root->ur->ul != e || m_root->ur->ur != e || m_root->ur->dr != e)
		|| (m_root->dl->ul != e || m_root->dl->dl != e || m_root->dl->dr != e)
		|| (m_root->dr->ur != e || m_root->dr->dl != e || m_root->dr->dr != e))
		expand();
	// To make the depth of RESULT equal to m_depth, we first expand the universe
	// This is nearly identical to code in expand() except we don't need to touch m_x and m_y
	e = emptyNode(m_depth - 1);
	Node *nul = m_nodeHash->get(e, e, e, m_root->ul);
	Node *nur = m_nodeHash->get(e, e, m_root->ur, e);
	Node *ndl = m_nodeHash->get(e, m_root->dl, e, e);
	Node *ndr = m_nodeHash->get(m_root->dr, e, e, e);
	Node *nroot = m_nodeHash->get(nul, nur, ndl, ndr);
	m_readLock->unlock();
	Node *new_root = runNode(nroot, m_depth + 1);
	m_readLock->lock();
	m_root = new_root;
	m_readLock->unlock();
	m_writeLock->unlock();
	m_generation += BigInteger::exp2(m_increment);
	m_running = false;
	emit gridChanged();
	qDebug() << timer.elapsed();
}
Esempio n. 16
0
void GridCommand::setGrid(int grid)
{
    this->grid = grid;
    emit gridChanged(this->grid);
}
Save_grid_dialog::Save_grid_dialog( const GsTL_project* project,
				    QWidget * parent, const char * name) 
  : QFileDialog( parent ) {

  if (name)
    setObjectName(name);
  
  setModal(true);
  setFileMode( QFileDialog::AnyFile );
  setLabelText(QFileDialog::Accept, "Save");

  QGridLayout * lo = dynamic_cast<QGridLayout*>(this->layout());
  
  grid_selector_ = new QComboBox( this);
  QLabel* label = new QLabel( "Grid to save", this );
  lo->addWidget(label, 4,0,Qt::AlignLeft);
  lo->addWidget(grid_selector_,4,1,Qt::AlignLeft);



  //TL modified
  propList_ = new QListWidget( this);
  propList_->setSelectionMode(QAbstractItemView::ExtendedSelection);
  QLabel* plabel = new QLabel( "Properties to save", this );
  lo->addWidget(plabel, 5,0,Qt::AlignLeft);
  lo->addWidget(propList_,5,1,Qt::AlignLeft);


  //TL + AB modified
  masked_as_regular_frame_ = new QFrame(this);
  saveRegular_ = new QCheckBox(masked_as_regular_frame_);
  //saveRegular_->setDisabled(true);
  QLabel* slabel = new QLabel( "Save masked grid as Cartesian", masked_as_regular_frame_ );
  QHBoxLayout* mgrid_to_cgrid_layout = new QHBoxLayout(masked_as_regular_frame_);
  mgrid_to_cgrid_layout->addWidget(slabel);
  mgrid_to_cgrid_layout->addWidget(saveRegular_);
  masked_as_regular_frame_->setLayout(mgrid_to_cgrid_layout);
  lo->addWidget(masked_as_regular_frame_,6,1,Qt::AlignLeft);
  masked_as_regular_frame_->setVisible(false);

 // lo->addWidget(slabel, 6,0,Qt::AlignLeft);
 // lo->addWidget(saveRegular_,6,1,Qt::AlignLeft);
  
  // search for available output filters

  QStringList filters;
  SmartPtr<Named_interface> ni_filter = 
    Root::instance()->interface( outfilters_manager );
  Manager* dir = dynamic_cast<Manager*>( ni_filter.raw_ptr() );
  appli_assert( dir );

  Manager::type_iterator begin = dir->begin();
  Manager::type_iterator end = dir->end();
  for( ; begin != end ; ++begin ) {
    SmartPtr<Output_filter> outf(dynamic_cast<Output_filter*>(dir->new_interface(*begin).raw_ptr() ));
    if( outf->type_data() != "Grid") continue;
    QString filt( begin->c_str() );
    filt += " (*.*)";
    filters.push_back( filt ) ;
  }

  setFilters( filters );

  
  // search for available grids

  const GsTL_project::String_list& grids = project->objects_list();
  typedef GsTL_project::String_list::const_iterator const_iterator;
  for( const_iterator it = grids.begin(); it != grids.end(); ++it ) {
    grid_selector_->addItem( it->c_str() );
  }

  QObject::connect( grid_selector_, SIGNAL( activated(const QString &) ),
	  this, SLOT( gridChanged(const QString &) ) );

  if (!grid_selector_->currentText().isEmpty())
	gridChanged(grid_selector_->currentText());
}
Esempio n. 18
0
void DataManager::addGridObject(int x, int y, ObjectPtr object) {
	CellData* cd = &GET_GRID_ITEM(grid,x,y);
	cd->objects.push_back(object);
	gridChanged(x, y, cd);
}
Esempio n. 19
0
void PreferencesEditorPage::widthGridSliderMoved(int value)
{
	SettingsManager::setValue("GridWidth", value);
	emit gridChanged();
}
Esempio n. 20
0
void PreferencesEditorPage::indexGridSliderMoved(int value)
{
	SettingsManager::setValue("IndexGrid", value);
	emit gridChanged();
}
Esempio n. 21
0
PlotControlWidget::PlotControlWidget(QWidget *parent) :
    ControlWidget(parent),
    ui(new Ui::PlotControlWidget)
{
    ui->setupUi(this);

    ui->gridLayout->setSpacing(0);
    ui->gridLayout->setMargin(0);
    ui->verticalLayout->setSpacing(0);
    ui->verticalLayout->setMargin(0);
    ui->verticalLayout_3->setSpacing(0);
    ui->verticalLayout_3->setMargin(0);
    ui->verticalLayout_4->setSpacing(0);
    ui->verticalLayout_4->setMargin(0);
    ui->verticalLayout_5->setSpacing(0);
    ui->verticalLayout_5->setMargin(0);
    ui->verticalLayout_6->setSpacing(0);
    ui->verticalLayout_6->setMargin(0);
    ui->verticalLayout_8->setSpacing(0);
    ui->verticalLayout_8->setMargin(0);


    layout()->setSpacing(0);
    layout()->setMargin(0);



    mFastenToolButtonVector << ui->fastenToolButton_0;
    mFastenToolButtonVector << ui->fastenToolButton_1;
    mFastenToolButtonVector << ui->fastenToolButton_2;
    mFastenToolButtonVector << ui->fastenToolButton_3;
    mFastenToolButtonVector << ui->fastenToolButton_4;
    mFastenToolButtonVector << ui->fastenToolButton_5;
    mFastenToolButtonVector << ui->fastenToolButton_6;
    mFastenToolButtonVector << ui->fastenToolButton_7;
    mFastenToolButtonVector << ui->fastenToolButton_8;
    mFastenToolButtonVector << ui->fastenToolButton_9;
    mFastenToolButtonVector << ui->fastenToolButton_10;
    mFastenToolButtonVector << ui->fastenToolButton_11;
    mFastenToolButtonVector << ui->fastenToolButton_12;
    for (int i = 0; i < mFastenToolButtonVector.size(); ++i) {
        mFastenToolButtonVector[i]->setChecked(sTabVisibilityVector[i]);
        connect(mFastenToolButtonVector[i], SIGNAL(toggled(bool)),
                this, SLOT(treatFastenToolButtonPressed()));
    }
    mTabsVector << ui->tab_0;
    mTabsVector << ui->tab_1;
    mTabsVector << ui->tab_2;
    mTabsVector << ui->tab_3;
    mTabsVector << ui->tab_4;
    mTabsVector << ui->tab_5;
    mTabsVector << ui->tab_6;
    mTabsVector << ui->tab_7;
    mTabsVector << ui->tab_8;
    mTabsVector << ui->tab_9;
    mTabsVector << ui->tab_10;
    mTabsVector << ui->tab_11;
    mTabsVector << ui->tab_12;

    for (auto tab : mTabsVector) {
        tab->layout()->setSpacing(0);
        tab->layout()->setMargin(0);
    }


    ui->xGridWidget->setHead("X grid");
    ui->yGridWidget->setHead("Y grid");
    ui->xSubGridWidget->setHead("X sub grid");
    ui->ySubGridWidget->setHead("Y sub grid");

    ui->scaleTypeComboBox->addItem("Linear", PlotLayoutModel::ScaleType::Linear);
    ui->scaleTypeComboBox->addItem("Logarithmic", PlotLayoutModel::ScaleType::Logarithmic);

    ui->timeFormatComboBox->addItem("Number", QCPAxis::ltNumber);
    ui->timeFormatComboBox->addItem("DateTime", QCPAxis::ltDateTime);

    ui->subTickEditingWidget->setSubTickCountVisibility(false);

    connect(ui->xLowMarginLineEdit, SIGNAL(editingFinished()),
            this, SLOT(treatXLowLimitRequest()));
    connect(ui->xHighMarginLineEdit, SIGNAL(editingFinished()),
            this, SLOT(treatXHighLimitRequest()));
    connect(ui->xLabelLineEdit, SIGNAL(editingFinished()),
            this, SLOT(treatXLabelChanging()));
    connect(ui->titleEditingWidget, SIGNAL(titleChanged()),
            this, SLOT(treatTitleChanging()));
    connect(ui->titleEditingWidget, SIGNAL(titlePropertiesChanged()),
            this, SLOT(treatTitlePropertiesChanging()));

    connect(ui->scaleTypeComboBox, SIGNAL(valueActivated(boost::any)),
            this, SLOT(treatScaleTypeChanging()));
    connect(ui->timeFormatComboBox, SIGNAL(valueActivated(boost::any)),
            this, SLOT(treatTimeAxisTypeChanging()));
    connect(ui->xTickRotationDoubleSpinBox, SIGNAL(valueChanged(double)),
            this, SLOT(treatXTickRotationChanging()));
    connect(ui->eventLabelRotationDoubleSpinBox, SIGNAL(valueChanged(double)),
            this, SLOT(treatCommandLabelRotationChanging()));

    connect(ui->legendLayoutComboBox, SIGNAL(currentLegendLocationChanged(style::LegendLocation)),
            this, SLOT(treatLegendLayoutChanging()));

    connect(ui->legendFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatLegendFontSizeChanging()));
    connect(ui->yLabelFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatUnitsFontSizeChanging()));
    connect(ui->xLabelFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatXLabelFontSizeChanging()));
    connect(ui->xAxisFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatXAxisFontSizeChanging()));
    connect(ui->yAxisFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatYAxisFontSizeChanging()));
//    connect(ui->titleFontSizeSpinBox, SIGNAL(valueChanged(int)),
//            this, SLOT(treatTitleFontSizeChanging()));
    connect(ui->eventFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatEventFontSizeChanging()));
    connect(ui->arrowedTextFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatArrowedTextFontSizeChanging()));

    connect(ui->legendFrameVisibilityCheckBox, SIGNAL(toggled ( bool )),
            this, SLOT(treatLegendFrameVisibilityChanging()));
    connect(ui->legendVisibilityCheckBox, SIGNAL(toggled ( bool )),
            this, SLOT(treatLegendVisibilityChanging()));
    connect(ui->unitsVisibilityCheckBox, SIGNAL(toggled ( bool )),
            this, SLOT(treatUnitsVisibilityChanging()));

    connect(ui->defaultPushButton, SIGNAL(clicked(bool)),
            this, SLOT(initiliazeLayoutPreferencesFromDefault()));


    connect(ui->xGridWidget, SIGNAL(gridChanged(style::Grid)),
            this, SLOT(treatXGridChanging()));
    connect(ui->yGridWidget, SIGNAL(gridChanged(style::Grid)),
            this, SLOT(treatYGridChanging()));
    connect(ui->xSubGridWidget, SIGNAL(gridChanged(style::Grid)),
            this, SLOT(treatXSubGridChanging()));
    connect(ui->ySubGridWidget, SIGNAL(gridChanged(style::Grid)),
            this, SLOT(treatYSubGridChanging()));
    connect(ui->axisRectEditingWidget, SIGNAL(axisRectPropertiesChanged()),
            this, SLOT(treatAxisRectChanging()));
    connect(ui->tickEditingWidget, SIGNAL(tickChanged()),
            this, SLOT(treatTickChanging()));
    connect(ui->subTickEditingWidget, SIGNAL(tickChanged()),
            this, SLOT(treatSubTickChanging()));
    connect(ui->colorSetEdititngWidget, SIGNAL(colorPrefChangedByUser()),
            this, SLOT(treatColorPrefChanging()));

    connect(ui->xAxisPrefWidget, SIGNAL(axisPrefChanged()),
            this, SLOT(treatXAxisPrefChanging()));
    connect(ui->yAxisPrefWidget, SIGNAL(axisPrefChanged()),
            this, SLOT(treatYAxisPrefChanging()));

    //NOTE: To avoid signal valueChanged emitting on each keyboard button pressing. ValueChanged signal will be emitted
    //only after Return is pressed or if widget loses focus.
    ui->xTickRotationDoubleSpinBox->setKeyboardTracking(false);
    ui->eventLabelRotationDoubleSpinBox->setKeyboardTracking(false);
    ui->legendFontSizeSpinBox->setKeyboardTracking(false);
    ui->yLabelFontSizeSpinBox->setKeyboardTracking(false);
    ui->xLabelFontSizeSpinBox->setKeyboardTracking(false);
    ui->xAxisFontSizeSpinBox->setKeyboardTracking(false);
//    ui->titleFontSizeSpinBox->setKeyboardTracking(false);
    ui->eventFontSizeSpinBox->setKeyboardTracking(false);
    ui->arrowedTextFontSizeSpinBox->setKeyboardTracking(false);

    QDoubleValidator *doubleValidator = new QDoubleValidator(this);
    ui->xLowMarginLineEdit->setValidator(doubleValidator);
    ui->xHighMarginLineEdit->setValidator(doubleValidator);

}