void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
{
  mcbDirection->clear();
  mcbSpeed->clear();

  mcbDirection->insertItem( 0, tr( "Always use default" ) );
  mcbSpeed->insertItem( 0, tr( "Always use default" ) );

  QgsVectorLayer* vl = selectedLayer();
  if ( !vl )
    return;

  QgsVectorDataProvider* provider = vl->dataProvider();
  if ( !provider )
    return;

  const QgsFields& fields = provider->fields();
  for ( int idx = 0; idx < fields.count(); ++idx )
  {
    const QgsField& currentField = fields[idx];
    QVariant currentType = currentField.type();
    if ( currentType == QVariant::Int || currentType == QVariant::String )
    {
      mcbDirection->insertItem( 1, currentField.name() );
    }
    if ( currentType == QVariant::Int || currentType == QVariant::Double )
    {
      mcbSpeed->insertItem( 1, currentField.name() );
    }
  }

} // RgDSettingsDlg::on_mcbLayers_selectItem()
Esempio n. 2
0
void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
{
  mcbDirection->clear();
  mcbSpeed->clear();

  mcbDirection->insertItem( 0, tr( "Always use default" ) );
  mcbSpeed->insertItem( 0, tr( "Always use default" ) );

  QgsVectorLayer* vl = selectedLayer();
  if ( !vl )
    return;

  Q_FOREACH ( const QgsField& currentField, vl->fields() )
  {
    QVariant currentType = currentField.type();
    if ( currentType == QVariant::Int || currentType == QVariant::LongLong ||
         currentType == QVariant::String )
    {
      mcbDirection->insertItem( 1, currentField.name() );
    }
    if ( currentType == QVariant::Int || currentType == QVariant::LongLong ||
         currentType == QVariant::Double )
    {
      mcbSpeed->insertItem( 1, currentField.name() );
    }
  }
}
void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
{
  mcbDirection->clear();
  mcbSpeed->clear();

  mcbDirection->insertItem( 0, tr( "Always use default" ) );
  mcbSpeed->insertItem( 0, tr( "Always use default" ) );

  QgsVectorLayer* vl = selectedLayer();
  if ( !vl )
    return;

  QgsVectorDataProvider* provider = vl->dataProvider();
  if ( !provider )
    return;

  const QgsFieldMap& fields = provider->fields();
  QgsFieldMap::const_iterator it;
  for ( it = fields.constBegin(); it != fields.constEnd(); ++it )
  {
    QgsField currentField = it.value();
    QVariant currentType = currentField.type();
    if ( currentType == QVariant::Int || currentType == QVariant::String )
    {
      mcbDirection->insertItem( 1, currentField.name() );
    }
    if ( currentType == QVariant::Int || currentType == QVariant::Double )
    {
      mcbSpeed->insertItem( 1, currentField.name() );
    }
  }

} // RgDSettingsDlg::on_mcbLayers_selectItem()
Esempio n. 4
0
/**
 * Removes selected layer, redraws view and emmits modelChanged signal.
 */
void TopologyWidget::removeSelected(){
	int layer = selectedLayer();
	if(layer == -2) return;
	model->removeLayer(layer);
	clearView();
	makeView();
	model->modelChanged(TopologyChange);
}
Esempio n. 5
0
/**
 * Fills weight table with weights biases and slopes of neurons in selected layer.
 */
void TopologyWidget::fillWeightTable(){
	//index of selected layer
	int layer = selectedLayer();
	if(layer == -2) return;

	//clears weight table
	ui->weightTable->clear();

	//input layer selected
	if(layer == -1){
        ui->layerLabel->setText(tr("[0] input layer:"));
		ui->weightTable->setRowCount(model->inputCount());
        ui->weightTable->setColumnCount(3);

		QStringList hList;
        hList.append(tr("Slope"));
        hList.append(tr("Bias"));
        hList.append(tr("Weight 1"));
		ui->weightTable->setHorizontalHeaderLabels(hList);

		QStringList vList;
		for(int i = 0; i < model->inputCount(); i++)
            vList.append(tr("Neuron ") + QString::number(i+1));
		ui->weightTable->setVerticalHeaderLabels(vList);

		for(int i = 0; i < model->inputCount(); i++){
            //slope
            QTableWidgetItem* item = new QTableWidgetItem();
            item->setText("-");
            ui->weightTable->setItem(i, 0, item);
			//bias
            item = new QTableWidgetItem();
            item->setText("0");
            ui->weightTable->setItem(i, 1, item);
			//weight
			item = new QTableWidgetItem();
			item->setText("1");
            ui->weightTable->setItem(i, 2, item);
		}

		return;
	};

	//generats weight table header
	if(layer < model->layerCount()-1)
        ui->layerLabel->setText("[" + QString::number(layer+1) + "]" + tr(" inner layer:"));
	else
        ui->layerLabel->setText("[" + QString::number(layer+1) + "]" + tr(" output layer:"));

    //sets table sizelogou
	ui->weightTable->setRowCount(model->neuronCount(layer));
    ui->weightTable->setColumnCount(model->weightCount(layer)+2);

	//column headers
	QStringList hList;
    hList.append(tr("Slope"));
    hList.append(tr("Bias"));
	for(int i = 0; i < model->weightCount(layer); i++)
        hList.append(tr("Weight ") + QString::number(i+1));
	ui->weightTable->setHorizontalHeaderLabels(hList);

	//row headers
	QStringList vList;
	for(int i = 0; i < model->neuronCount(layer); i++)
        vList.append(tr("Neuron ") + QString::number(i+1));
	ui->weightTable->setVerticalHeaderLabels(vList);

	//fills table with content
	for(int i = 0; i < model->neuronCount(layer); i++){
		QList<double> weight = (*model)[layer][i].weights();

        //slope
        QTableWidgetItem* item = new QTableWidgetItem();
        item->setText(QString::number((*model)[layer][i].slope()));
        ui->weightTable->setItem(i, 0, item);

		//bias
        item = new QTableWidgetItem();
		item->setText(QString::number((*model)[layer][i].bias()));
        ui->weightTable->setItem(i, 1, item);

		//weights
		for(int j = 0; j < weight.length(); j++){
			QTableWidgetItem* item = new QTableWidgetItem();
			item->setText(QString::number(weight[j]));
            ui->weightTable->setItem(i, j+2, item);
		}
	}
}