int main(){ Stack s1 = createStack(); int i; char s[1024];s[0] = '\0'; for(i = 0;i < maxSize + 2;i++){ showContent(&s1); if(!full(&s1)){ push(createNode('a' + i),&s1); printf("Stack pushed on top: '%c'\n",top(&s1).entry.c); }else printf("Stack is full\n"); } for(i = 0;i < maxSize + 2;i++){ showContent(&s1); if(!empty(&s1)){ printf("Stack top removed: '%c'\n",pop(&s1).entry.c); }else printf("Stack is empty\n"); } gets(s); return 0; }
ViewToolBar::ViewToolBar(QWidget *parent) : QToolBar(parent) { group = new QActionGroup(this); setIconSize(QSize(20,20)); setToolButtonStyle(Qt::ToolButtonTextBesideIcon); // adding a dummy space widget appears to even out the toolbar addWidget(new QWidget(this)); dbSelect = new QComboBox(this); dbSelect->setMinimumWidth(150); connect(dbSelect, SIGNAL(activated(int)), this, SLOT(dbComboModified(int))); addWidget(dbSelect); viewActions.append(addExclusiveAction(":content", "Content", SLOT(showContent()))); viewActions.append(addExclusiveAction(":schema", "Schema", SLOT(showStructure()))); viewActions.append(addExclusiveAction(":query", "Query", SLOT(showQuery()))); QWidget* spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); addWidget(spacer); back = QToolBar::addAction("<", this, SIGNAL(historyBack())); back->setEnabled(false); forward = QToolBar::addAction(">", this, SIGNAL(historyForward())); forward->setEnabled(false); viewActions.append(addAction(QIcon(":disconnect"), "Disconnect", this, SIGNAL(disconnect()))); }
void SCgNode::updateContentViewer() { bool isCntVis = mContentVisible; if(isCntVis) hideContent(); if (mContentViewer != 0) { delete mContentViewer; mContentViewer = 0; } if (!contentType() == SCgContent::Empty) { // creating new viewer if (!mContentViewer) mContentViewer = SCgContentFactory::createViewer(contentFormat()); Q_ASSERT(mContentViewer); mContentViewer->setData(contentData()); mContentViewer->setParentItem(this); if (isCntVis) showContent(); } update(); }
void on_mouse( int event, int x, int y, int flags, void* ptr) { if( event == CV_EVENT_LBUTTONDOWN ) { InitContour.push_back(cvPoint(x,y)); showContent((IplImage *)ptr); } }
void CMFCApplication7Dlg::sendmessage() { CString tmp; inputBox.GetWindowTextW(tmp); tmp += _T("\n"); inputBox.SetSel(0, -1); inputBox.Clear(); currentProtocol->mysend((char *)(tmp.GetBuffer()), 200, currentDialogue->peer); showContent(currentDialogue, (LPCTSTR)(tmp.GetBuffer())); inputBox.SetFocus(); }
void ProjectTree::onItemClicked(QTreeWidgetItem* item, int column) { Q_UNUSED(column); if (m_allItems.count(item)) { m_currentItem = item; QString location = ProjectManager::instance().getProject()->getProjectLocation(); QString fileName = location + "/" + m_allItems[item]; if (m_changedContent.count(m_currentItem)) { emit showContent(m_changedContent[m_currentItem], fileName); } else { emit showFileContent(fileName); } } }
int main(int argc,char* argv[]) { IplImage * srcimage = NULL; if ( argc == 2) srcimage = cvLoadImage((char *)argv[1], CV_LOAD_IMAGE_GRAYSCALE); else srcimage = cvLoadImage("snake_test.jpg", CV_LOAD_IMAGE_GRAYSCALE); if(srcimage==NULL){ std::cout<<"error file name"<<std::endl; return -1; } InitContour.clear(); cvNamedWindow("srcImage"); cvShowImage("srcImage", srcimage); cvSetMouseCallback("srcImage", on_mouse,srcimage); cvWaitKey(); //等待迭代开始 float alpha=0.01; float beta=0.1; float gamma=0.1; CvSize size; size.width=3; size.height=3; CvTermCriteria criteria; criteria.type=CV_TERMCRIT_ITER; criteria.max_iter=5; criteria.epsilon=0.1; int itetime =500 ; for(int ite=0;ite<itetime;ite++) { //对边界点查值,使所有边界点距离为(1-2) ReGeneralPtArrs(InitContour,InitContour); //将边界点的平均距离改为3;根据我的经验,距离大一点效果要好一些 removeNearPoints(InitContour,InitContour,3); CvPoint* pts = new CvPoint[InitContour.size()]; for (int i=0;i<InitContour.size();i++) { pts[i] = InitContour[i]; } if(InitContour.size()<5){ printf("迭代失败!\n"); break; } cvSnakeImage( srcimage, pts,InitContour.size(),&alpha,&beta,&gamma,CV_VALUE,size,criteria,1); int size = InitContour.size(); InitContour.clear(); for (int i=0;i<size;i++) { if(pts[i].x<0||pts[i].x>=srcimage->width) continue; if(pts[i].y<0||pts[i].y>=srcimage->height) continue; InitContour.push_back(pts[i]); } showContent(srcimage); cvWaitKey(20); Sleep(200); printf("迭代了 %d 次\n",ite); delete []pts; char c = cvWaitKey(1); if ((c&255)==27) break; } removeNearPoints(InitContour,InitContour,6); showContent(srcimage); cvWaitKey(); cvReleaseImage(&srcimage); cvReleaseImage(&temp); return 0; }