Exemplo n.º 1
0
void VRDevice::change_button(int key, int state) {
    if (BStates.count(key) == 0) BStates[key] = state;
    sig_key = key;
    sig_state = state;
    BStates[key] = state;
    triggerSignal(key, state);
    triggerSignal(-1, state);
}
Exemplo n.º 2
0
void VRDevice::change_slider(int key, float state) {
    if (SStates.count(key) == 0) SStates[key] = state;
    SStates[key] = state;
    sig_key = key;
    sig_state = state;
    if (abs(state) > 0.001) triggerSignal(key, 0);
}
Exemplo n.º 3
0
static void* timeoutThreadMain (void* passedPtr)
{
   void* Return = (void*) 0;
   
   /*  We grab all the data held in the calling thread right now. In some
    *  cases, we find that the calling thread has vanished and released
    *  its memory, including the details structure, by the time the timeout
    *  expires, and then we get an access violation when we try to set the
    *  'timed out' flag.
    */
   
   timeoutDetails details = *((timeoutDetails*) passedPtr);
   struct timespec requestedDelay = details.delay;
   
   /*  We do a nanosleep() for the specified delay, and then trigger a
    *  timeout. Note that we allow for the case where the nanosleep() is
    *  interrupted, and restart it for the remaining time. If the 
    *  thread that is doing the sem_wait() call gets the semaphore, it
    *  will cancel this thread, which is fine as we aren't doing anything
    *  other than a sleep and a signal.
    */
   
   for (;;) {
      struct timespec remainingDelay;
      if (nanosleep (&requestedDelay,&remainingDelay) == 0) {
         break;
      } else if (errno == EINTR) {
         requestedDelay = remainingDelay;
      } else {
         Return = (void*)(long) errno;
         break;
      }
   }
   
   /*  We've completed the delay without being cancelled, so we now trigger
    *  the timeout by sending a signal to the calling thread. And that's it,
    *  although we set the timeout flag first to indicate that it was us
    *  that interrupted the sem_wait() call. One precaution: before we
    *  try to set the timed-out flag, make sure the calling thread still
    *  exists - this may not be the case if things are closing down a bit
    *  messily. We check this quickly using a zero test signal.
    */
   
   if (pthread_kill(details.callingThread,0) == 0) {
      *(details.timedOutShort) = TRUE;
      if (triggerSignal (SIGUSR2,details.callingThread) < 0) {
         Return = (void*)(long) errno;
      }
   }
   
   return Return;
}
Exemplo n.º 4
0
Arquivo: ffcp.cpp Projeto: sylzd/FFCP
FFCP::FFCP(QWidget *parent) :
QMainWindow(parent)
{   
	this->resize(830, 500);
	
	this->setWindowTitle(tr("异构嵌入式流程图开发平台"));

	flowWidget = new FlowWidget(this);
	setCentralWidget(flowWidget);
	connect(flowWidget, SIGNAL(triggerSignal()), this, SLOT(changeCode()));   //建立定义变量与代码查看器的连接
	
	hardWidget = new HardWidget(this);
	connect(hardWidget, SIGNAL(triggerSignal()), this, SLOT(changeCode()));   //建立定义变量与代码查看器的连接

		
	createActions();
	createMenus();
	createToolBars();
	createStatusBars();
	createDockWidget();
	createComboBox();   //创建组合框	
	
}
Exemplo n.º 5
0
void FlowWidget::dropEvent(QDropEvent *event)
{   
	QPushButton *newModel = new QPushButton(this);
	flowIcon.push_back(newModel);//拷贝一个pushbutton指针给vector
	flowIcon.back()->hide();
	flowIcon.back()->setGeometry(event->pos().x() - flowIcon_sizeHalf, event->pos().y() - flowIcon_sizeHalf, 50, 50);  //设置生成的按钮的位置和大小

	QIcon icon = qvariant_cast<QIcon>(event->mimeData()->imageData());   //强行转变图片格式
	flowText[number] = (event->mimeData()->text());     //我流程图的代码转入flowText变量
	flowIcon.back()->setIcon(icon);    //设置按钮的图标
	flowIcon.back()->setIconSize(QSize(50, 50));   //设置按钮图标的大小
	flowIcon.back()->show();
	flowIcon.back()->installEventFilter(this);

	if (flowText[number] == "int main(){")   //把主函数加入代码
	{
		int count = globalCode.count();     //得到代码有多少个字符
		QString front;
		QString end;
		int j = 0;     //计数遇见几个“\n”
		int falg = 0;  //当遇见的不是“\n”时 不准赋值
		for (int i = 0; i < count; i++)
		{
			if (globalCode.at(i) == '\n')
			{
				j = j + 1;
				falg = 1;
			}
			else falg = 0;
			if (j-2 == 6 && falg == 1)//减去头文件的两行
			{
				front = globalCode.mid(0, i + 1);   //   定义变量前的代码
			}
			if (j-2 == 7 && falg == 1)
			{
				end = globalCode.mid(i);           //    定义变量后的代码
			}
		}
		globalCode += (front + flowText[number] + end + "\n");
		emit triggerSignal();    //给一个触发信号
	}
	number++;//暂留全局变量
}
Exemplo n.º 6
0
bool FilterToolButton::setFilter(FilterToolButton::ItemId id,const QString & filter) {
    QList<QAction *> actions = menu()->actions();
    for (int i=0;i<actions.count();i++) {
        ItemId item_id = ((actions[i]->menu() == NULL)?((IdAction *)actions[i])->id():IS_UNKNOWN);

        if (actions[i]->menu() == NULL) {
            bool is_ok = ((id == IS_GROUP) && (id == item_id) && (actions[i]->text() == filter));
            if (!is_ok) is_ok = ((id != IS_UNKNOWN) && (id != IS_GROUP) && (id == item_id));
            if (is_ok) {
                actions[i]->trigger();
                triggerSignal(actions[i]);
                return true;
            }
        }
        else if (actions[i]->menu() != NULL) {
            if (setFilter(actions[i]->menu(),id,filter)) return true;
        }
    }
    return false;
}
Exemplo n.º 7
0
void SVGroupview::TranslateSuccessful()
{
  void **args = 0;
  triggerSignal(signals_ + 2, args);
}
Exemplo n.º 8
0
void WSignalMapper::mapped(const std::string arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 1, args);
}
Exemplo n.º 9
0
void SVAddSE::backSVSEView()
{
  void **args = 0;
  triggerSignal(signals_ + 2, args);
}
Exemplo n.º 10
0
void CSVReportSet::ExChangeEvent()
{
  void **args = 0;
  triggerSignal(signals_ + 4, args);
}
Exemplo n.º 11
0
void CSVReportSet::AddNewPhone()
{
  void **args = 0;
  triggerSignal(signals_ + 2, args);
}
Exemplo n.º 12
0
void CSVReportSet::ShowWebSend(string arg0,string arg1)
{
  void *args[2] = {(void *)(&arg0), (void *)(&arg1)};  triggerSignal(signals_ + 0, args);
}
Exemplo n.º 13
0
SignalGuard::~SignalGuard()
{
    if( mShouldEmit )
        emit triggerSignal();
}
Exemplo n.º 14
0
SignalGuard::SignalGuard(QObject* target, const char* method) :
    mShouldEmit(true)
{
    connect(this, SIGNAL(triggerSignal()), target, method);
}
Exemplo n.º 15
0
bool FlowWidget::eventFilter(QObject *Object, QEvent *event)
{   
	QMouseEvent* e = static_cast<QMouseEvent*>(event);//鼠标事件
	static QPoint clickInipos;////记录鼠标点击的初始坐标,用来移动
	static bool leftMove = false;//判断是否左键移动
	QTimer mouseTimer;//鼠标按压时间计时器
	bool isSingleClick = true;//判断是否是单击
	int selNum = -1;//选择的模块号
	int numEnd = -1;//释放鼠标后找到的箭头结束模块号
	static int startNum = -1;//箭头开始的模块号,为保持记忆性,用静态变量
	//鼠标双击
	if (event->type() == QEvent::MouseButtonDblClick)
	{
		if (mouseTimer.isActive())
			mouseTimer.stop();//双击则停止鼠标计时器,判定为双击,不执行单击函数
		isSingleClick = false;

		//判断那个模块被鼠标双击
		selNum = findNum(e, flowIcon);
		num = selNum + 1;//num暂时先留着,传一下参,+1是去掉main模块
		if (selNum == -1)
		{
			qDebug() << "没有找到双击的模块" << endl;
		}
		else
		{
			if (flowIcon[selNum]->rect().contains(e->pos()) &&
				(e->button() == Qt::LeftButton)) //左键双击模块
			{
				Dialog *dialog = new Dialog(this);
				connect(dialog, SIGNAL(triggerSignal()), this->parent(), SLOT(changeCode()));//传信号给FFCP修正编辑框代码
				dialog->show();
			}
			if (flowIcon[selNum]->rect().contains(e->pos()) &&
				(e->button() == Qt::RightButton)) //右键双击模块
			{
				//销掉模块图
				flowIcon[selNum]->close();
				flowIcon.remove(selNum);

				//清除模块对应的线
				int selLineNum = selNum-1;//第1个模块对应第0个箭头
				if (selLineNum >= 0)
				{
					for (int i = 0; i < 4; i++){
						lines[selLineNum][i].setLine(0, 0, 0, 0);
					}
				}

				//清除相应模块代码
				QStringList globalCodeList = globalCode.split("\n");
				globalCodeList[selNum + 2] = "";//加上头文件两行头文件两行
				globalCode = globalCodeList.join("\n");
				emit triggerSignal();
			}
		}
		
	}

	//鼠标单击
	if (event->type() == QEvent::MouseButtonPress)
	{ 
		mouseTimer.start(300);//300毫秒后双击事件还不产生就判定是单击
		clickInipos = e->pos();//获得单击时鼠标位置
		if (isSingleClick){
			//找到被单击的模块
			selNum = findNum(e, flowIcon);
			startNum = selNum;
			if (selNum == -1){
				qDebug() << "没有找到单击的模块" << endl;
			}
			else{
				//左键单击模块
				if (flowIcon[selNum]->rect().contains(e->pos()) &&
					(e->button() == Qt::LeftButton))
				{					
				}
				//右键单击模块	
				else if (e->button() == Qt::RightButton)
				{
					qDebug() << "右键单击numstart:" << selNum<<endl;
					
				}
			}
			
		}
	}

	//鼠标移动
	if (event->type() == QEvent::MouseMove)
	{

		if (startNum == -1){
			qDebug() << "没有找到要移动的模块" << endl;
		}
		else{
			//移动的相对位移
			int dx = e->pos().x() - clickInipos.x();
			int dy = e->pos().y() - clickInipos.y();

			//左键移动
			if (e->buttons() & Qt::LeftButton)
			{
				//移动控件
				flowIcon[startNum]->move(flowIcon[startNum]->x() + dx, flowIcon[startNum]->y() + dy);
				leftMove = true;//控件移动,通知释放时箭头改变
			}
			//右键移动
			else if (e->buttons() & Qt::RightButton)
			{
				moveArrowShow(startNum, dx, dy);
				update();
			}

		}
	}

	//释放鼠标
	if ((event->type() == QEvent::MouseButtonRelease))
	{
		//找到释放后鼠标所在的模块
		numEnd = findNum(e, flowIcon);
		//右键释放
		if (e->button() == Qt::RightButton)
		{
			if (numEnd == -1 || startNum == -1){
				qDebug() << "没有找到两个模块" << endl;
			}
			else{
				drawArrow(flowIcon[startNum]->pos(), flowIcon[numEnd]->pos());
				update();

				//把箭头指向的所含的代码写入代码查看器
				globalCode = globalCode + flowText[num] + "\n";
				emit triggerSignal();
			}
			for (int i = 0; i < 4; i++){
				lineShow[i].setLine(0, 0, 0, 0);
			}
			update();//释放后清除实时显示的线
			
		}

		//左键释放
		if (e->button() == Qt::LeftButton)
		{
			qDebug() << "左键释放" << endl;
			if (leftMove){//左键移动后释放
				leftMove = false;
				moveArrowLast(numEnd);//移动模块上一个箭头
				moveArrowNext(numEnd);//移动模块下一个箭头
				update();
			}
		}

		startNum = -1;//释放鼠标后,开始位置归位
	}
	return false;
}
Exemplo n.º 16
0
void CSVPlanSet::EditPlanList1(ADD_PLAN_OK arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 5, args);
}
Exemplo n.º 17
0
void WTreeNode::addmonitor()
{
    void **args = 0;
    triggerSignal(signals_ + 0, args);
}
Exemplo n.º 18
0
void WComboBox::activated(int arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 0, args);
}
Exemplo n.º 19
0
void CSVReportSet::ShowComSend(string arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 1, args);
}
Exemplo n.º 20
0
void WComboBox::activated(const std::string arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 1, args);
}
Exemplo n.º 21
0
void CSVReportSet::EditPhone(SAVE_REPORT_LIST arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 3, args);
}
Exemplo n.º 22
0
void WAbstractToggleButton::unChecked()
{
  void **args = 0;
  triggerSignal(signals_ + 1, args);
}
Exemplo n.º 23
0
void SVAddSE::AddSVSESucc(string arg0,string arg1)
{
  void *args[2] = {(void *)(&arg0), (void *)(&arg1)};  triggerSignal(signals_ + 1, args);
}
Exemplo n.º 24
0
void CSVSendSMS::BackMailset()
{
  void **args = 0;
  triggerSignal(signals_ + 0, args);
}
Exemplo n.º 25
0
Arquivo: ffcp.cpp Projeto: sylzd/FFCP
void FFCP::defineSlot()
{
	VariableDialog *variableDialog = new VariableDialog(this);
	variableDialog->show();
	connect(variableDialog, SIGNAL(triggerSignal()), this, SLOT(changeCode()));   //建立定义变量与代码查看器的连接
}
Exemplo n.º 26
0
void CSVPlanSet::SaveSuccessful1(SEND_MAIL_PARAM arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 3, args);
}
Exemplo n.º 27
0
void WSignalMapper::mapped(int arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 0, args);
}
Exemplo n.º 28
0
void CSVPlanSet::AddNewPlan1()
{
  void **args = 0;
  triggerSignal(signals_ + 4, args);
}
Exemplo n.º 29
0
void WSignalMapper::mapped(WWidget * arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 2, args);
}
Exemplo n.º 30
0
void SVGroupview::ChangeSelNode(string arg0)
{
  void *args[1] = {(void *)(&arg0)};  triggerSignal(signals_ + 1, args);
}