Logo Search packages:      
Sourcecode: magics++ version File versions  Download package

MAGICS_NO_EXPORT void SVGDriver::endPage (  )  const [private, virtual]

ending a page

This method has to take care that for formats with multiple output files are closed.

Reimplemented from magics::BaseDriver.

Definition at line 261 of file SVGDriver.cc.

References debugOutput(), pFile_, and magics::BaseDriver::printOutputName().

{
      group_counter_=0;
      debugOutput("Page - END");
      // needed for y-axis translation in beginning!
      pFile_      << "</g>\n";  // end of Menu 

      if(getGui())
      {
            // menu-on-off button
/*          pFile_      << "<g id=\"menu_button\" stroke=\"blue\" fill=\"blue\" >\n"
                  << " <polyline points=\"0,0 0,5 5,0\" width=\"1\" />\n"
                  << "</g>\n";
*/          pFile_ << "<g>\n"
                   << "<g id=\"menu\" visibility=\"visible\" fill=\"blue\" stroke=\"none\" font-size=\"10\""
                   << " fill-opacity=\"0.2\" stroke-opacity=\"0.8\">\n";

            // lupe button
/*          pFile_      << "<g id=\"lupe_button\" stroke=\"blue\" transform=\"translate(10 5)\" >\n"
                  << " <circle cx=\"0\" cy=\"11\" r=\"10\" fill=\"rgb(230,230,255)\" />\n"
                  << " <circle cx=\"-2\" cy=\"9\" r=\"4\"  fill=\"rgb(230,230,255)\" />\n"
                  << " <rect x=\"2\" y=\"12\" transform=\"rotate(45 2 12)\" fill=\"blue\" width=\"4\" height=\"2\"/>\n"
                  << "</g>\n";
*/
            // layer button
/*          pFile_      << "<g id=\"layers_button\" stroke=\"blue\" transform=\"translate(32 5)\" >\n"
                  << " <circle cx=\"0\" cy=\"11\" r=\"10\" fill=\"rgb(230,230,255)\" />\n"
                  << " <rect x=\"2\" y=\"12\" fill=\"blue\" width=\"4\" height=\"2\"/>\n"
                  << "</g>\n";
*/
            // Menu
            if(!layers_.empty())
            {
              pFile_    << "<g id=\"layers_menu\" visibility=\"visible\" transform=\"translate(43 5)\" >\n"
                        << " <text x=\"10\" y=\"17\">Layers:</text>\n";
              int offset = 55;
              for(vector<string>::iterator iter=layers_.begin(); iter != layers_.end();++iter)
              {
              pFile_ << "<g id=\"button_"<<*iter<<"\" transform=\"translate("<<offset<<" 0)\">\n"
                     << " <rect x=\"0\" y=\"0\"  rx=\"5\" ry=\"5\" fill=\"rgb(230,230,230)\" width=\"90\" height=\"23\"/>\n"
                     << " <text x=\"20\" y=\"17\" font-size=\"11\">"<<*iter<<"</text>\n"
                     << " <polyline id=\""<<*iter<<"_tick\" points=\"4,12 8,17 15,6\" width=\"4\" stroke=\"red\" visibility=\"visible\" fill=\"none\"/>\n"
                     << "</g>\n";
                     offset += 100;
              }
              pFile_ << "</g>\n";
            }
            pFile_ << "</g>\n";  // end of Menu
            pFile_ << "</g>\n"; 
      }
      if(getGui() || (interactiveCounter_>0) )
      {
            // Scripting - JAVASCRIPT
            pFile_      << "<script type=\"text/ecmascript\"><![CDATA[\n"
                  << "var slider=null, thumb=null, page=null, sliderActive = false;\nvar doc=null;\n"
                  
/*                << "function scaleup(evt)\n"
                  << "{\n"
                  << "\ttarget=evt.target;\n"
                  << "\tif(target!=null)\n\t{\n"
                  << "\t\ttarget.setAttributeNS(null,\"transform\",\"scale(2,2)\");\n"
      //          << "\t\ttarget.setAttributeNS(null,\"transform\",\"translate()\");\n"
                  << "\t}\n"
                  << "}\n"
                  << "function scaledown(evt)\n"
                  << "{\n"
                  << "\ttarget=evt.target;\n"
                  << "\tif(target!=null)\n\t{\n"
                  << "\t\ttarget.setAttributeNS(null,\"transform\",\"scale(1,1)\");\n"
      //          << "\t\ttarget.setAttributeNS(null,\"transform\",\"translate()\");\n"
                  << "\t}\n"
                  << "}\n"

                  << "function switchMenu(evt){\n"
                  << "\tl=document.getElementById(\"menu\")\n"
                  << "\tvar at=l.getAttributeNS(null,\"visibility\");\n"
                  << "\tif(at==\"visible\") {l.setAttributeNS(null,\"visibility\",\"hidden\");}\n"
                  << "\telse {l.setAttributeNS(null,\"visibility\",\"visible\");}\n"
                  << "}\n"
                  << "function switchLayers(evt){\n"
                  << "\tl=document.getElementById(\"layers_menu\")\n"
                  << "\tvar at=l.getAttributeNS(null,\"visibility\");\n"
                  << "\tif(at==\"visible\") {l.setAttributeNS(null,\"visibility\",\"hidden\");}\n"
                  << "\telse {l.setAttributeNS(null,\"visibility\",\"visible\");}\n"
                  << "}\n"
                  << "function switchLupe(evt){\n"
                  << "\tl=document.getElementById(\"lupe\")\n"
                  << "\tvar at=l.getAttributeNS(null,\"visibility\");\n"
                  << "\tif(at==\"visible\") {l.setAttributeNS(null,\"visibility\",\"hidden\");}\n"
                  << "\telse {l.setAttributeNS(null,\"visibility\",\"visible\");}\n"
                  << "}\n"
                  << "function moveLupe(evt){\n"
                  << "\tl=document.getElementById(\"lupe\")\n"
                  << "\tc=document.getElementById(\"page_mirror\")\n"
                  << "\tx=evt.clientX\n"
                  << "\ty=evt.clientY\n"
                  << "\tl.setAttribute(\"transform\",\"translate(\"+x+\" \"+y+\")\")\n"
                  << "\tc.setAttribute(\"transform\",\"scale(5) translate(\"+(-x)+\" \"+(-y)+\")\")\n"
                  << "}\n"
*/
                  << "function OnLoadEvent(evt)\n"
                  << "{\n"
                  << "  doc = evt.target.ownerDocument;\n"
                  << "  if(doc!=null)\n"
                  << "  {\n"
//                << "   pa = doc.getElementById(\"page\");\n"
      //          << "   doc.addEventListener(\"click\", moveLupe, false);\n"
      //          << "   lu = doc.getElementById(\"lupe_button\");\n"
      //          << "   lu.addEventListener(\"click\", switchLupe, false);\n"
      //          << "   me = doc.getElementById(\"menu_button\");\n"
      //          << "   me.addEventListener(\"click\", switchMenu, false);\n"
      //          << "   la = doc.getElementById(\"layers_button\");\n"
      //          << "   la.addEventListener(\"click\", switchLayers, false);\n";
<< "\n";

                  if(!layers_.empty())
                  {
                     for(vector<string>::iterator iter=layers_.begin(); iter != layers_.end();++iter)
                     {
                        pFile_      << "   but_"<<*iter<<" = doc.getElementById(\"button_"<<*iter<<"\");\n"
                              << "   but_"<<*iter<<".addEventListener(\"click\", toggle"<<*iter<<", false);\n";
//                            << "   but_"<<*iter<<".addEventListener(\"mousedown\", down"<<*iter<<", false);\n"
//                            << "   but_"<<*iter<<".addEventListener(\"mouseup\", up"<<*iter<<", false);\n";
                     }
                  }
/*                pFile_      << "  }\n"
                        << "}\n"
                        << "function setDimension(w,h) {\n"
                        << "\tdoc.documentElement.setAttribute(\"width\", w);\n"
                        << "\tdoc.documentElement.setAttribute(\"height\", h);\n"
                        << "}\n";
*/
                  if(!layers_.empty())
                  {
                     for(vector<string>::iterator iter=layers_.begin(); iter != layers_.end();++iter)
                     {
                        pFile_      << "function toggle"<<*iter<<"(evt){\n"
                              << "\tvar cl=doc.getElementById(\""<<*iter<<"\");\n"
                              << "\tvar sb=doc.getElementById(\""<<*iter<<"_tick\");\n"
                              << "\tvar at=sb.getAttributeNS(null,\"visibility\");\n"
                              << "\tif(at==\"visible\") {sb.setAttributeNS(null,\"visibility\",\"hidden\");cl.setAttributeNS(null,\"visibility\",\"hidden\");}\n"
                              << "\telse {sb.setAttributeNS(null,\"visibility\",\"visible\");cl.setAttributeNS(null,\"visibility\",\"visible\");}\n"
//                            << "}\n"
//                            << "function down"<<*iter<<"(evt){\n"
//                            << "\tvar cl=doc.getElementById(\""<<*iter<<"\");\n"
//                            << "}\n"
//                            << "function up"<<*iter<<"(evt){\n"
//                            << "\tvar cl=doc.getElementById(\""<<*iter<<"\");\n"
                              << "}\n";
                     }
                  }

                  pFile_      << "]]></script>\n";
      }
/*
      if(getGui())
      {
            pFile_ << "<g id=\"lupe\" visibility=\"hidden\" transform=\"translate(55, -4)\">\n"
                   << " <circle cx=\"0\" cy=\"0\" r=\"75\" fill=\"white\" stroke=\"none\"/>\n"
                   << " <g clip-path=\"url(#clip_lupe)\">\n"
                   << "  <use id=\"page_mirror\" xlink:href=\"#page\" transform=\"scale(3, 3) translate(-55, 4)\"/>\n"
                   << " </g>\n"
                   << " <circle cx=\"0\" cy=\"0\" r=\"75\" fill=\"none\" stroke=\"black\" stroke-width=\"5\"/>\n"
                   << "</g>\n";
      }
*/    pFile_ << "</svg>\n";
      pFile_.close();

      layers_.clear();

      //
      // code to compress for SVGZ
      //
//    if(getCompress() && !svg_output_resource_list_.empty())
      {
/*          FILE * input_file;
            if ((input_file = fopen(fileName_.c_str(), "r")) == NULL)
                  fprintf(stderr, "Cannot open %s\n", fileName_.c_str());

            fileName_ = getFileName("svgz");
            FILE * output_file;
            if ((output_file = fopen(fileName_.c_str(), "w")) == NULL)
                  fprintf(stderr, "Cannot open %s\n", fileName_.c_str());

            gzip(input_file, output_file, Z_DEFAULT_COMPRESSION);
*/
/*          if (!getDebug())
            {
                  stringarray::iterator it    = svg_output_resource_list_.begin();
                  stringarray::iterator itend = svg_output_resource_list_.end();
                  for(; it != itend; it++)
                  {
                        remove((*it).c_str());
                  }
                  printOutputName("SVG svgz "+fileName_);
            }
*/    }// Zipping ---> SVGZ
//    else
      {
            stringarray::iterator it    = svg_output_resource_list_.begin();
            stringarray::iterator itend = svg_output_resource_list_.end();
            for(; it != itend; it++)
            {
                  printOutputName("SVG misc "+(*it));
            }
      }
      newLayout_ = true;
}


Generated by  Doxygen 1.6.0   Back to index