Beispiel #1
0
void RealPaintWidget::onPropertiesObj()
{
	GContainer* selCont = GCONTAINER(selection.getSelected());
	int _alpha = PropertiesObjDialog::changePropertiesObj( selCont,
					tr( "Properties of figure" ), this );
	selCont->setAlpha(_alpha);
	update();
}
Beispiel #2
0
void PaintWidget::setFigureHideLines(int value)
{
	if(painter.selection.countSelected() == 1)
	{
		GContainer* c = GCONTAINER(painter.selection.getSelected());
		if(c!=0)
		{
			GObject* ob =c->object(0);
			if(!ob->isContainer())
			{
				GVectorFigure* v =GVECTORFIGURE(ob);
				v->setHideLines(value);
				painter.update();
			}
		}
	}
}
Beispiel #3
0
int PaintWidget::getFigureHideLines()
{
	if(painter.selection.countSelected() == 1)
	{
		GContainer* c = GCONTAINER(painter.selection.getSelected());
		if(c!=0)
		{
			GObject* ob =c->object(0);
			if(!ob->isContainer())
			{
				GVectorFigure* v = GVECTORFIGURE(ob);
				return v->getHideLines();
			}
		}
	}
	return -1;
}
Beispiel #4
0
int PaintWidget::FigureIsSpline()
{
	if(painter.selection.countSelected() == 1)
	{
		GContainer* c = GCONTAINER(painter.selection.getSelected());
		if(c!=0)
		{
			GObject* ob =c->object(0);
			if(!ob->isContainer())
			{
				GVectorFigure* v = GVECTORFIGURE(ob);
				return (v->isSpline())?1:0;
			}
		}
	}
	return -1;
}
Beispiel #5
0
void PaintWidget::FigureSetStyle(bool spline)
{
	if(painter.selection.countSelected() == 1)
	{
		GContainer* c = GCONTAINER(painter.selection.getSelected());
		if(c!=0)
		{
			GObject* ob =c->object(0);
			if(!ob->isContainer())
			{

				GVectorFigure* v = GVECTORFIGURE(ob);
				if(spline)
					v->toSpline();
				else
					v->toNormal();

				painter.update();
			}
		}
	}
}
Beispiel #6
0
void PaintWidget::ungroup()
{
	if( !canUngroup() ) return;

	GContainer *c = GCONTAINER( painter.selection.selected( 0 ) );

	painter.selection.reset();
	painter.layers[painter.currentLayer]->remove( painter.layers[painter.currentLayer]->objectIndex( c ) );

	QVector< GObject* > ungrouped = c->removeAll();
	int countUngrouped = ungrouped.size();

	for( int i = countUngrouped - 1; i >= 0; i-- )
	{
		painter.layers[painter.currentLayer]->add( GOBJECT(ungrouped[ i ]), true );
		painter.selection.addSelected( ungrouped[ i ] );
	}

	delete c;
	emit allLayersChanged();
	painter.update();
	emit StateChanged("Ungroup");
}
Beispiel #7
0
void RealPaintWidget::alphaChanged(int _alpha)
{
	GContainer* selCont = GCONTAINER(selection.getSelected());
	selCont->setAlpha(_alpha);
	update();
}
Beispiel #8
0
void RealPaintWidget::mousePressEvent( QMouseEvent *event )
{
	QPoint pos = event->pos();
	int button = event->button();

	if(button == Qt::LeftButton || selection.isInAddPointMode())
	{
		if( fixedSize )
		{
			QSize sz = rect().size() - size;
			pos -= QPoint( sz.width() / 2, sz.height() / 2 );
		}

		if( currentTool != 0 )
		{
            isMousePress = true;
			GObjectInterface * o = GObject::create( currentTool, pos,
								currentTool->figureName(), currentFrame);

			layers[currentLayer]->add( GOBJECT(o), true );

			selection.setSelected( o );
			selection.setIsNewFigure(true);

			emit objectCreated();
			emit figureSelected( currentLayer, layers[currentLayer]->objectIndex( GOBJECT(o) ) );

			if( currentTool->createStyle() != FigureToolInterface::paint )
			{
				selection.mousePress( event->button(), pos, event->modifiers() );
				selection.setCreateFigureMode( true );
			}
			else
				selection.reset();

			QVector <int> frames = layers[currentLayer]->getFrames();
			for( int i = 0; i < frames.size(); i++ )
			{
				if( frames[i] != currentFrame )
					o->addFrame(frames[i], false);
			}
			return;
		}

		if( selection.mousePress( event->button(), pos, event->modifiers() ) )
			return;

		if(button == Qt::RightButton && !selection.isInAddPointMode())
		{
			paintConMenu->exec(QWidget::mapToGlobal(pos),0);
			return;
		}

		GContainer * cont = GCONTAINER(selection.getSelected());
		if(button != Qt::RightButton && cont != 0 && selection.isInAddPointMode() && cont->countObjects()==1)
		{
			cont->addPointToEnd(pos);
			emit StateChanged("Add point");
			return;
		}

		GObjectInterface* o = 0;
		for(int i=0;i<layers.size();i++)
		{
			o = layers[i]->contains( pos );
			if(o != 0)
			{
				currentLayer = i;
				break;
			}
		}

		if( o == 0 )
		{
			selection.reset();
			emit figureSelected( currentLayer, -1 );

			inSelectionMode = true;
			selectionRect = QRect( pos, QSize( 0, 0 ) );
			update();
			return;
		}



		if( ( ( event->modifiers() & Qt::ControlModifier ) == 0 ) ||
			( selection.countSelected() <= 0 ) )
		{
			selection.setSelected( o );
			emit figureSelected(currentLayer, layers[currentLayer]->objectIndex( GOBJECT(o) ) );
		}
		else
		{
			selection.addSelected( o );
			inKeyPressedHandler = true;
			emit figureSelected( currentLayer, -1 );
			inKeyPressedHandler = false;

		}


		selection.mousePress( event->button(), pos, event->modifiers() );
	}

	if(button == Qt::RightButton && !(selection.isInAddPointMode()))
	{
		if(selection.countSelected() != 1)
			propertiesAct->setEnabled(false);
		else
			propertiesAct->setEnabled(true);
		paintConMenu->exec(QWidget::mapToGlobal(pos),0);
	}


}