Ejemplo n.º 1
0
  public void setTransform(TransMatrix kTransform) {
    if (kTransform.getDim() == 3) {
      m_kImageTransform.MakeIdentity();
      m_kImageTransform.M00 = kTransform.M00;
      m_kImageTransform.M01 = kTransform.M01;
      m_kImageTransform.M02 = 0;
      m_kImageTransform.M03 = kTransform.M02;

      m_kImageTransform.M10 = kTransform.M10;
      m_kImageTransform.M11 = kTransform.M11;
      m_kImageTransform.M12 = 0;
      m_kImageTransform.M13 = kTransform.M12;
    } else {
      m_kImageTransform.Copy(kTransform);
    }
    if (m_kImageEffectDual != null) {
      /*
      Matrix4f toOrigin = new Matrix4f(false);
      Matrix4f fromOrigin = new Matrix4f(false);
      toOrigin.M03 = -m_kImageA.extents[0]/2.0f;
      toOrigin.M13 = -m_kImageA.extents[1]/2.0f;
      fromOrigin.M03 = m_kImageA.extents[0]/2.0f;
      fromOrigin.M13 = m_kImageA.extents[1]/2.0f;
      TransMatrix kMat = new TransMatrix(4,4);
      kMat.setTransform(0,0,0,0,0,15,1,1,1,0,0,0);
      m_kImageTransform.Copy(kMat);
      System.err.println( "captureImage" + m_iScreenCaptureCounter + " " + m_kImageTransform.ToString() );

      m_kImageTransform.MakeIdentity();
      m_kImageTransform.M00 = 0.9666009f;
      m_kImageTransform.M01 = -0.25924882f;
      m_kImageTransform.M02 = 0f;
      m_kImageTransform.M03 = 74.82431f;
      m_kImageTransform.M10 = 0.25845572f;
      m_kImageTransform.M11 = 0.9654881f;
      m_kImageTransform.M12 = 0f;
      m_kImageTransform.M13 = -57.23043f;
      System.err.println( m_kImageTransform.ToString() );
      m_kImageTransform.Inverse();
      System.err.println( m_kImageTransform.ToString() );

      m_kImageTransform.MakeIdentity();
      m_kImageTransform.M00 = 0.9652507f;
      m_kImageTransform.M01 = 0.25918508f;
      m_kImageTransform.M02 = 0f;
      m_kImageTransform.M03 = -56.043213f;
      m_kImageTransform.M10 = -0.25839218f;
      m_kImageTransform.M11 = 0.96636325f;
      m_kImageTransform.M12 = 0f;
      m_kImageTransform.M13 = 72.88661f;
      */
      // m_kImageTransform.MultLeft( m_kToOriginInv );
      // m_kImageTransform.Mult( m_kFromOriginInv );

      // System.err.println( "setTransform " + m_kImageTransform.ToString() );

      // m_kImageTransform.Inverse();

      // m_kImageTransform.MultLeft( m_kToOrigin );
      // m_kImageTransform.Mult( m_kFromOrigin );

      // m_kImageTransform.MultLeft(fromOrigin);
      // m_kImageTransform.Mult(toOrigin);
      m_kImageEffectDual.SetTransform(m_kImageTransform);
      // System.err.println( m_kImageTransform.ToString() );
    }
  }
Ejemplo n.º 2
0
  /**
   * Displays the file information.
   *
   * @param dlog JDialogBase dialog box that is written to
   * @param matrix transformation matrix
   */
  @SuppressWarnings("unchecked")
  public void displayAboutInfo(JDialogBase dlog, TransMatrix matrix) {
    JDialogFileInfoXML dialog = (JDialogFileInfoXML) dlog;
    int[] extents;
    int i;
    int[] editorChoice = new int[1];

    editorChoice[0] = JDialogEditor.STRING;

    dialog.displayAboutInfo(this); // setup layout in the dialog

    editorChoice[0] = JDialogEditor.STRING;

    if (this.imageDescription != null) {
      dialog.appendPrimaryData("Description", this.imageDescription, editorChoice);
    } else {
      dialog.appendPrimaryData("Description", "", editorChoice);
    }

    editorChoice[0] = JDialogEditor.XML_LINKEDIMAGE;

    if (this.linkedImagePath != null) {
      dialog.appendPrimaryData("Linked-image", this.linkedImagePath, editorChoice);
    } else {
      dialog.appendPrimaryData("Linked-image", "", editorChoice);
    }

    dialog.appendPrimaryData("Image-offset", Integer.toString(getOffset()));

    extents = super.getExtents();

    for (i = 0; i < extents.length; i++) {
      dialog.appendPrimaryData("Dimension " + i, Integer.toString(extents[i]));
    }

    dialog.appendPrimaryData("Type", ModelStorageBase.getBufferTypeStr(getDataType()));

    if (ModelImage.isColorImage(getDataType())) {
      dialog.appendPrimaryData("Min red", Double.toString(getMinR()));
      dialog.appendPrimaryData("Max red", Double.toString(getMaxR()));
      dialog.appendPrimaryData("Min green", Double.toString(getMinG()));
      dialog.appendPrimaryData("Max green", Double.toString(getMaxG()));
      dialog.appendPrimaryData("Min blue", Double.toString(getMinB()));
      dialog.appendPrimaryData("Max blue", Double.toString(getMaxB()));

    } else {
      dialog.appendPrimaryData("Min", Double.toString(getMin()));
      dialog.appendPrimaryData("Max", Double.toString(getMax()));
    }

    dialog.appendPrimaryData("Orientation", getImageOrientationStr(getImageOrientation()));

    dialog.appendPrimaryData("Axis X Orientation", getAxisOrientationStr(getAxisOrientation(0)));
    dialog.appendPrimaryData("Axis Y Orientation", getAxisOrientationStr(getAxisOrientation(1)));
    dialog.appendPrimaryData("Axis Z Orientation", getAxisOrientationStr(getAxisOrientation(2)));

    float[] resolutions; // = new float[5];

    resolutions = getResolutions();

    int[] measure; // = new int[5];

    measure = getUnitsOfMeasure();

    for (i = 0; i < extents.length; i++) {

      if (resolutions[i] > 0.0) {
        String pixelRes = "Pixel resolution " + i;

        dialog.appendPrimaryData(
            pixelRes,
            Float.toString(resolutions[i])
                + " "
                + (Unit.getUnitFromLegacyNum(measure[i])).toString());
      } // end of if (resolutions[i] > 0.0)
    } // for (i=0; i < 5; i++)

    if ((extents.length > 2) && (extents[2] > 0)) {
      dialog.appendPrimaryData(
          "Slice thickness ",
          Float.toString(getSliceThickness())
              + " "
              + (Unit.getUnitFromLegacyNum(measure[2])).toString());
    }

    float[] origin; // = new float[4];

    origin = getOrigin();

    for (i = 0; (i < extents.length) && (i < 4); i++) {
      String originStr = "Origin " + i;

      dialog.appendPrimaryData(originStr, Float.toString(origin[i]));
    } // for (i=0; i < 4; i++)

    if (getEndianess() == FileBase.LITTLE_ENDIAN) {
      dialog.appendPrimaryData("Endianess", "Little Endian");
    } else {
      dialog.appendPrimaryData("Endianess", "Big Endian");
    }

    if (matrix != null) {

      // when using displayAboutInfo(dialog) this doesn't appear
      // calling prg might use an editing panel to adjust this matrix

      // BEN: CHANGE the following...
      // dialog.appendPrimaryData("Transform ID", TransMatrix.getTransformIDStr(getTransformID()));
      dialog.appendPrimaryData("Matrix", matrix.matrixToString(10, 4));
    }

    editorChoice[0] = JDialogEditor.XML_MODALITY;
    dialog.appendPrimaryData("Modality", getModalityStr(getModality()), editorChoice);

    editorChoice[0] = JDialogEditor.STRING;
    dialog.appendPrimaryData("History", this.history, editorChoice);

    // now subject information
    String emptyString = new String("");

    editorChoice[0] = JDialogEditor.STRING;

    if (subjectName != null) {
      dialog.appendSubjectData("Subject Name", subjectName, editorChoice);
    } else {
      dialog.appendSubjectData("Subject Name", emptyString, editorChoice);
    }

    if (subjectID != null) {
      dialog.appendSubjectData("Subject ID", subjectID, editorChoice);
    } else {
      dialog.appendSubjectData("Subject ID", emptyString, editorChoice);
    }

    editorChoice[0] = JDialogEditor.XML_RACE;

    if (race != null) {
      dialog.appendSubjectData("Race", race, editorChoice);
    } else {
      dialog.appendSubjectData("Race", emptyString, editorChoice);
    }

    editorChoice[0] = JDialogEditor.STRING;

    if (diagnosis != null) {
      dialog.appendSubjectData("Diagnosis", diagnosis, editorChoice);
    } else {
      dialog.appendSubjectData("Diagnosis", emptyString, editorChoice);
    }

    editorChoice[0] = JDialogEditor.XML_DOB;

    if (DOB != null) {
      dialog.appendSubjectData("Date of Birth", DOB, editorChoice);
    } else {
      dialog.appendSubjectData("Date of Birth", "0000-01-01", editorChoice);
    }

    editorChoice[0] = JDialogEditor.STRING;
    dialog.appendSubjectData("Height", (new Integer(height)).toString(), editorChoice);
    dialog.appendSubjectData("Weight", (new Integer(weight)).toString(), editorChoice);
    editorChoice[0] = JDialogEditor.XML_SEX;

    if (sex != null) {
      dialog.appendSubjectData("Sex", sex, editorChoice);
    } else {
      dialog.appendSubjectData("Sex", "Unknown", editorChoice);
    }

    editorChoice[0] = JDialogEditor.STRING;

    if (bodyPart != null) {
      dialog.appendSubjectData("Body Part", bodyPart, editorChoice);
    } else {
      dialog.appendSubjectData("Body Part", emptyString, editorChoice);
    }

    // Scan Attributes
    editorChoice[0] = JDialogEditor.STRING;

    if (equipmentName != null) {
      dialog.appendScanData("Equipment Model Name", equipmentName, editorChoice);
    } else {
      dialog.appendScanData("Equipment Model Name", emptyString, editorChoice);
    }

    if (scanID != null) {
      dialog.appendScanData("Scan ID", scanID, editorChoice);
    } else {
      dialog.appendScanData("Scan ID", emptyString, editorChoice);
    }

    if (protocol != null) {
      dialog.appendScanData("Protocol", protocol, editorChoice);
    } else {
      dialog.appendScanData("Protocol", emptyString, editorChoice);
    }

    editorChoice[0] = JDialogEditor.XML_DATE;

    if (scanDate != null) {
      dialog.appendScanData("Scan Date", scanDate, editorChoice);
    } else {
      dialog.appendScanData("Scan Date", "0000-01-01", editorChoice);
    }

    editorChoice[0] = JDialogEditor.XML_TIME;

    if (scanTime != null) {
      dialog.appendScanData("Scan Time", scanTime, editorChoice);
    } else {
      dialog.appendScanData("Scan Time", "00:00:00-00:00", editorChoice);
    }

    // Investigator Data
    for (int j = 0; j < 3; j++) {
      editorChoice[0] = JDialogEditor.STRING;

      boolean isNull = (investigators[j] == null);

      // name is required if investigator data exists.
      // everything else is optional
      if (!isNull) {
        dialog.appendInvestigatorData((j + 1) + " Name", investigators[j].getName(), editorChoice);
      } else {
        dialog.appendInvestigatorData((j + 1) + " Name", emptyString, editorChoice);
      }

      if (!isNull && (investigators[j].getTitle() != null)) {
        dialog.appendInvestigatorData(
            (j + 1) + " Title", investigators[j].getTitle(), editorChoice);
      } else {
        dialog.appendInvestigatorData((j + 1) + " Title", emptyString, editorChoice);
      }

      if (!isNull && (investigators[j].getAffiliation() != null)) {
        dialog.appendInvestigatorData(
            (j + 1) + " Affiliation", investigators[j].getAffiliation(), editorChoice);
      } else {
        dialog.appendInvestigatorData((j + 1) + " Affiliation", emptyString, editorChoice);
      }

      if (!isNull && (investigators[j].getEmail() != null)) {
        dialog.appendInvestigatorData(
            (j + 1) + " Email", investigators[j].getEmail(), editorChoice);
      } else {
        dialog.appendInvestigatorData((j + 1) + " Email", emptyString, editorChoice);
      }

      if (!isNull && (investigators[j].getPhone() != null)) {
        dialog.appendInvestigatorData(
            (j + 1) + " Phone", investigators[j].getPhone(), editorChoice);
      } else {
        dialog.appendInvestigatorData((j + 1) + " Phone", emptyString, editorChoice);
      }
    }

    Enumeration<String> e = getPSetKeys();

    while (e.hasMoreElements()) {
      XMLPSet temp = getPSet(e.nextElement());
      String desc = temp.getDescription();
      Enumeration<String> pe = temp.getParameterKeys();

      while (pe.hasMoreElements()) {
        XMLParameter tp = temp.getParameter(pe.nextElement());
        editorChoice[0] = JDialogEditor.STRING;
        int loc = tp.getDescription().indexOf('[') + 1;
        int value = Integer.parseInt(tp.getDescription().substring(loc, loc + 1));
        if (value > 0)
          dialog.appendTagData(
              tp.getDescription().substring(0, tp.getDescription().indexOf('[')),
              desc + " [" + (value + 1) + "]",
              tp.getValue(),
              editorChoice);
        else
          dialog.appendTagData(
              tp.getDescription().substring(0, tp.getDescription().indexOf('[')),
              desc,
              tp.getValue(),
              editorChoice);
        //   dialog.appendParameter(desc, tp.getName(), tp.getDescription(), tp.getValueType(),
        // tp.getValue(), tp
        //          .getDate(), tp.getTime());

      }
    }
  }