//! [0] Window::Window(QString filename):run_animation(false),m_animation_number(0),anim_time(0.0) { scene = new GraphSceneJM(filename,this); graph_view = new GraphViewJM(scene); m_shotbutton = new QPushButton("Shot", this); m_saveposbutton = new QPushButton("Save Pos", this); m_newposbutton = new QPushButton("New Pos", this); m_newposname_edit = new QLineEdit(this); m_delposbutton = new QPushButton("Delete this position", this); m_gotoposbutton = new QPushButton("Goto Pos:", this); m_pos_list = new QComboBox(this); m_destpos_list = new QComboBox(this); m_animfile_label = new QLabel("Save as:",this); m_animfile_edit = new QLineEdit(this); m_writefilebutton = new QPushButton("Write File", this); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(graph_view,1,1,10,2); mainLayout->addWidget(m_shotbutton,1,3,1,2); mainLayout->addWidget(m_saveposbutton,2,3,1,2); mainLayout->addWidget(m_pos_list,3,3,1,2); mainLayout->addWidget(m_delposbutton,4,3,1,2); mainLayout->addWidget(m_newposbutton,5,3,1,1); mainLayout->addWidget(m_newposname_edit,5,4,1,1); mainLayout->addWidget(m_gotoposbutton,6,3,1,1); mainLayout->addWidget(m_destpos_list,6,4,1,1); mainLayout->addWidget(m_animfile_label,7,3,1,1); mainLayout->addWidget(m_animfile_edit,7,4,1,1); mainLayout->addWidget(m_writefilebutton,8,3,1,2); setLayout(mainLayout); setWindowTitle(tr("QAnimDrawer")); QObject::connect(m_shotbutton, SIGNAL(clicked()), graph_view, SLOT(ask_shot())); QObject::connect(m_saveposbutton, SIGNAL(clicked()), this, SLOT(save_pos())); QObject::connect(m_delposbutton, SIGNAL(clicked()), this, SLOT(del_pos())); QObject::connect(m_gotoposbutton, SIGNAL(clicked()), this, SLOT(goto_pos())); QObject::connect(m_newposbutton, SIGNAL(clicked()), this, SLOT(new_pos())); QObject::connect(m_pos_list, SIGNAL(currentIndexChanged(int)), this, SLOT(change_pos(int))); QObject::connect(m_writefilebutton, SIGNAL(clicked()), this, SLOT(write_file())); scene->draw_skel(); update_pos_list(); timer=new QTimer(this); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timer_timeout())); }
void main() { SeqList mylist; InitSeqList(&mylist); ElemType Item; int pos; int select = 1; while(select) { printf("**********************************************\n"); printf("** [1] push_back [2] push_front **\n"); printf("** [3] pop_back [4] pop_front **\n"); printf("** [5] insert_pos [6] show_list **\n"); printf("** [7] del_pos [8] del_val **\n"); printf("** [9] find_pos [10]find_Elem **\n"); printf("** [11]sort [12]resver **\n"); printf("** [13]clear [14]merge **\n"); printf("** [15]destroy [0]quit_system **\n"); printf("**********************************************\n"); printf("请选择:>"); scanf("%d",&select); if(select == 0) { break; } switch(select) { case 1: { printf("请输入要插入的数据(-1结束):>"); while(scanf("%d",&Item),Item!=-1) //此处为逗号表达式,真假值由最后一个表达式决定, //所以此处在扫描到Item不是-1时就会自动执行一下下面的函数, //所以每输入一次非-1的数就头插一次。 { push_back(&mylist,Item); } break; } case 2: { printf("请输入要插入的数据(-1结束):>"); while(scanf("%d",&Item),Item!=-1) //此处为逗号表达式,真假值由最后一个表达式决定, //所以此处在扫描到Item不是-1时就会自动执行一下下面的函数, //所以每输入一次非-1的数就头插一次。 { push_front(&mylist,Item); } break; } case 3: { pop_back(&mylist); break; } case 4: { pop_front(&mylist); break; } case 5: { ElemType e; printf("请输入要插入的位置,当前有元素%d:",mylist.size); scanf("%d",&pos); printf("请输入要插入的元素值:"); scanf("%d",&e); insert_pos(&mylist,pos,e); break; } case 6: { show_list(&mylist); break; } case 7: { printf("请输入要删除的位置,当前有元素%d:",mylist.size); scanf("%d",&pos); del_pos(&mylist,pos); break; } case 8: { printf("请输入要删除的元素:"); scanf("%d",&Item); printf("start and Item=%d\n",Item); del_val(&mylist,Item); break; } case 9: { printf("请输入要查找线性表元素的位置:"); scanf("%d",&pos); find_pos(&mylist,pos,&Item); printf("线性表的第%d个元素为:%d\n",pos,Item); break; } case 10: { printf("请输入要查找的元素:"); scanf("%d",&Item); find_Elem(&mylist,Item,&pos); printf("元素%d所在位置为:%d\n",Item,pos); break; } case 11: { sort(&mylist); break; } case 12: { printf("resver start.\n"); resver(&mylist); printf("resver end!\n"); break; } case 13: { clear(&mylist); break; } case 14: { printf("目前无法测试,因为只有一个线性表,无法做合并操作。\n"); //merge(SeqList *list1,SeqList *list2,SeqList *list_merge); break; } case 15: { destroy(&mylist); break; } default: { printf("输入的选择不存在,请重新输入。\n"); select=1; break; } } } }
int med_sdss(char *catfile, char *outfile, int format) { int i; /* Looping variable */ int no_error=1; /* Flag set to 0 on error */ int ncat; /* Number of lines in the final catalog */ int ncent; /* Number of lines in posfile (should be 1) */ Pos *offsets=NULL; /* Array to hold offsets */ Pos *pptr; /* Pointer to navigate offsets */ Skypos *skypos=NULL; /* Array of sky positions */ Skypos *skptr; /* Pointer to navigate skypos */ Secat *centpos=NULL; /* Central position for distance calculations */ SDSScat *scat=NULL; /* Data array from catalog, after purging */ SDSScat *sptr; /* Pointer to navigate secat */ #if 0 /* * Fill the data structure */ if(no_error) if(!(scat = read_sdss(catfile,'#',&ncat,format))) no_error = 0; /* * Read the central position */ if(no_error) if(!(centpos = read_distcalc(posfile,'#',&ncent,0))) no_error = 0; /* * Allocate memory for the skypos array */ if(!(skypos = new_skypos(ncat))) no_error = 0; /* * Load the skypos values into the skypos array */ else { for(i=0,sptr=scat,skptr=skypos; i<ncat; i++,sptr++,skptr++) { *skptr = sptr->skypos; sprintf(skptr->label,"%04d",sptr->id); } /* * Calculate the offsets */ if(!(offsets = dspos2xy(centpos->skypos,skypos,ncat))) no_error = 0; } /* * Put the offsets into the catalog structure */ if(no_error) { for(i=0,sptr=scat,pptr=offsets; i<ncat; i++,sptr++,pptr++) { sptr->dx = pptr->x; sptr->dy = pptr->y; sptr->dpos = sqrt(pptr->x * pptr->x + pptr->y * pptr->y); } } /* * Sort the catalog in order of * increasing distance from the central position. */ if(no_error) { printf("\nSorting the catalog in order of increasing distance "); printf("from the central position..."); qsort(scat,ncat,sizeof(scat[0]),dposcmp_sdss); printf(" Done.\n"); } /* * Renumber the sources */ if(no_error) { for(i=0,sptr=scat; i<ncat; i++,sptr++) sptr->id = i + 1; } /* * Write output file */ if(no_error) if(write_sdss(scat,ncat,outfile,format)) no_error = 0; /* * Clean up and exit */ scat = del_sdsscat(scat); centpos = del_secat(centpos); skypos = del_skypos(skypos); offsets = del_pos(offsets); if(no_error) return 0; else { fprintf(stderr,"ERROR: sort_secat\n"); return 0; } #endif }