00001 #include "vectorlayer.h" 00002 00003 VectorLayer::VectorLayer( VectorData *data ) : 00004 mData( data ), 00005 mSelSet( data->getSelSet() ) { 00006 mVisible = true; 00007 mEditable = true; 00008 } 00009 00010 void VectorLayer::draw( QPainter &p, Rect &imgclip, double scale ) { 00011 std::vector<Shape*> xyset = mData->getXYSet(); 00012 00013 DspAttr selAttr; 00014 selAttr.color = QColor( 255,255,0 ); 00015 selAttr.style = Qt::SolidLine; 00016 selAttr.width = 1; 00017 00018 if ( mData->getType() == VectorData::POINT ) { 00019 int nobj = (int)xyset.size(); 00020 for ( int inode=0; inode < nobj; inode++ ) { 00021 Shape &s = *xyset[inode]; 00022 Node node = dynamic_cast<Node&>( s ); 00023 node.x = (node.x - imgclip.x) * scale; 00024 node.y = (node.y - imgclip.y) * scale; 00025 00026 if ( mSelSet.isSelObj( inode ) ) { 00027 p.setPen( QPen( selAttr.color, 00028 selAttr.width, 00029 selAttr.style ) ); 00030 p.setBrush( selAttr.color ); 00031 } else { 00032 p.setPen( QPen( mLyrAttr.color, mLyrAttr.width, mLyrAttr.style ) ); 00033 p.setBrush( mLyrAttr.color ); 00034 } 00035 /* 00036 int halfw = mLyrAttr.width / 2; 00037 p.drawEllipse( (int)node.x - halfw, 00038 (int)node.y - halfw, 00039 (int)mLyrAttr.width, 00040 (int)mLyrAttr.width ); 00041 */ 00042 p.drawEllipse( (int)node.x-2, (int)node.y-2, 5, 5 ); 00043 } 00044 } else { 00045 for ( int iobj=0; iobj < (int)xyset.size(); iobj++ ) { 00046 Shape &s = *xyset[iobj]; 00047 Line &l = dynamic_cast<Line&>( s ); 00048 int nnodes = (int)l.size(); 00049 00050 DspAttr &attr = l.getAttr(); 00051 00052 if ( mSelSet.isSelObj( iobj ) ) { 00053 Node n = l[0]; 00054 n.x = (n.x - imgclip.x) * scale; 00055 n.y = (n.y - imgclip.y) * scale; 00056 00057 if ( mSelSet.isSelNode( iobj, 0 ) ) { 00058 p.setPen( QPen( selAttr.color, selAttr.width, selAttr.style ) ); 00059 p.setBrush( selAttr.color ); 00060 } else { 00061 p.setPen( QPen( attr.color, attr.width, attr.style ) ); 00062 p.setBrush( Qt::NoBrush ); 00063 } 00064 p.drawEllipse( (int)n.x-2, (int)n.y-2, 5, 5 ); 00065 00066 for ( int inode=1; inode < nnodes; inode++ ) { 00067 Node pn = l[inode-1]; 00068 Node n = l[inode]; 00069 n.x = (n.x - imgclip.x) * scale; 00070 n.y = (n.y - imgclip.y) * scale; 00071 pn.x = (pn.x - imgclip.x) * scale; 00072 pn.y = (pn.y - imgclip.y) * scale; 00073 00074 if ( mSelSet.isSelNode( iobj, inode ) ) { 00075 p.setPen( QPen( selAttr.color, selAttr.width, selAttr.style ) ); 00076 p.setBrush( selAttr.color ); 00077 } else { 00078 p.setPen( QPen( attr.color, attr.width, attr.style ) ); 00079 p.setBrush( Qt::NoBrush ); 00080 } 00081 p.drawEllipse( (int)n.x-2, (int)n.y-2, 5, 5 ); 00082 00083 p.setPen( QPen( selAttr.color, selAttr.width, selAttr.style ) ); 00084 p.drawLine( (int)pn.x, (int)pn.y, (int)n.x, (int)n.y ); 00085 } 00086 } else { 00087 p.setPen( QPen( attr.color, attr.width, attr.style ) ); 00088 for ( int inode=1; inode < nnodes; inode++ ) { 00089 Node pn = l[inode-1]; 00090 Node n = l[inode]; 00091 n.x = (n.x - imgclip.x) * scale; 00092 n.y = (n.y - imgclip.y) * scale; 00093 pn.x = (pn.x - imgclip.x) * scale; 00094 pn.y = (pn.y - imgclip.y) * scale; 00095 p.drawLine( (int)pn.x, (int)pn.y, (int)n.x, (int)n.y ); 00096 } 00097 } 00098 } 00099 } 00100 } 00101 00102
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |