QvisFileInformationWindow.C 7.16 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
3
* Copyright (c) 2000 - 2014, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
5
* LLNL-CODE-442911
hrchilds's avatar
hrchilds committed
6 7
* All rights reserved.
*
8
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
hrchilds's avatar
hrchilds committed
9 10 11 12 13 14 15 16 17 18
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
19 20 21
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
hrchilds's avatar
hrchilds committed
22 23 24 25 26
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
27 28 29
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
hrchilds's avatar
hrchilds committed
30 31 32 33 34 35 36 37 38
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

hrchilds's avatar
hrchilds committed
39
#include <visitstream.h>
whitlocb's avatar
whitlocb committed
40 41 42 43 44
#include <QTextEdit>
#include <QTabWidget>
#include <QPushButton>
#include <QLayout>
#include <QString>
hrchilds's avatar
hrchilds committed
45 46 47 48 49 50 51 52 53 54

#include <FileServerList.h>
#include <QvisFileInformationWindow.h>

#include <avtDatabaseMetaData.h>

//
// Static constants
//
const char *QvisFileInformationWindow::titleSeparator =
miller86's avatar
miller86 committed
55
"==============================================================================";
hrchilds's avatar
hrchilds committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

// ****************************************************************************
// Method: QvisFileInformationWindow::QvisFileInformationWindow
//
// Purpose: 
//   This is the constructor for the QvisFileInformationWindow class.
//
// Arguments:
//   msgAtts : The MessageAttributes object that the window observes.
//   caption : The name of the window that appears in the window
//             decoration.
//   notepad : A pointer to the notepad area to which the window will post.
//
// Programmer: Brad Whitlock
// Creation:   Tue Aug 20 13:56:24 PST 2002
//
// Modifications:
73 74
//   Brad Whitlock, Wed Apr  9 10:47:21 PDT 2008
//   QString for caption and shortName.
hrchilds's avatar
hrchilds committed
75 76 77 78
//
// ****************************************************************************

QvisFileInformationWindow::QvisFileInformationWindow(FileServerList *fs,
79
    const QString &caption, const QString &shortName, QvisNotepadArea *notepad) : 
hrchilds's avatar
hrchilds committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
    QvisPostableWindowObserver(fs, caption, shortName, notepad,
                               QvisPostableWindowObserver::NoExtraButtons,
                               false)
{
    // nothing here
}

// ****************************************************************************
// Method: QvisFileInformationWindow::~QvisFileInformationWindow
//
// Purpose: 
//   Destructor for the QvisFileInformationWindow class.
//
// Programmer: Brad Whitlock
// Creation:   Tue Aug 20 13:56:24 PST 2002
//
// Modifications:
//   
// ****************************************************************************

QvisFileInformationWindow::~QvisFileInformationWindow()
{
    // nothing here
}

// ****************************************************************************
// Method: QvisFileInformationWindow::CreateWindowContents
//
// Purpose: 
//   This method creates the window's widgets.
//
// Programmer: Brad Whitlock
// Creation:   Tue Aug 20 13:56:24 PST 2002
//
// Modifications:
whitlocb's avatar
whitlocb committed
115 116
//   Cyrus Harrison, Tue Jun 24 11:15:28 PDT 2008
//   Initial Qt4 Port.
hrchilds's avatar
hrchilds committed
117
//
miller86's avatar
miller86 committed
118 119 120
//   Mark C. Miller, Wed May  6 09:47:52 PDT 2009
//   Made it set min 'size' instead of just width. Also, increased length of
//   titleSeparator to achieve a bit larger size.
hrchilds's avatar
hrchilds committed
121 122 123 124 125 126
// ****************************************************************************

void
QvisFileInformationWindow::CreateWindowContents()
{
    // Create a multi line edit to display the text.
whitlocb's avatar
whitlocb committed
127
    outputText = new QTextEdit(central);
miller86's avatar
miller86 committed
128 129
    outputText->setMinimumSize(fontMetrics().width(titleSeparator),
                               fontMetrics().width(titleSeparator));
whitlocb's avatar
whitlocb committed
130
    outputText->setLineWrapMode(QTextEdit::NoWrap);
hrchilds's avatar
hrchilds committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
    outputText->setReadOnly(true);
    topLayout->addWidget(outputText);
}

// ****************************************************************************
// Method: QvisFileInformationWindow::UpdateWindow
//
// Purpose: 
//   Updates the output window when the FileServerList object that the
//   window watches is updated.
//
// Programmer: Brad Whitlock
// Creation:   Tue Aug 20 13:56:24 PST 2002
//
// Modifications:
//
hrchilds's avatar
hrchilds committed
147 148
//   Mark C. Miller, Wed Aug  2 19:58:44 PDT 2006
//   Changed interfaces to GetMetaData and GetSIL
149 150 151 152 153 154 155 156
//
//   Tom Fogal, Sat Aug 25 11:11:14 PDT 2007
//   Changed ostrstream to ostringstream
//
//   Cyrus Harrison, Mon Sep 10 10:08:31 PDT 2007
//   Added call to c_str() from ostringstream output to fix std:string
//   to QString linking error on AIX. 
//   (Also added modification message for Tom's recent change above)
157 158 159 160
//
//   Brad Whitlock, Tue Apr  8 12:26:44 PDT 2008
//   Support for internationalization.
//
whitlocb's avatar
whitlocb committed
161 162 163
//   Cyrus Harrison, Tue Jun 24 11:15:28 PDT 2008
//   Initial Qt4 Port.
//
hrchilds's avatar
hrchilds committed
164 165 166 167 168 169 170
// ****************************************************************************

void
QvisFileInformationWindow::UpdateWindow(bool doAll)
{
    if(fileServer->FileChanged() || doAll)
    {
hrchilds's avatar
hrchilds committed
171 172 173 174 175
        const QualifiedFilename &qf = fileServer->GetOpenFile();
        const avtDatabaseMetaData *md =
            fileServer->GetMetaData(qf, GetStateForSource(qf),
                                   !FileServerList::ANY_STATE,
                                    FileServerList::GET_NEW_MD);
hrchilds's avatar
hrchilds committed
176

hrchilds's avatar
hrchilds committed
177 178
        if(md != 0)
        {
179
            std::ostringstream os;
hrchilds's avatar
hrchilds committed
180 181 182 183
            os << "File = " << fileServer->GetOpenFile().FullName().c_str()
               << endl;
            os << titleSeparator << endl;
            md->Print(os);
184
            outputText->setText(os.str().c_str());
hrchilds's avatar
hrchilds committed
185 186 187
        }
        else if(fileServer->GetOpenFile().Empty())
        {
188 189
            outputText->setText(tr("There is no open file. File information is "
                                "not available until a file has been opened."));
hrchilds's avatar
hrchilds committed
190 191
        }
        else
192
            outputText->setText(tr("VisIt could not read the file meta-data."));
whitlocb's avatar
whitlocb committed
193 194
    
        outputText->moveCursor(QTextCursor::Start);
hrchilds's avatar
hrchilds committed
195 196
    }
}