Esempio n. 1
0
void LegendGroup::updateModel() {
	QList<QGraphicsItem*> pool;
	for (auto l : legends) { removeFromGroup(l); pool.append(l); }
	for (auto t : texts) { removeFromGroup(t); pool.append(t); }
	for (auto l : pool) delete l;
	legends.clear();
	texts.clear();
	for (int i=0; i<model->rowCount(); i++) {
		auto marker = model->at(i);
		QString l = marker->label() + "\t:  " + QString::number(marker->count());
		QColor color1 = marker->color1();
		QColor color2 = marker->color2();
		int type = marker->activeType();
		if (0 == type) {
			QRectF r = MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize);
			QLineF l(r.topLeft(), r.bottomRight());
			auto marker = new ArrowItem(l);
			marker->setArrowhead(ArrowHead::Start);
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		else if (1 == type) {
			auto marker = new RectItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize));
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		else {
			auto marker = new EllipseItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize));
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		auto label = new RichTextItem(l);
		label->setFont(myFont);
		label->setFontSize(myFontSize);
		label->setKeyPressFunc([this](QKeyEvent* event) { updateRect(); });
		label->setTextInteractionFlags(Qt::TextEditorInteraction);
		label->setFlag(QGraphicsItem::ItemIsFocusable);
		QPointF textPos = legends.at(i)->boundingRect().center() + 
			QPointF(legends.at(i)->boundingRect().width()/2+20, -label->boundingRect().height()*0.5);
		label->setPos(textPos);
		label->setZValue(1000);
		texts.append(label);
		addToGroup(label);
	}
	calculatePos();
}
Esempio n. 2
0
MagentaBlock::MagentaBlock()
{
    //Set color to magenta
    setColor1(1);
    setColor2(5);

    QGraphicsItem *oneBlock = new SingleBlock(this);
}
Esempio n. 3
0
YellowBlock::YellowBlock()
{
    //Set color to yellow
    setColor1(1);
    setColor2(6);

    QGraphicsItem *oneBlock = new SingleBlock(this);
}
Esempio n. 4
0
GreenBlock::GreenBlock()
{
    //Set color to green
    setColor1(1);
    setColor2(3);

    QGraphicsItem *oneBlock = new SingleBlock(this);
}
Esempio n. 5
0
BlueBlock::BlueBlock()
{
    //Set color to blue
    setColor1(1);
    setColor2(4);

    QGraphicsItem *oneBlock = new SingleBlock(this);
}
Esempio n. 6
0
RedBlock::RedBlock()
{
    //Set color to red
    setColor1(1);
    setColor2(2);

    QGraphicsItem *oneBlock = new SingleBlock(this);
}
Esempio n. 7
0
/*!
  Added by Manpreet Kohli
  prototype for transparent block
 */
EmptyBlock::EmptyBlock()
{
    //Set color to transparent
    setColor1(7);
    setColor2(7);

    QGraphicsItem *oneBlock = new SingleBlock(this);
}
Esempio n. 8
0
MonoBlock::MonoBlock()
{
    //Set color to black
    setColor1(1);
    setColor2(0);

    QGraphicsItem *oneBlock = new SingleBlock(this);
}
QgsVectorGradientColorRampV2Dialog::QgsVectorGradientColorRampV2Dialog( QgsVectorGradientColorRampV2* ramp, QWidget* parent )
    : QDialog( parent ), mRamp( ramp )
{

  setupUi( this );

  connect( btnColor1, SIGNAL( clicked() ), this, SLOT( setColor1() ) );
  connect( btnColor2, SIGNAL( clicked() ), this, SLOT( setColor2() ) );

  // handle stops
  QgsVectorGradientColorRampV2::StopsMap stops = ramp->stops();
  groupStops->setChecked( !stops.isEmpty() );

  QgsVectorGradientColorRampV2::StopsMap::iterator i;
  QList<QTreeWidgetItem *> items;
  for ( i = stops.begin(); i != stops.end(); ++i )
  {
    QStringList lst;
    lst << "." << QString::number( i.key()*100, 'f', 0 );
    QTreeWidgetItem* item = new QTreeWidgetItem( lst );

    setStopColor( item, i.value() );
    item->setData( 0, StopOffsetRole, i.key() );

    items.append( item );
  }
  treeStops->insertTopLevelItems( 0, items );
  treeStops->resizeColumnToContents( 0 );
  treeStops->sortByColumn( 1, Qt::AscendingOrder );
  treeStops->setSortingEnabled( true );

  connect( groupStops, SIGNAL( toggled( bool ) ), this, SLOT( toggledStops( bool ) ) );
  connect( btnAddStop, SIGNAL( clicked() ), this, SLOT( addStop() ) );
  connect( btnRemoveStop, SIGNAL( clicked() ), this, SLOT( removeStop() ) );
  connect( treeStops, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( stopDoubleClicked( QTreeWidgetItem*, int ) ) );

  updatePreview();
}
Esempio n. 10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    ui->setupUi(this);
    this->resize(800,680);
    this->setWindowState(Qt::WindowMaximized);
    ImageItem *image = new ImageItem();

    //create ColorSelection
    ColorSelection *CS1 = new ColorSelection(Qt::black);
    ColorSelection *CS2 = new ColorSelection(Qt::white);
    QObject::connect(CS1,SIGNAL(changeColor(QColor)),image,SLOT(setColor1(QColor)));
    QObject::connect(image->getPipette(),SIGNAL(changeColor1(QColor)),CS1,SLOT(setColor(QColor)));
    QObject::connect(CS2,SIGNAL(changeColor(QColor)),image,SLOT(setColor2(QColor)));
    QObject::connect(image->getPipette(),SIGNAL(changeColor2(QColor)),CS2,SLOT(setColor(QColor)));
    QHBoxLayout *Hlayout = new QHBoxLayout();
    Hlayout->addStretch(5);
    Hlayout->addWidget(CS1);
    Hlayout->addWidget(CS2);
    Hlayout->addStretch(5);

    //Create slider
    QSlider *slider = new QSlider(Qt::Horizontal);
    slider->setMaximum(100);
    slider->setMinimum(1);
    slider->setValue(10);
    QObject::connect(slider,SIGNAL(valueChanged(int)),image,SLOT(setSize(int)));


    QVBoxLayout *Blayout = new QVBoxLayout();
    Blayout->addWidget(slider);
    Blayout->addLayout(Hlayout);
    QWidget *wdg = new QWidget();
    wdg->setLayout(Blayout);
    // Create Dock
    //
    //
    QDockWidget *dock = new QDockWidget(tr("Настройка"),this);
    dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
    wdg->setFixedSize(200,100);
    dock->setWidget(wdg);
    dock->setMaximumHeight(300);
    dock->setMaximumWidth(300);

    addDockWidget(Qt::RightDockWidgetArea,dock);

    QActionGroup *GP = new QActionGroup(this);
    GP->addAction(ui->actionPencil);
    GP->addAction(ui->actionEraser);
    GP->addAction(ui->actionEllipse);
    GP->addAction(ui->actionRectangle);
    GP->addAction(ui->actionLine);
    GP->addAction(ui->actionCurveLine);
    GP->addAction(ui->actionFill);
    GP->addAction(ui->actionPipette);
    GP->addAction(ui->actionSelection);
    GP->setExclusive(true);

    //create tool bar
    QToolBar *TB = new QToolBar();
    TB->setAllowedAreas(Qt::TopToolBarArea | Qt::LeftToolBarArea);
    TB->setFloatable(false);
    TB->setMovable(true);

    TB->insertAction(0,ui->actionSaveAs);
    TB->insertAction(ui->actionSaveAs,ui->actionSave);
    TB->insertAction(ui->actionSave,ui->actionOpen);
    TB->insertAction(ui->actionOpen,ui->actionCreate);
    TB->addSeparator();
    TB->insertAction(0,ui->actionSelection);
    TB->insertAction(ui->actionSelection,ui->actionPipette);
    TB->insertAction(ui->actionPipette,ui->actionFill);
    TB->insertAction(ui->actionFill,ui->actionCurveLine);
    TB->insertAction(ui->actionCurveLine,ui->actionLine);
    TB->insertAction(ui->actionLine,ui->actionRectangle);
    TB->insertAction(ui->actionRectangle,ui->actionEllipse);
    TB->insertAction(ui->actionEllipse,ui->actionEraser);
    TB->insertAction(ui->actionEraser,ui->actionPencil);




    addToolBar(Qt::TopToolBarArea, TB);
    // create action connecting
    QObject::connect(ui->actionOpen,SIGNAL(triggered(bool)),image,SLOT(open()));
    QObject::connect(ui->actionSaveAs,SIGNAL(triggered(bool)),image,SLOT(saveAs()));
    QObject::connect(ui->actionSave,SIGNAL(triggered(bool)),image,SLOT(save()));
    QObject::connect(ui->actionPencil,SIGNAL(toggled(bool)),image,SLOT(setPencil(bool)));
    QObject::connect(ui->actionEraser,SIGNAL(toggled(bool)),image,SLOT(setEraser(bool)));
    QObject::connect(ui->actionEllipse,SIGNAL(toggled(bool)),image,SLOT(setEllipse(bool)));
    QObject::connect(ui->actionRectangle,SIGNAL(toggled(bool)),image,SLOT(setRectangle(bool)));
    QObject::connect(ui->actionLine,SIGNAL(toggled(bool)),image,SLOT(setLine(bool)));
    QObject::connect(ui->actionCurveLine,SIGNAL(toggled(bool)),image,SLOT(setCurveLine(bool)));
    QObject::connect(ui->actionFill,SIGNAL(toggled(bool)),image,SLOT(setFill(bool)));
    QObject::connect(ui->actionPipette,SIGNAL(toggled(bool)),image,SLOT(setPipette(bool)));
    QObject::connect(ui->actionSelection,SIGNAL(toggled(bool)),image,SLOT(setSelection(bool)));
    //undo and redo
    ui->actionUndo->setEnabled(false);
    ui->actionRedo->setEnabled(false);
    QObject::connect(image->getUndoStack(),SIGNAL(canUndo(bool)),ui->actionUndo,SLOT(setEnabled(bool)));
    QObject::connect(ui->actionUndo,SIGNAL(triggered(bool)),image->getUndoStack(),SLOT(undo()));
    QObject::connect(image->getUndoStack(),SIGNAL(canRedo(bool)),ui->actionRedo,SLOT(setEnabled(bool)));
    QObject::connect(image->getUndoStack(),SIGNAL(canRedo(bool)),image,SLOT(setNewCurve(bool)));
    QObject::connect(ui->actionRedo,SIGNAL(triggered(bool)),image->getUndoStack(),SLOT(redo()));

    //copy and cut and put

    ui->actionCopy->setEnabled(false);
    ui->actionCut->setEnabled(false);
    ui->actionPut->setEnabled(false);
    QObject::connect(image->getSelection(),SIGNAL(canCopy(bool)),ui->actionCopy,SLOT(setEnabled(bool)));
    QObject::connect(ui->actionCopy,SIGNAL(triggered(bool)),image,SLOT(makeCopy()));
    QObject::connect(image->getSelection(),SIGNAL(canCopy(bool)),ui->actionCut,SLOT(setEnabled(bool)));
    QObject::connect(ui->actionCut,SIGNAL(triggered(bool)),image,SLOT(makeCut()));
    QObject::connect(image->getSelection(),SIGNAL(canPut(bool)),ui->actionPut,SLOT(setEnabled(bool)));
    QObject::connect(ui->actionPut,SIGNAL(triggered(bool)),image,SLOT(makePut()));
    QObject::connect(ui->actionSelection,SIGNAL(changed()),image,SLOT(clearSelection()));


    ui->scrollArea->setBackgroundRole(QPalette :: Dark);
    ui->scrollArea->setWidget(image);





}
 MyGlobalUniformSet()
 {
     m_uniformSet = new UniformSet;
     setColor1(Color3f::RED);
 }