示例#1
0
/* This used to be called when moving all contours in an object but not anymore */
void imod_contour_move(int ob)
{
  /* DNM2/13/03: remove oldpt, co, cont */
  int oldob;
  int oldco;
  Iobj *obj;  
  Iobj *olObj;  
  Icont *ocont;
  ImodView *vi = App->cvi;
  Imod *imod = App->cvi->imod;
     
  oldob =  imod->cindex.object;
  oldco =  imod->cindex.contour;

  ocont = imodContourGet(imod);
  if (!ocont)
    return;
     
  if (ob == oldob)
    return;
     
  if (ob > imod->objsize)
    return;
     
  if (ob < 0)
    return;
     
  obj = &(imod->obj[ob]);
  olObj = &(imod->obj[oldob]);
  if (istoreCountContSurfItems(olObj->store, oldco, 0)) {
    vi->undo->objectPropChg(ob);
    istoreCopyContSurfItems(olObj->store, &obj->store, oldco,
                            obj->contsize, 0);
  }

  vi->undo->contourMove(imod->cindex.object, 0, ob, obj->contsize);

  /* DNM: switch to this Add and Remove method to avoid problems with
     labels */
  imodObjectAddContour(obj, ocont);
  
  imodObjectRemoveContour(olObj, oldco);
  /* DNM 3/29/01: delete old code. */
  return;
}
示例#2
0
// Changes the size of the current point given the zoom and scroll wheel delta value
void utilWheelChangePointSize(ImodView *vi, float zoom, int delta)
{
  int ix, iy, pt;
  Iobj *obj;
  Icont *cont;
  float size;
  imodGetIndex(vi->imod, &ix, &iy, &pt);
  obj = imodObjectGet(vi->imod);
  cont = imodContourGet(vi->imod);
  if (!cont || pt < 0)
    return;
  size = imodPointGetSize(obj, cont, pt);
  if (!size && (!cont->sizes || (cont->sizes && cont->sizes[pt] < 0)))
    return;
  size += delta * utilWheelToPointSizeScaling(zoom);
  size = B3DMAX(0., size);
  vi->undo->contourDataChg();
  imodPointSetSize(cont, pt, size);
  vi->undo->finishUnit();
  imodDraw(vi, IMOD_DRAW_MOD);
}
示例#3
0
Icont *utilAutoNewContour(ImodView *vi, Icont *cont, bool notInPlane, bool timeMismatch,
                          int timeLock, int setSurface, const char *planeText,
                          const char *surfText)
{
  Iobj *obj = imodObjectGet(vi->imod);
  const char *baseMess = "Started a new contour even though last contour had only 1 pt. ";
  if (cont->psize == 1) {
    if (notInPlane && iobjClose(obj->flags))
      wprint("\a%s Use open contours to model across %s.\n", baseMess, planeText);
    else if (notInPlane)
      wprint("\a%s Turn off \"Start new contour at new Z\" to model "
             "across %s.\n", baseMess, planeText);
    else
      wprint("\a%s Set contour time to 0 to model across times.\n", baseMess);
  }
  inputNewContourOrSurface(vi, setSurface, timeLock);
  cont = imodContourGet(vi->imod);
  if (!cont)
    return NULL;
  if (setSurface == INCOS_NEW_SURF)
    wprint("Started new surface # %d due to change in %s\n", cont->surf, surfText);
  return cont;
}
示例#4
0
void ContourCopy::apply()
{
  const char *badCopy = "Copy operation cancelled.  ";
  /*     char *badObjectErrorMsg = 
         "\nCopy operation cancelled.\n"
         "Object out of range or invalid\n.";
  */

  Imod *imod = sData.vw->imod;
  Iobj *obj   = imodObjectGet(imod);
  Icont *cont = imodContourGet(imod);
  Icont *ncont;
  bool doingSection = false;
  int ob, co, errcode, maxcont;

  if (!obj){
    wprint("\a%sBad input object.\n",badCopy);
    return;
  }

  /* DNM: check validity of current contour: here test on all the
     conditions where a current contour is not needed */
  if (!((sData.doAll || sData.doAllObj) && 
        (sData.copyOperation == COPY_TO_OBJECT ||
         sData.copyOperation == COPY_TO_CURRENT || 
         sData.copyOperation == COPY_TO_TIME))) {
    if ((!cont) || (cont->psize <= 0)){
      wprint("\a%sBad input contour.\n", badCopy);
      return;
    }
    
    /* Set surface number here since we know we have a contour */
    sData.surfaceNumber = cont->surf;
  }

  /* check copy to place is valid. */
  switch(sData.copyOperation){
  case COPY_TO_OBJECT:
    if ((sData.objectNumber < 1) ||
        (sData.objectNumber > (int)imod->objsize) ||
        (sData.objectNumber == imod->cindex.object + 1)){
      wprint("\a%sBad destination object.\n", badCopy);
      return;
    }
    if (sData.makeEllipse && 
        (!iobjClose(obj->flags) || !iobjClose(imod->obj[sData.objectNumber - 1].flags))) {
      wprint("\aTo make ellipses, objects to copy from and to must both be closed.\n");
      return;
    }
    break;

  case COPY_TO_CURRENT:
    break;

  case COPY_TO_SECTION:
    /* get section number to copy from.*/
    sData.currentSection = (int)floor(cont->pts->z + 0.5);

    /* check section number to copy to. */
    if ((sData.sectionNumber <= 0) || 
        ( sData.sectionNumber > sData.vw->zsize ) ||
        (sData.currentSection + 1 == sData.sectionNumber)){
      wprint("\a%sBad destination section.\n", badCopy);
      return;
    }
    doingSection = true;
    break;

  case COPY_TO_TIME:
    sData.currentTime = cont->time;
    if ((sData.timeIndex > sData.vw->numTimes) ||
        ( sData.timeIndex < 1) || 
        (sData.timeIndex ==  sData.vw->curTime)) {
      wprint("\a%sBad destination time index.\n", badCopy);
      return;
    }
    break;

    /* DNM 2/16/01: made these work relative to section of current
       contour */
  case COPY_TO_NEXT_SECTION:
    sData.currentSection = (int)floor(cont->pts->z + 0.5);
    if (sData.currentSection == (sData.vw->zsize - 1)){
      wprint("\a%sNext section invalid.\n", badCopy);
      return;
    }
    sData.sectionNumber = sData.currentSection + 2;
    doingSection = true;
    break;

  case COPY_TO_PREV_SECTION:
    sData.currentSection = (int)floor(cont->pts->z + 0.5);
    if (!sData.currentSection){
      wprint("\a%sPrevious section invalid.\n", badCopy);
      return;
    }
    sData.sectionNumber = sData.currentSection;
    doingSection = true;
    break;

  }


  /* Loop on all objects, skip if not doing all or it is not current one or it is not 
     selected and it is an allowed operation */
  for (ob = 0; ob < (int)imod->objsize; ob++) {
    if (!(sData.doAllObj || ob == imod->cindex.object || 
          (!sData.doAllObj && !sData.doSurface && !sData.doAll && 
           (doingSection || sData.copyOperation == COPY_TO_TIME) &&
           imodSelectionListQuery(sData.vw, ob, -1) > -2)))
      continue;

    sData.currentObject = ob;
    obj = &imod->obj[ob];
    maxcont = obj->contsize;

    /* look at all contours in current object */
    for (co = 0; co < maxcont; co++) {
      cont = &obj->cont[co];

      /* If copying to section, check for being at source section */
      if (doingSection) {
        if (!cont->psize)
          continue;
        if (floor(cont->pts->z + 0.5) != sData.currentSection)
          continue;
      }
        
      /* If copying to time, check for being at source time */
      if ((sData.copyOperation == COPY_TO_TIME) &&
          (cont->time != sData.currentTime))
        continue;

      /* If copying surface, make sure surface matches */
      if (sData.doSurface && cont->surf != sData.surfaceNumber)
        continue;

      /* copy the entire contour */
      if (cont->psize && (sData.doAll || sData.doAllObj || sData.doSurface || 
                          (co == imod->cindex.contour && ob == imod->cindex.object) || 
                          imodSelectionListQuery(sData.vw, ob, co) > -2)) {
        if (sData.copyOperation == COPY_TO_OBJECT && sData.makeEllipse) {
          errcode = copyAsEllipse(cont);
        } else {
          ncont  = imodContourDup(cont);
          errcode = copyContour(ncont, co);
          free(ncont);
        }
        if (errcode)
          wprint("\a%sFailed to duplicate contour correctly.\n", badCopy);
      }
    }
  }
  sData.vw->undo->finishUnit();
  wprint("Copy operation completed\n");
  imodDraw(sData.vw, IMOD_DRAW_MOD);
  imod_setxyzmouse();
}