Пример #1
0
MdiEditor::MdiEditor(QApplication* app,QWidget *parent)
: QMainWindow(parent)
{

	_app=app;
	readyLabel=NULL;
	new_pro=save_pro=mod_para=NULL;
	imageEditorL = new ImageEditor('L');
	imageEditorR = new ImageEditor('R');
	imageEditorM = new HalfwayImage('M');
	widgetA = new QWidget();
	imageEditorA = new RenderWidget();
	ctrbar=new CCtrBar();

	for(int i=0;i<MAX_LAYER;i++)
	{
		match_thread[i]=NULL;
		match_thread_GPU[i]=NULL;
		poison_thread[i]=NULL;
		qpath_thread[i]=NULL;
	}


	createDockWidget();
	createMenuBar();
	createStatusBar();
	gpu_flag=FALSE;
	gpu_cap=CudaInit();

	connect(imageEditorL,SIGNAL(sigUpdate()),this,SLOT(updateALL()));
	connect(imageEditorR,SIGNAL(sigUpdate()),this,SLOT(updateALL()));
	connect(imageEditorM,SIGNAL(sigUpdate()),this,SLOT(updateALL()));
	connect(ctrbar,SIGNAL(sigUpdate()),this,SLOT(updateALL()));
	connect(imageEditorL,SIGNAL(sigModified()),this,SLOT(PtModified()));
	connect(imageEditorR,SIGNAL(sigModified()),this,SLOT(PtModified()));
	connect(imageEditorM,SIGNAL(sigModified()),this,SLOT(PtModified()));
	connect(imageEditorL,SIGNAL(sigLayerReorder(char, bool,float, float)),this,SLOT(ReorderLayer(char, bool,float, float)));
	connect(imageEditorR,SIGNAL(sigLayerReorder(char, bool,float, float)),this,SLOT(ReorderLayer(char, bool,float, float)));
	connect(ctrbar,SIGNAL(sigStatusChange(int)),imageEditorA,SLOT(StatusChange(int)));
	connect(ctrbar,SIGNAL(sigRangeChange(int)),imageEditorA,SLOT(RangeChange(int)));
	connect(imageEditorA,SIGNAL(sigRecordFinished()),ctrbar,SLOT(record_finished()));
	connect(imageEditorA,SIGNAL(sigRecordFinished()),this,SLOT(AutoQuit()));

	layer_num=0;
	layer_index=0;

	clear();
    setWindowTitle(tr("Pixel Morph"));
	showMaximized();

}
Пример #2
0
void HalfwayImage::mousePressEvent(QMouseEvent *event)
{
	if (_scissor||_flag_error||_flag_multilayer||!_image_loaded||event->pos().x()>_real_size.width()-1||event->pos().y()>=_real_size.height()-1)
		return;

	if (event->button() == Qt::LeftButton) 
	{
		double2 p;
		p.x=((float)event->pos().x()+0.5)/(float)_real_size.width();
		p.y=((float)event->pos().y()+0.5)/(float)_real_size.height();
		ConstraintPoint elem;		
		elem.lp=elem.rp=p;
		parameters->ui_points.push_back(elem);
		parameters->ActIndex=parameters->ui_points.size()-1;	
		_pressed=true;
	}		

	_mouse_pos=_mouse_pos=QPointF(((float)event->pos().x()+0.5)/(float)_real_size.width(),((float)event->pos().y()+0.5)/(float)_real_size.height());
	emit sigUpdate();
}
Пример #3
0
void HalfwayImage::mouseMoveEvent(QMouseEvent *event)
{

	if (_scissor||_flag_error||_flag_multilayer||!_image_loaded||event->pos().x()>_real_size.width()-1||event->pos().y()>=_real_size.height()-1)
		return;

	if (event->buttons() == Qt::LeftButton) 
	{
		QPoint pos(MIN(event->pos().x(),_real_size.width()-1),MIN(event->pos().y(),_real_size.height()-1));
		pos=QPoint(MAX(pos.x(),0),MAX(pos.y(),0));

		double2 pointf;
		pointf.x=((float)pos.x()+0.5)/(float)_real_size.width();
		pointf.y=((float)pos.y()+0.5)/(float)_real_size.height();
		parameters->ui_points[parameters->ActIndex].rp=pointf;				
	} 

	_mouse_pos=QPointF(((float)event->pos().x()+0.5)/(float)_real_size.width(),((float)event->pos().y()+0.5)/(float)_real_size.height());
	emit sigUpdate();
}
Пример #4
0
CFileTransferAction::CFileTransferAction(QSharedPointer<CFileTransfer> file, const QString &szId, const QTime &date, const bool &me)
    : CChatAction(me, szId, date)
{
    m_File = file;
#ifdef MOBILE
    QDesktopWidget *pDesk = QApplication::desktop();
    int nWidth;
    if(pDesk->availableGeometry().width() > pDesk->availableGeometry().height())
        nWidth = pDesk->availableGeometry().height();
    else
        nWidth = pDesk->availableGeometry().width();
    if(nWidth < 200)
        m_ProgBarWidth = nWidth - 10;
    else
        m_ProgBarWidth = nWidth - 100;
#else
    m_ProgBarWidth = 250;
#endif

    m_ProgBarHeight = 10;

    bool check = connect(file.data(), SIGNAL(sigUpdate()),this, SLOT(slotUpdateHtml()));
    Q_ASSERT(check);
}
Пример #5
0
void ImageEditor::mouseMoveEvent(QMouseEvent *event)
{

	if(_scissor)
	{
		if (_compute)
		{
			int x=(float)(event->pos().x()+0.5)/(float)_real_size.width()*_image.width();
			int y=(float)(event->pos().y()+0.5)/(float)_real_size.height()*_image.height();
			
			if (x > _image.width()-2)
				x = _image.width()-2;
			if (x < 1)
				x = 1;
			if (y > _image.width()-2)
				y =_image.width()-2;
			if (y < 1)
				y = 1;
			
			_costGraph->computePath(y,x);
						
			//new seg
			_segList.clear();
			for (int i = 0; i < _costGraph->_path.size(); i++)
			{
				float segx = (_costGraph->_path[i]->_col+0.5)/_image.width();
				float segy = (_costGraph->_path[i]->_row+0.5)/_image.height();
				_segList.append(QPointF(segx,segy));				
			}
			emit sigUpdate();
		}
	}
	else
	{
		if (event->buttons() & Qt::LeftButton) 
		{
			if (!_image_loaded||parameters->ActIndex<0||parameters->ActIndex>=parameters->ui_points.size())
				return;

			QPoint pos(MIN(event->pos().x(),_real_size.width()-1),MIN(event->pos().y(),_real_size.height()-1));
			pos=QPoint(MAX(pos.x(),0),MAX(pos.y(),0));

			double2 pointf;
			pointf.x=((float)pos.x()+0.5)/(float)_real_size.width();
			pointf.y=((float)pos.y()+0.5)/(float)_real_size.height();

			QPoint ConP;
			switch(_name){
			case 'L':
			case 'l':				
				parameters->ui_points[parameters->ActIndex].lp=pointf;
				break;

			case 'R':
			case 'r':
				parameters->ui_points[parameters->ActIndex].rp=pointf;
				break;
			}
		} 

		emit sigUpdate();
	}
   
}
Пример #6
0
void ImageEditor::mousePressEvent(QMouseEvent *event)
{
	if (!_image_loaded||event->pos().x()>_real_size.width()-1||event->pos().y()>=_real_size.height()-1)
		return;

	float x=(float)(event->pos().x()+0.5)/(float)_real_size.width();
	float y=(float)(event->pos().y()+0.5)/(float)_real_size.height();
	
	if(_scissor)
	{		
		if (event->button() == Qt::LeftButton)
		{		
			//confirms seg
			QPointF pointf(x,y);	

			if(_compute)
				for(int i=0;i<_segList.size();i++)
					_contourList[_contourList.size()-1].append(_segList[_segList.size()-1-i]);		

			if (_contourList[_contourList.size()-1].size()>0)
			{				
				QPoint pt0=QPoint(_contourList[_contourList.size()-1][0].x()*_real_size.width(),_contourList[_contourList.size()-1][0].y()*_real_size.height());

				if (abs(pt0.x()-event->pos().x())<=3&&abs(pt0.y()-event->pos().y())<=3)
				{
					//new contour
					QList<QPointF> contour;
					_contourList.append(contour);
					_compute=false;	
					return;
				}	

			}

				_fixedSeedList.append(pointf);				
				_compute=true;
				_segList.clear();				
			
				_costGraph->liveWireDP(y*_image.height(),x*_image.width());	
				emit sigUpdate();
		 }		
	}
	else if(_flag_multilayer)
	{
		if (event->button() == Qt::LeftButton) 
		{
			emit sigLayerReorder(_name,true,x,y);
		}
		else if (event->button() == Qt::RightButton) 
		{
			emit sigLayerReorder(_name,false,x,y);
		}
	}
	else
	{
		if (event->button() == Qt::LeftButton) 
		{
			//select			
			bool flag=true;
			for (int i=0;i<parameters->ui_points.size();i++)
			{
				QPoint ConP;
				switch(_name){
			case 'L':
			case 'l':				
				ConP= QPoint(parameters->ui_points[i].lp.x*_real_size.width(),parameters->ui_points[i].lp.y*_real_size.height());
				break;

			case 'R':
			case 'r':
				ConP= QPoint(parameters->ui_points[i].rp.x*_real_size.width(),parameters->ui_points[i].rp.y*_real_size.height());
				break;
				}

				if (abs(ConP.x()-event->pos().x())<=3&&abs(ConP.y()-event->pos().y())<=3)
				{
					flag=false;
					parameters->ActIndex=i;
					break;
				}
			}

			//new point
			if(flag)
			{
				double2 pointf;
				pointf.x=x;
				pointf.y=y;
				ConstraintPoint elem;					
				elem.lp=elem.rp=pointf;
				parameters->ui_points.push_back(elem);
				parameters->ActIndex=parameters->ui_points.size()-1;		
								
			}
		}		

		else if (event->button() == Qt::RightButton) 
		{
			//select
			vector<ConstraintPoint>::iterator itr = parameters->ui_points.begin();
			while (itr != parameters->ui_points.end())
			{
				QPoint ConP;
				switch(_name){
				case 'L':
				case 'l':				
					ConP= QPoint(itr->lp.x*_real_size.width(),itr->lp.y*_real_size.height());
					break;

				case 'R':
				case 'r':
					ConP= QPoint(itr->rp.x*_real_size.width(),itr->rp.y*_real_size.height());
					break;
				}

				if (abs(ConP.x()-event->pos().x())<=3&&abs(ConP.y()-event->pos().y())<=3)
				{
					parameters->ui_points.erase(itr);
					parameters->ActIndex=-1;					
					break;
				}	
				itr++;
			}
			
		}

		emit sigUpdate();

	}

}