Ejemplo n.º 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;
}
Ejemplo n.º 2
0
static int copyAsEllipse(Icont *cont)
{
  Ipoint center;
  float aa, bb, angle, cosang, sinang, xx, yy;
  Icont *ellco;
  double theta;
  Iobj *toObj;
  int ind, numNew;
  ImodView *vw = sData.vw;
  int obnum = vw->imod->cindex.object;

  if (cont->psize < 3)
    return 0;
  aa = imodContourLength(cont, 1);
  numNew = B3DMAX(12., aa / 3.);
  if (imodContourEquivEllipse(cont, &center, &aa, &bb, &angle))
    return 1;
  ellco = imodContourNew();
  if (!ellco)
    return 1;
  cosang = (float)cos((double)angle * RADIANS_PER_DEGREE);
  sinang = (float)sin((double)angle * RADIANS_PER_DEGREE);
  ellco->pts = B3DMALLOC(Ipoint, numNew);
  if (!ellco->pts)
    return 1;
  ellco->psize = numNew;
  for (ind = 0; ind < numNew; ind++) {
    theta = (ind * 360. * RADIANS_PER_DEGREE) / numNew;
    xx = aa * cos(theta);
    yy = bb * sin(theta);
    ellco->pts[ind].x = cosang * xx - sinang * yy + center.x;
    ellco->pts[ind].y = sinang * xx + cosang * yy + center.y;
    ellco->pts[ind].z = cont->pts->z;
  }

  obnum = sData.objectNumber - 1;
  toObj = &vw->imod->obj[obnum];
  vbCleanupVBD(toObj);
  vw->undo->contourAddition(obnum, toObj->contsize);
  ind = imodObjectAddContour(toObj, ellco);
  imodContourDefault(ellco);
  if (ind < 0)
    return 1;
  return 0;
}
Ejemplo n.º 3
0
// Move all contours in current object to new object
void imodMoveAllContours(ImodView *vi, int obNew)
{
  int co;
  Imod *imod = vi->imod;
  Iobj *obj = imodObjectGet(imod);

  // Just record an object property change since there may be max surface number changes
  // as well as the store info
  vi->undo->objectPropChg();
  vi->undo->objectPropChg(obNew);

  // If object has mesh but no contours, transfers the meshes
  if (!obj->contsize && obj->meshsize) {
    for (co = 0; co < obj->meshsize; co++)
      imod->obj[obNew].mesh = imodel_mesh_add(&obj->mesh[co], imod->obj[obNew].mesh,
                                              &imod->obj[obNew].meshsize);
    return;
  }

  // Move all the fine grain information over then delete the store
  if (ilistSize(obj->store)) {
    for (co = 0; co <= obj->surfsize; co++)
      istoreCopyContSurfItems(obj->store, &imod->obj[obNew].store, co, co, 1);
    for (co = 0; co < obj->contsize; co++)
      istoreCopyContSurfItems(obj->store, &imod->obj[obNew].store, co, 
                                    imod->obj[obNew].contsize + co, 0);
    ilistDelete(obj->store);
    obj->store = NULL;
  }

  // Record all contours as moving
  vi->undo->allContourMove(imod->cindex.object, obNew);
  
  /* DNM: need to set contour inside loop because each deletion
     sets it to -1; and need to not increment counter!  */
  for (co = 0; co < (int)obj->contsize; ) {
    imod->cindex.contour = 0;
    imodObjectAddContour(&imod->obj[obNew], &obj->cont[co]);
    imodObjectRemoveContour(obj, co);
  }
}
Ejemplo n.º 4
0
// The view menu dispatch function
void imodvViewMenu(int item)
{
  ImodvApp *a = Imodv;
  Iobj *xobj;
  Icont *cont;
  bool freeXobj;
  switch (item) {
  case VVIEW_MENU_DB:
    imodv_setbuffer(a, 1 - a->dblBuf, -1, -1);
    a->mainWin->setEnabledMenuItem(VVIEW_MENU_TRANSBKGD, a->dblBuf &&
                                   (a->enableDepthDBal >= 0 ||
                                    a->enableDepthDBstAl >= 0));
    break;

  case VVIEW_MENU_TRANSBKGD:
    imodv_setbuffer(a, -1, -1, 1 - a->transBkgd);
    if (a->transBkgd)
      a->transBkgd = 0;
    else
      a->transBkgd = a->alphaVisual;
    a->mainWin->setCheckableItem(VVIEW_MENU_TRANSBKGD, a->transBkgd);
    a->mainWin->setEnabledMenuItem(VVIEW_MENU_DB, a->dbPossible && a->enableDepthSB >= 0
                                   && !a->transBkgd);
    break;

  case VVIEW_MENU_INVERTZ:
    toggleWorldFlag(a->invertZ, VIEW_WORLD_INVERT_Z, VVIEW_MENU_INVERTZ);
    break;

  case VVIEW_MENU_LIGHTING:
    toggleWorldFlag(a->lighting, VIEW_WORLD_LIGHT, VVIEW_MENU_LIGHTING);
    break;

  case VVIEW_MENU_WIREFRAME:
    toggleWorldFlag(a->wireframe, VIEW_WORLD_WIREFRAME, VVIEW_MENU_WIREFRAME);
    break;
 
  case VVIEW_MENU_LOWRES:
    toggleWorldFlag(a->lowres, VIEW_WORLD_LOWRES, VVIEW_MENU_LOWRES);
    break;

  case VVIEW_MENU_STEREO:
    imodvStereoEditDialog(a, 1);
    break;

  case VVIEW_MENU_DEPTH:
    imodvDepthCueEditDialog(a, 1);
    break;

  case VVIEW_MENU_SCALEBAR:
    scaleBarOpen();
    break;

  case VVIEW_MENU_RESIZE:
    a->mainWin->openResizeTool(a);
    break;

  case VVIEW_MENU_BOUNDBOX:
    freeXobj = true;
    if (a->boundBoxExtraObj <= 0) {
      a->boundBoxExtraObj = ivwGetFreeExtraObjectNumber(a->vi);
      if (a->boundBoxExtraObj <= 0)
        return;
      xobj = ivwGetAnExtraObject(a->vi, a->boundBoxExtraObj);
      if (xobj) {
        imodObjectDefault(xobj);
        strcpy(xobj->name, "Volume bounding box extra object");
        xobj->cont = imodContoursNew(6);
        if (xobj->cont) {
          xobj->contsize = 6;
          xobj->flags |= IMOD_OBJFLAG_OPEN | IMOD_OBJFLAG_WILD | 
            IMOD_OBJFLAG_EXTRA_MODV | IMOD_OBJFLAG_EXTRA_EDIT | 
            IMOD_OBJFLAG_ANTI_ALIAS | IMOD_OBJFLAG_MODV_ONLY;
          xobj->red = 1.;
          xobj->green = 1.;
          xobj->blue = 0.;
          xobj->linewidth = 2;
          if (!imodvAddBoundingBox(a))
            freeXobj = false;
        }
      }
    }
    if (freeXobj) {
      ivwFreeExtraObject(a->vi, a->boundBoxExtraObj);
      a->boundBoxExtraObj = 0;
    }
    a->mainWin->setCheckableItem(VVIEW_MENU_BOUNDBOX, !freeXobj);
    imodvObjedNewView();
    imodvDraw(a);
    break;

  case VVIEW_MENU_CURPNT:
    freeXobj = true;
    if (a->curPointExtraObj <= 0) {
      a->curPointExtraObj = ivwGetFreeExtraObjectNumber(a->vi);
      if (a->curPointExtraObj <= 0)
        return;
      xobj = ivwGetAnExtraObject(a->vi, a->curPointExtraObj);
      if (xobj) {
        imodObjectDefault(xobj);
        strcpy(xobj->name, "Current point extra object");
        xobj->flags |= IMOD_OBJFLAG_SCAT | IMOD_OBJFLAG_MESH |
          IMOD_OBJFLAG_NOLINE | IMOD_OBJFLAG_FILL | IMOD_OBJFLAG_EXTRA_MODV |
          IMOD_OBJFLAG_EXTRA_EDIT | IMOD_OBJFLAG_MODV_ONLY;
        xobj->pdrawsize = 7. * a->vi->xybin;
        xobj->red = 1.;
        xobj->green = 0.;
        xobj->blue = 0.;
        xobj->quality = 4;
        cont = imodContourNew();
        if (cont) {
          imodPointAppendXYZ(cont, 0., 0., 0.);
          imodPointSetSize(cont, 0, 5. * a->vi->xybin);
          if (cont->psize && cont->sizes && imodObjectAddContour(xobj, cont)
              >= 0)
            freeXobj = false;
          free(cont);
        }
      }
    }
    if (freeXobj) {
      ivwFreeExtraObject(a->vi, a->curPointExtraObj);
      a->curPointExtraObj = 0;
    }
    a->mainWin->setCheckableItem(VVIEW_MENU_CURPNT, !freeXobj);
    imodvObjedNewView();
    imodvDraw(a);
    break;
  }
}
Ejemplo n.º 5
0
/*
 * Copy a single contour, cont, to the place it needs to go.
 *
 */
static int copyContour(Icont *cont, int coNum)
{
  Iobj *toObj;
  int co,pt;
  int section;
  ImodView *vw = sData.vw;
  int obnum = vw->imod->cindex.object;

  if (!cont) return(-1);
  if (!cont->psize) return(-1);

  switch(sData.copyOperation){

  case COPY_TO_OBJECT:
    obnum = sData.objectNumber - 1;
    toObj = &vw->imod->obj[obnum];

    /* Don't copy if duplicate contour already exists. */
    for(co = 0; co < toObj->contsize; co++){
      if (contCompare(&toObj->cont[co], cont) == 0)
        return(0);
    }
    vbCleanupVBD(toObj);

    /* Remove duplicate points */
    if (iobjScat(toObj->flags)){
      for(co = 0; co < toObj->contsize; co++){
        contRmDup(&toObj->cont[co], cont);
      }
    }
    vw->undo->contourAddition(obnum, toObj->contsize);
    imodObjectAddContour(toObj, cont);
    break;

  case COPY_TO_CURRENT:
    toObj = imodObjectGet(vw->imod);
    vw->undo->contourAddition(obnum, toObj->contsize);
    imodObjectAddContour(toObj, cont);
    break;

  case COPY_TO_SECTION:
  case COPY_TO_NEXT_SECTION:
  case COPY_TO_PREV_SECTION:
    toObj   = &vw->imod->obj[sData.currentObject];
    section = sData.sectionNumber-1; 
    for(pt = 0; pt < cont->psize; pt++){
      cont->pts[pt].z = section;
    }
    vw->undo->contourAddition(sData.currentObject, toObj->contsize);
    imodObjectAddContour(toObj, cont);
    break;

  case COPY_TO_TIME:
  case COPY_TO_NEXT_TIME:
    toObj   = &vw->imod->obj[sData.currentObject];
    cont->time = sData.timeIndex;
    vw->undo->contourAddition(sData.currentObject, toObj->contsize);
    imodObjectAddContour(toObj, cont);
    break;
  }

  // Copy any contour properties from source to destination object
  if (istoreCountContSurfItems(vw->imod->obj[sData.currentObject].store, 
                               coNum, 0)) {
    vw->undo->objectPropChg(obnum);
    istoreCopyContSurfItems(vw->imod->obj[sData.currentObject].store, 
                             &toObj->store, coNum, toObj->contsize - 1, 0);
  }

  return(0);
}