CustomTextEdit::CustomTextEdit(const QString &text, QGraphicsItem *parent)
    : MTextEdit(MTextEditModel::MultiLine, text, parent)
{
    QObject::connect(this, SIGNAL(textChanged()), this, SLOT(changeLabel()));
    QObject::connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(changeButton()));
    QObject::connect(this, SIGNAL(gainedFocus(Qt::FocusReason)), this, SLOT(changeLabel()));
    QObject::connect(this, SIGNAL(gainedFocus(Qt::FocusReason)), this, SLOT(changeButton()));
    setInputMethodCorrectionEnabled(false);
}
Esempio n. 2
0
void CPBoolPlugin::setup()
{
    emit changeLabel(settings->value(uuid.toString() + "/Label", ui->label->text()).toString());
    ui->label->setVisible(settings->value(uuid.toString() + "/ShowLabel", true).toBool());
    ui->value->setAlignment((settings->value(uuid.toString() + "/ShowLabel", true).toBool() ? Qt::AlignLeft : Qt::AlignHCenter) | Qt::AlignVCenter);
    topic = settings->value(uuid.toString() + "/Topic", topic).toString();
    if(settings->value(uuid.toString() + "/Active", false).toBool())
        start();
}
void CPPositionPlugin::setup()
{
    emit changeLabel(settings->value(uuid.toString() + "/Label", ui->label->text()).toString());
    ui->label->setVisible(settings->value(uuid.toString() + "/ShowLabel", true).toBool());
    topic = settings->value(uuid.toString() + "/Topic", topic).toString();
    messageFlags = (enum MessageFlags)settings->value(uuid.toString() + "/Type", (int)messageFlags).toInt();
    if(settings->value(uuid.toString() + "/Active", false).toBool())
        start();
}
Esempio n. 4
0
void CPBoolPlugin::configDialog()
{
    QDialog dialog;
    QGridLayout *layout = new QGridLayout;

    QLabel *topictxt = new QLabel(tr("Topic Name:"));
    QLineEdit *topicedit = new QLineEdit(topic);
    layout->addWidget(topictxt, 0, 0);
    layout->addWidget(topicedit, 0, 1);

    QLabel *slabeltxt = new QLabel(tr("Show Label:"));
    QCheckBox *slabelcheck = new QCheckBox();
    slabelcheck->setChecked(ui->label->isVisible());
    layout->addWidget(slabeltxt, 1, 0);
    layout->addWidget(slabelcheck, 1, 1);

    QLabel *labeltxt = new QLabel(tr("Label:"));
    QLineEdit *labeledit = new QLineEdit(ui->label->text());
    connect(slabelcheck, SIGNAL(toggled(bool)), labeledit, SLOT(setEnabled(bool)));
    labeledit->setEnabled(ui->label->isVisible());
    layout->addWidget(labeltxt, 2, 0);
    layout->addWidget(labeledit, 2, 1);

    QPushButton *okbutton = new QPushButton(tr("&OK"));
    layout->addWidget(okbutton, 3, 1);

    dialog.setLayout(layout);

    dialog.setWindowTitle("Plugin Configuration - Bool");

    connect(okbutton, SIGNAL(clicked()), &dialog, SLOT(accept()));

    if(!dialog.exec())
        return;

    if(topic != topicedit->text())
    {
        emit changeValue("N/A");
        topic = topicedit->text();
        settings->setValue(uuid.toString() + "/Topic", topic);
        activateNodelet(true);
    }

    if(ui->label->isVisible() != slabelcheck->isChecked())
    {
        ui->label->setVisible(slabelcheck->isChecked());
        ui->value->setAlignment((slabelcheck->isChecked() ? Qt::AlignLeft : Qt::AlignHCenter) | Qt::AlignVCenter);
        settings->setValue(uuid.toString() + "/ShowLabel", slabelcheck->isChecked());
    }

    if(ui->label->text() != labeledit->text())
    {
        emit changeLabel(labeledit->text());
        settings->setValue(uuid.toString() + "/Label", labeledit->text());
    }
}
void CPJoyToAckermannPlugin::setup()
{
    emit changeLabel(settings->value(uuid.toString() + "/Label", ui->label->text()).toString());
    linear_scale = settings->value(uuid.toString() + "/LinearScale", linear_scale).toFloat();
    nodelet_priv->set_linear_scale(linear_scale);
    angular_scale = settings->value(uuid.toString() + "/AngularScale", angular_scale).toFloat();
    nodelet_priv->set_angular_scale(angular_scale);
    if(settings->value(uuid.toString() + "/Active", false).toBool())
        start();
}
Esempio n. 6
0
    void setLabel(const QString &name, const QColor &color) {
        labelName = name;

        if(indicatorSymbol.isNull()) {
            if(fontMetrics().inFont(QChar(0x25CF)))
                indicatorSymbol = QChar(0x25CF);
            else
                indicatorSymbol = '#';
        }
        changeLabel(color);

    }
CPJoyToAckermannPlugin::CPJoyToAckermannPlugin() :
    ui(new Ui::CPJoyToAckermannPlugin),
    linear_scale(0.20),
    angular_scale(M_PI / 4),
    nodelet_priv(new joy_to_ackermann::joy_to_ackermann_nodelet(false))
{
    ui->setupUi(this);
    connect(this, SIGNAL(changeLabel(const QString &)), ui->label, SLOT(setText(const QString &)));
    connect(this, SIGNAL(changeEnabled(bool)), ui->label, SLOT(setEnabled(bool)));
    emit changeLabel("CP Joy To Ackermann");
    emit changeEnabled(false);
}
void CPJoyToAckermannPlugin::configDialog()
{
    QDialog dialog;
    QGridLayout *layout = new QGridLayout;

    QLabel *labeltxt = new QLabel(tr("Label:"));
    QLineEdit *labeledit = new QLineEdit(ui->label->text());
    layout->addWidget(labeltxt, 0, 0);
    layout->addWidget(labeledit, 0, 1);

    QLabel *lineartxt = new QLabel(tr("Linear Scale:"));
    QLineEdit *linearedit = new QLineEdit(QString::number(linear_scale));
    layout->addWidget(lineartxt, 1, 0);
    layout->addWidget(linearedit, 1, 1);

    QLabel *angulartxt = new QLabel(tr("Angular Scale:"));
    QLineEdit *angularedit = new QLineEdit(QString::number(angular_scale));
    layout->addWidget(angulartxt, 2, 0);
    layout->addWidget(angularedit, 2, 1);

    QPushButton *okbutton = new QPushButton(tr("&OK"));
    layout->addWidget(okbutton, 3, 1);

    dialog.setLayout(layout);

    dialog.setWindowTitle("Plugin Configuration - CP Joy To Ackermann");

    connect(okbutton, SIGNAL(clicked()), &dialog, SLOT(accept()));

    if(!dialog.exec())
        return;

    if(ui->label->text() != labeledit->text())
    {
        emit changeLabel(labeledit->text());
        settings->setValue(uuid.toString() + "/Label", labeledit->text());
    }

    if(linearedit->text().toFloat() != linear_scale)
    {
        linear_scale = linearedit->text().toFloat();
        nodelet_priv->set_linear_scale(linear_scale);
        settings->setValue(uuid.toString() + "/LinearScale", linear_scale);
    }

    if(angularedit->text().toFloat() != angular_scale)
    {
        angular_scale = angularedit->text().toFloat();
        nodelet_priv->set_angular_scale(angular_scale);
        settings->setValue(uuid.toString() + "/AngularScale", angular_scale);
    }
}
Esempio n. 9
0
CPBoolPlugin::CPBoolPlugin() :
    ui(new Ui::CPBoolPlugin),
    topic("cp_bool"),
    nodelet_priv(new CPSSN())
{
    ui->setupUi(this);
    connect(this, SIGNAL(changeValue(const QString &)), ui->value, SLOT(setText(const QString &)));
    connect(this, SIGNAL(changeLabel(const QString &)), ui->label, SLOT(setText(const QString &)));
    connect(this, SIGNAL(changeEnabled(bool)), ui->value, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(changeEnabled(bool)), ui->label, SLOT(setEnabled(bool)));
    emit changeEnabled(false);
    emit changeLabel("CPBool: ");
}
Esempio n. 10
0
void CPPositionPlugin::configDialog()
{
    bool reactivate = false;
    enum MessageFlags newMessageFlags;

    positionConfigDialog *dialog = new positionConfigDialog(topic, ui->label->isVisible(), ui->label->text(), messageFlags);


    if(!dialog->exec())
        return;

    if(topic != dialog->topicedit->text())
    {
        topic = dialog->topicedit->text();
        settings->setValue(uuid.toString() + "/Topic", topic);
        reactivate = true;
    }

    newMessageFlags = (enum MessageFlags)(dialog->typebox->itemData(dialog->typebox->currentIndex()).toInt() | (dialog->stampedcheck->isChecked() ? MessageStamped : MessageNone ) | (dialog->withcovcheck->isChecked() ? MessageWithCov : MessageNone ));

    if(newMessageFlags != messageFlags)
        reactivate = true;

    messageFlags = newMessageFlags; 
    settings->setValue(uuid.toString() + "/Type", (int)messageFlags);

    if (reactivate)
    {
        emit changeX("N/A");
        emit changeY("N/A");
        emit changeZ("N/A");
        activateNodelet(true);
    }

    if(ui->label->isVisible() != dialog->slabelcheck->isChecked())
    {
        ui->label->setVisible(dialog->slabelcheck->isChecked());
        settings->setValue(uuid.toString() + "/ShowLabel", dialog->slabelcheck->isChecked());
    }

    if(ui->label->text() != dialog->labeledit->text())
    {
        emit changeLabel(dialog->labeledit->text());
        settings->setValue(uuid.toString() + "/Label", dialog->labeledit->text());
    }
}
Esempio n. 11
0
// Slot called when the buffer menu item is activated
void QgsCopyrightLabelPlugin::run()
{
  QgsCopyrightLabelPluginGui *myPluginGui = new QgsCopyrightLabelPluginGui( qGisInterface->mainWindow(), QgisGui::ModalDialogFlags );
  myPluginGui->setAttribute( Qt::WA_DeleteOnClose );
  //listen for when the layer has been made so we can draw it
  //connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
  //connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));
  //refresh the canvas when the user presses ok
  connect( myPluginGui, SIGNAL( changeFont( QFont ) ), this, SLOT( setFont( QFont ) ) );
  connect( myPluginGui, SIGNAL( changeLabel( QString ) ), this, SLOT( setLabel( QString ) ) );
  connect( myPluginGui, SIGNAL( changeColor( QColor ) ), this, SLOT( setColor( QColor ) ) );
  connect( myPluginGui, SIGNAL( changePlacement( int ) ), this, SLOT( setPlacement( int ) ) );
  connect( myPluginGui, SIGNAL( enableCopyrightLabel( bool ) ), this, SLOT( setEnable( bool ) ) );
  myPluginGui->setText( mLabelQString );
  myPluginGui->setPlacementLabels( mPlacementLabels );
  myPluginGui->setPlacement( mPlacementIndex );
  myPluginGui->setColor( mLabelQColor );
  myPluginGui->setEnabled( mEnable );
  myPluginGui->show();
}
Esempio n. 12
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QPalette palWhite;
    palWhite.setColor(  ui->LeftWidget->backgroundRole(), Qt::white);
    ui->LeftWidget->setPalette( palWhite);
    ui->LeftWidget->setAutoFillBackground(true);
    ui->RightWidget->setPalette(palWhite);
    ui->RightWidget->setAutoFillBackground(true);

    controller = new Controller(ui->LeftWidget, ui->RightWidget);

//   QObject::connect( ui->LeftWidget, SIGNAL(DotCreated(QPoint)),
//                      controller, SLOT(controleLeftWidget(QPoint)));
    QObject::connect( ui->LeftWidget, SIGNAL(DotCreated(QPoint)),
                       controller, SLOT(addDotToLeftWidget(QPoint)));

    QObject::connect( ui->RightWidget, SIGNAL(DotCreated(QPoint)),
                      controller, SLOT(addDotToRightWidget(QPoint)));

    QObject::connect(ui->pushButton,  SIGNAL(clicked()),
                     controller, SLOT(buttonClicked()));
    QObject::connect(ui->pushButton_2, SIGNAL(clicked()),
                     controller, SLOT(clearDrawingPlace()));

    QObject::connect(ui->LeftWidget, SIGNAL(mouseMove(QPoint)),
                     controller, SLOT(lengthBetweenMouseAndContour(QPoint)));

    QObject::connect(controller, SIGNAL(changeLabel(QString)),
                     ui->label, SLOT(setText(QString)));

    QObject::connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
                     controller, SLOT(epsChanged(double)));
}
Esempio n. 13
0
void GraphView::executeContextMenu(const QPoint& menuPosition)
{
    QMenu menu;

    GraphNode* node = dynamic_cast<GraphNode*>(selectedItem);
    GraphEdge* edge = dynamic_cast<GraphEdge*>(selectedItem);

    if (node) {
        QAction *changeLabelAction = menu.addAction("Change label");
        QAction *deleteAction = menu.addAction("Delete vertex");
        QAction *selectedAction = menu.exec(menuPosition);

        if (selectedAction == changeLabelAction)
          changeLabel(node);
        else if (selectedAction == deleteAction)
          removeItemCommand(node);
    }
    else if (edge){
        QAction *changeWeightAction(NULL);

        if (weightedGraph)
            changeWeightAction = menu.addAction("Change weight");

        QAction *changeDirectionSDAction(NULL);
        QAction *changeDirectionDSAction(NULL);
        QAction *changeUndirectedAction(NULL);

        if (!undirectedGraph) {
            QMenu *changeDirectionMenu = new QMenu("Change direction");
            menu.addMenu(changeDirectionMenu);
            QString sourceLabel = edge->getSourceNode()->getLabel();
            if (sourceLabel.isEmpty())
                sourceLabel = "no_label";
            QString destinationLabel = edge->getDestinationNode()->getLabel();
            if (destinationLabel.isEmpty())
                destinationLabel = "no_label";

            changeDirectionSDAction = changeDirectionMenu->addAction(sourceLabel + " -> " + destinationLabel);
            changeDirectionDSAction = changeDirectionMenu->addAction(destinationLabel + " -> " + sourceLabel);
            changeUndirectedAction = changeDirectionMenu->addAction("Change to undirected");

            if (edge->isUndirected())
                changeUndirectedAction->setEnabled(false);
            else
                changeDirectionSDAction->setEnabled(false);
        }

        QAction *deleteAction = menu.addAction("Delete edge");
        QAction *selectedAction = menu.exec(menuPosition);

        if (selectedAction) {
            if (selectedAction == deleteAction)
                removeItemCommand(edge);
            else if (selectedAction == changeWeightAction)
                changeWeight(edge);
            else if (selectedAction == changeDirectionSDAction)
                undoStack->push(new ChangeEdgeDirectionCommand(edge, false, false));
            else if (selectedAction == changeDirectionDSAction)
                undoStack->push(new ChangeEdgeDirectionCommand(edge, true, false));
            else if (selectedAction == changeUndirectedAction)
                undoStack->push(new ChangeEdgeDirectionCommand(edge, false, true));
        }
    }
}
Esempio n. 14
0
int main(void){

    // initialize
    init();
    
    while(1) {
        // input & process
        if (Stylus.Released) {
            clearButton();
        }
        if (Pad.Released.L || Pad.Released.R) {
            pushed_trig = 0;
        }
        if (Pad.Released.Left || Pad.Released.Y) {
            pushed_left = 0;
        }
        if (Pad.Released.Right || Pad.Released.A) {
            pushed_right = 0;
        }
        if (Pad.Released.Up || Pad.Released.X) {
            pushed_up = 0;
        }
        if (Pad.Released.Down || Pad.Released.B) {
            pushed_down = 0;
        }

        if (Stylus.Held) {
            if (!pushed_stylus) {
                if (result_print == 2) {
                    insertString(inputValue, inputPos, " ", 100);
                    inputValue[inputPos] = getStylusValue();
                    if (actionStylus2(checkValue(inputValue[inputPos])))
                        goto LOOP_END;
//                    if (on_graph) {
//                    
//                    } else {
//                    
//                    }
                } else {
                    insertString(expr, exprPos, " ", 200);
                    expr[exprPos] = getStylusValue();
                    insertString(p_expr, printStrPos, " ", 340);
                    p_expr[printStrPos] = expr[exprPos];

                    if (actionStylus(checkValue(expr[exprPos])))
                        goto LOOP_END;
                }
            }
            pushed_stylus = 1;
        }
        
        if (Pad.Held.L || Pad.Held.R) {
            if (!pushed_trig) {
                stylus_page = stylus_page == 1 ? 2 : 1;
                changeLabel(stylus_page);
            }
            pushed_trig = 1;
        }
        
        if (Pad.Held.Left || Pad.Held.Y) {
            if (!pushed_left) {
                moveCursor(-1); // left move
            }
            pushed_left = 1;
        }
        if (Pad.Held.Right || Pad.Held.A) {
            if (!pushed_right) {
                moveCursor(1); // right move
            }
            pushed_right = 1;
        }
        if (Pad.Held.Up || Pad.Held.X) {
            if (!pushed_up) {
                overviewPrevExpr();
            }
            pushed_up = 1;
        }
        if (Pad.Held.Down || Pad.Held.B) {
            if (!pushed_down) {
                overviewNextExpr();
            }
            pushed_down = 1;
        }
        // teardown
        printExpr();
        //moveCursor(1);
        
    LOOP_END:
        PA_WaitForVBL(); // process interrupt
    }
    return 0;
}
Esempio n. 15
0
QgsPalettedRendererWidget::QgsPalettedRendererWidget( QgsRasterLayer *layer, const QgsRectangle &extent ): QgsRasterRendererWidget( layer, extent )
{
  setupUi( this );

  mCalculatingProgressBar->hide();
  mCancelButton->hide();

  mContextMenu = new QMenu( tr( "Options" ), this );
  mContextMenu->addAction( tr( "Change Color…" ), this, SLOT( changeColor() ) );
  mContextMenu->addAction( tr( "Change Opacity…" ), this, SLOT( changeOpacity() ) );
  mContextMenu->addAction( tr( "Change Label…" ), this, SLOT( changeLabel() ) );

  mAdvancedMenu = new QMenu( tr( "Advanced Options" ), this );
  QAction *mLoadFromLayerAction = mAdvancedMenu->addAction( tr( "Load Classes from Layer" ) );
  connect( mLoadFromLayerAction, &QAction::triggered, this, &QgsPalettedRendererWidget::loadFromLayer );
  QAction *loadFromFile = mAdvancedMenu->addAction( tr( "Load Color Map from File…" ) );
  connect( loadFromFile, &QAction::triggered, this, &QgsPalettedRendererWidget::loadColorTable );
  QAction *exportToFile = mAdvancedMenu->addAction( tr( "Export Color Map to File…" ) );
  connect( exportToFile, &QAction::triggered, this, &QgsPalettedRendererWidget::saveColorTable );


  mButtonAdvanced->setMenu( mAdvancedMenu );

  mModel = new QgsPalettedRendererModel( this );
  mTreeView->setSortingEnabled( false );
  mTreeView->setModel( mModel );

#ifdef ENABLE_MODELTEST
  new ModelTest( mModel, this );
#endif

  mSwatchDelegate = new QgsColorSwatchDelegate( this );
  mTreeView->setItemDelegateForColumn( QgsPalettedRendererModel::ColorColumn, mSwatchDelegate );
  mTreeView->setColumnWidth( QgsPalettedRendererModel::ColorColumn, Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 6.6 );
  mTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
  mTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
  mTreeView->setDragEnabled( true );
  mTreeView->setAcceptDrops( true );
  mTreeView->setDropIndicatorShown( true );
  mTreeView->setDragDropMode( QAbstractItemView::InternalMove );
  mTreeView->setSelectionBehavior( QAbstractItemView::SelectRows );
  mTreeView->setDefaultDropAction( Qt::MoveAction );

  connect( mTreeView, &QTreeView::customContextMenuRequested, this, [ = ]( QPoint ) { mContextMenu->exec( QCursor::pos() ); }
         );

  btnColorRamp->setShowRandomColorRamp( true );

  connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsPalettedRendererWidget::applyColorRamp );

  mBandComboBox->setLayer( mRasterLayer );

  if ( mRasterLayer )
  {
    QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
    if ( !provider )
    {
      return;
    }
    setFromRenderer( mRasterLayer->renderer() );
  }

  connect( mBandComboBox, &QgsRasterBandComboBox::bandChanged, this, &QgsRasterRendererWidget::widgetChanged );
  connect( mModel, &QgsPalettedRendererModel::classesChanged, this, &QgsPalettedRendererWidget::widgetChanged );
  connect( mDeleteEntryButton, &QPushButton::clicked, this, &QgsPalettedRendererWidget::deleteEntry );
  connect( mButtonDeleteAll, &QPushButton::clicked, mModel, &QgsPalettedRendererModel::deleteAll );
  connect( mAddEntryButton, &QPushButton::clicked, this, &QgsPalettedRendererWidget::addEntry );
  connect( mClassifyButton, &QPushButton::clicked, this, &QgsPalettedRendererWidget::classify );

  QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
  if ( provider )
  {
    mLoadFromLayerAction->setEnabled( !provider->colorTable( mBandComboBox->currentBand() ).isEmpty() );
  }
  else
  {
    mLoadFromLayerAction->setEnabled( false );
  }

  connect( QgsProject::instance(), static_cast < void ( QgsProject::* )( QgsMapLayer * ) >( &QgsProject::layerWillBeRemoved ), this, &QgsPalettedRendererWidget::layerWillBeRemoved );
  connect( mBandComboBox, &QgsRasterBandComboBox::bandChanged, this, &QgsPalettedRendererWidget::bandChanged );
}