void VerilogExporterVisitor::visit(View& inView) throw (Error) { // begin the port declaration mOut << "(" << endl; // look up the ports PortSharedPtrVector ports; inView.getPorts(ports); // iterate through the ports PortSharedPtrVector::const_iterator pp = ports.begin(); PortSharedPtrVector::const_iterator pe = ports.end(); while(pp < pe) { // process each port PortSharedPtr portPtr = *pp++; mOut << mTab << portPtr->getName(); if(pp < pe) mOut << ","; mOut << endl; } // end the port declaration mOut << ");" << endl; inView.applyOnAllPorts(mVisitor); inView.applyOnAllNets(mVisitor); inView.applyOnAllInstances(mVisitor); TemporaryAssignment<string> t(mPropertyContainerName, inView.getName()); inView.applyOnAllProperties(mVisitor); }
void GetView<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot) { VERIFYNR(pRoot != NULL); const std::vector<View*> views = getViews(); for (std::vector<View*>::const_iterator iter = views.begin(); iter != views.end(); ++iter) { View* pView = *iter; VERIFYNR(pView != NULL); if (pView->isKindOf(TypeConverter::toString<T>()) == false) { continue; } QTreeWidgetItem* pChild = new QTreeWidgetItem; std::string name = pView->getDisplayName(); if (name.empty() == true) { name = pView->getName(); } std::vector<std::string> classList; Service<DesktopServices>()->getViewTypes(pView->getObjectType(), classList); VERIFYNR(classList.empty() == false); pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name)); pChild->setData(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pView)); pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(classList.front())); pChild->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); pRoot->addChild(pChild); } }
void GetLayer<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot) { VERIFYNR(pRoot != NULL); const std::vector<View*> views = getViews(); for (std::vector<View*>::const_iterator iter = views.begin(); iter != views.end(); ++iter) { View* pView = *iter; VERIFYNR(pView != NULL); std::auto_ptr<QTreeWidgetItem> pChild(new QTreeWidgetItem); std::string name = pView->getDisplayName(); if (name.empty() == true) { name = pView->getName(); } std::vector<std::string> classList; Service<DesktopServices>()->getViewTypes(pView->getObjectType(), classList); VERIFYNR(classList.empty() == false); pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name)); pChild->setData(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pView)); pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(classList.front())); pChild->setFlags(Qt::NoItemFlags); populateTreeWidgetItemWithLayers(pChild.get()); if (pChild->childCount() > 0) { pRoot->addChild(pChild.release()); } } }
void Config::activateCanvas( Canvas* canvas ) { LBASSERT( canvas->isStopped( )); LBASSERT( lunchbox::find( getCanvases(), canvas ) != getCanvases().end( )); const Layouts& layouts = canvas->getLayouts(); const Segments& segments = canvas->getSegments(); for( Layouts::const_iterator i = layouts.begin(); i != layouts.end(); ++i ) { const Layout* layout = *i; if( !layout ) continue; const Views& views = layout->getViews(); for( Views::const_iterator j = views.begin(); j != views.end(); ++j ) { View* view = *j; for( Segments::const_iterator k = segments.begin(); k != segments.end(); ++k ) { Segment* segment = *k; Viewport viewport = segment->getViewport(); viewport.intersect( view->getViewport( )); if( !viewport.hasArea( )) { LBLOG( LOG_VIEW ) << "View " << view->getName() << view->getViewport() << " doesn't intersect " << segment->getName() << segment->getViewport() << std::endl; continue; } Channel* segmentChannel = segment->getChannel(); if( !segmentChannel ) { LBWARN << "Segment " << segment->getName() << " has no output channel" << std::endl; continue; } if ( findChannel( segment, view )) continue; // create and add new channel Channel* channel = new Channel( *segmentChannel ); channel->init(); // not in ctor, virtual method channel->setOutput( view, segment ); //----- compute channel viewport: // segment/view intersection in canvas space... Viewport contribution = viewport; // ... in segment space... contribution.transform( segment->getViewport( )); // segment output area if( segmentChannel->hasFixedViewport( )) { Viewport subViewport = segmentChannel->getViewport(); LBASSERT( subViewport.isValid( )); if( !subViewport.isValid( )) subViewport = eq::fabric::Viewport::FULL; // ...our part of it subViewport.apply( contribution ); channel->setViewport( subViewport ); LBLOG( LOG_VIEW ) << "View @" << (void*)view << ' ' << view->getViewport() << " intersects " << segment->getName() << segment->getViewport() << " at " << subViewport << " using channel @" << (void*)channel << std::endl; } else { PixelViewport pvp = segmentChannel->getPixelViewport(); LBASSERT( pvp.isValid( )); pvp.apply( contribution ); channel->setPixelViewport( pvp ); LBLOG( LOG_VIEW ) << "View @" << (void*)view << ' ' << view->getViewport() << " intersects " << segment->getName() << segment->getViewport() << " at " << pvp << " using channel @" << (void*)channel << std::endl; } if( channel->getWindow()->isAttached( )) // parent is already registered - register channel as well getServer()->registerObject( channel ); } } } }
bool PostScriptExporter::execute(PlugInArgList *pInArgList, PlugInArgList *pOutArgList) { StepResource pStep("Execute PostScript Exporter", "app", "5BE7D170-BFB5-43C9-A980-06C8C376D558"); Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()); View* pView = pInArgList->getPlugInArgValue<View>(Exporter::ExportItemArg()); if (pView == NULL) { string msg = "No view specified."; if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } pStep->finalize(Message::Failure, msg); return false; } string outPath; string viewName = pView->getName(); pStep->addProperty("View Name", viewName); FileDescriptor* pFileDescriptor = pInArgList->getPlugInArgValue<FileDescriptor>(Exporter::ExportDescriptorArg()); if (pFileDescriptor != NULL) { outPath = pFileDescriptor->getFilename().getFullPathAndName(); } if (outPath.empty()) { string msg = "The destination path is invalid."; if (pProgress) { pProgress->updateProgress(msg, 0, ERRORS); } pStep->finalize(Message::Failure, msg); return false; } pStep->addProperty("Filename", outPath); QSize outputSize; unsigned int outputWidth = 0; unsigned int outputHeight = 0; if (pInArgList->getPlugInArgValue("Output Width", outputWidth) && pInArgList->getPlugInArgValue("Output Height", outputHeight)) { pStep->addProperty("Output Width", outputWidth); pStep->addProperty("Output Height", outputHeight); outputSize = QSize(outputWidth, outputHeight); } // Get the current image from the viewer FileResource outFile(outPath.c_str(), "wb"); VERIFY(outFile.get() != NULL); mpOutFile = outFile.get(); if (outputSize == QSize()) { QImage image; pView->getCurrentImage(image); writePostScriptHeader(outPath, QPoint(0, 0), image.size()); writeImageSegment(image, QPoint(0, 0)); } else { writePostScriptHeader(outPath, QPoint(0, 0), outputSize); QSize subImageSize(512, 512); QPoint origin(0, 0); View::SubImageIterator* pSubImage = pView->getSubImageIterator(outputSize, subImageSize); int totalX; int totalTiles; pSubImage->count(totalX, totalTiles); totalTiles *= totalX; while (pSubImage->hasNext()) { QImage subImage; if (!pSubImage->next(subImage)) { if (pProgress != NULL) { pProgress->updateProgress("An error occurred when generating the image", 0, ERRORS); } delete pSubImage; return false; } writeImageSegment(subImage, origin); int newX = origin.x() + subImage.width(); int newY = origin.y(); if (newX >= outputSize.width()) { newY += subImage.height(); newX = 0; } origin = QPoint(newX, newY); if (pProgress != NULL) { int x; int y; pSubImage->location(x, y); int tileNumber = y * totalX + x; QString msg = QString("Processing sub-image %1 of %2...").arg(y * totalX + x + 1).arg(totalTiles); pProgress->updateProgress(msg.toStdString(), 100 * tileNumber / totalTiles - 1, NORMAL); } } delete pSubImage; } writePostScriptFooter(); if (pProgress != NULL) { pProgress->updateProgress("PostScript Exporter completed", 100, NORMAL); } mpOutFile = NULL; pStep->finalize(Message::Success); return true; }
View* getView(const char* pName, const char* pType) { View* pView = NULL; const std::string name(pName == NULL ? std::string() : pName); const std::string type(pType == NULL ? std::string() : pType); SessionItem* pSessionItem = Service<SessionManager>()->getSessionItem(name); if (pSessionItem != NULL) { pView = dynamic_cast<View*>(pSessionItem); if (pView == NULL || (!type.empty() && !pView->isKindOf(type))) { setLastError(SIMPLE_WRONG_TYPE); return NULL; } } else { std::vector<std::string> id = splitIdentifier(name); if (id.empty() || id.front().empty()) { pView = Service<DesktopServices>()->getCurrentWorkspaceWindowView(); if (pView == NULL) { setLastError(SIMPLE_NOT_FOUND); return NULL; } else { if (!type.empty() && !pView->isKindOf(type)) { setLastError(SIMPLE_WRONG_TYPE); return NULL; } } } else { std::vector<Window*> windows; Service<DesktopServices>()->getWindows(windows); for (std::vector<Window*>::iterator window = windows.begin(); window != windows.end(); ++window) { ViewWindow* pTmp = dynamic_cast<ViewWindow*>(*window); View* pTmpView = pTmp == NULL ? NULL : pTmp->getView(); if (pTmpView != NULL && (pTmpView->getName() == id.front() || pTmpView->getDisplayName() == id.front())) { if (!type.empty() && !pTmpView->isKindOf(type)) { setLastError(SIMPLE_WRONG_TYPE); return NULL; } else { if (id.size() == 1) { pView = pTmpView; } else { SpatialDataView* pSpatialDataView = dynamic_cast<SpatialDataView*>(pTmpView); if (pSpatialDataView != NULL) { LayerList* pLayerList = pSpatialDataView->getLayerList(); if (pLayerList != NULL) { std::vector<Layer*> layers; pLayerList->getLayers(layers); for (std::vector<Layer*>::iterator iter = layers.begin(); iter != layers.end(); ++iter) { Layer* pLayer = *iter; if (pLayer != NULL && (pLayer->getName() == id.back() || pLayer->getDisplayName() == id.back())) { pView = pTmpView; break; } } } } } } break; } } if (pView == NULL) { setLastError(SIMPLE_NOT_FOUND); return NULL; } } } setLastError(SIMPLE_NO_ERROR); return pView; }