Commit 3e802a28 authored by whitlocb's avatar whitlocb
Browse files

I made some changes that fix printing on the Mac.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12382 18c085ea-50e0-402c-830e-de6fd14e8384
parent 518701a4
......@@ -6464,6 +6464,8 @@ QvisGUIApplication::SaveWindow()
void
QvisGUIApplication::SetPrinterOptions()
{
PrinterAttributes *p = GetViewerState()->GetPrinterAttributes();
#if defined(Q_WS_MACX) && !defined(VISIT_MAC_NO_CARBON)
//
// If we're on MacOS X and the Mac application style is being used, manage
......@@ -6484,7 +6486,7 @@ QvisGUIApplication::SetPrinterOptions()
{
if(PMCreateSession(&psession) != kPMNoError)
{
EXCEPTION0(VisItException);
EXCEPTION0(VisItException);
}
nObjectsToFree = 1;
......@@ -6515,9 +6517,7 @@ QvisGUIApplication::SetPrinterOptions()
Boolean accepted = false;
if(PMSessionPrintDialog(psession, psettings, pformat, &accepted) == kPMNoError &&
accepted == true)
{
PrinterAttributes *p = GetViewerState()->GetPrinterAttributes();
{
// Get the name of the printer to use for printing the image.
CFArrayRef printerList = NULL;
CFIndex currentIndex;
......@@ -6567,6 +6567,7 @@ QvisGUIApplication::SetPrinterOptions()
// Set some of the last properties
p->SetOutputToFile(false);
p->SetOutputToFileName("");
p->SetPrintColor(true);
p->SetCreator(GetViewerProxy()->GetLocalUserName());
......@@ -6607,20 +6608,25 @@ QvisGUIApplication::SetPrinterOptions()
// print once the options are set.
//
if(okayToPrint)
PrintWindow();
GetViewerMethods()->PrintWindow();
}
else
{
#endif
#if defined(Q_WS_MACX)
// Each time through on the Mac, clear out the printer's save to filename.
bool setupPrinter = true;
p->SetOutputToFile(false);
p->SetOutputToFileName("");
#else
bool setupPrinter = false;
#endif
//
// If we've never set up the printer options, set them up now using
// Qt's printer object and printer dialog.
//
PrinterAttributes *p = GetViewerState()->GetPrinterAttributes();
if(printer == 0)
{
int timeid = visitTimer->StartTimer();
// Create a new printer object.
printer = new QPrinter;
......@@ -6638,12 +6644,15 @@ QvisGUIApplication::SetPrinterOptions()
printerObserver = new ObserverToCallback(p,
UpdatePrinterAttributes, (void *)printer);
// Store the printer attributes into the printer object.
PrinterAttributesToQPrinter(p, printer);
visitTimer->StopTimer(timeid, "Setting up printer");
// Indicate that we need to set up the printer.
setupPrinter = true;
}
// Store the printer attributes into the printer object.
if(setupPrinter)
PrinterAttributesToQPrinter(p, printer);
// Execute the printer dialog
QPrintDialog printDialog(printer, mainWin);
if(printDialog.exec() == QDialog::Accepted)
{
......@@ -6661,7 +6670,7 @@ QvisGUIApplication::SetPrinterOptions()
// options. This says to me that applications expect to print once
// the options are set.
//
PrintWindow();
GetViewerMethods()->PrintWindow();
#endif
}
#if defined(Q_WS_MACX) && !defined(VISIT_MAC_NO_CARBON)
......@@ -6679,13 +6688,19 @@ QvisGUIApplication::SetPrinterOptions()
// Creation: Wed Feb 20 12:41:13 PDT 2002
//
// Modifications:
//
// Brad Whitlock, Mon Aug 30 11:36:10 PDT 2010
// If no printer options have been set up yet then we should do
// SetPrinterOptions.
//
// ****************************************************************************
void
QvisGUIApplication::PrintWindow()
{
GetViewerMethods()->PrintWindow();
if(printer == 0)
SetPrinterOptions();
else
GetViewerMethods()->PrintWindow();
}
// ****************************************************************************
......@@ -6705,6 +6720,9 @@ QvisGUIApplication::PrintWindow()
// Cyrus Harrison, Tue Jul 1 09:14:16 PDT 2008
// Initial Qt4 Port.
//
// Brad Whitlock, Mon Aug 30 14:58:11 PDT 2010
// Be more agressive about setting empty strings.
//
// ****************************************************************************
static void
......@@ -6712,17 +6730,32 @@ QPrinterToPrinterAttributes(QPrinter *printer, PrinterAttributes *p)
{
if(!printer->printerName().isNull())
p->SetPrinterName(printer->printerName().toStdString());
if(!printer->outputFileName().isNull())
{
p->SetOutputToFileName(printer->outputFileName().toStdString());
p->SetOutputToFile(true);
}
else
{
p->SetOutputToFileName("");
p->SetOutputToFile(false);
}
if(!printer->printProgram().isNull())
p->SetPrintProgram(printer->printProgram().toStdString());
else
p->SetPrintProgram("");
if(!printer->docName().isNull())
p->SetDocumentName(printer->docName().toStdString());
p->SetOutputToFile(!printer->outputFileName().isNull());
else
p->SetDocumentName("untitled");
p->SetNumCopies(printer->numCopies());
p->SetPortrait(printer->orientation() == QPrinter::Portrait);
p->SetPrintColor(printer->colorMode() == QPrinter::Color);
p->SetPageSize(printer->pageSize());
p->SetPageSize((int)printer->paperSize());
}
// ****************************************************************************
......@@ -6771,9 +6804,11 @@ PrinterAttributesToQPrinter(PrinterAttributes *p, QPrinter *printer)
printer->setFromTo(1, 1);
printer->setColorMode(p->GetPrintColor() ? QPrinter::Color :
QPrinter::GrayScale);
printer->setOutputFileName(p->GetOutputToFileName().c_str());
//printer->setOutputToFile(p->GetOutputToFile());
printer->setPageSize((QPrinter::PageSize)p->GetPageSize());
if(p->GetOutputToFile())
printer->setOutputFileName(p->GetOutputToFileName().c_str());
else
printer->setOutputFileName(QString());
printer->setPaperSize((QPrinter::PaperSize)p->GetPageSize());
}
// ****************************************************************************
......
......@@ -366,6 +366,9 @@
// Brad Whitlock, Fri Aug 6 16:58:31 PDT 2010
// Add Selections window.
//
// Brad Whitlock, Mon Aug 30 11:47:46 PDT 2010
// Don't do "Set print options" on Mac.
//
// ****************************************************************************
QvisMainWindow::QvisMainWindow(int orientation, const char *captionString)
......@@ -508,11 +511,20 @@ QvisMainWindow::QvisMainWindow(int orientation, const char *captionString)
filePopup->addAction(saveMovieIcon, tr("Save movie . . ."),
this, SIGNAL(saveMovie()));
#ifdef Q_WS_MACX
// Only have "Print window" on Mac and always make it activate the
// printer dialog.
filePopup->addAction(printIcon, tr("Print window"),
this, SIGNAL(activatePrintWindow()),
QKeySequence(Qt::CTRL + Qt::Key_P));
#else
filePopup->addAction(printIcon, tr("Print window"),
this, SIGNAL(printWindow()));
filePopup->addAction(tr("Set Print options . . ."),
this, SIGNAL(activatePrintWindow()),
QKeySequence(Qt::CTRL + Qt::Key_P));
#endif
filePopup->addSeparator();
......
......@@ -126,7 +126,8 @@ enhancements and bug-fixes that were added to this release.</p>
<ul>
<li>Data that is larger than 1e+18 can now be rendered (and lit) correctly.</li>
<li>Macro recording was changed so it generates a function name based on the name supplied for the macro. This eliminates a problem where giving a function name with invalid Python characters caused the macro to be discarded.</li>
<li>Macro recording for the Cord Length Distribution Query was improved.</li>
<li>Macro recording for the Chord Length Distribution Query was improved.</li>
<li>Printing on the Mac was fixed.</li>
</ul>
<a name="Config_changes"></a>
......
......@@ -2390,6 +2390,10 @@ ViewerWindowManager::GetDataset(int windowIndex,
// Brad Whitlock, Tue May 27 14:26:18 PDT 2008
// Qt 4.
//
// Brad Whitlock, Mon Aug 30 14:58:49 PDT 2010
// I added debugging log statements and I made the printer use the doc name
// for regular printing and the output filename for file printing.
//
// ****************************************************************************
void
......@@ -2440,21 +2444,52 @@ ViewerWindowManager::PrintWindow(int windowIndex)
//
vtkQtImagePrinter *imagePrinter = vtkQtImagePrinter::New();
QPrinter &printer = imagePrinter->printer();
debug1 << "Setting printer attributes: " << endl;
printer.setPrinterName(printerAtts->GetPrinterName().c_str());
debug1 << "\tprinterName=" << printerAtts->GetPrinterName() << endl;
if(!printerAtts->GetPrintProgram().empty())
{
printer.setPrintProgram(printerAtts->GetPrintProgram().c_str());
debug1 << "\tprintProgram=" << printerAtts->GetPrintProgram() << endl;
}
printer.setCreator(printerAtts->GetCreator().c_str());
debug1 << "\tcreator=" << printerAtts->GetCreator() << endl;
printer.setDocName(printerAtts->GetDocumentName().c_str());
debug1 << "\tdocName=" << printerAtts->GetDocumentName() << endl;
printer.setNumCopies(printerAtts->GetNumCopies());
debug1 << "\tnumCopies=" << printerAtts->GetNumCopies() << endl;
printer.setOrientation(printerAtts->GetPortrait() ? QPrinter::Portrait :
QPrinter::Landscape);
debug1 << "\torientation="
<< (printerAtts->GetPortrait()?"portrait":"landscape") << endl;
printer.setFromTo(1,1);
debug1 << "\tfromTo=1,1" << endl;
printer.setColorMode(printerAtts->GetPrintColor() ? QPrinter::Color :
QPrinter::GrayScale);
printer.setOutputFileName(printerAtts->GetOutputToFileName().c_str());
debug1 << "\tprintColor="
<< (printerAtts->GetPrintColor()?"color":"grayscale") << endl;
if(printerAtts->GetOutputToFile())
{
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPageSize((QPrinter::PageSize)printerAtts->GetPageSize());
debug1 << "\toutputFormat=PDF" << endl;
printer.setOutputFileName(printerAtts->GetOutputToFileName().c_str());
debug1 << "\toutputFilename=" << printerAtts->GetOutputToFileName() << endl;
}
else
{
printer.setOutputFileName(QString());
debug1 << "\toutputFilename=(empty)" << endl;
}
printer.setPaperSize((QPrinter::PageSize)printerAtts->GetPageSize());
debug1 << "\tpaperSize=" << printerAtts->GetPageSize() << endl;
//
// Create an image that will fit on the printer, else scale the
......@@ -2481,8 +2516,16 @@ ViewerWindowManager::PrintWindow(int windowIndex)
//
avtDataObject_p dob;
CopyTo(dob, image);
fileWriter->WriteImageDirectly(imagePrinter,
printerAtts->GetDocumentName().c_str(), dob);
if(printerAtts->GetOutputToFile())
{
fileWriter->WriteImageDirectly(imagePrinter,
printerAtts->GetOutputToFileName().c_str(), dob);
}
else
{
fileWriter->WriteImageDirectly(imagePrinter,
printerAtts->GetDocumentName().c_str(), dob);
}
//
// Delete the image printer.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment