Plot::Plot( QWidget *parent ): QwtPlot( parent ) { setObjectName( "FriedbergPlot" ); setTitle( "Temperature of Friedberg/Germany" ); setAxisTitle( QwtPlot::xBottom, "2007" ); setAxisScaleDiv( QwtPlot::xBottom, yearScaleDiv() ); setAxisScaleDraw( QwtPlot::xBottom, new YearScaleDraw() ); setAxisTitle( QwtPlot::yLeft, QString( "Temperature [%1C]" ).arg( QChar( 0x00B0 ) ) ); // grid QwtPlotGrid *grid = new Grid; grid->attach( this ); insertLegend( new QwtLegend(), QwtPlot::RightLegend ); const int numDays = 365; QVector<QPointF> averageData( numDays ); QVector<QwtIntervalSample> rangeData( numDays ); for ( int i = 0; i < numDays; i++ ) { const Temperature &t = friedberg2007[i]; averageData[i] = QPointF( double( i ), t.averageValue ); rangeData[i] = QwtIntervalSample( double( i ), QwtInterval( t.minValue, t.maxValue ) ); } insertCurve( "Average", averageData, Qt::black ); insertErrorBars( "Range", rangeData, Qt::blue ); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size QwtPlotZoomer* zoomer = new QwtPlotZoomer( canvas() ); zoomer->setRubberBandPen( QColor( Qt::black ) ); zoomer->setTrackerPen( QColor( Qt::black ) ); zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); panner->setMouseButton( Qt::MidButton ); canvas()->setPalette( Qt::darkGray ); canvas()->setBorderRadius( 10 ); }
void MyPlugin2SelectionObserver::HandleSelectionChanged(const ISelectionMessage* selectionMessage) { // get selection manager for active selection. ISelectionManager* iSelectionManager = Utils<ISelectionUtils>()->GetActiveSelection(); return; //get pointer to textSelectionSuite using selection manager OR fCurrentSelection. InterfacePtr<ITextSelectionSuite> iTextSelectionSuite(iSelectionManager, UseDefaultIID()); CAlert::InformationAlert("Selection** changed.."); if (iTextSelectionSuite) { //get pointer to integrator target text using textSelectionSuite. //Use to Return a list of interfaces from the "concrete selection" InterfacePtr<const IIntegratorTarget> iIntegratorTarget_text(iTextSelectionSuite, UseDefaultIID()); if (iIntegratorTarget_text == nil) return; RangeData rangeData(0, RangeData::kLeanForward); UIDRef textRef; PMString tagName; PMString childCountString = "xml child count-"; PMString tagUIDString = "UID of TAG -"; UID tagUID; TextIndex startPosXML = 0, endPosXML = 0; int startIndexSelection; int endIndexSelection; // Return a list of interfaces from the "concrete selection" //auto_ptr automatically makes clean up of objects. std::auto_ptr<IIntegratorTarget::TargetSuiteCollection> selectionSuites_text(iIntegratorTarget_text->GetTarget(ITextTarget::kDefaultIID)); for (IIntegratorTarget::TargetSuiteCollection::size_type i = 0; i < selectionSuites_text->size(); i++) { //Get target text. ITextTarget* target = (ITextTarget*)selectionSuites_text->at(i).get(); if (!target) continue; // extract range from target text. rangeData = target->GetRange(); // get start and end index of range selected. startIndexSelection = rangeData.Start(nil); endIndexSelection = rangeData.End(); // get text model for target text. InterfacePtr<ITextModel>textModel(target->QueryTextModel()); // get UIDRef of text model. textRef = target->GetTextModel(); // query xml reference data for text model. IXMLReferenceData *xmlReferenceData = Utils<IXMLUtils>()->QueryXMLReferenceData(textRef); if (xmlReferenceData) { // get xml reference from xml reference data. XMLReference xmlRef = xmlReferenceData->GetReference(); // obtain xml element from xml reference InterfacePtr<IIDXMLElement> xmlElement(xmlRef.Instantiate()); if (xmlElement != nil) { childCountString.AppendNumber(xmlElement->GetChildCount()); XMLReference childRef = xmlElement->GetNthChild(0); InterfacePtr<IIDXMLElement> childXMLElement(childRef.Instantiate()); if (childXMLElement != nil){ tagUID = childXMLElement->GetTagUID(); tagName = childXMLElement->GetTagString(); Utils<IXMLUtils>()->GetElementMarkerPositions(childXMLElement, &startPosXML, &endPosXML); } } } } // for end int length = rangeData.Length(); if (length >= 1) { PMString textFrameContentLength = "selected content length-"; textFrameContentLength.AppendNumber(length); PMString srtPosString = "Start Position XML tag-"; PMString endPosString = "End postion XML tag-"; PMString srtPosSelString = "Start Position of Selection-"; PMString endPosSelString = "End postion Selection-"; srtPosString.AppendNumber(startPosXML); endPosString.AppendNumber(endPosXML); srtPosSelString.AppendNumber(startIndexSelection); endPosSelString.AppendNumber(endIndexSelection); CAlert::InformationAlert(textFrameContentLength); CAlert::InformationAlert(childCountString); CAlert::InformationAlert(tagName); CAlert::InformationAlert(srtPosString); CAlert::InformationAlert(endPosString); CAlert::InformationAlert(srtPosSelString); CAlert::InformationAlert(endPosSelString); if (startPosXML <= startIndexSelection && endPosXML >= endIndexSelection) { CAlert::InformationAlert("Selection inside tag- "+tagName); } else { CAlert::WarningAlert("Selection not inside tag- " + tagName); } } } // --------:: Table selection ::--------- InterfacePtr<ITableSelectionSuite> iTableSelectionSuite(fCurrentSelection, UseDefaultIID()); if (iTableSelectionSuite == nil) return; InterfacePtr<const IIntegratorTarget> iIntegratorTarget_table(iTableSelectionSuite, UseDefaultIID()); if (iIntegratorTarget_table == nil) return; UIDRef tableUIDRef; GridArea tableGridArea; PMString PMRowCount = "Total no of rows-"; PMString PMColCount = "Total no of cols-"; std::auto_ptr<IIntegratorTarget::TargetSuiteCollection> selectionSuites_table(iIntegratorTarget_table->GetTarget(ITableTarget::kDefaultIID)); for (IIntegratorTarget::TargetSuiteCollection::size_type i = 0; i < selectionSuites_table->size(); i++) { ITableTarget* target = (ITableTarget*)selectionSuites_table->at(i).get(); if (!target) continue; tableUIDRef = target->GetModel(); if (tableUIDRef != UIDRef(nil, kInvalidUID)) { CAlert::WarningAlert("Table selection occured"); tableGridArea = target->GetRange(); } InterfacePtr<ITableModel>tableModel(target->QueryModel()); if (tableModel != nil) { RowRange totalRows = tableModel->GetTotalRows(); ColRange totalCols = tableModel->GetTotalCols(); int rowCount = totalRows.count; int colCount = totalCols.count; PMRowCount.AppendNumber(rowCount); PMColCount.AppendNumber(colCount); CAlert::InformationAlert(PMRowCount); CAlert::InformationAlert(PMColCount); InterfacePtr<ITableLayout> tableLayout(tableModel, UseDefaultIID()); if (tableLayout == nil) { break; } CAlert::InformationAlert("table layout present"); ITableLayout::frame_iterator frameIter = tableLayout->begin_frame_iterator(); CAlert::InformationAlert("Frame Iterator ppresent"); CAlert::InformationAlert("Frame Iterator present"); InterfacePtr<ITableFrame> tableFrame(frameIter->QueryFrame()); CAlert::InformationAlert("table frame ppresent"); if (tableFrame == nil){ break; } CAlert::InformationAlert("table frame present"); UIDRef tableContainerUIDRef = tableFrame->GetFrameRef(); if (tableContainerUIDRef == nil){ break; } CAlert::InformationAlert("table container UIDRef present"); InterfacePtr<IFrameType> frameType(tableContainerUIDRef, UseDefaultIID()); //if (frameType == nil) { //break; //} CAlert::InformationAlert("container frame present"); PMString textFrameType = "Is container , text frame-"; // TYPE OF TEXT FRAME // bool isTextFrame = frameType->IsTextFrame(); CAlert::InformationAlert("Is text frame success"); if (true) { textFrameType.Append("YES"); CAlert::InformationAlert(textFrameType); } else { textFrameType.Append("NO"); CAlert::InformationAlert(textFrameType); } } } };