/* 初始化相应的信号与槽 */ void TextEditer::initConnection() { /* menuFile里的信号与槽 */ connect(actNew, SIGNAL(triggered()), this, SLOT(doNew())); connect(actOpen, SIGNAL(triggered()), this, SLOT(doOpen())); connect(actClose, SIGNAL(triggered()), this, SLOT(doClose())); connect(actSave, SIGNAL(triggered()), this, SLOT(doSave())); connect(actASave, SIGNAL(triggered()), this, SLOT(doASave())); connect(actExit, SIGNAL(triggered()), this, SLOT(doExit())); /* menuEdit里的信号与槽 */ connect(actUndo, SIGNAL(triggered()), this, SLOT(doUndo())); connect(actRedo, SIGNAL(triggered()), this, SLOT(doRedo())); connect(actCut, SIGNAL(triggered()), this, SLOT(doCut())); connect(actCopy, SIGNAL(triggered()), this, SLOT(doCopy())); connect(actPast, SIGNAL(triggered()), this, SLOT(doPast())); connect(actAll, SIGNAL(triggered()), this, SLOT(doSelectAll())); /* menuTool里的信号与槽 */ connect(actFont, SIGNAL(triggered()), this, SLOT(setFontForText())); /* 当当前文本内容改变后, 自动调用doModified() */ connect(textEdit->document(), SIGNAL(contentsChanged()), this, SLOT(doModified())); /* 当文档修改后, 刷新光标所在的位置 */ connect(textEdit->document(), SIGNAL(contentsChanged()), this, SLOT(doCursorChanged())); }
float ImageLens::imageInten(int i, int j) const { if (trans_) doTrans(i, j); if (cut_) doCut(i, j); float ret = image_.inten2d(i, j); const Image& normalizer = gSession->corrset.getNormalizer(); if (gSession->corrset.isEnabledAndValid()) ret *= normalizer.inten2d(i, j); return ret; }
void CMainWindow::iniConnect() { connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(doCursorChanged())); connect(actNew, SIGNAL(triggered()), this, SLOT(doNew())); connect(actOpen, SIGNAL(triggered()), this, SLOT(doOpen())); connect(actClose, SIGNAL(triggered()), this, SLOT(doClose())); connect(actSave, SIGNAL(triggered()), this, SLOT(doSave())); connect(actASave, SIGNAL(triggered()), this, SLOT(doASave())); connect(actQuit, SIGNAL(triggered()), this, SLOT(doQuit())); connect(actUndo, SIGNAL(triggered()), this, SLOT(doUndo())); connect(actCut, SIGNAL(triggered()), this, SLOT(doCut())); connect(actCopy, SIGNAL(triggered()), this, SLOT(doCopy())); connect(actPaste, SIGNAL(triggered()), this, SLOT(doPast())); connect(actAll, SIGNAL(triggered()), this, SLOT(doAll())); connect(actFind, SIGNAL(triggered()), this, SLOT(doFind())); connect(textEdit->document(), SIGNAL(contentsChanged()), this, SLOT(doModified())); separatorAct = menu_F->insertSeparator(actQuit); separatorAct->setVisible(false); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActs[i] = new QAction(this); menu_F->insertAction(separatorAct, recentFileActs[i]); recentFileActs[i]->setVisible(false); connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } actPrint = menu_T->addAction(tr("打印文档")); connect(actPrint, SIGNAL(triggered()), this, SLOT(doPrint())); }
void Canvas::mouseDragged(int x, int y, int button) { if (strokeType == 0) { if (currentSpringStroke) { currentSpringStroke->addPoint(x, y); } } else if (strokeType == 3) { if (currentSurfaceStroke) { currentSurfaceStroke->addPoint(x, y); } } else if (strokeType == 2) { if (currentParticleStroke) { for (int i=0; i<10; i++) { currentParticleStroke->addPoint(ofVec2f(x+ofRandom(20)-10, y+ofRandom(20)-10)); } } } else if (strokeType == 5) { if (currentRepeatableStroke) { currentRepeatableStroke->addPoint(x, y); } } else if (strokeType == 1) { if (currentSpringStroke) { currentSpringStroke->addPoint(x, y); } } else if (strokeType == 4) { // blade bladePrev = blade; blade = ofVec2f(x, y); doCut(bladePrev, blade); } else if (strokeType == 6) { DropEmitter *de = new DropEmitter(); de->setup(ofVec2f(x, y)); emitters.push_back(de); history.push_back(6); } }