void neuron_tipspicker_dialog::change_tip(int c)
{
    checkwindow();
    checkStatus();

    int info[4];
    if(curIdx<mList->size())
    {
        get_marker_info(mList->at(curIdx),info);
        int color[3]={0};
        if(info[2]==1)
            color[1]=255;
        else if(info[2]==2)
            color[0]=255;
        else
            color[2]=255;
        update_marker_info(mList->at(curIdx),info,color);
    }

    if(cb_tips->count()>0)
    {
        int color[3]={255,0,255};
        int i=cb_tips->currentIndex();
        get_marker_info(mList->at(i),info);
        update_marker_info(mList->at(i),info,color);
        curIdx=i;
    }

    //for test
    qDebug()<<"===========UPDATE MARKER============ change tip";

    updatemarker();
}
void neuron_tipspicker_dialog::link_new_marker_neuron()
{
    if(mList->size()<=0){
        return;
    }

    int color[3]={0,0,255};

    double dis;
    for(int i=0; i<mList->size(); i++){
        int info[4];
        if(get_marker_info(mList->at(i),info))
            continue;
        double mdis=1e10;
        int nid=-1;
        int pid=0;

        for(int j=0; j<ntList->size(); j++){
            for(int k=0; k<ntList->at(j).listNeuron.size(); k++){
                dis=NTDIS(ntList->at(j).listNeuron[k],mList->at(i));
                if(dis<mdis){
                    mdis=dis;
                    nid=j;
                    pid=k;
                }
            }
        }
        info[0]=nid;
        info[1]=pid;
        info[2]=info[3]=0;
        update_marker_info((*mList)[i],info,color);
    }
}
void neuron_tipspicker_dialog::update_tip()
{
    checkwindow();

    link_new_marker_neuron();

    //populate tips
    cb_tips->clear();
    int info[4];

    for(int i=0; i<mList->size(); i++){
        if(get_marker_info(mList->at(i),info)){
            if(info[2]==1)
                cb_tips->addItem("Marker: " + QString::number(i+1) + " accepted");
            else if(info[2]==2)
                cb_tips->addItem("Marker: " + QString::number(i+1) + " rejected");
            else
                cb_tips->addItem("Marker: " + QString::number(i+1));

        }
    }

    if(curIdx>=cb_tips->count())
        curIdx=0;
    checkStatus();
}
void neuron_tipspicker_dialog::reset_tip()
{
    checkwindow();

    //link marker neuron
    relink_marker_neuron();

    //populate tips
    cb_tips->clear();
    int info[4];

    for(int i=0; i<mList->size(); i++){
        if(get_marker_info(mList->at(i),info)){
            if(info[2]==1)
                cb_tips->addItem("Marker: " + QString::number(i+1) + " accepted");
            else if(info[2]==2)
                cb_tips->addItem("Marker: " + QString::number(i+1) + " rejected" );
            else
                cb_tips->addItem("Marker: " + QString::number(i+1));

        }
    }

    curIdx=0;
    checkStatus();

    //for test
    qDebug()<<"===========UPDATE MARKER============ reset tip";

    updatemarker();
}
示例#5
0
int setup_menu(Image *image, Setup *setup)
{
  char line[MAXC];    /* Generic string for reading input */

  printf("\nAdjust display menu\n");
  printf("-------------------\n");
  printf(" Enter one of the following codes:\n");
  printf("   f - Change display range\n");
  printf("   p - Change pixel scale of image\n");
  printf("   t - Change title\n");
  printf("   z - Change display center and size (crude zoom)\n");
  printf("       (%d %d centered at %f %f)\n",setup->xsize,setup->ysize,
	 setup->centx,setup->centy);
  printf("   + - Toggle compass display on/off\n");
  printf("   x - Add/move the cross-hair marker\n");
  printf("   q - Quit out of display adjustment and continue with program\n");
  printf("\nEnter option: [q] ");
  fgets(line,MAXC,stdin);
  if(line[0] == '\n')
    return 0;
  else {
    switch(line[0]) {
    case 'f': case 'F':
      get_frange(image,setup);
      break;
    case 'p': case 'P':
      get_pixscale(image,setup);
      break;
    case 't': case 'T':
      get_title(image,setup);
      break;
    case 'z': case 'Z':
      get_imsize(image,setup);
      break;
    case '+':
      toggle_compass(setup);
      break;
    case 'x':
      setup->drawmarker = TRUE;
      get_marker_info(setup);
      break;
    case 'q': case 'Q':
      return 0;
      break;
    default:
      fprintf(stderr,"\nsetup_menu: Not a valid option.\n");
      break;
    }
  }

  return 1;
}
void neuron_tipspicker_dialog::output_markers(QString fname)
{
    QFile file(fname);
    if (!file.open(QIODevice::WriteOnly|QIODevice::Text)){
        v3d_msg("cannot open "+ fname +" for write");
        return;
    }
    QTextStream myfile(&file);
    myfile<<"##x,y,z,radius,shape,name,comment, color_r,color_g,color_b"<<endl;
    //matched candidates first
    int info[4];
    for(int i=0; i<mList->size(); i++){
        get_marker_info(mList->at(i), info);
        if(info[2]==1)
            myfile<<mList->at(i).x<<","<<mList->at(i).y<<","<<mList->at(i).z<<",0,1, , ,0,255,0"<<endl;
    }
    file.close();
}
void neuron_tipspicker_dialog::reject_tip()
{
    checkwindow();
    checkStatus();

    int info[4];
    int color[3]={255,0,0};
    int i=cb_tips->currentIndex();
    get_marker_info(mList->at(i),info);
    info[2]=2;
    update_marker_info(mList->at(i),info,color);
    cb_tips->setItemText(i, "Marker: " + QString::number(i+1) + " rejected");

    if(i+1<cb_tips->count()){
        cb_tips->setCurrentIndex(i+1);
    }else{
        //for test
        qDebug()<<"===========UPDATE MARKER============ reject tip";

        updatemarker();
    }
}
示例#8
0
int setup_interact(Image *image, Setup *setup)
{
  char line[MAXC];     /* General string variable for getting input */


  /*
   * Get pixel scale if not already set
   */

  if(image->wcs.validwcs == 0) {
    if(get_pixscale(image, setup)) {
      fprintf(stderr,"ERROR: setup_interact\n");
      return 1;
    }
  }
#if 0
  /*
   * Get image size
   */

  if(get_imsize(image,setup)) {
    fprintf(stderr,"ERROR: setup_interact\n");
    return 1;
  }

  /*
   * Mark an object?  Note that the mark position is set to be the
   *  requested center pixel in the get_imsize function
   */

  if(setup->drawmarker != TRUE)
    get_marker_info(setup);

  /*
   * Get display range.  Note that display range for DSS plots is
   *  set automatically.
   */

  printf("\nSetting limits for image display.\n");
  /*
   * Get overall image statistics.
   */

  if(setup->lo != setup->hi) {
    printf("  *** Using display values set in setup file ***\n");
    printf("      Min = %f\n",setup->lo);
    printf("      Max = %f\n",setup->hi);
  }
  else {
    setup->lo = image->pixmean - 2.0 *image->pixrms;
    setup->hi = image->pixmean + 20.0 * image->pixrms;
    printf("   Initial guess for range: %9.3f %9.3f\n",setup->lo,
	   setup->hi);
    if(get_frange(image,setup)) {
      fprintf(stderr,"ERROR: setup_interact\n");
      return 1;
    }
  }

  /*
   * Get image title
   */

  get_title(image,setup);
#endif
  /*
   * Get image scaling information
   */

  if(setup->instrument != DSS && setup->trans == UNSET)
    if(get_transfunc(setup))
      fprintf(stderr,"ERROR: setup_interact\n");
  
  /*
   * Get contour info
   */

  if(setup->instrument != DSS && setup->docontour != FALSE)
    if(get_contours(setup))
      fprintf(stderr,"ERROR: setup_interact\n");

  /*
   * Get internal label info
   */

  if(setup->instrument != DSS && setup->dolabel != FALSE)
    if(get_intlab(image,setup))
      fprintf(stderr,"ERROR: setup_interact\n");

  /*
   * Get image scaling information
   */

  if(setup->nintlab > 0 && setup->instrument != DSS)
    if(get_labscale(setup))
      fprintf(stderr,"ERROR: setup_interact\n");
  
  /*
   * Draw a compass?
   */

  if(setup->drawcompass == UNSET) {
    printf("Draw a compass? [y] ");
    fgets(line,MAXC,stdin);
    if(line[0] == 'n' || line[0] == 'N')
      setup->drawcompass = FALSE;
    else
      setup->drawcompass = TRUE;
  }

  /*
   * Put border and external labels on the plot?
   */

  if(setup->instrument != DSS)
    if(get_border_info(image,setup))
      fprintf(stderr,"ERROR: setup_interact\n");

  /*
   * Get the character height for plot labels if not set.  The default
   *  value is 1.2, but the user can change this.
   */

  if(setup->instrument != DSS && setup->cheight<0.0) {
    setup->cheight = 1.2;
    printf("\nEnter character height for plot labels: [%4.1f]  ",
	   setup->cheight);
    fgets(line,MAXC,stdin);
    if(line[0] != '\n') {
      while(sscanf(line,"%f",&setup->cheight) != 1 || setup->cheight < 0.0) {
	fprintf(stderr,"ERROR: Bad input format.  Enter character height: ");
	fgets(line,MAXC,stdin);
      }
    }
  }

  /*
   * If a WFPC2 overlay is desired, get the overlay parameters.
   */

  if(setup->plotwfpc)
    if(get_wfpc_overlay(setup))
      fprintf(stderr,"ERROR: setup_interact\n");
    
  return 0;
}