2

I am using papaya to view DICOM images. I want to swap the main slices to view the sagittal and coronal views of the images. This is my code. But I get an error saying this.canvas not defined.

What am I doing wrong? Here's my code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
        <link rel="stylesheet" type="text/css" href="papaya.css" />
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script type="text/javascript" src="papaya.js"></script>

        <script>
        $(document).ready(function(){
            $(".papaya-main-swap").click(function(){
                papaya.viewer.Viewer.prototype.rotateViews();
            });
        });
        </script>
        <title>Papaya </title>
    </head>

    <body>
        <div class="papaya">
        <button id="swap-slice" class="papaya-main-swap" type="button" style="display: block; top: 475px; left: 700px; position: relative;">Swap Main Slice</button>
        </div>
    </body>
</html>
martinez314
  • 12,162
  • 5
  • 36
  • 63
chrisrhyno2003
  • 3,906
  • 8
  • 53
  • 102

1 Answers1

4

You need to reference the instance of the Viewer. In general, you can access this using the papayaContainers global variable. This should fix your example:

$(".papaya-main-swap").click(function() {
    papayaContainers[0].viewer.rotateViews();
});

It's possible to have more than one viewer on a page. The index into papayaContainers is used to specify the viewer instance.

martinez314
  • 12,162
  • 5
  • 36
  • 63