//----------------------------------------------------------------------------------
//! Macro module ROICombineSelect
/*!
// \file    ROICombineSelect.js
// \author  Dimitre Hristvo
// \date    2009-12-10
//
// 
*/
//----------------------------------------------------------------------------------

debug_MultiLoaders = 0;

//---------------------------------------------------------------------------------------
//! display message if the current debug level is high enough
function displayMsg(str, dbglvl) {
  if (dbglvl <= debug_MultiLoaders) ctx.log("ML: "+str);
}


function doResetAll() {
    ctx.field("greyCenter").setFloatValue(0.25);
    ctx.field("greyWidth").setFloatValue(0.5);
    ctx.field("resetROI").value = 1;
    ctx.field("reformat.resetMatrix").touch();
    MLAB.processInventorQueue();
//    ctx.callLater(0, "subApply"); // was before (hkh):    MLABTimeUtils.callLater(0, "js: subApply();");
    subApply();
    a = vectorFromField("startWorldPos");
    b = vectorFromField("endWorldPos");
    a = a.add(b);
    a = a.mult(0.5);
    a.setField("currentPos");
}

function subApply() {
  ctx.field("sub.apply").touch();  
  ctx.field("ModelSub.apply").touch();
}

function setEditMode ()
{
  var message = "in setEditMode()";
  displayMsg(message, 0);

  if (ctx.field("editMode").stringValue() == "Edit") 
  {
     message = "editMode == Edit";
     displayMsg(message, 0);
     ctx.field("reformat.interactive").setStringValue("False");
     ctx.field("rect.editingOn").setStringValue("True");

   //  ctx.field("rect.shift").value = "RELEASED";
   //  ctx.field("pos.shift").value = "PRESSED";
  }
  else if (ctx.field("editMode").stringValue() == "RegisterManaual") 
  {
     message = "editMode == RegisterManaual";
     displayMsg(message, 0);
     ctx.field("reformat.interactive").setStringValue("True");
     ctx.field("rect.editingOn").setStringValue("False");

   //  ctx.field("rect.shift").value = "PRESSED";
   //  ctx.field("pos.shift").value = "RELEASED";
  }

}

//# MeVis signature v1
//# key: MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANEfsmYse2e1dRhkQ9AQbreCq9uxwzWLoGom13MNYmyfwoJqQOEXljLFAgw2eEjaT12G4CdqKWhRxh9ANP6n7GMCARE=:VI/mB8bT4u+mRtf/ru8yUQi8BzpaS3UeL2x62YxsUYnVqCWuLrVNLiukIIjnJMKQXlc8ezmgOIcVAV7pgvgKpQ==
//# owner: MeVis
//# date: 2009-06-10T04:12:25
//# hash: GR07ofKvUJxcWY2mZPAc+u8Uos0wOFSrGj71GYKLjshEsst7A2837GAdUyJwfkxMwiqDeUVcCaL8r4+m7JhPeA==
//# MeVis end

