00001 #include "lineselectordlg.h" 00002 #include "configdlg.h" 00003 00004 #include <stdio.h> 00005 00006 LineSelectorDlg::LineSelectorDlg( GLIMSLineData &linedata ) : 00007 mLineData( linedata ) { 00008 mSelLDF = -1; 00009 00010 mListView = new QListView( this ); 00011 mListView->addColumn( "Color" ); 00012 mListView->addColumn( "Glacier Type" ); 00013 mListView->addColumn( "Segment Label" ); 00014 mListView->addColumn( "Left Mat" ); 00015 mListView->addColumn( "Right Mat" ); 00016 mListView->addColumn( "Style" ); 00017 mListView->addColumn( "Width" ); 00018 mListView->addColumn( "Measured" ); 00019 00020 mListView->setSorting( -1 ); 00021 // mListView->setColumnWidthMode( QListView::Maximum ); 00022 00023 QPushButton *pb2 = new QPushButton( "New", this ); 00024 QPushButton *pb3 = new QPushButton( "Edit", this ); 00025 // QPushButton *pb4 = new QPushButton( "Edit Materials", this ); 00026 QPushButton *pb5 = new QPushButton( "Change Line", this ); 00027 QPushButton *pb6 = new QPushButton( "Export", this ); 00028 QPushButton *pb7 = new QPushButton( "Import", this ); 00029 00030 connect( pb2, SIGNAL( clicked() ), this, SLOT( newLineDef() ) ); 00031 connect( pb3, SIGNAL( clicked() ), this, SLOT( editLineDef() ) ); 00032 // connect( pb4, SIGNAL( clicked() ), this, SLOT( editMaterials() ) ); 00033 connect( pb5, SIGNAL( clicked() ), this, SLOT( changeCurLine() ) ); 00034 connect( pb6, SIGNAL( clicked() ), this, SLOT( exportFile() ) ); 00035 connect( pb7, SIGNAL( clicked() ), this, SLOT( importFile() ) ); 00036 00037 connect( mListView, SIGNAL( selectionChanged() ), this, SLOT( makeDefaultLineDef() ) ); 00038 QVBoxLayout *vbl = new QVBoxLayout( this ); 00039 vbl->addWidget( mListView ); 00040 00041 QHBoxLayout *hbl = new QHBoxLayout( vbl ); 00042 hbl->addWidget( pb2 ); 00043 hbl->addWidget( pb3 ); 00044 // hbl->addWidget( pb4 ); 00045 hbl->addWidget( pb5 ); 00046 hbl->addWidget( pb6 ); 00047 hbl->addWidget( pb7 ); 00048 00049 connect( &linedata, 00050 SIGNAL( datasetChanged( ) ), 00051 this, 00052 SLOT( loadList( ) ) ); 00053 00054 loadList(); 00055 00056 } 00057 00058 void LineSelectorDlg::loadList( ) { 00059 QListViewItem *item; 00060 00061 mListView->clear(); 00062 00063 LineDefSet &ldfset = mLineData.getLDFSet(); 00064 for ( int i=0; i < (int)ldfset.size(); i++ ) { 00065 char buf[20]; 00066 LineDef &ldf = mLineData.getLDFSet()[i]; 00067 std::string lmat = GLIMSGlobals::mGlbMDF[ldf.mLMat].id; 00068 std::string rmat = GLIMSGlobals::mGlbMDF[ldf.mRMat].id; 00069 std::string color = GLIMSGlobals::AVAILCOLORSTR[ldf.mColor]; 00070 std::string glactype = GLIMSGlobals::mGlbGlacTypes[ldf.mGlacType].id; 00071 std::string segmentlbl = GLIMSGlobals::mGlbLbls[ldf.mLabel].id; 00072 std::string style = ""; 00073 std::string type = GLIMSGlobals::mGlbTypes[ ldf.mType ].id; 00074 00075 if ( ldf.mStyle == 1 ) 00076 style = "Solid Line"; 00077 else if ( ldf.mStyle == 2 ) 00078 style = "Dash Line"; 00079 else 00080 style = "Dot Line"; 00081 00082 sprintf( buf, "%d", ldf.mWidth ); 00083 string width = buf; 00084 00085 item = new QListViewItem( mListView, 00086 color.c_str(), 00087 glactype.c_str(), 00088 segmentlbl.c_str(), 00089 lmat.c_str(), 00090 rmat.c_str(), 00091 style.c_str(), 00092 width.c_str(), 00093 type.c_str() ); 00094 mListView->insertItem( item ); 00095 } 00096 } 00097 00098 void LineSelectorDlg::makeDefaultLineDef( ) { 00099 QListViewItem *selectedItem = mListView->selectedItem(); 00100 QListViewItem *item; 00101 00102 int i=0; 00103 00104 item = mListView->firstChild(); 00105 while ( selectedItem != item && i < mListView->childCount() ) { 00106 i++; 00107 item = item->nextSibling(); 00108 } 00109 00110 mSelLDF = mListView->childCount() - i -1; 00111 mLineData.setDefLDF( mSelLDF ); 00112 // emit selLdfChanged( mSelLDF ); 00113 } 00114 00115 void LineSelectorDlg::newLineDef( ) { 00116 LineDefDlg *ald = new LineDefDlg( mLineData ); 00117 ald->exec(); 00118 loadList(); 00119 } 00120 00121 void LineSelectorDlg::editLineDef( ) { 00122 if ( mSelLDF == -1 ) 00123 return; 00124 00125 LineDefDlg *ald = new LineDefDlg( mLineData, mSelLDF ); 00126 ald->exec(); 00127 00128 loadList(); 00129 // HMMMM 00130 // mLineTool->emit repaintAll( 0,0,0,0 ); 00131 } 00132 00133 void LineSelectorDlg::changeCurLine( ) { 00134 SelectionSet &selset = mLineData.getSelSet(); 00135 for ( int isel=0; isel < selset.size(); isel++ ) { 00136 int iline = selset[isel].obj; 00137 mLineData.setLDF( iline, mSelLDF ); 00138 } 00139 emit repaintViews(); 00140 } 00141 00142 void LineSelectorDlg::importFile( ) { 00143 QString qfname = QFileDialog::getOpenFileName(); 00144 if ( qfname.isNull() ) 00145 return; 00146 00147 mLineData.getLDFSet().fromXMLFile( (const char*)qfname, 00148 "LDF_Export_File" ); 00149 00150 loadList(); 00151 } 00152 00153 void LineSelectorDlg::exportFile( ) { 00154 QString qfname = QFileDialog::getSaveFileName(); 00155 if ( qfname.isNull() ) 00156 return; 00157 00158 mLineData.getLDFSet().toXMLFile( (const char*)qfname, 00159 "LDF_Export_File" ); 00160 } 00161 00162 00163
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |